commit e6f7e7f26eb4078c72c5a0d5a238386fdd8e8368 Author: 吉浩茹 Date: Wed Jan 21 21:16:14 2026 +0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e76c77c --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..3279b6b --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..245a82c --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..f13fa33 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7725e4f --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..0f3cc8b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..b8d7e61 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d5e9660 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..3abf53e --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..3543521 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..75400c0 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,115 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 29 + useLibrary 'org.apache.http.legacy' + defaultConfig { + applicationId "com.sipai.js" + minSdkVersion 23 + targetSdkVersion 29 + multiDexEnabled true + versionCode 136 + versionName "1.36" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + ndk { + abiFilters "armeabi" + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } + + configurations.all { + resolutionStrategy { + //force 'androidx.core:core-ktx:1.6.0' + force 'androidx.core:core:1.6.0' + } + } + + sourceSets { + main { + jniLibs.srcDirs = ['libs'] + res.srcDirs = [ + 'src/main/res', + 'src/main/res/layout/main', + 'src/main/res/layout/alarm', + 'src/main/res/layout/fragment_fifth', + 'src/main/res/layout/fragment_main', + 'src/main/res/layout/monitor_screen', + 'src/main/res/layout/setting', + 'src/main/res/layout/statement', + 'src/main/res/layout/login', + 'src/main/res/layout/fault', + 'src/main/res/layout/patrol', + 'src/main/res/layout/ui', + 'src/main/res/layout/nfc', + 'src/main/res/layout/webv', + 'src/main/res/layout/equ', + 'src/main/res/layout/message', + 'src/main/res/layout/layout_production_monitoring' + ] + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(':swipemenulib') + implementation project(':superlibrary') + implementation 'com.github.f0ris.sweetalert:library:1.5.1' +// implementation 'org.litepal.guolindev:core:3.2.3' + implementation 'com.github.pinguo-zhouwei:CustomPopwindow:2.1.1' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'com.kyleduo.switchbutton:library:2.0.0' + implementation 'q.rorbin:badgeview:1.1.3' + implementation 'com.google.code.gson:gson:2.8.6' + implementation 'com.squareup.okhttp3:okhttp:3.4.1' + implementation 'com.github.devlight.navigationtabstrip:navigationtabstrip:1.0.4' + implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'com.github.bumptech.glide:glide:3.7.0' + implementation 'com.github.devlight.shadowlayout:library:1.0.2' + implementation 'de.hdodenhof:circleimageview:2.1.0' + implementation 'org.xutils:xutils:3.3.36' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +// implementation project(path: ':xAlertDialogLibrary') + implementation files('libs\\NativeImgCompress.jar') + implementation 'com.github.yuzhiqiang1993:zxing:2.2.5' + implementation 'com.android.support:multidex:1.0.3' + implementation 'com.github.Hitomis:transferee:1.6.1' + implementation 'com.haozhang.libary:android-slanted-textview:1.2' + +// 单独添加核心 module Transferee, 之后至少还需要添加以下三种图片加载器中的一种 + implementation 'com.github.Hitomis.transferee:Transferee:1.6.1' + +// 添加 Glide 图片加载器 + implementation 'com.github.Hitomis.transferee:GlideImageLoader:1.6.1' + +// 添加 Picasso 图片加载器 + implementation 'com.github.Hitomis.transferee:PicassoImageLoader:1.6.1' + +// 添加 Universal 图片加载器 + implementation 'com.github.Hitomis.transferee:UniversalImageLoader:1.6.1' + + //mqtt + implementation 'com.github.hannesa2:paho.mqtt.android:3.5.0' + + //echart + implementation 'com.github.abel533:ECharts:3.0.0.2' + implementation 'com.contrarywind:Android-PickerView:4.1.9' + + implementation 'io.github.scwang90:refresh-layout-kernel:2.0.6' //核心必须依赖 + implementation 'io.github.scwang90:refresh-header-classics:2.0.6' + implementation 'io.github.scwang90:refresh-footer-classics:2.0.6' +} diff --git a/app/libs/BaiduLBS_Android.jar b/app/libs/BaiduLBS_Android.jar new file mode 100644 index 0000000..dc45cc1 Binary files /dev/null and b/app/libs/BaiduLBS_Android.jar differ diff --git a/app/libs/MPAndroidChart-v3.0.2.jar b/app/libs/MPAndroidChart-v3.0.2.jar new file mode 100644 index 0000000..3da6e51 Binary files /dev/null and b/app/libs/MPAndroidChart-v3.0.2.jar differ diff --git a/app/libs/NativeImgCompress.jar b/app/libs/NativeImgCompress.jar new file mode 100644 index 0000000..ecf724c Binary files /dev/null and b/app/libs/NativeImgCompress.jar differ diff --git a/app/libs/android-async-http-1.4.4.jar b/app/libs/android-async-http-1.4.4.jar new file mode 100644 index 0000000..75af701 Binary files /dev/null and b/app/libs/android-async-http-1.4.4.jar differ diff --git a/app/libs/armeabi/libBaiduMapSDK_base_v6_3_0.so b/app/libs/armeabi/libBaiduMapSDK_base_v6_3_0.so new file mode 100644 index 0000000..f1df914 Binary files /dev/null and b/app/libs/armeabi/libBaiduMapSDK_base_v6_3_0.so differ diff --git a/app/libs/armeabi/libBaiduMapSDK_map_v6_3_0.so b/app/libs/armeabi/libBaiduMapSDK_map_v6_3_0.so new file mode 100644 index 0000000..b6fd27f Binary files /dev/null and b/app/libs/armeabi/libBaiduMapSDK_map_v6_3_0.so differ diff --git a/app/libs/armeabi/libbitherjni.so b/app/libs/armeabi/libbitherjni.so new file mode 100644 index 0000000..9b1256d Binary files /dev/null and b/app/libs/armeabi/libbitherjni.so differ diff --git a/app/libs/armeabi/libindoor.so b/app/libs/armeabi/libindoor.so new file mode 100644 index 0000000..a0879cf Binary files /dev/null and b/app/libs/armeabi/libindoor.so differ diff --git a/app/libs/armeabi/libjpegbither.so b/app/libs/armeabi/libjpegbither.so new file mode 100644 index 0000000..ef38bd4 Binary files /dev/null and b/app/libs/armeabi/libjpegbither.so differ diff --git a/app/libs/armeabi/liblocSDK8a.so b/app/libs/armeabi/liblocSDK8a.so new file mode 100644 index 0000000..5286996 Binary files /dev/null and b/app/libs/armeabi/liblocSDK8a.so differ diff --git a/app/libs/armeabi/libtbs.so b/app/libs/armeabi/libtbs.so new file mode 100644 index 0000000..e69de29 diff --git a/app/libs/litepal-2.0.0.jar b/app/libs/litepal-2.0.0.jar new file mode 100644 index 0000000..0dc67bf Binary files /dev/null and b/app/libs/litepal-2.0.0.jar differ diff --git a/app/libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar b/app/libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar new file mode 100644 index 0000000..87c40fa Binary files /dev/null and b/app/libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..6e7ffa9 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/sipai/ipatrol/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/sipai/ipatrol/ExampleInstrumentedTest.java new file mode 100644 index 0000000..3aaf89c --- /dev/null +++ b/app/src/androidTest/java/com/sipai/ipatrol/ExampleInstrumentedTest.java @@ -0,0 +1,27 @@ +package com.sipai.jspatrol; + +import android.content.Context; + +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.sipai.jspatrol", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..48fdab7 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/echart.html b/app/src/main/assets/echart.html new file mode 100644 index 0000000..87a76bd --- /dev/null +++ b/app/src/main/assets/echart.html @@ -0,0 +1,30 @@ + + + + + + + +
+ + + + diff --git a/app/src/main/assets/echarts.min.js b/app/src/main/assets/echarts.min.js new file mode 100644 index 0000000..7eb9bfb --- /dev/null +++ b/app/src/main/assets/echarts.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).echarts={})}(this,function(t){"use strict";var h=function(t,e){return(h=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(t,e)};function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var c=function(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1},w=new function(){this.browser=new c,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow="undefined"!=typeof window};"object"==typeof wx&&"function"==typeof wx.getSystemInfoSync?(w.wxa=!0,w.touchEventsSupported=!0):"undefined"==typeof document&&"undefined"!=typeof self?w.worker=!0:"undefined"==typeof navigator||0===navigator.userAgent.indexOf("Node.js")?(w.node=!0,w.svgSupported=!0):(et=navigator.userAgent,ie=(Ft=w).browser,st=et.match(/Firefox\/([\d.]+)/),A=et.match(/MSIE\s([\d.]+)/)||et.match(/Trident\/.+?rv:(([\d.]+))/),tt=et.match(/Edge?\/([\d.]+)/),et=/micromessenger/i.test(et),st&&(ie.firefox=!0,ie.version=st[1]),A&&(ie.ie=!0,ie.version=A[1]),tt&&(ie.edge=!0,ie.version=tt[1],ie.newEdge=18<+tt[1].split(".")[0]),et&&(ie.weChat=!0),Ft.svgSupported="undefined"!=typeof SVGRect,Ft.touchEventsSupported="ontouchstart"in window&&!ie.ie&&!ie.edge,Ft.pointerEventsSupported="onpointerdown"in window&&(ie.edge||ie.ie&&11<=+ie.version),Ft.domSupported="undefined"!=typeof document,st=document.documentElement.style,Ft.transform3dSupported=(ie.ie&&"transition"in st||ie.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in st)&&!("OTransition"in st),Ft.transformSupported=Ft.transform3dSupported||ie.ie&&9<=+ie.version);var p=12,y="sans-serif",K=p+"px "+y;var m,v,_=function(t){var e={};if("undefined"!=typeof JSON)for(var n=0;n>1)%2;s.cssText=["position: absolute","visibility: hidden","padding: 0","margin: 0","border-width: 0","user-select: none","width:0","height:0",i[l]+":0",o[u]+":0",i[1-l]+":auto",o[1-u]+":auto",""].join("!important;"),t.appendChild(a),n.push(a)}}return n}(e,r),r,o);if(e)return e(t,n,i),!0}return!1}function ge(t){return"CANVAS"===t.nodeName.toUpperCase()}var ye=/([&<>"'])/g,me={"&":"&","<":"<",">":">",'"':""","'":"'"};function ve(t){return null==t?"":(t+"").replace(ye,function(t,e){return me[e]})}var _e=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,xe=[],be=w.browser.firefox&&+w.browser.version.split(".")[0]<39;function we(t,e,n,i){return n=n||{},i?Se(t,e,n):be&&null!=e.layerX&&e.layerX!==e.offsetX?(n.zrX=e.layerX,n.zrY=e.layerY):null!=e.offsetX?(n.zrX=e.offsetX,n.zrY=e.offsetY):Se(t,e,n),n}function Se(t,e,n){if(w.domSupported&&t.getBoundingClientRect){var i,o=e.clientX,e=e.clientY;if(ge(t))return i=t.getBoundingClientRect(),n.zrX=o-i.left,void(n.zrY=e-i.top);if(fe(xe,t,o,e))return n.zrX=xe[0],void(n.zrY=xe[1])}n.zrX=n.zrY=0}function Me(t){return t||window.event}function Te(t,e,n){var i;return null==(e=Me(e)).zrX&&((i=e.type)&&0<=i.indexOf("touch")?(i=("touchend"!==i?e.targetTouches:e.changedTouches)[0])&&we(t,i,e,n):(we(t,e,e,n),i=function(t){var e=t.wheelDelta;if(e)return e;var n=t.deltaX,t=t.deltaY;return null!=n&&null!=t?3*(0!==t?Math.abs(t):Math.abs(n))*(0=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height},Ke.prototype.clone=function(){return new Ke(this.x,this.y,this.width,this.height)},Ke.prototype.copy=function(t){Ke.copy(this,t)},Ke.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},Ke.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},Ke.prototype.isZero=function(){return 0===this.width||0===this.height},Ke.create=function(t){return new Ke(t.x,t.y,t.width,t.height)},Ke.copy=function(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},Ke.applyTransform=function(t,e,n){var i,o,r,a;n?n[1]<1e-5&&-1e-5t.getWidth()||n<0||n>t.getHeight()}G(["click","mousedown","mouseup","mousewheel","dblclick","contextmenu"],function(a){sn.prototype[a]=function(t){var e,n,i=t.zrX,o=t.zrY,r=hn(this,i,o);if("mouseup"===a&&r||(n=(e=this.findHover(i,o)).target),"mousedown"===a)this._downEl=n,this._downPoint=[t.zrX,t.zrY],this._upEl=n;else if("mouseup"===a)this._upEl=n;else if("click"===a){if(this._downEl!==this._upEl||!this._downPoint||4>>1])<0?l=r:s=1+r;var u=i-s;switch(u){case 3:t[s+3]=t[s+2];case 2:t[s+2]=t[s+1];case 1:t[s+1]=t[s];break;default:for(;0>>1);0>>1);r(t,e[n+h])<0?l=h:a=h+1}return l}function mn(A,P){var L,O,R=pn,N=0,z=[];function e(t){var e=L[t],n=O[t],i=L[t+1],o=O[t+1],t=(O[t]=n+o,t===N-3&&(L[t+1]=L[t+2],O[t+1]=O[t+2]),N--,yn(A[i],A,e,n,0,P));if(e+=t,0!=(n-=t)&&0!==(o=gn(A[e+n-1],A,i,o,o-1,P)))if(n<=o){var r=e,a=n,t=i,s=o,l=0;for(l=0;lO[t+1])break;e(t)}},forceMergeRuns:function(){for(;1>=1;return t+e}(o);do{}while((r=dn(t,n,i,e))=this._maxSize&&0>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,5===i?parseInt(n.slice(4),16)/15:1),gi(t,e),e):void ci(e,0,0,0,1):7===i||9===i?0<=(o=parseInt(n.slice(1,7),16))&&o<=16777215?(ci(e,(16711680&o)>>16,(65280&o)>>8,255&o,9===i?parseInt(n.slice(7),16)/255:1),gi(t,e),e):void ci(e,0,0,0,1):void 0;var o=n.indexOf("("),r=n.indexOf(")");if(-1!==o&&r+1===i){var i=n.substr(0,o),a=n.substr(o+1,r-(o+1)).split(","),s=1;switch(i){case"rgba":if(4!==a.length)return 3===a.length?ci(e,+a[0],+a[1],+a[2],1):ci(e,0,0,0,1);s=li(a.pop());case"rgb":return 3<=a.length?(ci(e,si(a[0]),si(a[1]),si(a[2]),3===a.length?s:li(a[3])),gi(t,e),e):void ci(e,0,0,0,1);case"hsla":return 4!==a.length?void ci(e,0,0,0,1):(a[3]=li(a[3]),mi(a,e),gi(t,e),e);case"hsl":return 3!==a.length?void ci(e,0,0,0,1):(mi(a,e),gi(t,e),e);default:return}}ci(e,0,0,0,1)}}function mi(t,e){var n=(parseFloat(t[0])%360+360)%360/360,i=li(t[1]),o=li(t[2]),i=o<=.5?o*(i+1):o+i-o*i,o=2*o-i;return ci(e=e||[],ri(255*ui(o,i,n+1/3)),ri(255*ui(o,i,n)),ri(255*ui(o,i,n-1/3)),1),4===t.length&&(e[3]=t[3]),e}function vi(t,e){var n=yi(t);if(n){for(var i=0;i<3;i++)n[i]=e<0?n[i]*(1-e)|0:(255-n[i])*e+n[i]|0,255e);g++);g=f(g-1,h-2)}i=u[g+1],n=u[g]}n&&i&&(this._lastFr=g,this._lastFrP=e,d=i.percent-n.percent,o=0==d?1:f((e-n.percent)/d,1),i.easingFunc&&(o=i.easingFunc(o)),f=a?this._additiveValue:p?Qi:t[c],($i(l)||p)&&(f=f||(this._additiveValue=[])),this.discrete?t[c]=(o<1?n:i).rawValue:$i(l)?(1===l?Xi:function(t,e,n,i){for(var o=e.length,r=o&&e[0].length,a=0;athis._sleepAfterStill)&&this.animation.stop()},fr.prototype.setSleepAfterStill=function(t){this._sleepAfterStill=t},fr.prototype.wakeUp=function(){this._disposed||(this.animation.start(),this._stillFrameAccum=0)},fr.prototype.refreshHover=function(){this._needsRefreshHover=!0},fr.prototype.refreshHoverImmediately=function(){this._disposed||(this._needsRefreshHover=!1,this.painter.refreshHover&&"canvas"===this.painter.getType()&&this.painter.refreshHover())},fr.prototype.resize=function(t){this._disposed||(this.painter.resize((t=t||{}).width,t.height),this.handler.resize())},fr.prototype.clearAnimation=function(){this._disposed||this.animation.clear()},fr.prototype.getWidth=function(){if(!this._disposed)return this.painter.getWidth()},fr.prototype.getHeight=function(){if(!this._disposed)return this.painter.getHeight()},fr.prototype.setCursorStyle=function(t){this._disposed||this.handler.setCursorStyle(t)},fr.prototype.findHover=function(t,e){if(!this._disposed)return this.handler.findHover(t,e)},fr.prototype.on=function(t,e,n){return this._disposed||this.handler.on(t,e,n),this},fr.prototype.off=function(t,e){this._disposed||this.handler.off(t,e)},fr.prototype.trigger=function(t,e){this._disposed||this.handler.trigger(t,e)},fr.prototype.clear=function(){if(!this._disposed){for(var t=this.storage.getRoots(),e=0;el&&(l=s[h],u=h);++r[u],s[u]=0,++a}return B(r,function(t){return t/i})}function Dr(t){var e=2*Math.PI;return(t%e+e)%e}function kr(t){return-1e-4=e.maxIterations){t+=e.ellipsis;break}var s=0===a?function(t,e,n,i){for(var o=0,r=0,a=t.length;rr){0i.width&&(r=e.split("\n"),c=!0),i.accumWidth=t):(t=Ea(e,h,i.width,i.breakAll,i.accumWidth),i.accumWidth=t.accumWidth+n,a=t.linesWidths,r=t.lines)):r=e.split("\n");for(var p=0;pthis._ux||i>this._uy;return this.addData(rs.L,t,e),this._ctx&&o&&this._ctx.lineTo(t,e),o?(this._xi=t,this._yi=e,this._pendingPtDist=0):(o=n*n+i*i)>this._pendingPtDist&&(this._pendingPtX=t,this._pendingPtY=e,this._pendingPtDist=o),this},i.prototype.bezierCurveTo=function(t,e,n,i,o,r){return this._drawPendingPt(),this.addData(rs.C,t,e,n,i,o,r),this._ctx&&this._ctx.bezierCurveTo(t,e,n,i,o,r),this._xi=o,this._yi=r,this},i.prototype.quadraticCurveTo=function(t,e,n,i){return this._drawPendingPt(),this.addData(rs.Q,t,e,n,i),this._ctx&&this._ctx.quadraticCurveTo(t,e,n,i),this._xi=n,this._yi=i,this},i.prototype.arc=function(t,e,n,i,o,r){return this._drawPendingPt(),xs[0]=i,xs[1]=o,ws(xs,r),this.addData(rs.A,t,e,n,n,i=xs[0],(o=xs[1])-i,0,r?0:1),this._ctx&&this._ctx.arc(t,e,n,i,o,r),this._xi=fs(o)*n+t,this._yi=gs(o)*n+e,this},i.prototype.arcTo=function(t,e,n,i,o){return this._drawPendingPt(),this._ctx&&this._ctx.arcTo(t,e,n,i,o),this},i.prototype.rect=function(t,e,n,i){return this._drawPendingPt(),this._ctx&&this._ctx.rect(t,e,n,i),this.addData(rs.R,t,e,n,i),this},i.prototype.closePath=function(){this._drawPendingPt(),this.addData(rs.Z);var t=this._ctx,e=this._x0,n=this._y0;return t&&t.closePath(),this._xi=e,this._yi=n,this},i.prototype.fill=function(t){t&&t.fill(),this.toStatic()},i.prototype.stroke=function(t){t&&t.stroke(),this.toStatic()},i.prototype.len=function(){return this._len},i.prototype.setData=function(t){var e=t.length;this.data&&this.data.length===e||!_s||(this.data=new Float32Array(e));for(var n=0;nu.length&&(this._expandData(),u=this.data);for(var h=0;hn||ys(y)>i||c===e-1)&&(f=Math.sqrt(C*C+y*y),o=g,r=_);break;case rs.C:var m=t[c++],v=t[c++],g=t[c++],_=t[c++],x=t[c++],b=t[c++],f=function(t,e,n,i,o,r,a,s,l){for(var u=t,h=e,c=0,p=1/l,d=1;d<=l;d++){var f=d*p,g=Bn(t,n,o,a,f),f=Bn(e,i,r,s,f),y=g-u,m=f-h;c+=Math.sqrt(y*y+m*m),u=g,h=f}return c}(o,r,m,v,g,_,x,b,10),o=x,r=b;break;case rs.Q:f=function(t,e,n,i,o,r,a){for(var s=t,l=e,u=0,h=1/a,c=1;c<=a;c++){var p=c*h,d=Un(t,n,o,p),p=Un(e,i,r,p),f=d-s,g=p-l;u+=Math.sqrt(f*f+g*g),s=d,l=p}return u}(o,r,m=t[c++],v=t[c++],g=t[c++],_=t[c++],10),o=g,r=_;break;case rs.A:var x=t[c++],b=t[c++],w=t[c++],S=t[c++],M=t[c++],T=t[c++],I=T+M;c+=1,d&&(a=fs(M)*w+x,s=gs(M)*S+b),f=ds(w,S)*ps(vs,Math.abs(T)),o=fs(I)*w+x,r=gs(I)*S+b;break;case rs.R:a=o=t[c++],s=r=t[c++];f=2*t[c++]+2*t[c++];break;case rs.Z:var C=a-o,y=s-r;f=Math.sqrt(C*C+y*y),o=a,r=s}0<=f&&(u+=l[h++]=f)}return this._pathLen=u},i.prototype.rebuildPath=function(t,e){var n,i,o,r,a,s,l,u,h=this.data,z=this._ux,E=this._uy,B=this._len,c=e<1,p=0,d=0,f=0;if(!c||(this._pathSegLen||this._calculateLength(),a=this._pathSegLen,s=e*this._pathLen))t:for(var g=0;g=Ls[i=0]+t&&a<=Ls[1]+t?h:0;oMath.PI/2&&c<1.5*Math.PI?-h:h)}return l}(y,m,_,x,x+b,w,T,o);u=Math.cos(x+b)*v+y,h=Math.sin(x+b)*_+m;break;case ks.R:c=u=a[d++],p=h=a[d++];if(S=c+a[d++],M=p+a[d++],n){if(Ms(c,p,S,p,e,i,o)||Ms(S,p,S,M,e,i,o)||Ms(S,M,c,M,e,i,o)||Ms(c,M,c,p,e,i,o))return!0}else l=(l+=Ds(S,p,S,M,i,o))+Ds(c,M,c,p,i,o);break;case ks.Z:if(n){if(Ms(u,h,c,p,e,i,o))return!0}else l+=Ds(u,h,c,p,i,o);u=c,h=p}}return n||(t=h,r=p,Math.abs(t-r)i.len()&&(uMath.abs(i[1])?0':'':{renderMode:o,content:"{"+(t.markerId||"markerX")+"|} ",style:"subItem"===i?{width:4,height:4,borderRadius:2,backgroundColor:n}:{width:10,height:10,borderRadius:5,backgroundColor:n}}:""}function ad(t,e){return e=e||"transparent",U(t)?t:L(t)&&t.colorStops&&(t.colorStops[0]||{}).color||e}function sd(t,e){var n;"_blank"===e||"blank"===e?((n=window.open()).opener=null,n.location.href=t):window.open(t,e)}var ld=G,ud=["left","right","top","bottom","width","height"],hd=[["width","left","right"],["height","top","bottom"]];function cd(a,s,l,u,h){var c=0,p=0,d=(null==u&&(u=1/0),null==h&&(h=1/0),0);s.eachChild(function(t,e){var n,i,o,r=t.getBoundingRect(),e=s.childAt(e+1),e=e&&e.getBoundingRect();d="horizontal"===a?(i=r.width+(e?-e.x+r.x:0),u<(n=c+i)||t.newline?(c=0,n=i,p+=d+l,r.height):Math.max(d,r.height)):(i=r.height+(e?-e.y+r.y:0),h<(o=p+i)||t.newline?(c+=d+l,p=0,o=i,r.width):Math.max(d,r.width)),t.newline||(t.x=c,t.y=p,t.markRedraw(),"horizontal"===a?c=n+l:p=o+l)})}var pd=cd;function dd(t,e,n){n=td(n||0);var i=e.width,o=e.height,r=q(t.left,i),a=q(t.top,o),e=q(t.right,i),s=q(t.bottom,o),l=q(t.width,i),u=q(t.height,o),h=n[2]+n[0],c=n[1]+n[3],p=t.aspect;switch(isNaN(l)&&(l=i-e-c-r),isNaN(u)&&(u=o-s-h-a),null!=p&&(isNaN(l)&&isNaN(u)&&(i/oe)return t[i];return t[n-1]}var $d,Qd="\0_ec_inner",Jd=(u(tf,$d=dp),tf.prototype.init=function(t,e,n,i,o,r){i=i||{},this.option=null,this._theme=new dp(i),this._locale=new dp(o),this._optionManager=r},tf.prototype.setOption=function(t,e,n){e=of(e);this._optionManager.setOption(t,n,e),this._resetOption(null,e)},tf.prototype.resetOption=function(t,e){return this._resetOption(t,of(e))},tf.prototype._resetOption=function(t,e){var n,i=!1,o=this._optionManager;return t&&"recreate"!==t||(n=o.mountOption("recreate"===t),this.option&&"recreate"!==t?(this.restoreData(),this._mergeOption(n,e)):Yd(this,n),i=!0),"timeline"!==t&&"media"!==t||this.restoreData(),t&&"recreate"!==t&&"timeline"!==t||(n=o.getTimelineOption(this))&&(i=!0,this._mergeOption(n,e)),t&&"recreate"!==t&&"media"!==t||(n=o.getMediaOption(this)).length&&G(n,function(t){i=!0,this._mergeOption(t,e)},this),i},tf.prototype.mergeOption=function(t){this._mergeOption(t,null)},tf.prototype._mergeOption=function(i,t){var o=this.option,h=this._componentsMap,c=this._componentsCount,n=[],r=R(),p=t&&t.replaceMergeMainTypeMap;Ed(this).datasetMap=R(),G(i,function(t,e){null!=t&&(g.hasClass(e)?e&&(n.push(e),r.set(e,!0)):o[e]=null==o[e]?S(t):d(o[e],t,!0))}),p&&p.each(function(t,e){g.hasClass(e)&&!r.get(e)&&(n.push(e),r.set(e,!0))}),g.topologicalTravel(n,g.getAllClassMainTypes(),function(r){var a,t=function(t,e,n){return(e=(e=Wd.get(e))&&e(t))?n.concat(e):n}(this,r,Gr(i[r])),e=h.get(r),n=e?p&&p.get(r)?"replaceMerge":"normalMerge":"replaceAll",e=Yr(e,t,n),s=(Qr(e,r,g),o[r]=null,h.set(r,null),c.set(r,0),[]),l=[],u=0;G(e,function(t,e){var n=t.existing,i=t.newOption;if(i){var o=g.getClass(r,t.keyInfo.subType,!("series"===r));if(!o)return;if("tooltip"===r){if(a)return;a=!0}n&&n.constructor===o?(n.name=t.keyInfo.name,n.mergeOption(i,this),n.optionUpdated(i,!1)):(e=F({componentIndex:e},t.keyInfo),F(n=new o(i,this,this,e),e),t.brandNew&&(n.__requireNewView=!0),n.init(i,this,this),n.optionUpdated(null,!0))}else n&&(n.mergeOption({},this),n.optionUpdated({},!1));n?(s.push(n.option),l.push(n),u++):(s.push(void 0),l.push(void 0))},this),o[r]=s,h.set(r,l),c.set(r,u),"series"===r&&Ud(this)},this),this._seriesIndices||Ud(this)},tf.prototype.getOption=function(){var a=S(this.option);return G(a,function(t,e){if(g.hasClass(e)){for(var n=Gr(t),i=n.length,o=!1,r=i-1;0<=r;r--)n[r]&&!$r(n[r])?o=!0:(n[r]=null,o||i--);n.length=i,a[e]=n}}),delete a[Qd],a},tf.prototype.getTheme=function(){return this._theme},tf.prototype.getLocaleModel=function(){return this._locale},tf.prototype.setUpdatePayload=function(t){this._payload=t},tf.prototype.getUpdatePayload=function(){return this._payload},tf.prototype.getComponent=function(t,e){var n=this._componentsMap.get(t);if(n){t=n[e||0];if(t)return t;if(null==e)for(var i=0;ig[1]&&(g[1]=f)}return{start:a,end:this._rawCount=this._count=s}},l.prototype._initDataFromProvider=function(t,e,n){for(var i=this._provider,o=this._chunks,r=this._dimensions,a=r.length,s=this._rawExtent,l=B(r,function(t){return t.property}),u=0;uf[1]&&(f[1]=g)}!i.persistent&&i.clean&&i.clean(),this._rawCount=this._count=e,this._extent=[]},l.prototype.count=function(){return this._count},l.prototype.get=function(t,e){return 0<=e&&e=this._rawCount||t<0)){if(!this._indices)return t;var e=this._indices,n=e[t];if(null!=n&&nt))return r;o=r-1}}}return-1},l.prototype.indicesOfNearest=function(t,e,n){var i=this._chunks[t],o=[];if(i){null==n&&(n=1/0);for(var r=1/0,a=-1,s=0,l=0,u=this.count();lt[S][1])&&(b=!1)}b&&(a[s++]=e.getRawIndex(f))}return sy[1]&&(y[1]=g)}}}},l.prototype.lttbDownSample=function(t,e){var n,i=this.clone([t],!0),o=i._chunks[t],r=this.count(),a=0,s=Math.floor(1/e),l=this.getRawIndex(0),u=new(Xg(this._rawCount))(Math.min(2*(Math.ceil(r/s)+2),r));u[a++]=l;for(var h=1;hh[1]&&(h[1]=y),c[p++]=m}return o._count=p,o._indices=c,o._updateGetRawIdx(),o},l.prototype.each=function(t,e){if(this._count)for(var n=t.length,i=this._chunks,o=0,r=this.count();o'+ve(u)+""+h,t))}function uy(t,e,n,i){var o,r,a,s,l=t.renderMode,u=e.noName,h=e.noValue,c=!e.markerType,p=e.name,d=t.useUTC,f=e.valueFormatter||t.valueFormatter||function(t){return B(t=V(t)?t:[t],function(t,e){return ed(t,V(r)?r[e]:r,d)})};if(!u||!h)return o=c?"":t.markupStyleCreator.makeTooltipMarker(e.markerType,e.markerColor||"#333",l),p=u?"":ed(p,"ordinal",d),r=e.valueType,f=h?[]:f(e.value,e.dataIndex),e=!c||!u,a=!c&&u,i=ny(i,l),s=i.nameStyle,i=i.valueStyle,"richText"===l?(c?"":o)+(u?"":py(t,p,s))+(h?"":function(t,e,n,i,o){o=[o],i=i?10:20;return n&&o.push({padding:[0,0,0,i],align:"right"}),t.markupStyleCreator.wrapRichTextStyle(V(e)?e.join(" "):e,o)}(t,f,e,a,i)):cy((c?"":o)+(u?"":''+ve(p)+"")+(h?"":function(t,e,n,i){n=n?"10px":"20px",e=e?"float:right;margin-left:"+n:"";return t=V(t)?t:[t],''+B(t,ve).join("  ")+""}(f,e,a,i)),n)}function hy(t,e,n,i,o,r){if(t)return sy(t)({useUTC:o,renderMode:n,orderMode:i,markupStyleCreator:e,valueFormatter:t.valueFormatter},t,0,r)}function cy(t,e){return'
'+t+'
'}function py(t,e,n){return t.markupStyleCreator.wrapRichTextStyle(e,n)}function dy(t,e){t=t.get("padding");return null!=t?t:"richText"===e?[8,10]:10}gy.prototype._generateStyleName=function(){return"__EC_aUTo_"+this._nextStyleNameId++},gy.prototype.makeTooltipMarker=function(t,e,n){var i="richText"===n?this._generateStyleName():null,e=rd({color:e,type:t,renderMode:n,markerId:i});return U(e)?e:(this.richTextStyles[i]=e.style,e.content)},gy.prototype.wrapRichTextStyle=function(t,e){var n={},e=(V(e)?G(e,function(t){return F(n,t)}):F(n,e),this._generateStyleName());return this.richTextStyles[e]=n,"{"+e+"|"+t+"}"};var fy=gy;function gy(){this.richTextStyles={},this._nextStyleNameId=Br()}function yy(t){var e,n,i,o,r,a,s,l,u,h,c,p=t.series,d=t.dataIndex,t=t.multipleSeries,f=p.getData(),g=f.mapDimensionsAll("defaultedTooltip"),y=g.length,m=p.getRawValue(d),v=V(m),_=(_=d,ad((b=p).getData().getItemVisual(_,"style")[b.visualDrawType]));function x(t,e){e=s.getDimensionInfo(e);e&&!1!==e.otherDims.tooltip&&(l?c.push(ry("nameValue",{markerType:"subItem",markerColor:a,name:e.displayName,value:t,valueType:e.type})):(u.push(t),h.push(e.type)))}1this.getShallow("animationThreshold")?!1:t)},o.prototype.restoreData=function(){this.dataTask.dirty()},o.prototype.getColorFromPalette=function(t,e,n){var i=this.ecModel;return qd.prototype.getColorFromPalette.call(this,t,e,n)||i.getColorFromPalette(t,e,n)},o.prototype.coordDimToDataDim=function(t){return this.getRawData().mapDimensionsAll(t)},o.prototype.getProgressive=function(){return this.get("progressive")},o.prototype.getProgressiveThreshold=function(){return this.get("progressiveThreshold")},o.prototype.select=function(t,e){this._innerSelect(this.getData(e),t)},o.prototype.unselect=function(t,e){var n=this.option.selectedMap;if(n){var i=this.option.selectedMode,o=this.getData(e);if("series"===i||"all"===n)this.option.selectedMap={},this._selectedDataIndicesMap={};else for(var r=0;re.outputData.count()&&e.model.getRawData().cloneShallow(e.outputData)}function Ty(e,n){G(Nt(e.CHANGABLE_METHODS,e.DOWNSAMPLE_METHODS),function(t){e.wrapMethod(t,T(Iy,n))})}function Iy(t,e){t=Cy(t);return t&&t.setOutputEnd((e||this).count()),e}function Cy(t){var e,n=(t.ecModel||{}).scheduler,n=n&&n.getPipeline(t.uid);if(n)return(n=n.currentTask)&&(e=n.agentStubMap)?e.get(t.uid):n}ut(xy,hp),ut(xy,qd),fa(xy,g);ky.prototype.init=function(t,e){},ky.prototype.render=function(t,e,n,i){},ky.prototype.dispose=function(t,e){},ky.prototype.updateView=function(t,e,n,i){},ky.prototype.updateLayout=function(t,e,n,i){},ky.prototype.updateVisual=function(t,e,n,i){},ky.prototype.toggleBlurSeries=function(t,e,n){},ky.prototype.eachRendered=function(t){var e=this.group;e&&e.traverse(t)};var Dy=ky;function ky(){this.group=new lr,this.uid=yp("viewComponent")}function Ay(){var r=ta();return function(t){var e=r(t),t=t.pipelineContext,n=!!e.large,i=!!e.progressiveRender,o=e.large=!(!t||!t.large),e=e.progressiveRender=!(!t||!t.progressiveRender);return!(n==o&&i==e)&&"reset"}}da(Dy),va(Dy);var Py=ta(),Ly=Ay(),Oy=(Ry.prototype.init=function(t,e){},Ry.prototype.render=function(t,e,n,i){},Ry.prototype.highlight=function(t,e,n,i){t=t.getData(i&&i.dataType);t&&zy(t,i,"emphasis")},Ry.prototype.downplay=function(t,e,n,i){t=t.getData(i&&i.dataType);t&&zy(t,i,"normal")},Ry.prototype.remove=function(t,e){this.group.removeAll()},Ry.prototype.dispose=function(t,e){},Ry.prototype.updateView=function(t,e,n,i){this.render(t,e,n,i)},Ry.prototype.updateLayout=function(t,e,n,i){this.render(t,e,n,i)},Ry.prototype.updateVisual=function(t,e,n,i){this.render(t,e,n,i)},Ry.prototype.eachRendered=function(t){Vc(this.group,t)},Ry.markUpdateMethod=function(t,e){Py(t).updateMethod=e},Ry.protoInitialize=void(Ry.prototype.type="chart"),Ry);function Ry(){this.group=new lr,this.uid=yp("viewChart"),this.renderTask=ug({plan:Ey,reset:By}),this.renderTask.context={view:this}}function Ny(t,e,n){t&&yu(t)&&("emphasis"===e?Ql:Jl)(t,n)}function zy(e,t,n){var i,o=Jr(e,t),r=t&&null!=t.highlightKey?(t=t.highlightKey,i=null==(i=Sl[t])&&wl<=32?Sl[t]=wl++:i):null;null!=o?G(Gr(o),function(t){Ny(e.getItemGraphicEl(t),n,r)}):e.eachItemGraphicEl(function(t){Ny(t,n,r)})}function Ey(t){return Ly(t.model)}function By(t){var e=t.model,n=t.ecModel,i=t.api,o=t.payload,r=e.pipelineContext.progressiveRender,t=t.view,a=o&&Py(o).updateMethod,r=r?"incrementalPrepareRender":a&&t[a]?a:"render";return"render"!==r&&t[r](e,n,i,o),Vy[r]}da(Oy),va(Oy);var Vy={incrementalPrepareRender:{progress:function(t,e){e.view.incrementalRender(t,e.model,e.ecModel,e.api,e.payload)}},render:{forceFirstProgress:!0,progress:function(t,e){e.view.render(e.model,e.ecModel,e.api,e.payload)}}},Fy="\0__throttleOriginMethod",Hy="\0__throttleRate",Gy="\0__throttleType";function Wy(t,o,r){var a,s,l,u,h,c=0,p=0,d=null;function f(){p=(new Date).getTime(),d=null,t.apply(l,u||[])}o=o||0;function e(){for(var t=[],e=0;en.blockIndex?n.step:null,modBy:null!=(t=i&&i.modDataCount)?Math.ceil(t/e):null,modDataCount:t}},t0.prototype.getPipeline=function(t){return this._pipelineMap.get(t)},t0.prototype.updateStreamModes=function(t,e){var n=this._pipelineMap.get(t.uid),i=t.getData().count(),e=n.progressiveEnabled&&e.incrementalPrepareRender&&i>=n.threshold,o=t.get("large")&&i>=t.get("largeThreshold"),i="mod"===t.get("progressiveChunkMode")?i:null;t.pipelineContext=n.context={progressiveRender:e,modDataCount:i,large:o}},t0.prototype.restorePipelines=function(t){var i=this,o=i._pipelineMap=R();t.eachSeries(function(t){var e=t.getProgressive(),n=t.uid;o.set(n,{id:n,head:null,tail:null,threshold:t.getProgressiveThreshold(),progressiveEnabled:e&&!(t.preventIncremental&&t.preventIncremental()),blockIndex:-1,step:Math.round(e||700),count:0}),i._pipe(t,t.dataTask)})},t0.prototype.prepareStageTasks=function(){var n=this._stageTaskMap,i=this.api.getModel(),o=this.api;G(this._allHandlers,function(t){var e=n.get(t.uid)||n.set(t.uid,{});Tt(!(t.reset&&t.overallReset),""),t.reset&&this._createSeriesStageTask(t,e,i,o),t.overallReset&&this._createOverallStageTask(t,e,i,o)},this)},t0.prototype.prepareView=function(t,e,n,i){var o=t.renderTask,r=o.context;r.model=e,r.ecModel=n,r.api=i,o.__block=!t.incrementalPrepareRender,this._pipe(e,o)},t0.prototype.performDataProcessorTasks=function(t,e){this._performStageTasks(this._dataProcessorHandlers,t,e,{block:!0})},t0.prototype.performVisualTasks=function(t,e,n){this._performStageTasks(this._visualHandlers,t,e,n)},t0.prototype._performStageTasks=function(t,s,l,u){u=u||{};var h=!1,c=this;function p(t,e){return t.setDirty&&(!t.dirtyMap||t.dirtyMap.get(e.__pipeline.id))}G(t,function(i,t){var e,n,o,r,a;u.visualType&&u.visualType!==i.visualType||(e=(n=c._stageTaskMap.get(i.uid)).seriesTaskMap,(n=n.overallTask)?((r=n.agentStubMap).each(function(t){p(u,t)&&(t.dirty(),o=!0)}),o&&n.dirty(),c.updatePayload(n,l),a=c.getPerformArgs(n,u.block),r.each(function(t){t.perform(a)}),n.perform(a)&&(h=!0)):e&&e.each(function(t,e){p(u,t)&&t.dirty();var n=c.getPerformArgs(t,u.block);n.skip=!i.performRawSeries&&s.isSeriesFiltered(t.context.model),c.updatePayload(t,l),t.perform(n)&&(h=!0)}))}),this.unfinished=h||this.unfinished},t0.prototype.performSeriesTasks=function(t){var e;t.eachSeries(function(t){e=t.dataTask.perform()||e}),this.unfinished=e||this.unfinished},t0.prototype.plan=function(){this._pipelineMap.each(function(t){var e=t.tail;do{if(e.__block){t.blockIndex=e.__idxInPipeline;break}}while(e=e.getUpstream())})},t0.prototype.updatePayload=function(t,e){"remain"!==e&&(t.context.payload=e)},t0.prototype._createSeriesStageTask=function(n,t,i,o){var r=this,a=t.seriesTaskMap,s=t.seriesTaskMap=R(),t=n.seriesType,e=n.getTargetSeries;function l(t){var e=t.uid,e=s.set(e,a&&a.get(e)||ug({plan:r0,reset:a0,count:u0}));e.context={model:t,ecModel:i,api:o,useClearVisual:n.isVisual&&!n.isLayout,plan:n.plan,reset:n.reset,scheduler:r},r._pipe(t,e)}n.createOnAllSeries?i.eachRawSeries(l):t?i.eachRawSeriesByType(t,l):e&&e(i,o).each(l)},t0.prototype._createOverallStageTask=function(t,e,n,i){var o=this,r=e.overallTask=e.overallTask||ug({reset:e0}),a=(r.context={ecModel:n,api:i,overallReset:t.overallReset,scheduler:o},r.agentStubMap),s=r.agentStubMap=R(),e=t.seriesType,l=t.getTargetSeries,u=!0,h=!1;function c(t){var e=t.uid,e=s.set(e,a&&a.get(e)||(h=!0,ug({reset:n0,onDirty:o0})));e.context={model:t,overallProgress:u},e.agent=r,e.__block=u,o._pipe(t,e)}Tt(!t.createOnAllSeries,""),e?n.eachRawSeriesByType(e,c):l?l(n,i).each(c):(u=!1,G(n.getSeries(),c)),h&&r.dirty()},t0.prototype._pipe=function(t,e){t=t.uid,t=this._pipelineMap.get(t);t.head||(t.head=e),t.tail&&t.tail.pipe(e),(t.tail=e).__idxInPipeline=t.count++,e.__pipeline=t},t0.wrapStageHandler=function(t,e){return(t=C(t)?{overallReset:t,seriesType:function(t){h0=null;try{t(c0,p0)}catch(t){}return h0}(t)}:t).uid=yp("stageHandler"),e&&(t.visualType=e),t};var Jy=t0;function t0(t,e,n,i){this._stageTaskMap=R(),this.ecInstance=t,this.api=e,n=this._dataProcessorHandlers=n.slice(),i=this._visualHandlers=i.slice(),this._allHandlers=n.concat(i)}function e0(t){t.overallReset(t.ecModel,t.api,t.payload)}function n0(t){return t.overallProgress&&i0}function i0(){this.agent.dirty(),this.getDownstream().dirty()}function o0(){this.agent&&this.agent.dirty()}function r0(t){return t.plan?t.plan(t.model,t.ecModel,t.api,t.payload):null}function a0(t){t.useClearVisual&&t.data.clearAllVisual();t=t.resetDefines=Gr(t.reset(t.model,t.ecModel,t.api,t.payload));return 1'+t.dom+""}),f.painter.getSvgRoot().innerHTML=g,i.connectedBackgroundColor&&f.painter.setBackgroundColor(i.connectedBackgroundColor),f.refreshImmediately(),f.painter.toDataURL()):(i.connectedBackgroundColor&&f.add(new il({shape:{x:0,y:0,width:t,height:n},style:{fill:i.connectedBackgroundColor}})),G(p,function(t){t=new qs({style:{x:t.left*e-l,y:t.top*e-u,image:t.dom}});f.add(t)}),f.refreshImmediately(),d.toDataURL("image/"+(i&&i.type||"png")))):this.getDataURL(i);this.id},r.prototype.convertToPixel=function(t,e){return Nm(this,"convertToPixel",t,e)},r.prototype.convertFromPixel=function(t,e){return Nm(this,"convertFromPixel",t,e)},r.prototype.containPixel=function(t,i){var o;if(!this._disposed)return G(na(this._model,t),function(t,n){0<=n.indexOf("Models")&&G(t,function(t){var e=t.coordinateSystem;e&&e.containPoint?o=o||!!e.containPoint(i):"seriesModels"===n&&(e=this._chartsMap[t.__viewId])&&e.containPoint&&(o=o||e.containPoint(i,t))},this)},this),!!o;this.id},r.prototype.getVisual=function(t,e){var t=na(this._model,t,{defaultMainType:"series"}),n=t.seriesModel.getData(),t=t.hasOwnProperty("dataIndexInside")?t.dataIndexInside:t.hasOwnProperty("dataIndex")?n.indexOfRawIndex(t.dataIndex):null;return null!=t?b0(n,t,e):w0(n,e)},r.prototype.getViewOfComponentModel=function(t){return this._componentsMap[t.__viewId]},r.prototype.getViewOfSeriesModel=function(t){return this._chartsMap[t.__viewId]},r.prototype._initEvents=function(){var t,n,i,s=this;G(nv,function(a){function t(t){var n,e,i,o=s.getModel(),r=t.target;"globalout"===a?n={}:r&&I0(r,function(t){var e,t=D(t);return t&&null!=t.dataIndex?(e=t.dataModel||o.getSeriesByIndex(t.seriesIndex),n=e&&e.getDataParams(t.dataIndex,t.dataType,r)||{},1):t.eventData&&(n=F({},t.eventData),1)},!0),n&&(e=n.componentType,i=n.componentIndex,"markLine"!==e&&"markPoint"!==e&&"markArea"!==e||(e="series",i=n.seriesIndex),i=(e=e&&null!=i&&o.getComponent(e,i))&&s["series"===e.mainType?"_chartsMap":"_componentsMap"][e.__viewId],n.event=t,n.type=a,s._$eventProcessor.eventInfo={targetEl:r,packedEvent:n,model:e,view:i},s.trigger(a,n))}t.zrEventfulCallAtLast=!0,s._zr.on(a,t,s)}),G(ov,function(t,e){s._messageCenter.on(e,function(t){this.trigger(e,t)},s)}),G(["selectchanged"],function(e){s._messageCenter.on(e,function(t){this.trigger(e,t)},s)}),t=this._messageCenter,i=(n=this)._api,t.on("selectchanged",function(t){var e=i.getModel();t.isFromClick?(T0("map","selectchanged",n,e,t),T0("pie","selectchanged",n,e,t)):"select"===t.fromAction?(T0("map","selected",n,e,t),T0("pie","selected",n,e,t)):"unselect"===t.fromAction&&(T0("map","unselected",n,e,t),T0("pie","unselected",n,e,t))})},r.prototype.isDisposed=function(){return this._disposed},r.prototype.clear=function(){this._disposed?this.id:this.setOption({series:[]},!0)},r.prototype.dispose=function(){var t,e,n;this._disposed?this.id:(this._disposed=!0,this.getDom()&&sa(this.getDom(),fv,""),e=(t=this)._api,n=t._model,G(t._componentsViews,function(t){t.dispose(n,e)}),G(t._chartsViews,function(t){t.dispose(n,e)}),t._zr.dispose(),t._dom=t._model=t._chartsMap=t._componentsMap=t._chartsViews=t._componentsViews=t._scheduler=t._api=t._zr=t._throttledZrFlush=t._theme=t._coordSysMgr=t._messageCenter=null,delete hv[t.id])},r.prototype.resize=function(t){if(!this[xm])if(this._disposed)this.id;else{this._zr.resize(t);var e=this._model;if(this._loadingFX&&this._loadingFX.resize(),e){var e=e.resetOption("media"),n=t&&t.silent;this[bm]&&(null==n&&(n=this[bm].silent),e=!0,this[bm]=null),this[xm]=!0;try{e&&Pm(this),Rm.update.call(this,{type:"resize",animation:F({duration:0},t&&t.animation)})}catch(t){throw this[xm]=!1,t}this[xm]=!1,Bm.call(this,n),Vm.call(this,n)}}},r.prototype.showLoading=function(t,e){this._disposed?this.id:(L(t)&&(e=t,t=""),t=t||"default",this.hideLoading(),uv[t]&&(t=uv[t](this._api,e),e=this._zr,this._loadingFX=t,e.add(t)))},r.prototype.hideLoading=function(){this._disposed?this.id:(this._loadingFX&&this._zr.remove(this._loadingFX),this._loadingFX=null)},r.prototype.makeActionFromEvent=function(t){var e=F({},t);return e.type=ov[t.type],e},r.prototype.dispatchAction=function(t,e){var n;this._disposed?this.id:(L(e)||(e={silent:!!e}),iv[t.type]&&this._model&&(this[xm]?this._pendingActions.push(t):(n=e.silent,Em.call(this,t,n),(t=e.flush)?this._zr.flush():!1!==t&&w.browser.weChat&&this._throttledZrFlush(),Bm.call(this,n),Vm.call(this,n))))},r.prototype.updateLabelLayout=function(){vm.trigger("series:layoutlabels",this._model,this._api,{updatedSeries:[]})},r.prototype.appendData=function(t){var e;this._disposed?this.id:(e=t.seriesIndex,this.getModel().getSeriesByIndex(e).appendData(t),this._scheduler.unfinished=!0,this.getZr().wakeUp())},r.internalField=(Pm=function(t){var e=t._scheduler;e.restorePipelines(t._model),e.prepareStageTasks(),Lm(t,!0),Lm(t,!1),e.plan()},Lm=function(t,o){for(var r=t._model,a=t._scheduler,s=o?t._componentsViews:t._chartsViews,l=o?t._componentsMap:t._chartsMap,u=t._zr,h=t._api,e=0;es.get("hoverLayerThreshold")&&!w.node&&!w.worker&&s.eachSeries(function(t){t.preventUsingHoverLayer||(t=i._chartsMap[t.__viewId]).__alive&&t.eachRendered(function(t){t.states.emphasis&&(t.states.emphasis.hoverLayer=!0)})}),vm.trigger("series:afterupdate",t,e,n)},Zm=function(t){t[wm]=!0,t.getZr().wakeUp()},qm=function(t){t[wm]&&(t.getZr().storage.traverse(function(t){sc(t)||Qm(t)}),t[wm]=!1)},Xm=function(n){return u(t,e=rf),t.prototype.getCoordinateSystems=function(){return n._coordSysMgr.getCoordinateSystems()},t.prototype.getComponentByElement=function(t){for(;t;){var e=t.__ecComponentInfo;if(null!=e)return n._model.getComponent(e.mainType,e.index);t=t.parent}},t.prototype.enterEmphasis=function(t,e){Ql(t,e),Zm(n)},t.prototype.leaveEmphasis=function(t,e){Jl(t,e),Zm(n)},t.prototype.enterBlur=function(t){tu(t),Zm(n)},t.prototype.leaveBlur=function(t){eu(t),Zm(n)},t.prototype.enterSelect=function(t){nu(t),Zm(n)},t.prototype.leaveSelect=function(t){iu(t),Zm(n)},t.prototype.getModel=function(){return n.getModel()},t.prototype.getViewOfComponentModel=function(t){return n.getViewOfComponentModel(t)},t.prototype.getViewOfSeriesModel=function(t){return n.getViewOfSeriesModel(t)},new t(n);function t(){return null!==e&&e.apply(this,arguments)||this}var e},void(Ym=function(i){function o(t,e){for(var n=0;ne[1]&&(e[1]=t[1])},y1.prototype.unionExtentFromData=function(t,e){this.unionExtent(t.getApproximateExtent(e))},y1.prototype.getExtent=function(){return this._extent.slice()},y1.prototype.setExtent=function(t,e){var n=this._extent;isNaN(t)||(n[0]=t),isNaN(e)||(n[1]=e)},y1.prototype.isInExtentRange=function(t){return this._extent[0]<=t&&this._extent[1]>=t},y1.prototype.isBlank=function(){return this._isBlank},y1.prototype.setBlank=function(t){this._isBlank=t};var g1=y1;function y1(t){this._setting=t||{},this._extent=[1/0,-1/0]}va(g1);var m1=0,v1=(_1.createByAxisModel=function(t){var t=t.option,e=t.data,e=e&&B(e,x1);return new _1({categories:e,needCollect:!e,deduplication:!1!==t.dedplication})},_1.prototype.getOrdinal=function(t){return this._getOrCreateMap().get(t)},_1.prototype.parseAndCollect=function(t){var e,n,i=this._needCollect;return U(t)||i?(i&&!this._deduplication?(n=this.categories.length,this.categories[n]=t):null==(n=(e=this._getOrCreateMap()).get(t))&&(i?(n=this.categories.length,this.categories[n]=t,e.set(t,n)):n=NaN),n):t},_1.prototype._getOrCreateMap=function(){return this._map||(this._map=R(this.categories))},_1);function _1(t){this.categories=t.categories||[],this._needCollect=t.needCollect,this._deduplication=t.deduplication,this.uid=++m1}function x1(t){return L(t)&&null!=t.value?t.value:t+""}function b1(t){return"interval"===t.type||"log"===t.type}function w1(t,e,n,i){var o={},r=t[1]-t[0],r=o.interval=Rr(r/e,!0),e=(null!=n&&ri[1]&&(i[0]=i[1]),o}function S1(t){var e=Math.pow(10,Or(t)),t=t/e;return t?2===t?t=3:3===t?t=5:t*=2:t=1,wr(t*e)}function M1(t){return Mr(t)+2}function T1(t,e,n){t[e]=Math.max(Math.min(t[e],n[1]),n[0])}function I1(t,e){return t>=e[0]&&t<=e[1]}function C1(t,e){return e[1]===e[0]?.5:(t-e[0])/(e[1]-e[0])}function D1(t,e){return t*(e[1]-e[0])+e[0]}u(P1,k1=g1),P1.prototype.parse=function(t){return null==t?NaN:U(t)?this._ordinalMeta.getOrdinal(t):Math.round(t)},P1.prototype.contain=function(t){return I1(t=this.parse(t),this._extent)&&null!=this._ordinalMeta.categories[t]},P1.prototype.normalize=function(t){return C1(t=this._getTickNumber(this.parse(t)),this._extent)},P1.prototype.scale=function(t){return t=Math.round(D1(t,this._extent)),this.getRawOrdinalNumber(t)},P1.prototype.getTicks=function(){for(var t=[],e=this._extent,n=e[0];n<=e[1];)t.push({value:n}),n++;return t},P1.prototype.getMinorTicks=function(t){},P1.prototype.setSortInfo=function(t){if(null==t)this._ordinalNumbersByTick=this._ticksByOrdinalNumber=null;else{for(var e=t.ordinalNumbers,n=this._ordinalNumbersByTick=[],i=this._ticksByOrdinalNumber=[],o=0,r=this._ordinalMeta.categories.length,a=Math.min(r,e.length);o=t},P1.prototype.getOrdinalMeta=function(){return this._ordinalMeta},P1.prototype.calcNiceTicks=function(){},P1.prototype.calcNiceExtent=function(){},P1.type="ordinal";var k1,A1=P1;function P1(t){var t=k1.call(this,t)||this,e=(t.type="ordinal",t.getSetting("ordinalMeta"));return V(e=e||new v1({}))&&(e=new v1({categories:B(e,function(t){return L(t)?t.value:t})})),t._ordinalMeta=e,t._extent=t.getSetting("extent")||[0,e.categories.length-1],t}g1.registerClass(A1);var L1,O1=wr,R1=(u(N1,L1=g1),N1.prototype.parse=function(t){return t},N1.prototype.contain=function(t){return I1(t,this._extent)},N1.prototype.normalize=function(t){return C1(t,this._extent)},N1.prototype.scale=function(t){return D1(t,this._extent)},N1.prototype.setExtent=function(t,e){var n=this._extent;isNaN(t)||(n[0]=parseFloat(t)),isNaN(e)||(n[1]=parseFloat(e))},N1.prototype.unionExtent=function(t){var e=this._extent;t[0]e[1]&&(e[1]=t[1]),this.setExtent(e[0],e[1])},N1.prototype.getInterval=function(){return this._interval},N1.prototype.setInterval=function(t){this._interval=t,this._niceExtent=this._extent.slice(),this._intervalPrecision=M1(t)},N1.prototype.getTicks=function(t){var e=this._interval,n=this._extent,i=this._niceExtent,o=this._intervalPrecision,r=[];if(e){n[0]s&&r.push(t?{value:O1(s+e,o)}:{value:n[1]})}return r},N1.prototype.getMinorTicks=function(t){for(var e=this.getTicks(!0),n=[],i=this.getExtent(),o=1;oi[0]&&h=M[0]&&d<=M[1]&&a++)}u=(M[1]-M[0])/w;if(1.5*u=M[0]&&t.value<=M[1]&&!t.notAdd})}),function(t){return 0n&&(this._approxInterval=n),K1.length),t=Math.min(function(t,e,n,i){for(;n>>1;t[o][1]>1^-(1&s),l=(l=t.charCodeAt(a+1)-64)>>1^-(1&l);i.push([(o=s+=o)/n,(r=l+=r)/n])}return i}function X_(t,r){var e,n,o;return B(pt((t=(e=t).UTF8Encoding?(null==(o=(n=e).UTF8Scale)&&(o=1024),G(n.features,function(t){var e=t.geometry,n=e.encodeOffsets,i=e.coordinates;if(n)switch(e.type){case"LineString":e.coordinates=U_(i,n,o);break;case"Polygon":case"MultiLineString":W_(i,n,o);break;case"MultiPolygon":G(i,function(t,e){return W_(t,n[e],o)})}}),n.UTF8Encoding=!1,n):e).features,function(t){return t.geometry&&t.properties&&0l[1],h(n[0].coord,l[0])&&(t?n[0].coord=l[0]:n.shift()),t&&h(l[0],n[0].coord)&&n.unshift({coord:l[0]}),h(l[1],i.coord)&&(t?i.coord=l[1]:n.pop()),t)&&h(i.coord,l[1])&&n.push({coord:l[1]}),u},nx.prototype.getMinorTicksCoords=function(){var t;return"ordinal"===this.scale.type?[]:(t=this.model.getModel("minorTick").get("splitNumber"),B(this.scale.getMinorTicks(t=0=u}}for(var r,a=this.__startIndex;ao[0]){for(l=0;lt);l++);s=i[o[l]]}o.splice(l+1,0,t),(i[t]=e).virtual||(s?(n=s.dom).nextSibling?a.insertBefore(e.dom,n.nextSibling):a.appendChild(e.dom):a.firstChild?a.insertBefore(e.dom,a.firstChild):a.appendChild(e.dom)),e.painter||(e.painter=this)}},Yx.prototype.eachLayer=function(t,e){for(var n=this._zlevelList,i=0;ie&&(e=t[n]);return isFinite(e)?e:NaN},min:function(t){for(var e=1/0,n=0;n=o.r0?"endArc":"startArc":o.endAngle>=o.startAngle?"endAngle":"startAngle":a?0<=o.height?"bottom":"top":0<=o.width?"right":"left"),h=Xc(i),l=(Uc(t,h,{labelFetcher:r,labelDataIndex:n,defaultText:gb(r.getData(),n),inheritColor:l.fill,defaultOpacity:l.opacity,defaultOutsidePosition:u}),t.getTextContent()),h=(s&&l&&(s=i.get(["label","position"]),t.textConfig.inside="middle"===s||null,function(t,e,n,i){if(X(i))t.setTextConfig({rotation:i});else if(V(e))t.setTextConfig({rotation:0});else{var o,i=t.shape,r=i.clockwise?i.startAngle:i.endAngle,a=i.clockwise?i.endAngle:i.startAngle,s=(r+a)/2,i=n(e);switch(i){case"startArc":case"insideStartArc":case"middle":case"insideEndArc":case"endArc":o=s;break;case"startAngle":case"insideStartAngle":o=r;break;case"endAngle":case"insideEndAngle":o=a;break;default:return t.setTextConfig({rotation:0})}n=1.5*Math.PI-o;"middle"===i&&n>Math.PI/2&&n<1.5*Math.PI&&(n-=Math.PI),t.setTextConfig({rotation:n})}}(t,"outside"===s?u:s,Ob(a),i.get(["label","rotate"]))),u=l,s=h,a=r.getRawValue(n),l=function(t){return yb(e,t)},u&&((u=Qc(u)).prevValue=u.value,u.value=a,a=s.normal,u.valueAnimation=a.get("valueAnimation"),u.valueAnimation)&&(u.precision=a.get("precision"),u.defaultInterpolatedText=l,u.statesModels=s),i.getModel(["emphasis"]));cu(t,h.get("focus"),h.get("blurScope"),h.get("disabled")),fu(t,i),null!=(r=o).startAngle&&null!=r.endAngle&&r.startAngle===r.endAngle&&(t.style.fill="none",t.style.stroke="none",G(t.states,function(t){t.style&&(t.style.fill=t.style.stroke="none")}))}var Nb,zb=function(){},Eb=(u(Bb,Nb=j),Bb.prototype.getDefaultShape=function(){return new zb},Bb.prototype.buildPath=function(t,e){for(var n=e.points,i=this.baseDimIdx,o=1-this.baseDimIdx,r=[],a=[],s=this.barWidth,l=0;le[u-1].coord&&(e.reverse(),h.reverse()),function(t,e){var n,i,o=[],r=t.length;function a(t,e,n){var i=t.coord;return{coord:n,color:bi((n-i)/(e.coord-i),[t.color,e.color])}}for(var s=0;si)return;return 1}(a,e))return o=e.mapDimension(a.dim),r={},G(a.getViewLabels(),function(t){t=a.scale.getRawOrdinalNumber(t.tickValue);r[t]=1}),function(t){return!r.hasOwnProperty(e.get(o,t))}}}function Sw(t){for(var e,n,i=t.length/2;0l?x:_,(g=Math.abs(d.label.y-l))>=f.maxY&&(m=d.label.x-s-d.len2*h,y=u+d.len,m=Math.abs(m)t.unconstrainedWidth)?null:s,i.setStyle("width",l)),u=i.getBoundingRect(),o.width=u.width,e=(i.style.margin||0)+2.1,o.height=u.height+e,o.y-=(o.height-a)/2)}function Bw(t){return"center"===t.position}function Vw(t){var S,M,T=t.getData(),I=[],C=!1,D=(t.get("minShowLabelAngle")||0)*Nw,e=T.getLayout("viewRect"),k=T.getLayout("r"),A=e.width,P=e.x,n=e.y,e=e.height;function L(t){t.ignore=!0}if(T.each(function(t){var e,n,i,o,r,a,s,l,u,h,c=T.getItemGraphicEl(t),p=c.shape,d=c.getTextContent(),f=c.getTextGuideLine(),t=T.getItemModel(t),g=t.getModel("label"),y=g.get("position")||t.get(["emphasis","label","position"]),m=g.get("distanceToLabelLine"),v=g.get("alignTo"),_=q(g.get("edgeDistance"),A),x=g.get("bleedMargin"),t=t.getModel("labelLine"),b=q(t.get("length"),A),w=q(t.get("length2"),A);Math.abs(p.endAngle-p.startAngle)=e.r0},Xw.type="pie";var Ww,Uw=Xw;function Xw(){var t=null!==Ww&&Ww.apply(this,arguments)||this;return t.ignoreLabelLineUpdate=!0,t}Zw.prototype.getAllNames=function(){var t=this._getRawData();return t.mapArray(t.getName)},Zw.prototype.containName=function(t){return 0<=this._getRawData().indexOfName(t)},Zw.prototype.indexOfName=function(t){return this._getDataWithEncodedVisual().indexOfName(t)},Zw.prototype.getItemVisual=function(t,e){return this._getDataWithEncodedVisual().getItemVisual(t,e)};var Yw=Zw;function Zw(t,e){this._getDataWithEncodedVisual=t,this._getRawData=e}var qw,jw=ta(),Kw=(u($w,qw=xy),$w.prototype.init=function(t){qw.prototype.init.apply(this,arguments),this.legendVisualProvider=new Yw(M(this.getData,this),M(this.getRawData,this)),this._defaultLabelLine(t)},$w.prototype.mergeOption=function(){qw.prototype.mergeOption.apply(this,arguments)},$w.prototype.getInitialData=function(){return e=V(e={coordDimensions:["value"],encodeDefaulter:T(Vd,t=this)})?{coordDimensions:e}:F({encodeDefine:t.getEncode()},e),i=t.getSource(),e=s1(i,e).dimensions,(e=new a1(e,t)).initData(i,n),e;var t,e,n,i},$w.prototype.getDataParams=function(t){var e,n=this.getData(),i=jw(n),o=i.seats,i=(o||(e=[],n.each(n.mapDimension("value"),function(t){e.push(t)}),o=i.seats=Cr(e,n.hostModel.get("percentPrecision"))),qw.prototype.getDataParams.call(this,t));return i.percent=o[t]||0,i.$vars.push("percent"),i},$w.prototype._defaultLabelLine=function(t){Wr(t,"labelLine",["show"]);var e=t.labelLine,n=t.emphasis.labelLine;e.show=e.show&&t.label.show,n.show=n.show&&t.emphasis.label.show},$w.type="series.pie",$w.defaultOption={z:2,legendHoverLink:!0,colorBy:"data",center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,endAngle:"auto",padAngle:0,minAngle:0,minShowLabelAngle:0,selectedOffset:10,percentPrecision:2,stillShowZeroSum:!0,left:0,top:0,right:0,bottom:0,width:null,height:null,label:{rotate:0,show:!0,overflow:"truncate",position:"outer",alignTo:"none",edgeDistance:"25%",bleedMargin:10,distanceToLabelLine:5},labelLine:{show:!0,length:15,length2:15,smooth:!1,minTurnAngle:90,maxSurfaceAngle:90,lineStyle:{width:1,type:"solid"}},itemStyle:{borderWidth:1,borderJoin:"round"},showEmptyCircle:!0,emptyCircleStyle:{color:"lightgray",opacity:1},labelLayout:{hideOverlap:!0},emphasis:{scale:!0,scaleSize:5},avoidLabelOverlap:!0,animationType:"expansion",animationDuration:1e3,animationTypeUpdate:"transition",animationEasingUpdate:"cubicInOut",animationDurationUpdate:500,animationEasing:"cubicInOut"},$w);function $w(){return null!==qw&&qw.apply(this,arguments)||this}D_(function(t){t.registerChartView(Uw),t.registerSeriesModel(Kw),M0("pie",t.registerAction),t.registerLayout(T(Rw,"pie")),t.registerProcessor({seriesType:"pie",reset:function(t,e){var i,o=e.findComponents({mainType:"legend"});o&&o.length&&(i=t.getData()).filterSelf(function(t){for(var e=i.getName(t),n=0;ne[1]&&e.reverse(),e},yS.prototype.pointToData=function(t,e){return this.coordToData(this.toLocalCoord(t["x"===this.dim?0:1]),e)},yS.prototype.setCategorySortInfo=function(t){if("category"!==this.type)return!1;this.model.option.categorySortInfo=t,this.scale.setSortInfo(t)};var fS,gS=yS;function yS(t,e,n,i,o){t=fS.call(this,t,e,n)||this;return t.index=0,t.type=i||"value",t.position=o||"bottom",t}function mS(t,e,n){n=n||{};var t=t.coordinateSystem,i=e.axis,o={},r=i.getAxesOnZeroOf()[0],a=i.position,s=r?"onZero":a,i=i.dim,t=t.getRect(),t=[t.x,t.x+t.width,t.y,t.y+t.height],l={left:0,right:1,top:0,bottom:1,onZero:2},u=e.get("offset")||0,u="x"===i?[t[2]-u,t[3]+u]:[t[0]-u,t[1]+u],h=(r&&(h=r.toGlobalCoord(r.dataToCoord(0)),u[l.onZero]=Math.max(Math.min(h,u[1]),u[0])),o.position=["y"===i?u[l[s]]:t[0],"x"===i?u[l[s]]:t[3]],o.rotation=Math.PI/2*("x"===i?0:1),o.labelDirection=o.tickDirection=o.nameDirection={top:-1,bottom:1,left:-1,right:1}[a],o.labelOffset=r?u[l[a]]-u[l.onZero]:0,e.get(["axisTick","inside"])&&(o.tickDirection=-o.tickDirection),bt(n.labelInside,e.get(["axisLabel","inside"]))&&(o.labelDirection=-o.labelDirection),e.get(["axisLabel","rotate"]));return o.labelRotate="top"===s?-h:h,o.z2=1,o}function vS(t){return"cartesian2d"===t.get("coordinateSystem")}function _S(i){var o={xAxisModel:null,yAxisModel:null};return G(o,function(t,e){var n=e.replace(/Model$/,""),n=i.getReferringComponents(n,oa).models[0];o[e]=n}),o}var xS=Math.log;wS.prototype.getRect=function(){return this._rect},wS.prototype.update=function(t,e){var n=this._axesMap;function i(t){var d,e=W(t),n=e.length;if(n){for(var i=[],o=n-1;0<=o;o--){var r=t[+e[o]],a=r.model,s=r.scale;b1(s)&&a.get("alignTicks")&&null==a.get("interval")?i.push(r):(y_(s,a),b1(s)&&(d=r))}i.length&&(d||y_((d=i.pop()).scale,d.model),G(i,function(t){var e=t.scale,t=t.model,n=d.scale,i=R1.prototype,o=i.getTicks.call(n),r=i.getTicks.call(n,!0),a=o.length-1,n=i.getInterval.call(n),s=(t=g_(e,t)).extent,l=t.fixMin,t=t.fixMax,u=("log"===e.type&&(u=xS(e.base),s=[xS(s[0])/u,xS(s[1])/u]),e.setExtent(s[0],s[1]),e.calcNiceExtent({splitNumber:a,fixMin:l,fixMax:t}),i.getExtent.call(e)),h=(l&&(s[0]=u[0]),t&&(s[1]=u[1]),i.getInterval.call(e)),c=s[0],p=s[1];if(l&&t)h=(p-c)/a;else if(l)for(p=s[0]+h*a;ps[0]&&isFinite(c)&&isFinite(s[0]);)h=S1(h),c=s[1]-h*a;else{u=(h=ah[1]?-1:1,r=["start"===c?h[0]-r*u:"end"===c?h[1]+r*u:(h[0]+h[1])/2,LS(c)?t.labelOffset+l*u:0],null!=(u=e.get("nameRotate"))&&(u=u*IS/180),LS(c)?a=CS.innerTextLayout(t.rotation,null!=u?u:t.rotation,l):(a=function(t,e,n,i){var o,n=Dr(n-t),t=i[0]>i[1],i="start"===e&&!t||"start"!==e&&t;e=kr(n-IS/2)?(o=i?"bottom":"top","center"):kr(n-1.5*IS)?(o=i?"top":"bottom","center"):(o="middle",n<1.5*IS&&IS/2u[1]&&u.reverse(),(s=null==s||s>u[1]?u[1]:s)n[o],f=[-c.x,-c.y],e=(e||(f[i]=l[s]),[0,0]),s=[-p.x,-p.y],g=O(t.get("pageButtonGap",!0),t.get("itemGap",!0)),f=(d&&("end"===t.get("pageButtonPosition",!0)?s[i]+=n[o]-p[o]:e[i]+=p[o]+g),s[1-i]+=c[r]/2-p[r]/2,l.setPosition(f),u.setPosition(e),h.setPosition(s),{x:0,y:0}),c=(f[o]=(d?n:c)[o],f[r]=Math.max(c[r],p[r]),f[a]=Math.min(0,p[a]+s[1-i]),u.__rectSize=n[o],d?((e={x:0,y:0})[o]=Math.max(n[o]-p[o]-g,0),e[r]=f[r],u.setClipPath(new il({shape:e})),u.__rectSize=e[o]):h.eachChild(function(t){t.attr({invisible:!0,silent:!0})}),this._getPageInfo(t));return null!=c.pageIndex&&rc(l,{x:c.contentPosition[0],y:c.contentPosition[1]},d?t:null),this._updatePageInfoView(t,c),f},zM.prototype._pageGo=function(t,e,n){t=this._getPageInfo(e)[t];null!=t&&n.dispatchAction({type:"legendScroll",scrollDataIndex:t,legendId:e.id})},zM.prototype._updatePageInfoView=function(n,i){var o=this._controllerGroup,t=(G(["pagePrev","pageNext"],function(t){var e=null!=i[t+"DataIndex"],t=o.childOfName(t);t&&(t.setStyle("fill",e?n.get("pageIconColor",!0):n.get("pageIconInactiveColor",!0)),t.cursor=e?"pointer":"default")}),o.childOfName("pageText")),e=n.get("pageFormatter"),r=i.pageIndex,r=null!=r?r+1:0,a=i.pageCount;t&&e&&t.setStyle("text",U(e)?e.replace("{current}",null==r?"":r+"").replace("{total}",null==a?"":a+""):e({current:r,total:a}))},zM.prototype._getPageInfo=function(t){var e=t.get("scrollDataIndex",!0),n=this.getContentGroup(),i=this._containerGroup.__rectSize,t=t.getOrient().index,o=OM[t],r=RM[t],e=this._findTargetItemIndex(e),a=n.children(),s=a[e],l=a.length,u=l?1:0,h={contentPosition:[n.x,n.y],pageCount:u,pageIndex:u-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(s){n=g(s);h.contentPosition[t]=-n.s;for(var c=e+1,p=n,d=n,f=null;c<=l;++c)(!(f=g(a[c]))&&d.e>p.s+i||f&&!y(f,p.s))&&(p=d.i>p.i?d:f)&&(null==h.pageNextDataIndex&&(h.pageNextDataIndex=p.i),++h.pageCount),d=f;for(c=e-1,p=n,d=n,f=null;-1<=c;--c)(f=g(a[c]))&&y(d,f.s)||!(p.i=e&&t.s<=e+i}},zM.prototype._findTargetItemIndex=function(n){var i,o;return this._showController?(this.getContentGroup().eachChild(function(t,e){t=t.__legendDataIndex;null==o&&null!=t&&(o=e),t===n&&(i=e)}),null!=i?i:o):0},zM.type="legend.scroll",zM);function zM(){var t=null!==PM&&PM.apply(this,arguments)||this;return t.type=zM.type,t.newlineDisabled=!0,t._currentIndex=0,t}D_(function(t){D_(IM),t.registerComponentModel(DM),t.registerComponentView(NM),t.registerAction("legendScroll","legendscroll",function(t,e){var n=t.scrollDataIndex;null!=n&&e.eachComponent({mainType:"legend",subType:"scroll",query:t},function(t){t.setScrollDataIndex(n)})})});var EM=ta(),BM=S,VM=M;function FM(){this._dragging=!1,this.animationThreshold=15}function HM(t,e,n,i){!function n(i,t){{var o;return L(i)&&L(t)?(o=!0,G(t,function(t,e){o=o&&n(i[e],t)}),!!o):i===t}}(EM(n).lastProp,i)&&(EM(n).lastProp=i,e?rc(n,i,t):(n.stopAnimation(),n.attr(i)))}function GM(t,e){t[e.get(["label","show"])?"show":"hide"]()}function WM(t){return{x:t.x||0,y:t.y||0,rotation:t.rotation||0}}function UM(t,e,n){var i=e.get("z"),o=e.get("zlevel");t&&t.traverse(function(t){"group"!==t.type&&(null!=i&&(t.z=i),null!=o&&(t.zlevel=o),t.silent=n)})}function XM(t,e,n,i,o){var r=YM(n.get("value"),e.axis,e.ecModel,n.get("seriesDataIndices"),{precision:n.get(["label","precision"]),formatter:n.get(["label","formatter"])}),n=n.getModel("label"),a=td(n.get("padding")||0),s=n.getFont(),l=Uo(r,s),u=o.position,h=l.width+a[1]+a[3],l=l.height+a[0]+a[2],c=o.align,c=("right"===c&&(u[0]-=h),"center"===c&&(u[0]-=h/2),o.verticalAlign),i=("bottom"===c&&(u[1]-=l),"middle"===c&&(u[1]-=l/2),o=u,c=h,h=l,i=(l=i).getWidth(),l=l.getHeight(),o[0]=Math.min(o[0]+c,i)-c,o[1]=Math.min(o[1]+h,l)-h,o[0]=Math.max(o[0],0),o[1]=Math.max(o[1],0),n.get("backgroundColor"));i&&"auto"!==i||(i=e.get(["axisLine","lineStyle","color"])),t.label={x:u[0],y:u[1],style:Yc(n,{text:r,font:s,fill:n.getTextColor(),padding:a,backgroundColor:i}),z2:10}}function YM(t,e,n,i,o){t=e.scale.parse(t);var r,a=e.scale.getLabel({value:t},{precision:o.precision}),o=o.formatter;return o&&(r={value:__(e,{value:t}),axisDimension:e.dim,axisIndex:e.index,seriesData:[]},G(i,function(t){var e=n.getSeriesByIndex(t.seriesIndex),t=t.dataIndexInside,e=e&&e.getDataParams(t);e&&r.seriesData.push(e)}),U(o)?a=o.replace("{value}",a):C(o)&&(a=o(r))),a}function ZM(t,e,n){var i=Le();return Ee(i,i,n.rotation),ze(i,i,n.position),Dc([t.dataToCoord(e),(n.labelOffset||0)+(n.labelDirection||1)*(n.labelMargin||0)],i)}FM.prototype.render=function(t,e,n,i){var o,r,a=e.get("value"),s=e.get("status");this._axisModel=t,this._axisPointerModel=e,this._api=n,!i&&this._lastValue===a&&this._lastStatus===s||(this._lastValue=a,this._lastStatus=s,i=this._group,o=this._handle,s&&"hide"!==s?(i&&i.show(),o&&o.show(),this.makeElOption(s={},a,t,e,n),(r=s.graphicKey)!==this._lastGraphicKey&&this.clear(n),this._lastGraphicKey=r,r=this._moveAnimation=this.determineAnimation(t,e),i?(r=T(HM,e,r),this.updatePointerEl(i,s,r),this.updateLabelEl(i,s,r,e)):(i=this._group=new lr,this.createPointerEl(i,s,t,e),this.createLabelEl(i,s,t,e),n.getZr().add(i)),UM(i,e,!0),this._renderHandle(a)):(i&&i.hide(),o&&o.hide()))},FM.prototype.remove=function(t){this.clear(t)},FM.prototype.dispose=function(t){this.clear(t)},FM.prototype.determineAnimation=function(t,e){var n,i=e.get("animation"),o=t.axis,r="category"===o.type,e=e.get("snap");return!(!e&&!r)&&("auto"===i||null==i?(n=this.animationThreshold,r&&o.getBandWidth()>n||!!e&&(r=zS(t).seriesDataCount,e=o.getExtent(),Math.abs(e[0]-e[1])/r>n)):!0===i)},FM.prototype.makeElOption=function(t,e,n,i,o){},FM.prototype.createPointerEl=function(t,e,n,i){var o=e.pointer;o&&(o=EM(t).pointerEl=new Fc[o.type](BM(e.pointer)),t.add(o))},FM.prototype.createLabelEl=function(t,e,n,i){e.label&&(e=EM(t).labelEl=new ll(BM(e.label)),t.add(e),GM(e,i))},FM.prototype.updatePointerEl=function(t,e,n){t=EM(t).pointerEl;t&&e.pointer&&(t.setStyle(e.pointer.style),n(t,{shape:e.pointer.shape}))},FM.prototype.updateLabelEl=function(t,e,n,i){t=EM(t).labelEl;t&&(t.setStyle(e.label.style),n(t,{x:e.label.x,y:e.label.y}),GM(t,i))},FM.prototype._renderHandle=function(t){var e,n,i,o,r,a;!this._dragging&&this.updateHandleTransform&&(e=this._axisPointerModel,n=this._api.getZr(),i=this._handle,o=e.getModel("handle"),a=e.get("status"),o.get("show")&&a&&"hide"!==a?(this._handle||(r=!0,i=this._handle=Rc(o.get("icon"),{cursor:"move",draggable:!0,onmousemove:function(t){Ie(t.event)},onmousedown:VM(this._onHandleDragMove,this,0,0),drift:VM(this._onHandleDragMove,this),ondragend:VM(this._onHandleDragEnd,this)}),n.add(i)),UM(i,e,!1),i.setStyle(o.getItemStyle(null,["color","borderColor","borderWidth","opacity","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY"])),V(a=o.get("size"))||(a=[a,a]),i.scaleX=a[0]/2,i.scaleY=a[1]/2,Uy(this,"_doDispatchAxisPointer",o.get("throttle")||0,"fixRate"),this._moveHandleToValue(t,r)):(i&&n.remove(i),this._handle=null))},FM.prototype._moveHandleToValue=function(t,e){HM(this._axisPointerModel,!e&&this._moveAnimation,this._handle,WM(this.getHandleTransform(t,this._axisModel,this._axisPointerModel)))},FM.prototype._onHandleDragMove=function(t,e){var n=this._handle;n&&(this._dragging=!0,t=this.updateHandleTransform(WM(n),[t,e],this._axisModel,this._axisPointerModel),this._payloadInfo=t,n.stopAnimation(),n.attr(WM(t)),EM(n).lastProp=null,this._doDispatchAxisPointer())},FM.prototype._doDispatchAxisPointer=function(){var t,e;this._handle&&(t=this._payloadInfo,e=this._axisModel,this._api.dispatchAction({type:"updateAxisPointer",x:t.cursorPoint[0],y:t.cursorPoint[1],tooltipOption:t.tooltipOption,axesInfo:[{axisDim:e.axis.dim,axisIndex:e.componentIndex}]}))},FM.prototype._onHandleDragEnd=function(){var t;this._dragging=!1,this._handle&&(t=this._axisPointerModel.get("value"),this._moveHandleToValue(t),this._api.dispatchAction({type:"hideTip"}))},FM.prototype.clear=function(t){this._lastValue=null,this._lastStatus=null;var t=t.getZr(),e=this._group,n=this._handle;t&&e&&(this._lastGraphicKey=null,e&&t.remove(e),n&&t.remove(n),this._group=null,this._handle=null,this._payloadInfo=null),Xy(this,"_doDispatchAxisPointer")},FM.prototype.doClear=function(){},FM.prototype.buildLabel=function(t,e,n){return{x:t[n=n||0],y:t[1-n],width:e[n],height:e[1-n]}};u(KM,qM=FM),KM.prototype.makeElOption=function(t,e,n,i,o){var r,a,s=n.axis,l=s.grid,u=i.get("type"),h=$M(l,s).getOtherAxis(s).getGlobalExtent(),c=s.toGlobalCoord(s.dataToCoord(e,!0)),p=(u&&"none"!==u&&(r=(a=i).get("type"),a=a.getModel(r+"Style"),"line"===r?(p=a.getLineStyle()).fill=null:"shadow"===r&&((p=a.getAreaStyle()).stroke=null),r=p,(a=QM[u](s,c,h)).style=r,t.graphicKey=a.type,t.pointer=a),mS(l.model,n));u=e,s=t,c=p,h=n,r=i,a=o,l=CS.innerTextLayout(c.rotation,0,c.labelDirection),c.labelMargin=r.get(["label","margin"]),XM(s,h,r,a,{position:ZM(h.axis,u,c),align:l.textAlign,verticalAlign:l.textVerticalAlign})},KM.prototype.getHandleTransform=function(t,e,n){var i=mS(e.axis.grid.model,e,{labelInside:!1}),n=(i.labelMargin=n.get(["handle","margin"]),ZM(e.axis,t,i));return{x:n[0],y:n[1],rotation:i.rotation+(i.labelDirection<0?Math.PI:0)}},KM.prototype.updateHandleTransform=function(t,e,n,i){var n=n.axis,o=n.grid,r=n.getGlobalExtent(!0),o=$M(o,n).getOtherAxis(n).getGlobalExtent(),n="x"===n.dim?0:1,a=[t.x,t.y],e=(a[n]+=e[n],a[n]=Math.min(r[1],a[n]),a[n]=Math.max(r[0],a[n]),(o[1]+o[0])/2),r=[e,e];r[n]=a[n];return{x:a[0],y:a[1],rotation:t.rotation,cursorPoint:r,tooltipOption:[{verticalAlign:"middle"},{align:"center"}][n]}};var qM,jM=KM;function KM(){return null!==qM&&qM.apply(this,arguments)||this}function $M(t,e){var n={};return n[e.dim+"AxisIndex"]=e.index,t.getCartesian(n)}var QM={line:function(t,e,n){var i;return i=[e,n[0]],e=[e,n[1]],n=JM(t),{type:"Line",subPixelOptimize:!0,shape:{x1:i[n=n||0],y1:i[1-n],x2:e[n],y2:e[1-n]}}},shadow:function(t,e,n){var i=Math.max(1,t.getBandWidth()),o=n[1]-n[0];return{type:"Rect",shape:(e=[e-i/2,n[0]],n=[i,o],i=JM(t),{x:e[i=i||0],y:e[1-i],width:n[i],height:n[1-i]})}}};function JM(t){return"x"===t.dim?0:1}u(nT,tT=g),nT.type="axisPointer",nT.defaultOption={show:"auto",z:50,type:"line",snap:!1,triggerTooltip:!0,triggerEmphasis:!0,value:null,status:null,link:[],animation:null,animationDurationUpdate:200,lineStyle:{color:"#B9BEC9",width:1,type:"dashed"},shadowStyle:{color:"rgba(210,219,238,0.2)"},label:{show:!0,formatter:null,precision:"auto",margin:3,color:"#fff",padding:[5,7,5,7],backgroundColor:"auto",borderColor:null,borderWidth:0,borderRadius:3},handle:{show:!1,icon:"M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z",size:45,margin:50,color:"#333",shadowBlur:3,shadowColor:"#aaa",shadowOffsetX:0,shadowOffsetY:2,throttle:40}};var tT,eT=nT;function nT(){var t=null!==tT&&tT.apply(this,arguments)||this;return t.type=nT.type,t}var iT=ta(),oT=G;function rT(t,e,n){var i,c,p;function o(t,h){c.on(t,function(e){n=p;var n,i,o={dispatchAction:r,pendings:i={showTip:[],hideTip:[]}};function r(t){var e=i[t.type];e?e.push(t):(t.dispatchAction=r,n.dispatchAction(t))}oT(iT(c).records,function(t){t&&h(t,e,o.dispatchAction)});var t,a=o.pendings,s=p,l=a.showTip.length,u=a.hideTip.length;l?t=a.showTip[l-1]:u&&(t=a.hideTip[u-1]),t&&(t.dispatchAction=null,s.dispatchAction(t))})}w.node||(i=e.getZr(),iT(i).records||(iT(i).records={}),p=e,iT(c=i).initialized||(iT(c).initialized=!0,o("click",T(sT,"click")),o("mousemove",T(sT,"mousemove")),o("globalout",aT)),(iT(i).records[t]||(iT(i).records[t]={})).handler=n)}function aT(t,e,n){t.handler("leave",null,n)}function sT(t,e,n,i){e.handler(t,n,i)}function lT(t,e){w.node||(e=e.getZr(),(iT(e).records||{})[t]&&(iT(e).records[t]=null))}u(cT,uT=Dy),cT.prototype.render=function(t,e,n){var e=e.getComponent("tooltip"),i=t.get("triggerOn")||e&&e.get("triggerOn")||"mousemove|click";rT("axisPointer",n,function(t,e,n){"none"!==i&&("leave"===t||0<=i.indexOf(t))&&n({type:"updateAxisPointer",currTrigger:t,x:e&&e.offsetX,y:e&&e.offsetY})})},cT.prototype.remove=function(t,e){lT("axisPointer",e)},cT.prototype.dispose=function(t,e){lT("axisPointer",e)},cT.type="axisPointer";var uT,hT=cT;function cT(){var t=null!==uT&&uT.apply(this,arguments)||this;return t.type=cT.type,t}function pT(t,e){var n,i,o,r,a=[],s=t.seriesIndex;return null==s||!(e=e.getSeriesByIndex(s))||null==(s=Jr(n=e.getData(),t))||s<0||V(s)?{point:[]}:(i=n.getItemGraphicEl(s),o=e.coordinateSystem,e.getTooltipPosition?a=e.getTooltipPosition(s)||[]:o&&o.dataToPoint?a=t.isStacked?(e=o.getBaseAxis(),t=o.getOtherAxis(e).dim,e=e.dim,t="x"===t||"radius"===t?1:0,e=n.mapDimension(e),(r=[])[t]=n.get(e,s),r[1-t]=n.get(n.getCalculationInfo("stackResultDimension"),s),o.dataToPoint(r)||[]):o.dataToPoint(n.getValues(B(o.dimensions,function(t){return n.mapDimension(t)}),s))||[]:i&&((e=i.getBoundingRect().clone()).applyTransform(i.transform),a=[e.x+e.width/2,e.y+e.height/2]),{point:a,el:i})}var dT=ta();function fT(t,e,n){var r,a,i,s,l,o,u,h,c,p,d,f,g,y,m=t.currTrigger,v=[t.x,t.y],_=t,x=t.dispatchAction||M(n.dispatchAction,n),b=e.getComponent("axisPointer").coordSysAxesInfo;if(b)return _T(v)&&(v=pT({seriesIndex:_.seriesIndex,dataIndex:_.dataIndex},e).point),r=_T(v),a=_.axesInfo,i=b.axesInfo,s="leave"===m||_T(v),l={},e={list:[],map:{}},u={showPointer:T(yT,o={}),showTooltip:T(mT,e)},G(b.coordSysMap,function(t,e){var o=r||t.containPoint(v);G(b.coordSysAxesInfo[e],function(t,e){var n=t.axis,i=function(t,e){for(var n=0;n<(t||[]).length;n++){var i=t[n];if(e.axis.dim===i.axisDim&&e.axis.model.componentIndex===i.axisIndex)return i}}(a,t);s||!o||a&&!i||null!=(i=null!=(i=i&&i.value)||r?i:n.pointToData(v))&&gT(t,i,u,!1,l)})}),h={},G(i,function(n,t){var i=n.linkGroup;i&&!o[t]&&G(i.axesInfo,function(t,e){var e=o[e];t!==n&&e&&(e=e.value,i.mapper&&(e=n.axis.scale.parse(i.mapper(e,vT(t),vT(n)))),h[n.key]=e)})}),G(h,function(t,e){gT(i[e],t,u,!0,l)}),c=o,_=i,p=l.axesInfo=[],G(_,function(t,e){var n=t.axisPointerModel.option,e=c[e];e?(t.useHandle||(n.status="show"),n.value=e.value,n.seriesDataIndices=(e.payloadBatch||[]).slice()):t.useHandle||(n.status="hide"),"show"===n.status&&p.push({axisDim:t.axis.dim,axisIndex:t.axis.model.componentIndex,value:n.value})}),m=e,_=t,e=x,_T(t=v)||!m.list.length?e({type:"hideTip"}):(x=((m.list[0].dataByAxis[0]||{}).seriesDataIndices||[])[0]||{},e({type:"showTip",escapeConnect:!0,x:t[0],y:t[1],tooltipOption:_.tooltipOption,position:_.position,dataIndexInside:x.dataIndexInside,dataIndex:x.dataIndex,seriesIndex:x.seriesIndex,dataByCoordSys:m.list})),e=i,_=(t=n).getZr(),x="axisPointerLastHighlights",d=dT(_)[x]||{},f=dT(_)[x]={},G(e,function(t,e){var n=t.axisPointerModel.option;"show"===n.status&&t.triggerEmphasis&&G(n.seriesDataIndices,function(t){var e=t.seriesIndex+" | "+t.dataIndex;f[e]=t})}),g=[],y=[],G(d,function(t,e){f[e]||y.push(t)}),G(f,function(t,e){d[e]||g.push(t)}),y.length&&t.dispatchAction({type:"downplay",escapeConnect:!0,notBlur:!0,batch:y}),g.length&&t.dispatchAction({type:"highlight",escapeConnect:!0,notBlur:!0,batch:g}),l}function gT(t,e,n,i,o){var r,a,s,l,u,h,c,p,d,f,g=t.axis;!g.scale.isBlank()&&g.containData(e)&&(t.involveSeries?(a=e,s=t.axis,l=s.dim,u=a,h=[],c=Number.MAX_VALUE,p=-1,G(t.seriesModels,function(e,t){var n,i=e.getData().mapDimensionsAll(l);if(e.getAxisTooltipData)var o=e.getAxisTooltipData(i,a,s),r=o.dataIndices,o=o.nestestValue;else{if(!(r=e.getData().indicesOfNearest(i[0],a,"category"===s.type?.5:null)).length)return;o=e.getData().get(i[0],r[0])}null!=o&&isFinite(o)&&(i=a-o,(n=Math.abs(i))<=c)&&((n'):""),U(t))r.innerHTML=t+c;else if(t){r.innerHTML="",V(t)||(t=[t]);for(var p,d=0;d"),r=f.join(e);this._showOrMove(i,function(){this._updateContentNotChangedOnAxis(t,p)?this._updatePosition(i,o,n[0],n[1],this._tooltipContent,p):this._showTooltipContent(i,r,p,Math.random()+"",n[0],n[1],o,null,g)})},UT.prototype._showSeriesItemTooltip=function(t,e,n){var i,o,r,a,s,l=this._ecModel,e=D(e),u=e.seriesIndex,h=l.getSeriesByIndex(u),c=e.dataModel||h,p=e.dataIndex,e=e.dataType,d=c.getData(e),f=this._renderMode,g=t.positionDefault,y=XT([d.getItemModel(p),c,h&&(h.coordinateSystem||{}).model],this._tooltipModel,g?{position:g}:null),h=y.get("trigger");null!=h&&"item"!==h||(i=c.getDataParams(p,e),o=new fy,i.marker=o.makeTooltipMarker("item",ad(i.color),f),g=lg(c.formatTooltip(p,!1,e)),h=y.get("order"),e=y.get("valueFormatter"),r=g.frag,a=r?hy(e?F({valueFormatter:e},r):r,o,f,h,l.get("useUTC"),y.get("textStyle")):g.text,s="item_"+c.name+"_"+p,this._showOrMove(y,function(){this._showTooltipContent(y,a,i,s,t.offsetX,t.offsetY,t.position,t.target,o)}),n({type:"showTip",dataIndexInside:p,dataIndex:d.getRawIndex(p),seriesIndex:u,from:this.uid}))},UT.prototype._showComponentItemTooltip=function(e,n,t){var i=D(n),o=i.tooltipConfig.option||{},r=[o=U(o)?{content:o,formatter:o}:o],i=this._ecModel.getComponent(i.componentMainType,i.componentIndex),i=(i&&r.push(i),r.push({formatter:o.content}),e.positionDefault),a=XT(r,this._tooltipModel,i?{position:i}:null),s=a.get("content"),l=Math.random()+"",u=new fy;this._showOrMove(a,function(){var t=S(a.get("formatterParams")||{});this._showTooltipContent(a,s,t,l,e.offsetX,e.offsetY,e.position,n,u)}),t({type:"showTip",from:this.uid})},UT.prototype._showTooltipContent=function(n,t,i,e,o,r,a,s,l){var u,h,c,p,d;this._ticket="",n.get("showContent")&&n.get("show")&&((u=this._tooltipContent).setEnterable(n.get("enterable")),h=n.get("formatter"),a=a||n.get("position"),t=t,c=this._getNearestPoint([o,r],i,n.get("trigger"),n.get("borderColor")).color,h&&(t=U(h)?(p=n.ecModel.get("useUTC"),t=h,od(t=(d=V(i)?i[0]:i)&&d.axisType&&0<=d.axisType.indexOf("time")?zp(d.axisValue,t,p):t,i,!0)):C(h)?(d=M(function(t,e){t===this._ticket&&(u.setContent(e,l,n,c,a),this._updatePosition(n,a,o,r,u,i,s))},this),this._ticket=e,h(i,e,d)):h),u.setContent(t,l,n,c,a),u.show(n,c),this._updatePosition(n,a,o,r,u,i,s))},UT.prototype._getNearestPoint=function(t,e,n,i){return"axis"===n||V(e)?{color:i||("html"===this._renderMode?"#fff":"none")}:V(e)?void 0:{color:i||e.color||e.borderColor}},UT.prototype._updatePosition=function(t,e,n,i,o,r,a){var s,l=this._api.getWidth(),u=this._api.getHeight(),h=(e=e||t.get("position"),o.getSize()),c=t.get("align"),p=t.get("verticalAlign"),d=a&&a.getBoundingRect().clone();a&&d.applyTransform(a.transform),V(e=C(e)?e([n,i],r,o.el,d,{viewSize:[l,u],contentSize:h.slice()}):e)?(n=q(e[0],l),i=q(e[1],u)):L(e)?((r=e).width=h[0],r.height=h[1],n=(r=dd(r,{width:l,height:u})).x,i=r.y,p=c=null):i=(n=(s=U(e)&&a?function(t,e,n,i){var o=n[0],r=n[1],a=Math.ceil(Math.SQRT2*i)+8,s=0,l=0,u=e.width,h=e.height;switch(t){case"inside":s=e.x+u/2-o/2,l=e.y+h/2-r/2;break;case"top":s=e.x+u/2-o/2,l=e.y-r-a;break;case"bottom":s=e.x+u/2-o/2,l=e.y+h+a;break;case"left":s=e.x-o-a,l=e.y+h/2-r/2;break;case"right":s=e.x+u+a,l=e.y+h/2-r/2}return[s,l]}(e,d,h,t.get("borderWidth")):function(t,e,n,i,o,r,a){var n=n.getSize(),s=n[0],n=n[1];null!=r&&(ih[0]?s:o)[0]:r[0]=(a[0]>h[0]?o:s)[0],"y0"===n[1]?r[1]=(a[1]>h[1]?s:o)[1]:r[1]=(a[1]>h[1]?o:s)[1],i.getMarkerPosition(r,n,!0)):(a=[l=t.get(n[0],e),u=t.get(n[1],e)],c.clampData&&c.clampData(a,a),c.dataToPoint(a,!0)),fb(c,"cartesian2d")&&(o=c.getAxis("x"),s=c.getAxis("y"),l=t.get(n[0],e),u=t.get(n[1],e),i2(l)?h[0]=o.toGlobalCoord(o.getExtent()["x0"===n[0]?0:1]):i2(u)&&(h[1]=s.toGlobalCoord(s.getExtent()["y0"===n[1]?0:1]))),isNaN(d)||(h[0]=d),isNaN(p)||(h[1]=p)):h=[d,p],h}var s2,l2=[["x0","y0"],["x1","y0"],["x1","y1"],["x0","y1"]],u2=(u(h2,s2=Wu),h2.prototype.updateTransform=function(t,e,o){e.eachSeries(function(n){var i,t=QT.getMarkerModelFromSeries(n,"markArea");t&&(i=t.getData()).each(function(e){var t=B(l2,function(t){return a2(i,e,t,n,o)});i.setItemLayout(e,t),i.getItemGraphicEl(e).setShape("points",t)})},this)},h2.prototype.renderSeries=function(a,o,t,s){var l=a.coordinateSystem,e=a.id,u=a.getData(),n=this.markerGroupMap,i=n.get(e)||n.set(e,{group:new lr}),h=(this.group.add(i.group),this.markKeep(i),function(t,n,e){var i,o;{var r;i=t?(r=B(t&&t.dimensions,function(t){var e=n.getData();return F(F({},e.getDimensionInfo(e.mapDimension(t))||{}),{name:t,ordinalMeta:null})}),o=B(["x0","y0","x1","y1"],function(t,e){return{name:t,type:r[e%2].type}}),new a1(o,e)):new a1(o=[{name:"value",type:"float"}],e)}e=B(e.get("data"),T(e2,n,t,e));t&&(e=pt(e,T(r2,t)));t=t?function(t,e,n,i){return bg(t.coord[Math.floor(i/2)][i%2],o[i])}:function(t,e,n,i){return bg(t.value,o[i])};return i.initData(e,null,t),i.hasItemOption=!0,i}(l,a,o));o.setData(h),h.each(function(e){var t=B(l2,function(t){return a2(h,e,t,a,s)}),n=l.getAxis("x").scale,i=l.getAxis("y").scale,o=n.getExtent(),r=i.getExtent(),n=[n.parse(h.get("x0",e)),n.parse(h.get("x1",e))],i=[i.parse(h.get("y0",e)),i.parse(h.get("y1",e))],o=(Sr(n),Sr(i),!(o[0]>n[1]||o[1]i[1]||r[1]=this._data.count()-1},p2.prototype.setPlayState=function(t){this.option.autoPlay=!!t},p2.prototype.getPlayState=function(){return!!this.option.autoPlay},p2.prototype._initData=function(){var o,t=this.option,e=t.data||[],t=t.axisType,r=this._names=[],e=("category"===t?(o=[],G(e,function(t,e){var n,i=jr(Xr(t),"");L(t)?(n=S(t)).value=e:n=e,o.push(n),r.push(i)})):o=e,{category:"ordinal",time:"time",value:"number"}[t]||"number");(this._data=new a1([{name:"value",type:e}],this)).initData(o,r)},p2.prototype.getData=function(){return this._data},p2.prototype.getCategories=function(){if("category"===this.get("axisType"))return this._names.slice()},p2.type="timeline",p2.defaultOption={z:4,show:!0,axisType:"time",realtime:!0,left:"20%",top:null,right:"20%",bottom:0,width:null,height:40,padding:5,controlPosition:"left",autoPlay:!1,rewind:!1,loop:!0,playInterval:2e3,currentIndex:0,itemStyle:{},label:{color:"#000"},data:[]};var c2,tc=p2;function p2(){var t=null!==c2&&c2.apply(this,arguments)||this;return t.type=p2.type,t.layoutMode="box",t}u(g2,d2=tc),g2.type="timeline.slider",g2.defaultOption=mp(tc.defaultOption,{backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,orient:"horizontal",inverse:!1,tooltip:{trigger:"item"},symbol:"circle",symbolSize:12,lineStyle:{show:!0,width:2,color:"#DAE1F5"},label:{position:"auto",show:!0,interval:"auto",rotate:0,color:"#A4B1D7"},itemStyle:{color:"#A4B1D7",borderWidth:1},checkpointStyle:{symbol:"circle",symbolSize:15,color:"#316bf3",borderColor:"#fff",borderWidth:2,shadowBlur:2,shadowOffsetX:1,shadowOffsetY:1,shadowColor:"rgba(0, 0, 0, 0.3)",animation:!0,animationDuration:300,animationEasing:"quinticInOut"},controlStyle:{show:!0,showPlayBtn:!0,showPrevBtn:!0,showNextBtn:!0,itemSize:24,itemGap:12,position:"left",playIcon:"path://M31.6,53C17.5,53,6,41.5,6,27.4S17.5,1.8,31.6,1.8C45.7,1.8,57.2,13.3,57.2,27.4S45.7,53,31.6,53z M31.6,3.3 C18.4,3.3,7.5,14.1,7.5,27.4c0,13.3,10.8,24.1,24.1,24.1C44.9,51.5,55.7,40.7,55.7,27.4C55.7,14.1,44.9,3.3,31.6,3.3z M24.9,21.3 c0-2.2,1.6-3.1,3.5-2l10.5,6.1c1.899,1.1,1.899,2.9,0,4l-10.5,6.1c-1.9,1.1-3.5,0.2-3.5-2V21.3z",stopIcon:"path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z",nextIcon:"M2,18.5A1.52,1.52,0,0,1,.92,18a1.49,1.49,0,0,1,0-2.12L7.81,9.36,1,3.11A1.5,1.5,0,1,1,3,.89l8,7.34a1.48,1.48,0,0,1,.49,1.09,1.51,1.51,0,0,1-.46,1.1L3,18.08A1.5,1.5,0,0,1,2,18.5Z",prevIcon:"M10,.5A1.52,1.52,0,0,1,11.08,1a1.49,1.49,0,0,1,0,2.12L4.19,9.64,11,15.89a1.5,1.5,0,1,1-2,2.22L1,10.77A1.48,1.48,0,0,1,.5,9.68,1.51,1.51,0,0,1,1,8.58L9,.92A1.5,1.5,0,0,1,10,.5Z",prevBtnSize:18,nextBtnSize:18,color:"#A4B1D7",borderColor:"#A4B1D7",borderWidth:1},emphasis:{label:{show:!0,color:"#6f778d"},itemStyle:{color:"#316BF3"},controlStyle:{color:"#316BF3",borderColor:"#316BF3",borderWidth:2}},progress:{lineStyle:{color:"#316BF3"},itemStyle:{color:"#316BF3"},label:{color:"#6f778d"}},data:[]});var d2,f2=g2;function g2(){var t=null!==d2&&d2.apply(this,arguments)||this;return t.type=g2.type,t}ut(f2,hp.prototype);u(m2,y2=Dy),m2.type="timeline";var y2,Vh=m2;function m2(){var t=null!==y2&&y2.apply(this,arguments)||this;return t.type=m2.type,t}u(x2,v2=lp),x2.prototype.getLabelModel=function(){return this.model.getModel("label")},x2.prototype.isHorizontal=function(){return"horizontal"===this.model.get("orient")};var v2,_2=x2;function x2(t,e,n,i){t=v2.call(this,t,e,n)||this;return t.type=i||"value",t}var b2,w2=Math.PI,S2=ta(),M2=(u(T2,b2=Vh),T2.prototype.init=function(t,e){this.api=e},T2.prototype.render=function(e,t,n){var i,o,r;this.model=e,this.api=n,this.ecModel=t,this.group.removeAll(),e.get("show",!0)&&(i=this._layout(e,n),o=this._createGroup("_mainGroup"),t=this._createGroup("_labelGroup"),r=this._axis=this._createAxis(i,e),e.formatTooltip=function(t){return ry("nameValue",{noName:!0,value:r.scale.getLabel({value:t})})},G(["AxisLine","AxisTick","Control","CurrentPointer"],function(t){this["_render"+t](i,o,r,e)},this),this._renderAxisLabel(i,t,r,e),this._position(i,e)),this._doPlayStop(),this._updateTicksStatus()},T2.prototype.remove=function(){this._clearTimer(),this.group.removeAll()},T2.prototype.dispose=function(){this._clearTimer()},T2.prototype._layout=function(t,e){var n,i,o,r=t.get(["label","position"]),a=t.get("orient"),s=(s=e,dd((l=t).getBoxLayoutParams(),{width:s.getWidth(),height:s.getHeight()},l.get("padding"))),l=null==r||"auto"===r?"horizontal"===a?s.y+s.height/2n[1]?n[1]:t)r&&(e[1-i]=e[i]+n.sign*r)}function Z2(t,e){t=t[e]-t[1-e];return{span:Math.abs(t),sign:0e[1]&&(e[1]=t[1])})}),[(e=d_((n=e.getAxisModel()).axis.scale,n,o).calculate()).min,e.max]),this._updateMinMaxSpan(),n=this.calculateDataWindow(t.settledOption),this._valueWindow=n.valueWindow,this._percentWindow=n.percentWindow,this._setAxisModel())},vC.prototype.filterData=function(t,e){var o,n,r,c;t===this._dataZoomModel&&(o=this._dimName,n=this.getTargetSeriesModels(),r=t.get("filterMode"),c=this._valueWindow,"none"!==r)&&gC(n,function(n){var l,u,i=n.getData(),h=i.mapDimensionsAll(o);h.length&&("weakFilter"===r?(l=i.getStore(),u=B(h,function(t){return i.getDimensionIndex(t)},i),i.filterSelf(function(t){for(var e,n,i,o=0;oc[1];if(a&&!s&&!r)return!0;a&&(i=!0),s&&(e=!0),r&&(n=!0)}return i&&e&&n})):gC(h,function(t){var e;"empty"===r?n.setData(i=i.map(t,function(t){return(e=t)>=c[0]&&e<=c[1]?t:NaN;var e})):((e={})[t]=c,i.selectRange(e))}),gC(h,function(t){i.setApproximateExtent(c,t)}))})},vC.prototype._updateMinMaxSpan=function(){var i=this._minMaxSpan={},o=this._dataZoomModel,r=this._dataExtent;gC(["min","max"],function(t){var e=o.get(t+"Span"),n=o.get(t+"ValueSpan");null!=(n=null!=n?this.getAxisModel().axis.scale.parse(n):n)?e=br(r[0]+n,r,[0,100],!0):null!=e&&(n=br(e,[0,100],r,!0)-r[0]),i[t+"Span"]=e,i[t+"ValueSpan"]=n},this)},vC.prototype._setAxisModel=function(){var t,e=this.getAxisModel(),n=this._percentWindow,i=this._valueWindow;n&&(t=Ir(i,[0,500]),t=Math.min(t,20),e=e.axis.scale.rawExtentInfo,0!==n[0]&&e.setDeterminedMinMax("min",+i[0].toFixed(t)),100!==n[1]&&e.setDeterminedMinMax("max",+i[1].toFixed(t)),e.freeze())},vC);function vC(t,e,n,i){this._dimName=t,this._axisIndex=e,this.ecModel=i,this._dataZoomModel=n}var _C={getTargetSeries:function(r){function t(o){r.eachComponent("dataZoom",function(i){i.eachTargetAxis(function(t,e){var n=r.getComponent(O2(t),e);o(t,e,n,i)})})}t(function(t,e,n,i){n.__dzAxisProxy=null});var o=[],e=(t(function(t,e,n,i){n.__dzAxisProxy||(n.__dzAxisProxy=new mC(t,e,i,r),o.push(n.__dzAxisProxy))}),R());return G(o,function(t){G(t.getTargetSeriesModels(),function(t){e.set(t.uid,t)})}),e},overallReset:function(t,i){t.eachComponent("dataZoom",function(n){n.eachTargetAxis(function(t,e){n.getAxisProxy(t,e).reset(n)}),n.eachTargetAxis(function(t,e){n.getAxisProxy(t,e).filterData(n,i)})}),t.eachComponent("dataZoom",function(t){var e,n=t.findRepresentativeAxisProxy();n&&(e=n.getDataPercentWindow(),n=n.getDataValueWindow(),t.setCalculatedRange({start:e[0],end:e[1],startValue:n[0],endValue:n[1]}))})}};var xC=!1;function bC(t){xC||(xC=!0,t.registerProcessor(t.PRIORITY.PROCESSOR.FILTER,_C),t.registerAction("dataZoom",function(e,t){G(R2(t,e),function(t){t.setRawRange({start:e.start,end:e.end,startValue:e.startValue,endValue:e.endValue})})}),t.registerSubTypeDefaulter("dataZoom",function(){return"slider"}))}function wC(t){bC(t),t.registerComponentModel(G2),t.registerComponentView(hC),lC(t)}u(TC,SC=hh),TC.type="dataZoom.slider",TC.layoutMode="box",TC.defaultOption=mp(hh.defaultOption,{show:!0,right:"ph",top:"ph",width:"ph",height:"ph",left:null,bottom:null,borderColor:"#d2dbee",borderRadius:3,backgroundColor:"rgba(47,69,84,0)",dataBackground:{lineStyle:{color:"#d2dbee",width:.5},areaStyle:{color:"#d2dbee",opacity:.2}},selectedDataBackground:{lineStyle:{color:"#8fb0f7",width:.5},areaStyle:{color:"#8fb0f7",opacity:.2}},fillerColor:"rgba(135,175,274,0.2)",handleIcon:"path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z",handleSize:"100%",handleStyle:{color:"#fff",borderColor:"#ACB8D1"},moveHandleSize:7,moveHandleIcon:"path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z",moveHandleStyle:{color:"#D2DBEE",opacity:.7},showDetail:!0,showDataShadow:"auto",realtime:!0,zoomLock:!1,textStyle:{color:"#6E7079"},brushSelect:!0,brushStyle:{color:"rgba(135,175,274,0.15)"},emphasis:{handleStyle:{borderColor:"#8FB0F7"},moveHandleStyle:{color:"#8FB0F7"}}});var SC,MC=TC;function TC(){var t=null!==SC&&SC.apply(this,arguments)||this;return t.type=TC.type,t}var IC,CC=il,DC="horizontal",kC="vertical",AC=["line","bar","candlestick","scatter"],PC={easing:"cubicOut",duration:100,delay:0},LC=(u(OC,IC=op),OC.prototype.init=function(t,e){this.api=e,this._onBrush=M(this._onBrush,this),this._onBrushEnd=M(this._onBrushEnd,this)},OC.prototype.render=function(t,e,n,i){IC.prototype.render.apply(this,arguments),Uy(this,"_dispatchZoomAction",t.get("throttle"),"fixRate"),this._orient=t.getOrient(),!1===t.get("show")?this.group.removeAll():t.noTarget()?(this._clear(),this.group.removeAll()):(i&&"dataZoom"===i.type&&i.from===this.uid||this._buildView(),this._updateView())},OC.prototype.dispose=function(){this._clear(),IC.prototype.dispose.apply(this,arguments)},OC.prototype._clear=function(){Xy(this,"_dispatchZoomAction");var t=this.api.getZr();t.off("mousemove",this._onBrush),t.off("mouseup",this._onBrushEnd)},OC.prototype._buildView=function(){var t=this.group,e=(t.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval(),this._displayables.sliderGroup=new lr);this._renderBackground(),this._renderHandle(),this._renderDataShadow(),t.add(e),this._positionGroup()},OC.prototype._resetLocation=function(){var t=this.dataZoomModel,e=this.api,n=t.get("brushSelect")?7:0,i=this._findCoordRect(),e={width:e.getWidth(),height:e.getHeight()},o=this._orient===DC?{right:e.width-i.x-i.width,top:e.height-30-7-n,width:i.width,height:30}:{right:7,top:i.y,width:30,height:i.height},r=md(t.option),n=(G(["right","top","width","height"],function(t){"ph"===r[t]&&(r[t]=o[t])}),dd(r,e));this._location={x:n.x,y:n.y},this._size=[n.width,n.height],this._orient===kC&&this._size.reverse()},OC.prototype._positionGroup=function(){var t=this.group,e=this._location,n=this._orient,i=this.dataZoomModel.getFirstTargetAxisModel(),i=i&&i.get("inverse"),o=this._displayables.sliderGroup,r=(this._dataShadowInfo||{}).otherAxisInverse,n=(o.attr(n!==DC||i?n===DC&&i?{scaleY:r?1:-1,scaleX:-1}:n!==kC||i?{scaleY:r?-1:1,scaleX:-1,rotation:Math.PI/2}:{scaleY:r?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:r?1:-1,scaleX:1}),t.getBoundingRect([o]));t.x=e.x-n.x,t.y=e.y-n.y,t.markRedraw()},OC.prototype._getViewExtent=function(){return[0,this._size[0]]},OC.prototype._renderBackground=function(){var t=this.dataZoomModel,e=this._size,n=this._displayables.sliderGroup,i=t.get("brushSelect"),t=(n.add(new CC({silent:!0,shape:{x:0,y:0,width:e[0],height:e[1]},style:{fill:t.get("backgroundColor")},z2:-40})),new CC({shape:{x:0,y:0,width:e[0],height:e[1]},style:{fill:"transparent"},z2:0,onclick:M(this._onClickPanel,this)})),e=this.api.getZr();i?(t.on("mousedown",this._onBrushStart,this),t.cursor="crosshair",e.on("mousemove",this._onBrush),e.on("mouseup",this._onBrushEnd)):(e.off("mousemove",this._onBrush),e.off("mouseup",this._onBrushEnd)),n.add(t)},OC.prototype._renderDataShadow=function(){var t=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],t){var e=this._size,n=this._shadowSize||[],i=t.series,o=i.getRawData(),r=i.getShadowDim&&i.getShadowDim(),r=r&&o.getDimensionInfo(r)?i.getShadowDim():t.otherDim;if(null!=r)for(var a,s,l,u,h,c,p,d,f,g,y=this._shadowPolygonPts,m=this._shadowPolylinePts,v=(o===this._shadowData&&r===this._shadowDim&&e[0]===n[0]&&e[1]===n[1]||(i=.3*((a=o.getDataExtent(r))[1]-a[0]),a=[a[0]-i,a[1]+i],s=[0,e[1]],t=[0,e[0]],l=[[e[0],0],[0,0]],u=[],h=t[1]/(o.count()-1),c=0,p=Math.round(o.count()/e[0]),o.each([r],function(t,e){var n;0e[0]||t[1]<0||t[1]>e[1]||(e=((e=this._handleEnds)[0]+e[1])/2,t=this._updateInterval("all",t[0]-e),this._updateView(),t&&this._dispatchZoomAction(!1))},OC.prototype._onBrushStart=function(t){var e=t.offsetX,t=t.offsetY;this._brushStart=new z(e,t),this._brushing=!0,this._brushStartTime=+new Date},OC.prototype._onBrushEnd=function(t){var e,n,i;this._brushing&&(e=this._displayables.brushRect,this._brushing=!1,e)&&(e.attr("ignore",!0),e=e.shape,+new Date-this._brushStartTime<200&&Math.abs(e.width)<5||(n=this._getViewExtent(),this._range=Sr([br(e.x,n,i=[0,100],!0),br(e.x+e.width,n,i,!0)]),this._handleEnds=[e.x,e.x+e.width],this._updateView(),this._dispatchZoomAction(!1)))},OC.prototype._onBrush=function(t){this._brushing&&(Ie(t.event),this._updateBrushRect(t.offsetX,t.offsetY))},OC.prototype._updateBrushRect=function(t,e){var n=this._displayables,i=this.dataZoomModel,o=n.brushRect,i=(o||(o=n.brushRect=new CC({silent:!0,style:i.getModel("brushStyle").getItemStyle()}),n.sliderGroup.add(o)),o.attr("ignore",!1),this._brushStart),n=this._displayables.sliderGroup,t=n.transformCoordToLocal(t,e),e=n.transformCoordToLocal(i.x,i.y),n=this._size;t[0]=Math.max(Math.min(n[0],t[0]),0),o.setShape({x:e[0],y:0,width:t[0]-e[0],height:n[1]})},OC.prototype._dispatchZoomAction=function(t){var e=this._range;this.api.dispatchAction({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,animation:t?PC:null,start:e[0],end:e[1]})},OC.prototype._findCoordRect=function(){var t,e,n=N2(this.dataZoomModel).infoList;return t=(t=!t&&n.length?(n=n[0].model.coordinateSystem).getRect&&n.getRect():t)?t:{x:.2*(n=this.api.getWidth()),y:.2*(e=this.api.getHeight()),width:.6*n,height:.6*e}},OC.type="dataZoom.slider",OC);function OC(){var t=null!==IC&&IC.apply(this,arguments)||this;return t.type=OC.type,t._displayables={},t}function RC(t){return"vertical"===t?"ns-resize":"ew-resize"}function NC(t){t.registerComponentModel(MC),t.registerComponentView(LC),bC(t)}D_(function(t){D_(wC),D_(NC)});var zC=["rect","polygon","keep","clear"];function EC(t,e){var n,i,o,r=Gr(t?t.brush:[]);r.length&&(n=[],G(r,function(t){t=t.hasOwnProperty("toolbox")?t.toolbox:[];t instanceof Array&&(n=n.concat(t))}),(r=V(r=t&&t.toolbox)?r[0]:r)||(t.toolbox=[r={feature:{}}]),r=(t=r.feature||(r.feature={})).brush||(t.brush={}),(t=r.type||(r.type=[])).push.apply(t,n),o={},G(i=t,function(t){o[t]=1}),i.length=0,G(o,function(t,e){i.push(e)}),e)&&!t.length&&t.push.apply(t,zC)}var BC,VC=!0,FC=Math.min,HC=Math.max,GC=Math.pow,WC=1e4,UC=6,XC=6,YC="globalPan",ZC={w:[0,0],e:[0,1],n:[1,0],s:[1,1]},qC={w:"ew",e:"ew",n:"ns",s:"ns",ne:"nesw",sw:"nesw",nw:"nwse",se:"nwse"},jC={brushStyle:{lineWidth:2,stroke:"rgba(210,219,238,0.3)",fill:"#D2DBEE"},transformable:!0,brushMode:"single",removeOnClick:!1},KC=0,$C=(u(QC,BC=se),QC.prototype.enableBrush=function(t){return this._brushType&&this._doDisableBrush(),t.brushType&&this._doEnableBrush(t),this},QC.prototype._doEnableBrush=function(t){var e,n,i=this._zr;this._enableGlobalPan||(e=YC,n=this._uid,$2(i)[e]=n),G(this._handlers,function(t,e){i.on(e,t)}),this._brushType=t.brushType,this._brushOption=d(S(jC),t,!0)},QC.prototype._doDisableBrush=function(){var t,e,n,i=this._zr;t=i,e=YC,n=this._uid,(t=$2(t))[e]===n&&(t[e]=null),G(this._handlers,function(t,e){i.off(e,t)}),this._brushType=this._brushOption=null},QC.prototype.setPanels=function(t){var e;return t&&t.length?(e=this._panels={},G(t,function(t){e[t.panelId]=S(t)})):this._panels=null,this},QC.prototype.mount=function(t){this._enableGlobalPan=(t=t||{}).enableGlobalPan;var e=this.group;return this._zr.add(e),e.attr({x:t.x||0,y:t.y||0,rotation:t.rotation||0,scaleX:t.scaleX||1,scaleY:t.scaleY||1}),this._transform=e.getLocalTransform(),this},QC.prototype.updateCovers=function(i){i=B(i,function(t){return d(S(jC),t,!0)});var n="\0-brush-index-",o=this._covers,r=this._covers=[],a=this,s=this._creatingCover;return new Rv(o,i,function(t,e){return l(t.__brushOption,e)},l).add(t).update(t).remove(function(t){o[t]!==s&&a.group.remove(o[t])}).execute(),this;function l(t,e){return(null!=t.id?t.id:n+e)+"-"+t.brushType}function t(t,e){var n=i[t];null!=e&&o[e]===s?r[t]=o[e]:(t=r[t]=null!=e?(o[e].__brushOption=n,o[e]):tD(a,JC(a,n)),iD(a,t))}},QC.prototype.unmount=function(){return this.enableBrush(!1),sD(this),this._zr.remove(this.group),this},QC.prototype.dispose=function(){this.unmount(),this.off()},QC);function QC(t){var e=BC.call(this)||this;return e._track=[],e._covers=[],e._handlers={},e._zr=t,e.group=new lr,e._uid="brushController_"+KC++,G(ID,function(t,e){this._handlers[e]=M(t,this)},e),e}function JC(t,e){var n=DD[e.brushType].createCover(t,e);return n.__brushOption=e,nD(n,e),t.group.add(n),n}function tD(t,e){var n=oD(e);return n.endCreating&&(n.endCreating(t,e),nD(e,e.__brushOption)),e}function eD(t,e){var n=e.__brushOption;oD(e).updateCoverShape(t,e,n.range,n)}function nD(t,e){var n=e.z;null==n&&(n=WC),t.traverse(function(t){t.z=n,t.z2=n})}function iD(t,e){oD(e).updateCommon(t,e),eD(t,e)}function oD(t){return DD[t.__brushOption.brushType]}function rD(t,e,n){var i,o,r=t._panels;return r?(o=t._transform,G(r,function(t){t.isTargetByCursor(e,n,o)&&(i=t)}),i):VC}function aD(t,e){t=t._panels;return t&&null!=(e=e.__brushOption.panelId)?t[e]:VC}function sD(e){var t=e._covers,n=t.length;return G(t,function(t){e.group.remove(t)},e),t.length=0,n}function lD(t,e){var n=B(t._covers,function(t){var t=t.__brushOption,e=S(t.range);return{brushType:t.brushType,panelId:t.panelId,range:e}});t.trigger("brush",{areas:n,isEnd:!!e.isEnd,removeOnClick:!!e.removeOnClick})}function uD(t){var e=t.length-1;return[t[0],t[e=e<0?0:e]]}function hD(e,n,t,i){var o=new lr;return o.add(new il({name:"main",style:fD(t),silent:!0,draggable:!0,cursor:"move",drift:T(mD,e,n,o,["n","s","w","e"]),ondragend:T(lD,n,{isEnd:!0})})),G(i,function(t){o.add(new il({name:t.join(""),style:{opacity:0},draggable:!0,silent:!0,invisible:!0,drift:T(mD,e,n,o,t),ondragend:T(lD,n,{isEnd:!0})}))}),o}function cD(t,e,n,i){var o=i.brushStyle.lineWidth||0,r=HC(o,XC),a=n[0][0],s=n[1][0],l=a-o/2,u=s-o/2,h=n[0][1],n=n[1][1],c=h-r+o/2,p=n-r+o/2,h=h-a,n=n-s,d=h+o,o=n+o;dD(t,e,"main",a,s,h,n),i.transformable&&(dD(t,e,"w",l,u,r,o),dD(t,e,"e",c,u,r,o),dD(t,e,"n",l,u,d,r),dD(t,e,"s",l,p,d,r),dD(t,e,"nw",l,u,r,r),dD(t,e,"ne",c,u,r,r),dD(t,e,"sw",l,p,r,r),dD(t,e,"se",c,p,r,r))}function pD(n,i){var t=i.__brushOption,o=t.transformable,e=i.childAt(0);e.useStyle(fD(t)),e.attr({silent:!o,cursor:o?"move":"default"}),G([["w"],["e"],["n"],["s"],["s","e"],["s","w"],["n","e"],["n","w"]],function(t){var e=i.childOfName(t.join("")),t=1===t.length?yD(n,t[0]):function(t,e){t=[yD(t,e[0]),yD(t,e[1])];return"e"!==t[0]&&"w"!==t[0]||t.reverse(),t.join("")}(n,t);e&&e.attr({silent:!o,invisible:!o,cursor:o?qC[t]+"-resize":null})})}function dD(t,e,n,i,o,r,a){var n=e.childOfName(n);n&&n.setShape((n=xD(t,e,[[i,o],[i+r,o+a]]),t=FC(n[0][0],n[1][0]),e=FC(n[0][1],n[1][1]),i=HC(n[0][0],n[1][0]),n=HC(n[0][1],n[1][1]),{x:t,y:e,width:i-t,height:n-e}))}function fD(t){return E({strokeNoScale:!0},t.brushStyle)}function gD(t,e,n,i){var o=[FC(t,n),FC(e,i)],t=[HC(t,n),HC(e,i)];return[[o[0],t[0]],[o[1],t[1]]]}function yD(t,e){return{left:"w",right:"e",top:"n",bottom:"s"}[kc({w:"left",e:"right",n:"top",s:"bottom"}[e],Cc(t.group))]}function mD(t,e,n,i,o,r){var a=n.__brushOption,s=t.toRectRange(a.range),l=_D(e,o,r);G(i,function(t){t=ZC[t];s[t[0]][t[1]]+=l[t[0]]}),a.range=t.fromRectRange(gD(s[0][0],s[1][0],s[0][1],s[1][1])),iD(e,n),lD(e,{isEnd:!1})}function vD(t,e,n,i){var o=e.__brushOption.range,r=_D(t,n,i);G(o,function(t){t[0]+=r[0],t[1]+=r[1]}),iD(t,e),lD(t,{isEnd:!1})}function _D(t,e,n){t=t.group,e=t.transformCoordToLocal(e,n),n=t.transformCoordToLocal(0,0);return[e[0]-n[0],e[1]-n[1]]}function xD(t,e,n){e=aD(t,e);return e&&e!==VC?e.clipPath(n,t._transform):S(n)}function bD(t,e,n){if(t._brushType&&!function(t,e,n){t=t._zr;return e<0||e>t.getWidth()||n<0||n>t.getHeight()}(t,e.offsetX,e.offsetY)){var i=t._zr,o=t._covers,r=rD(t,e,n);if(!t._dragging)for(var a=0;at[1]&&t.reverse(),t}function ak(t,e){return na(t,e,{includeMainTypes:nk})}var sk={grid:function(t,i){var o=t.xAxisModels,r=t.yAxisModels,t=t.gridModels,e=R(),a={},s={};(o||r||t)&&(G(o,function(t){t=t.axis.grid.model;e.set(t.id,t),a[t.id]=!0}),G(r,function(t){t=t.axis.grid.model;e.set(t.id,t),s[t.id]=!0}),G(t,function(t){e.set(t.id,t),a[t.id]=!0,s[t.id]=!0}),e.each(function(t){var e=t.coordinateSystem,n=[];G(e.getCartesians(),function(t,e){(0<=H(o,t.getAxis("x").model)||0<=H(r,t.getAxis("y").model))&&n.push(t)}),i.push({panelId:"grid--"+t.id,gridModel:t,coordSysModel:t,coordSys:n[0],coordSyses:n,getPanelRect:uk.grid,xAxisDeclared:a[t.id],yAxisDeclared:s[t.id]})}))},geo:function(t,n){G(t.geoModels,function(t){var e=t.coordinateSystem;n.push({panelId:"geo--"+t.id,geoModel:t,coordSysModel:t,coordSys:e,coordSyses:[e],getPanelRect:uk.geo})})}},lk=[function(t,e){var n=t.xAxisModel,i=t.yAxisModel,t=t.gridModel;return(t=!(t=!t&&n?n.axis.grid.model:t)&&i?i.axis.grid.model:t)&&t===e.gridModel},function(t,e){t=t.geoModel;return t&&t===e.geoModel}],uk={grid:function(){return this.coordSys.master.getRect().clone()},geo:function(){var t=this.coordSys,e=t.getBoundingRect().clone();return e.applyTransform(Cc(t)),e}},hk={lineX:T(ck,0),lineY:T(ck,1),rect:function(t,e,n,i){var o=t?e.pointToData([n[0][0],n[1][0]],i):e.dataToPoint([n[0][0],n[1][0]],i),t=t?e.pointToData([n[0][1],n[1][1]],i):e.dataToPoint([n[0][1],n[1][1]],i),e=[rk([o[0],t[0]]),rk([o[1],t[1]])];return{values:e,xyMinMax:e}},polygon:function(e,n,t,i){var o=[[1/0,-1/0],[1/0,-1/0]];return{values:B(t,function(t){t=e?n.pointToData(t,i):n.dataToPoint(t,i);return o[0][0]=Math.min(o[0][0],t[0]),o[1][0]=Math.min(o[1][0],t[1]),o[0][1]=Math.max(o[0][1],t[0]),o[1][1]=Math.max(o[1][1],t[1]),t}),xyMinMax:o}}};function ck(t,e,n,i){var o=n.getAxis(["x","y"][t]),n=rk(B([0,1],function(t){return e?o.coordToData(o.toLocalCoord(i[t]),!0):o.toGlobalCoord(o.dataToCoord(i[t]))})),r=[];return r[t]=n,r[1-t]=[NaN,NaN],{values:n,xyMinMax:r}}var pk={lineX:T(dk,0),lineY:T(dk,1),rect:function(t,e,n){return[[t[0][0]-n[0]*e[0][0],t[0][1]-n[0]*e[0][1]],[t[1][0]-n[1]*e[1][0],t[1][1]-n[1]*e[1][1]]]},polygon:function(t,n,i){return B(t,function(t,e){return[t[0]-i[0]*n[e][0],t[1]-i[1]*n[e][1]]})}};function dk(t,e,n,i){return[e[0]-i[t]*n[0],e[1]-i[t]*n[1]]}function fk(t){return t?[t[0][1]-t[0][0],t[1][1]-t[1][0]]:[NaN,NaN]}var gk=["inBrush","outOfBrush"],yk="__ecBrushSelect",mk="__ecInBrushSelectEvent";function vk(e){e.eachComponent({mainType:"brush"},function(t){(t.brushTargetManager=new ik(t.option,e)).setInputRanges(t.areas,e)})}function _k(c,t,e){var o,r,n,i,a,s,l=[];c.eachComponent({mainType:"brush"},function(t){e&&"takeGlobalCursor"===e.type&&t.setBrushOption("brush"===e.key?e.brushOption:{brushType:!1})}),vk(c),c.eachComponent({mainType:"brush"},function(u,t){var y={brushId:u.id,brushIndex:t,brushName:u.name,areas:S(u.areas),selected:[]},e=(l.push(y),u.option),n=e.brushLink,i=[],m=[],v=[],_=!1,h=(t||(o=e.throttleType,r=e.throttleDelay),B(u.areas,function(t){var e,n,i,o=wk[t.brushType],o=E({boundingRect:o?o(t):void 0},t);return o.selectors=(n=(e=o).brushType,i={point:function(t){return KD[n].point(t,i,e)},rect:function(t){return KD[n].rect(t,i,e)}}),o})),x=qD(u.option,gk,function(t){t.mappingMethod="fixed"});function b(t){return"all"===n||i[t]}function w(t){return!!t.length}V(n)&&G(n,function(t){i[t]=1}),c.eachSeries(function(t,e){var n,i,o,r,a,s,l=v[e]=[];"parallel"===t.subType?(a=e,s=(r=t).coordinateSystem,_=_||s.hasAxisBrushed(),b(a)&&s.eachActiveState(r.getData(),function(t,e){"active"===t&&(m[e]=1)})):(a=e,i=l,(n=t).brushSelector&&!function(t,e){t=t.option.seriesIndex;return null!=t&&"all"!==t&&(V(t)?H(t,e)<0:e!==t)}(u,a)&&(G(h,function(t){u.brushTargetManager.controlSeries(t,n,c)&&i.push(t),_=_||w(i)}),b(a))&&w(i)&&(o=n.getData()).each(function(t){bk(n,i,o,t)&&(m[t]=1)}))}),c.eachSeries(function(e,t){var s,l,u,h,c,p,d,n={seriesId:e.id,seriesIndex:t,seriesName:e.name,dataIndex:[]},i=(y.selected.push(n),v[t]),o=e.getData(),r=b(t)?function(t){return m[t]?(n.dataIndex.push(o.getRawIndex(t)),"inBrush"):"outOfBrush"}:function(t){return bk(e,i,o,t)?(n.dataIndex.push(o.getRawIndex(t)),"inBrush"):"outOfBrush"};function f(t){return b0(l,p,t)}function g(t,e){S0(l,p,t,e)}function a(t,e){p=null==c?t:e;e=l.getRawDataItem(p);if(!e||!1!==e.visualMap)for(var e=u.call(h,t),n=s[e],i=d[e],o=0,r=i.length;oo[0][1]&&(o[0][1]=r[0]),r[1]o[1][1]&&(o[1][1]=r[1])}return o&&Sk(o)}};function Sk(t){return new Z(t[0][0],t[1][0],t[0][1]-t[0][0],t[1][1]-t[1][0])}u(Ik,Mk=Dy),Ik.prototype.init=function(t,e){this.ecModel=t,this.api=e,this.model,(this._brushController=new $C(e.getZr())).on("brush",M(this._onBrush,this)).mount()},Ik.prototype.render=function(t,e,n,i){this.model=t,this._updateController(t,e,n,i)},Ik.prototype.updateTransform=function(t,e,n,i){vk(e),this._updateController(t,e,n,i)},Ik.prototype.updateVisual=function(t,e,n,i){this.updateTransform(t,e,n,i)},Ik.prototype.updateView=function(t,e,n,i){this._updateController(t,e,n,i)},Ik.prototype._updateController=function(t,e,n,i){i&&i.$from===t.id||this._brushController.setPanels(t.brushTargetManager.makePanelOpts(n)).enableBrush(t.brushOption).updateCovers(t.areas.slice())},Ik.prototype.dispose=function(){this._brushController.dispose()},Ik.prototype._onBrush=function(t){var e=this.model.id,n=this.model.brushTargetManager.setOutputRanges(t.areas,this.ecModel);t.isEnd&&!t.removeOnClick||this.api.dispatchAction({type:"brush",brushId:e,areas:S(n),$from:e}),t.isEnd&&this.api.dispatchAction({type:"brushEnd",brushId:e,areas:S(n),$from:e})},Ik.type="brush";var Mk,Tk=Ik;function Ik(){var t=null!==Mk&&Mk.apply(this,arguments)||this;return t.type=Ik.type,t}u(kk,Ck=g),kk.prototype.optionUpdated=function(t,e){var n=this.option,e=(e||jD(n,t,["inBrush","outOfBrush"]),n.inBrush=n.inBrush||{});n.outOfBrush=n.outOfBrush||{color:"#ddd"},e.hasOwnProperty("liftZ")||(e.liftZ=5)},kk.prototype.setAreas=function(t){t&&(this.areas=B(t,function(t){return Ak(this.option,t)},this))},kk.prototype.setBrushOption=function(t){this.brushOption=Ak(this.option,t),this.brushType=this.brushOption.brushType},kk.type="brush",kk.dependencies=["geo","grid","xAxis","yAxis","parallel","series"],kk.defaultOption={seriesIndex:"all",brushType:"rect",brushMode:"single",transformable:!0,brushStyle:{borderWidth:1,color:"rgba(210,219,238,0.3)",borderColor:"#D2DBEE"},throttleType:"fixRate",throttleDelay:0,removeOnClick:!0,z:1e4};var Ck,Dk=kk;function kk(){var t=null!==Ck&&Ck.apply(this,arguments)||this;return t.type=kk.type,t.areas=[],t.brushOption={},t}function Ak(t,e){return d({brushType:t.brushType,brushMode:t.brushMode,transformable:t.transformable,brushStyle:new dp(t.brushStyle).getItemStyle(),removeOnClick:t.removeOnClick,z:t.z},e,!0)}var Pk,Lk=["rect","polygon","lineX","lineY","keep","clear"];function Ok(){return null!==Pk&&Pk.apply(this,arguments)||this}u(Ok,Pk=function(){}),Ok.prototype.render=function(e,t,n){var i,o,r;t.eachComponent({mainType:"brush"},function(t){i=t.brushType,o=t.brushOption.brushMode||"single",r=r||!!t.areas.length}),this._brushType=i,this._brushMode=o,G(e.get("type",!0),function(t){e.setIconStatus(t,("keep"===t?"multiple"===o:"clear"===t?r:t===i)?"emphasis":"normal")})},Ok.prototype.updateView=function(t,e,n){this.render(t,e,n)},Ok.prototype.getIcons=function(){var t=this.model,e=t.get("icon",!0),n={};return G(t.get("type",!0),function(t){e[t]&&(n[t]=e[t])}),n},Ok.prototype.onclick=function(t,e,n){var i=this._brushType,o=this._brushMode;"clear"===n?(e.dispatchAction({type:"axisAreaSelect",intervals:[]}),e.dispatchAction({type:"brush",command:"clear",areas:[]})):e.dispatchAction({type:"takeGlobalCursor",key:"brush",brushOption:{brushType:"keep"===n?i:i!==n&&n,brushMode:"keep"===n?"multiple"===o?"single":"multiple":o}})},Ok.getDefaultOption=function(t){return{show:!0,type:Lk.slice(),icon:{rect:"M7.3,34.7 M0.4,10V-0.2h9.8 M89.6,10V-0.2h-9.8 M0.4,60v10.2h9.8 M89.6,60v10.2h-9.8 M12.3,22.4V10.5h13.1 M33.6,10.5h7.8 M49.1,10.5h7.8 M77.5,22.4V10.5h-13 M12.3,31.1v8.2 M77.7,31.1v8.2 M12.3,47.6v11.9h13.1 M33.6,59.5h7.6 M49.1,59.5 h7.7 M77.5,47.6v11.9h-13",polygon:"M55.2,34.9c1.7,0,3.1,1.4,3.1,3.1s-1.4,3.1-3.1,3.1 s-3.1-1.4-3.1-3.1S53.5,34.9,55.2,34.9z M50.4,51c1.7,0,3.1,1.4,3.1,3.1c0,1.7-1.4,3.1-3.1,3.1c-1.7,0-3.1-1.4-3.1-3.1 C47.3,52.4,48.7,51,50.4,51z M55.6,37.1l1.5-7.8 M60.1,13.5l1.6-8.7l-7.8,4 M59,19l-1,5.3 M24,16.1l6.4,4.9l6.4-3.3 M48.5,11.6 l-5.9,3.1 M19.1,12.8L9.7,5.1l1.1,7.7 M13.4,29.8l1,7.3l6.6,1.6 M11.6,18.4l1,6.1 M32.8,41.9 M26.6,40.4 M27.3,40.2l6.1,1.6 M49.9,52.1l-5.6-7.6l-4.9-1.2",lineX:"M15.2,30 M19.7,15.6V1.9H29 M34.8,1.9H40.4 M55.3,15.6V1.9H45.9 M19.7,44.4V58.1H29 M34.8,58.1H40.4 M55.3,44.4 V58.1H45.9 M12.5,20.3l-9.4,9.6l9.6,9.8 M3.1,29.9h16.5 M62.5,20.3l9.4,9.6L62.3,39.7 M71.9,29.9H55.4",lineY:"M38.8,7.7 M52.7,12h13.2v9 M65.9,26.6V32 M52.7,46.3h13.2v-9 M24.9,12H11.8v9 M11.8,26.6V32 M24.9,46.3H11.8v-9 M48.2,5.1l-9.3-9l-9.4,9.2 M38.9-3.9V12 M48.2,53.3l-9.3,9l-9.4-9.2 M38.9,62.3V46.4",keep:"M4,10.5V1h10.3 M20.7,1h6.1 M33,1h6.1 M55.4,10.5V1H45.2 M4,17.3v6.6 M55.6,17.3v6.6 M4,30.5V40h10.3 M20.7,40 h6.1 M33,40h6.1 M55.4,30.5V40H45.2 M21,18.9h62.9v48.6H21V18.9z",clear:"M22,14.7l30.9,31 M52.9,14.7L22,45.7 M4.7,16.8V4.2h13.1 M26,4.2h7.8 M41.6,4.2h7.8 M70.3,16.8V4.2H57.2 M4.7,25.9v8.6 M70.3,25.9v8.6 M4.7,43.2v12.6h13.1 M26,55.8h7.8 M41.6,55.8h7.8 M70.3,43.2v12.6H57.2"},title:t.getLocaleModel().get(["toolbox","brush","title"])}},D_(function(t){t.registerComponentView(Tk),t.registerComponentModel(Dk),t.registerPreprocessor(EC),t.registerVisual(t.PRIORITY.VISUAL.BRUSH,_k),t.registerAction({type:"brush",event:"brush",update:"updateVisual"},function(e,t){t.eachComponent({mainType:"brush",query:e},function(t){t.setAreas(e.areas)})}),t.registerAction({type:"brushSelect",event:"brushSelected",update:"none"},Bt),t.registerAction({type:"brushEnd",event:"brushEnd",update:"none"},Bt)});var Rk,Nk=function(t,e,n){t=S((zk[t]||{})[e]);return n&&V(t)?t[t.length-1]:t},zk={color:{active:["#006edd","#e0ffff"],inactive:["rgba(0,0,0,0)"]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}},Ek=OD.mapVisual,Bk=OD.eachVisual,Vk=V,Fk=G,Hk=Sr,Gk=br,ga=(u(Wk,Rk=g),Wk.prototype.init=function(t,e,n){this.mergeDefaultAndTheme(t,n)},Wk.prototype.optionUpdated=function(t,e){var n=this.option;e||jD(n,t,this.replacableOptionKeys),this.textStyleModel=this.getModel("textStyle"),this.resetItemSize(),this.completeVisualOption()},Wk.prototype.resetVisual=function(t){var e=this.stateList;t=M(t,this),this.controllerVisuals=qD(this.option.controller,e,t),this.targetVisuals=qD(this.option.target,e,t)},Wk.prototype.getItemSymbol=function(){return null},Wk.prototype.getTargetSeriesIndices=function(){var t=this.option.seriesIndex,n=[];return null==t||"all"===t?this.ecModel.eachSeries(function(t,e){n.push(e)}):n=Gr(t),n},Wk.prototype.eachTargetSeries=function(e,n){G(this.getTargetSeriesIndices(),function(t){t=this.ecModel.getSeriesByIndex(t);t&&e.call(n,t)},this)},Wk.prototype.isTargetSeries=function(e){var n=!1;return this.eachTargetSeries(function(t){t===e&&(n=!0)}),n},Wk.prototype.formatValueText=function(t,e,n){var i,o=this.option,r=o.precision,a=this.dataBound,o=o.formatter,e=(n=n||["<",">"],V(t)&&(t=t.slice(),i=!0),e?t:i?[s(t[0]),s(t[1])]:s(t));return U(o)?o.replace("{value}",i?e[0]:e).replace("{value2}",i?e[1]:e):C(o)?i?o(t[0],t[1]):o(t):i?t[0]===a[0]?n[0]+" "+e[1]:t[1]===a[1]?n[1]+" "+e[0]:e[0]+" - "+e[1]:e;function s(t){return t===a[0]?"min":t===a[1]?"max":(+t).toFixed(Math.min(r,20))}},Wk.prototype.resetExtent=function(){var t=this.option,t=Hk([t.min,t.max]);this._dataExtent=t},Wk.prototype.getDataDimensionIndex=function(t){var e=this.option.dimension;if(null!=e)return t.getDimensionIndex(e);for(var n=t.dimensions,i=n.length-1;0<=i;i--){var o=n[i],o=t.getDimensionInfo(o);if(!o.isCalculationCoord)return o.storeDimIndex}},Wk.prototype.getExtent=function(){return this._dataExtent.slice()},Wk.prototype.completeVisualOption=function(){var e=this.ecModel,n=this.option,t={inRange:n.inRange,outOfRange:n.outOfRange},i=n.target||(n.target={}),o=n.controller||(n.controller={}),u=(d(i,t),d(o,t),this.isCategory());function r(t){Vk(n.color)&&!t.inRange&&(t.inRange={color:n.color.slice().reverse()}),t.inRange=t.inRange||{color:e.get("gradientColor")}}r.call(this,i),r.call(this,o),function(t,e,n){var e=t[e],i=t[n];e&&!i&&(i=t[n]={},Fk(e,function(t,e){var n;OD.isValidType(e)&&null!=(n=Nk(e,"inactive",u))&&(i[e]=n,"color"!==e||i.hasOwnProperty("opacity")||i.hasOwnProperty("colorAlpha")||(i.opacity=[0,0]))}))}.call(this,i,"inRange","outOfRange"),function(o){var r=(o.inRange||{}).symbol||(o.outOfRange||{}).symbol,a=(o.inRange||{}).symbolSize||(o.outOfRange||{}).symbolSize,s=this.get("inactiveColor"),l=this.getItemSymbol()||"roundRect";Fk(this.stateList,function(t){var e,n=this.itemSize,i=o[t],t=(null==(i=i||(o[t]={color:u?s:[s]})).symbol&&(i.symbol=r&&S(r)||(u?l:[l])),null==i.symbolSize&&(i.symbolSize=a&&S(a)||(u?n[0]:[n[0],n[0]])),i.symbol=Ek(i.symbol,function(t){return"none"===t?l:t}),i.symbolSize);null!=t&&(e=-1/0,Bk(t,function(t){ee[1]&&e.reverse(),e[0]=Math.max(e[0],t[0]),e[1]=Math.min(e[1],t[1]))},Zk.prototype.completeVisualOption=function(){Uk.prototype.completeVisualOption.apply(this,arguments),G(this.stateList,function(t){t=this.option.controller[t].symbolSize;t&&t[0]!==t[1]&&(t[0]=t[1]/3)},this)},Zk.prototype.setSelected=function(t){this.option.range=t.slice(),this._resetRange()},Zk.prototype.getSelected=function(){var t=this.getExtent(),e=Sr((this.get("range")||[]).slice());return e[0]>t[1]&&(e[0]=t[1]),e[1]>t[1]&&(e[1]=t[1]),e[0]=n[1]||t<=e[1])?"inRange":"outOfRange"},Zk.prototype.findTargetDataIndices=function(i){var o=[];return this.eachTargetSeries(function(t){var n=[],e=t.getData();e.each(this.getDataDimensionIndex(e),function(t,e){i[0]<=t&&t<=i[1]&&n.push(e)},this),o.push({seriesId:t.id,dataIndex:n})},this),o},Zk.prototype.getVisualMeta=function(n){var t=qk(0,0,this.getExtent()),e=qk(0,0,this.option.range.slice()),i=[];function o(t,e){i.push({value:t,color:n(t,e)})}for(var r=0,a=0,s=e.length,l=t.length;at[1])break;n.push({color:this.getControllerVisual(r,"color",e),offset:o/100})}return n.push({color:this.getControllerVisual(t[1],"color",e),offset:1}),n},aA.prototype._createBarPoints=function(t,e){var n=this.visualMapModel.itemSize;return[[n[0]-e[0],t[0]],[n[0],t[0]],[n[0],t[1]],[n[0]-e[1],t[1]]]},aA.prototype._createBarGroup=function(t){var e=this._orient,n=this.visualMapModel.get("inverse");return new lr("horizontal"!==e||n?"horizontal"===e&&n?{scaleX:"bottom"===t?-1:1,rotation:-Math.PI/2}:"vertical"!==e||n?{scaleX:"left"===t?1:-1}:{scaleX:"left"===t?1:-1,scaleY:-1}:{scaleX:"bottom"===t?1:-1,rotation:Math.PI/2})},aA.prototype._updateHandle=function(i,o){var r,a,s,l,u,h;this._useHandle&&(r=this._shapes,a=this.visualMapModel,s=r.handleThumbs,l=r.handleLabels,u=a.itemSize,h=a.getExtent(),nA([0,1],function(t){var e=s[t],n=(e.setStyle("fill",o.handlesColor[t]),e.y=i[t],eA(i[t],[0,u[1]],h,!0)),n=this.getControllerVisual(n,"symbolSize"),n=(e.scaleX=e.scaleY=n/u[0],e.x=u[0]-n/2,Dc(r.handleLabelPoints[t],Cc(e,this.group)));l[t].setStyle({x:n[0],y:n[1],text:a.formatValueText(this._dataInterval[t]),verticalAlign:"middle",align:"vertical"===this._orient?this._applyTransform("left",r.mainGroup):"center"})},this))},aA.prototype._showIndicator=function(t,e,n,i){var o=this.visualMapModel,r=o.getExtent(),a=o.itemSize,s=[0,a[1]],l=this._shapes,u=l.indicator;if(u){u.attr("invisible",!1);var h=this.getControllerVisual(t,"color",{convertOpacityToAlpha:!0}),c=this.getControllerVisual(t,"symbolSize"),t=eA(t,r,s,!0),r=a[0]-c/2,s={x:u.x,y:u.y},a=(u.y=t,u.x=r,Dc(l.indicatorLabelPoint,Cc(u,this.group))),c=l.indicatorLabel,l=(c.attr("invisible",!1),this._applyTransform("left",l.mainGroup)),p="horizontal"===this._orient,n=(c.setStyle({text:(n||"")+o.formatValueText(e),verticalAlign:p?l:"middle",align:p?"center":l}),{x:r,y:t,style:{fill:h}}),e={style:{x:a[0],y:a[1]}},d=(o.ecModel.isAnimationEnabled()&&!this._firstShowIndicator?(p={duration:100,easing:"cubicInOut",additive:!0},u.x=s.x,u.y=s.y,u.animateTo(n,p),c.animateTo(e,p)):(u.attr(n),c.attr(e)),this._firstShowIndicator=!1,this._shapes.handleLabels);if(d)for(var f=0;f ",o):this._showIndicator(t,t,"≈ ",o)),a=this._hoverLinkDataIndices,n=[],(e||lA(r))&&(n=this._hoverLinkDataIndices=r.findTargetDataIndices(i)),t=n,o={},s(a||[],e={}),s(t||[],o,e),i=[l(e),l(o)],this._dispatchHighDown("downplay",Jk(i[0],r)),this._dispatchHighDown("highlight",Jk(i[1],r)))},aA.prototype._hoverLinkFromSeriesMouseOver=function(t){var e,n;I0(t.target,function(t){t=D(t);return null!=t.dataIndex&&(e=t,1)},!0),e&&(t=this.ecModel.getSeriesByIndex(e.seriesIndex),(n=this.visualMapModel).isTargetSeries(t))&&(n=(t=t.getData(e.dataType)).getStore().get(n.getDataDimensionIndex(t),e.dataIndex),isNaN(n)||this._showIndicator(n,n))},aA.prototype._hideIndicator=function(){var t=this._shapes,e=(t.indicator&&t.indicator.attr("invisible",!0),t.indicatorLabel&&t.indicatorLabel.attr("invisible",!0),this._shapes.handleLabels);if(e)for(var n=0;nn&&s([n,t[0]],"outOfRange"),s(t.slice()),n=t[1])},this),{stops:o,outerColors:r};function s(t,e){var n=a.getRepresentValue({interval:t}),n=(e=e||a.getValueState(n),i(n,e));t[0]===-1/0?r[0]=n:t[1]===1/0?r[1]=n:o.push({value:t[0],color:n},{value:t[1],color:n})}},wA.type="visualMap.piecewise",wA.defaultOption=mp(ga.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieces:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10,hoverLink:!0});var xA,bA=wA;function wA(){var t=null!==xA&&xA.apply(this,arguments)||this;return t.type=wA.type,t._pieceList=[],t}var SA={splitNumber:function(t){var e=this.option,n=Math.min(e.precision,20),i=this.getExtent(),o=e.splitNumber,o=Math.max(parseInt(o,10),1);e.splitNumber=o;for(var r=(i[1]-i[0])/o;+r.toFixed(n)!==r&&n<5;)n++;e.precision=n,r=+r.toFixed(n),e.minOpen&&t.push({interval:[-1/0,i[0]],close:[0,0]});for(var a=0,s=i[0];a","≥"][e[0]]];t.text=t.text||this.formatValueText(null!=t.value?t.value:t.interval,!1,e)},this)}};function MA(t,e){var n=t.inverse;("vertical"===t.orient?!n:n)&&e.reverse()}u(CA,TA=k0),CA.prototype.doRender=function(){var i=this.group,o=(i.removeAll(),this.visualMapModel),r=o.get("textGap"),t=o.textStyleModel,a=t.getFont(),s=t.getTextColor(),l=this._getItemAlign(),u=o.itemSize,t=this._getViewData(),e=t.endsText,h=bt(o.get("showLabel",!0),!e);e&&this._renderEndsText(i,e[0],u,h,l),G(t.viewPieceList,function(t){var e=t.piece,n=new lr,t=(n.onclick=M(this._onItemClick,this,e),this._enableHoverLink(n,t.indexInModelPieceList),o.getRepresentValue(e));this._createItemSymbol(n,t,[0,0,u[0],u[1]]),h&&(t=this.visualMapModel.getValueState(t),n.add(new ll({style:{x:"right"===l?-r:u[0]+r,y:u[1]/2,text:e.text,verticalAlign:"middle",align:l,font:a,fill:s,opacity:"outOfRange"===t?.5:1}}))),i.add(n)},this),e&&this._renderEndsText(i,e[1],u,h,l),pd(o.get("orient"),i,o.get("itemGap")),this.renderBackground(i),this.positionGroup(i)},CA.prototype._enableHoverLink=function(t,n){var i=this,e=(t.on("mouseover",function(){return e("highlight")}).on("mouseout",function(){return e("downplay")}),function(t){var e=i.visualMapModel;e.option.hoverLink&&i.api.dispatchAction({type:t,batch:Jk(e.findTargetDataIndices(n),e)})})},CA.prototype._getItemAlign=function(){var t=this.visualMapModel,e=t.option;return"vertical"===e.orient?Qk(t,this.api,t.itemSize):(t=e.align)&&"auto"!==t?t:"left"},CA.prototype._renderEndsText=function(t,e,n,i,o){var r,a;e&&(r=new lr,a=this.visualMapModel.textStyleModel,r.add(new ll({style:Yc(a,{x:i?"right"===o?n[0]:0:n[0]/2,y:n[1]/2,verticalAlign:"middle",align:i?o:"center",text:e})})),t.add(r))},CA.prototype._getViewData=function(){var t=this.visualMapModel,e=B(t.getPieceList(),function(t,e){return{piece:t,indexInModelPieceList:e}}),n=t.get("text"),i=t.get("orient"),t=t.get("inverse");return("horizontal"===i?t:!t)?e.reverse():n=n&&n.slice().reverse(),{viewPieceList:e,endsText:n}},CA.prototype._createItemSymbol=function(t,e,n){t.add(V0(this.getControllerVisual(e,"symbol"),n[0],n[1],n[2],n[3],this.getControllerVisual(e,"color")))},CA.prototype._onItemClick=function(t){var n,i,e=this.visualMapModel,o=e.option,r=o.selectedMode;r&&(n=S(o.selected),i=e.getSelectedMapKey(t),"single"===r||!0===r?(n[i]=!0,G(n,function(t,e){n[e]=e===i})):n[i]=!n[i],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:n}))},CA.type="visualMap.piecewise";var TA,IA=CA;function CA(){var t=null!==TA&&TA.apply(this,arguments)||this;return t.type=CA.type,t}function DA(t){t.registerComponentModel(bA),t.registerComponentView(IA),vA(t)}function kA(e,t){var n;return G(t,function(t){null!=e[t]&&"auto"!==e[t]&&(n=!0)}),n}D_(function(t){D_(_A),D_(DA)});var AA=["transition","enterFrom","leaveTo"],PA=AA.concat(["enterAnimation","updateAnimation","leaveAnimation"]);function LA(t,e,n){if(n&&(!t[n]&&e[n]&&(t[n]={}),t=t[n],e=e[n]),t&&e)for(var i=n?AA:PA,o=0;o":"gt",">=":"gte","=":"eq","!=":"ne","<>":"ne"},uP=(hP.prototype.evaluate=function(t){var e=typeof t;return U(e)?this._condVal.test(t):!!X(e)&&this._condVal.test(t+"")},hP);function hP(t){null==(this._condVal=U(t)?new RegExp(t):_t(t)?t:null)&&f("")}pP.prototype.evaluate=function(){return this.value};var cP=pP;function pP(){}fP.prototype.evaluate=function(){for(var t=this.children,e=0;e"}(i,o)+("style"!==i?ve(e):e||"")+(n?r+B(n,t).join(r)+r:"")+""}(t)}function qP(t){return{zrId:t,shadowCache:{},patternCache:{},gradientCache:{},clipPathCache:{},defs:{},cssNodes:{},cssAnims:{},cssStyleCache:{},cssAnimIdx:0,shadowIdx:0,gradientIdx:0,patternIdx:0,clipPathIdx:0}}function jP(t,e,n,i){return YP("svg","root",{width:t,height:e,xmlns:FP,"xmlns:xlink":HP,version:"1.1",baseProfile:"full",viewBox:!!i&&"0 0 "+t+" "+e},n)}var KP=0;var $P={cubicIn:"0.32,0,0.67,0",cubicOut:"0.33,1,0.68,1",cubicInOut:"0.65,0,0.35,1",quadraticIn:"0.11,0,0.5,0",quadraticOut:"0.5,1,0.89,1",quadraticInOut:"0.45,0,0.55,1",quarticIn:"0.5,0,0.75,0",quarticOut:"0.25,1,0.5,1",quarticInOut:"0.76,0,0.24,1",quinticIn:"0.64,0,0.78,0",quinticOut:"0.22,1,0.36,1",quinticInOut:"0.83,0,0.17,1",sinusoidalIn:"0.12,0,0.39,0",sinusoidalOut:"0.61,1,0.88,1",sinusoidalInOut:"0.37,0,0.63,1",exponentialIn:"0.7,0,0.84,0",exponentialOut:"0.16,1,0.3,1",exponentialInOut:"0.87,0,0.13,1",circularIn:"0.55,0,1,0.45",circularOut:"0,0.55,0.45,1",circularInOut:"0.85,0,0.15,1"},QP="transform-origin";var JP={fill:"fill",opacity:"opacity",lineWidth:"stroke-width",lineDashOffset:"stroke-dashoffset"};function tL(t,e){var n=e.zrId+"-ani-"+e.cssAnimIdx++;return e.cssAnims[n]=t,n}function eL(t){return U(t)?$P[t]?"cubic-bezier("+$P[t]+")":Kn(t)?t:"":""}function nL(k,A,P,L){var t=k.animators,e=t.length,n=[];if(k instanceof Eh){if(o=function(t,e,u){var h,c,t=t.shape.paths,p={};if(G(t,function(t){var e=qP(u.zrId),t=(e.animation=!0,nL(t,{},e,!0),e.cssAnims),n=e.cssNodes,e=W(t),i=e.length;if(i){var o,r,a=t[c=e[i-1]];for(o in a){var s=a[o];p[o]=p[o]||{d:""},p[o].d+=s.d||""}for(r in n){var l=n[r].animation;0<=l.indexOf(c)&&(h=l)}}}),h)return e.d=!1,t=tL(p,u),h.replace(c,t)}(k,A,P))n.push(o);else if(!e)return}else if(!e)return;for(var i,o,r,a={},s=0;s"].join(r):"")&&(e=YP("style","stl",{},[],c),h.push(e)),jP(i,l,h,t.useViewBox)},VL.prototype.renderToString=function(t){return ZP(this.renderToVNode({animation:O((t=t||{}).cssAnimation,!0),emphasis:O(t.cssEmphasis,!0),willUpdate:!1,compress:!0,useViewBox:O(t.useViewBox,!0)}),{newline:!0})},VL.prototype.setBackgroundColor=function(t){this._backgroundColor=t},VL.prototype.getSvgRoot=function(){return this._mainVNode&&this._mainVNode.elm},VL.prototype._paintList=function(t,e,n){for(var i,o,r,a,s,l,u,h=t.length,c=[],p=0,d=0,f=0;f + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/sipai/jspatrol/Alarm/AlarmAdapter.java b/app/src/main/java/com/sipai/jspatrol/Alarm/AlarmAdapter.java new file mode 100644 index 0000000..3b194cc --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Alarm/AlarmAdapter.java @@ -0,0 +1,86 @@ +package com.sipai.jspatrol.Alarm; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.Alarm; +import com.sipai.jspatrol.Fault.NewFaultActivity; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.Global.GlobalVal; + +import java.util.List; + +/** + * created by lvliming on 2020/11/9 + */ +public class AlarmAdapter extends RecyclerView.Adapter { + private List list; + private Context context; + + public AlarmAdapter(Context context,List list) { + this.context = context; + this.list = list; + } + + @Override + public AlarmAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alarm,parent,false); + final AlarmAdapter.ViewHolder viewHolder = new AlarmAdapter.ViewHolder(view); + viewHolder.msg.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + NewFaultActivity.alarmStart(context,list.get(position).getDescribe()); + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(AlarmAdapter.ViewHolder holder, int position) { + Alarm item = list.get(position); + holder.time.setText(item.getAlarmtime()); + holder.content.setText(item.getDescribe()); + holder.tv_type.setText(item.getAlarmTypeName()); + holder.tv_lvl.setText(item.getPointName()); + if (item.getStatus().equals(GlobalVal.Status_N)){ + holder.tv_status.setText("未处理"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.error_red)); + }else if (item.getStatus().equals(GlobalVal.Status_C)){ + holder.tv_status.setText("已确认"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.error_yellow)); + }else if (item.getStatus().equals(GlobalVal.Status_Y)){ + holder.tv_status.setText("已恢复"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.little_blue)); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + @Override + public int getItemViewType(int position) { + return position; + } + + static class ViewHolder extends RecyclerView.ViewHolder{ + View msg; + TextView time,content,tv_type,tv_lvl,tv_status; + public ViewHolder(View itemView) { + super(itemView); + msg = itemView; + time = itemView.findViewById(R.id.moudle_item_alarm_tv_time); + content = itemView.findViewById(R.id.moudle_item_alarm_tv_content); + tv_type = itemView.findViewById(R.id.moudle_item_alarm_tv_alarmtype); + tv_lvl = itemView.findViewById(R.id.moudle_item_alarm_tv_alarmlvl); + tv_status = itemView.findViewById(R.id.moudle_item_alarm_tv_status);; + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Alarm/AlarmListActivity.java b/app/src/main/java/com/sipai/jspatrol/Alarm/AlarmListActivity.java new file mode 100644 index 0000000..d30034b --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Alarm/AlarmListActivity.java @@ -0,0 +1,339 @@ +package com.sipai.jspatrol.Alarm; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import android.app.DatePickerDialog; +import android.app.TimePickerDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.TimePicker; + +import com.sipai.jspatrol.Bean.Alarm; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.DateFormatUtils; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.SharedPreferencesData; +import com.sipai.ui.EmptyLayout; +import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class AlarmListActivity extends AppCompatActivity implements View.OnClickListener { + private SharedPreferencesData sharedpre; + private HashMap map_base = new HashMap<>(); + private String mServer; + private String mBizid; + private EditText tvstartdate,tvenddate; + private int year,month,day,hour,minute,lastday,lastmonth; + private int page = 1; + private LinearLayoutManager manager; + private SuperRecyclerView rc_view; + private SwipeRefreshLayout refresh; + private EmptyLayout emptyLayout; + private ImageView iv_back; + private EditText edt_name; + private TextView tv_search; + private String name = ""; + private List alarms = new ArrayList<>(); + private AlarmAdapter adapter; + + public static void actionStart(Context context){ + Intent intent = new Intent(context,AlarmListActivity.class); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_alarm_list); + init(); + initView(); + getAlarmMsgs(); + } + + private void initView() { + iv_back = findViewById(R.id.moudle_alarm_list_iv_back); + iv_back.setOnClickListener(this); + edt_name = findViewById(R.id.moudle_alarm_list_edt_equname); + tv_search = findViewById(R.id.moudle_alarm_list_tv_search); + tv_search.setOnClickListener(this); + tvstartdate=(EditText)findViewById(R.id.moudle_alarm_list_edt_sd); + tvstartdate.setCursorVisible(false); + tvstartdate.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //创建DatePickerDialog对象 + if (event.getAction() == MotionEvent.ACTION_DOWN) { + MyDatePickerDialog dpd = new MyDatePickerDialog(AlarmListActivity.this, Datelistener, year, month, day); + dpd.show();//显示DatePickerDialog组件 + } + return false; + } + }); + tvenddate=(EditText)findViewById(R.id.moudle_alarm_list_edt_ed); + tvenddate.setCursorVisible(false); + tvenddate.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //创建DatePickerDialog对象 + if (event.getAction() == MotionEvent.ACTION_DOWN) { + MyDatePickerDialog dpd = new MyDatePickerDialog(AlarmListActivity.this, Datelistener, year, month, day); + dpd.show();//显示DatePickerDialog组件 + } + return false; + } + }); + if (day<8){ + if (month!=0) { + Calendar calendar = Calendar.getInstance(Locale.CHINA); + calendar.set(Calendar.MONTH, month - 1); + int tday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year + "-" + month + "-" + lastday + " " + hour + ":" + minute)); + }else{ + Calendar calendar = Calendar.getInstance(Locale.CHINA); + calendar.set(Calendar.MONTH, 11); + int tday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + tvstartdate.setText(DateFormatUtils.DateFormatMinString((year-1) + "-" + 12 + "-" + lastday + " " + hour + ":" + minute)); + } + }else { + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year + "-" + (month + 1) + "-" + lastday + " " + hour + ":" + minute)); + } + tvenddate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + rc_view = findViewById(R.id.moudle_alarm_list_rc); + emptyLayout = findViewById(R.id.moudle_alarm_list_ui_empty); + refresh = findViewById(R.id.moudle_alarm_list_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + page = 1; + getAlarmMsgs(); + } + }); + manager = new LinearLayoutManager(this); + rc_view.setLayoutManager(manager); + rc_view.setRefreshEnabled(false); + rc_view.setLoadMoreEnabled(true); + rc_view.setLoadingListener(new SuperRecyclerView.LoadingListener() { + @Override + public void onRefresh() { + + } + + @Override + public void onLoadMore() { + page = page+1; + getAlarmMsgs(); + } + }); + } + + private void init() { + sharedpre = new SharedPreferencesData(this); + map_base = sharedpre.getAll(); + mServer = map_base.get("mServer"); + SharedPreferences sharedPreferences = getSharedPreferences("config",MODE_PRIVATE); + mBizid = sharedPreferences.getString("bizid",""); + //初始化Calendar日历对象 + Calendar mycalendar=Calendar.getInstance(Locale.CHINA); + Date mydate=new Date(); //获取当前日期Date对象 + mycalendar.setTime(mydate);////为Calendar对象设置时间为当前日期 + year=mycalendar.get(Calendar.YEAR); //获取Calendar对象中的年 + month=mycalendar.get(Calendar.MONTH);//获取Calendar对象中的月 + day=mycalendar.get(Calendar.DAY_OF_MONTH);//获取这个月的第几天 + lastday=getBeforeDay(mycalendar).get(Calendar.DAY_OF_MONTH); + lastmonth=getBeforeDay(mycalendar).get(Calendar.MONTH); + hour=mycalendar.get(Calendar.HOUR_OF_DAY);//获取这个月的第几天 + minute=mycalendar.get(Calendar.MINUTE);//获取这个月的第几天 + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_alarm_list_iv_back: + finish(); + break; + case R.id.moudle_alarm_list_tv_search: + startSearch(); + break; + } + } + + private void startSearch() { + if (edt_name.getText()!=null&&!edt_name.getText().toString().isEmpty()){ + name = edt_name.getText().toString(); + } + getAlarmMsgs(); + } + + public class MyDatePickerDialog extends DatePickerDialog { + + public MyDatePickerDialog(Context context, OnDateSetListener callBack, + int year, int month, int day) { + super(context, callBack, year, month, day); + // TODO Auto-generated constructor stub + } + @Override + protected void onStop() { + //super.onStop();//防止onDateSet执行两次 + + } + } + + private DatePickerDialog.OnDateSetListener Datelistener=new DatePickerDialog.OnDateSetListener() { + @Override + public void onDateSet(DatePicker view, int myyear, int monthOfYear, int dayOfMonth) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + year=myyear; + month=monthOfYear; + day=dayOfMonth; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + TimePickerDialog dpd=new TimePickerDialog(AlarmListActivity.this,Timelistener,hour,minute,true); + dpd.show();//显示DatePickerDialog组件 + } + }; + + private TimePickerDialog.OnTimeSetListener Timelistener=new TimePickerDialog.OnTimeSetListener() { + @Override + public void onTimeSet(TimePicker view, int hours, int minutes) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + hour=hours; + minute=minutes; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + if(tvstartdate.isFocused()){ + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + }else if(tvenddate.isFocused()){ + tvenddate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + } + getAlarmMsgs(); + } + }; + + /** + * 获取当前时间的前一周 + * @param cl + * @return + */ + private static Calendar getBeforeDay(Calendar cl){ + //使用roll方法进行向前回滚 + //cl.roll(Calendar.DATE, -1); + //使用set方法直接进行设置 + int day = cl.get(Calendar.DATE); + cl.set(Calendar.DATE, day-7); + return cl; + } + + private void getAlarmMsgs() { + HashMap map = new HashMap<>(); + map.put("companyId",mBizid); + map.put("search_name",name); + map.put("alarmlevel",""); + map.put("status",""); + map.put("page",String.valueOf(page)); + map.put("sdt",tvstartdate.getText().toString()); + map.put("edt",tvenddate.getText().toString()); + map.put("rows","50"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetAlarmList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); +// showError(a); + updateList(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("describe")&&res.contains("id")){ + alarms = parseAlarmList(res); + }else { + alarms = new ArrayList<>(); + } + updateList(); + } + }); + } + + private void updateList() { + if (!AlarmListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + if (alarms.size()>0){ + emptyLayout.setVisibility(View.GONE); + rc_view.setVisibility(View.VISIBLE); + adapter = new AlarmAdapter(AlarmListActivity.this,alarms); + rc_view.setAdapter(adapter); + }else { + rc_view.setVisibility(View.GONE); + emptyLayout.setVisibility(View.VISIBLE); + } + } + }); + } + } + + private List parseAlarmList(String res) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(res); + for (int i=0;i16){ + item.setAlarmtime(array.getJSONObject(i).optString("alarmTime").substring(0,16)); + }else { + item.setAlarmtime(array.getJSONObject(i).optString("alarmTime")); + } + item.setPointCode(array.getJSONObject(i).optString("pointCode")); + item.setPointName(array.getJSONObject(i).optString("pointName")); + item.setAlarmTypeName(array.getJSONObject(i).optString("alarmTypeName")); + item.setStatus(array.getJSONObject(i).optString("status")); + item.setAlarmtype(array.getJSONObject(i).optString("alarmType")); + item.setDescribe(array.getJSONObject(i).optString("describe")); + list.add(item); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Application/App.java b/app/src/main/java/com/sipai/jspatrol/Application/App.java new file mode 100644 index 0000000..b6dfe4a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Application/App.java @@ -0,0 +1,57 @@ +package com.sipai.jspatrol.Application; + +import android.app.Application; + +import androidx.multidex.MultiDex; + +import com.sipai.jspatrol.utils.CrashHandler; + +import org.litepal.LitePal; +import org.litepal.LitePalApplication; +import org.xutils.x; + +/** + * created by lvliming on 2020/3/23 + */ +public class App extends LitePalApplication { + + private double latitude; + private double longitude; + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + private static App instance; + + public static App getInstance(){ + if (instance == null){ + + } + return instance; + } + + @Override + public void onCreate() { + super.onCreate(); + instance = this; + //全局捕捉异常 + CrashHandler crashHandler = CrashHandler.getInstance(); + crashHandler.init(getApplicationContext()); + x.Ext.init(this); + x.Ext.setDebug(false); + MultiDex.install(this); +// LitePal.initialize(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Base/ActivityCollector.java b/app/src/main/java/com/sipai/jspatrol/Base/ActivityCollector.java new file mode 100644 index 0000000..646f000 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Base/ActivityCollector.java @@ -0,0 +1,29 @@ +package com.sipai.jspatrol.Base; + +import android.app.Activity; + +import java.util.ArrayList; +import java.util.List; + +/** + * created by lvliming on 2020/3/23 + */ +public class ActivityCollector { + public static List activities = new ArrayList<>(); + + public static void addActivity(Activity activity){ + activities.add(activity); + } + + public static void removeActivity(Activity activity){ + activities.remove(activity); + } + + public static void finishAll(){ + for (Activity activity:activities){ + if (!activity.isFinishing()){ + activity.finish(); + } + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentModel.java b/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentModel.java new file mode 100644 index 0000000..4953674 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentModel.java @@ -0,0 +1,15 @@ +package com.sipai.jspatrol.Base; + +/** + * created by lvliming on 2020/3/23 + */ +public abstract class BaseFragmentModel

{ + + protected P p; + + public BaseFragmentModel(P p) { + this.p = p; + } + + public abstract CONTRACT getContract(); +} diff --git a/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentPresenter.java b/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentPresenter.java new file mode 100644 index 0000000..0264ba1 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentPresenter.java @@ -0,0 +1,40 @@ +package com.sipai.jspatrol.Base; + +import java.lang.ref.WeakReference; + +/** + * created by lvliming on 2020/3/23 + */ +public abstract class BaseFragmentPresenter { + protected M m; + + //绑定View层弱引用 + private WeakReference vWeakReference; + + public BaseFragmentPresenter() { + m = getModel(); + } + + public void bindView(V v) { + vWeakReference = new WeakReference<>(v); + } + + public void unBindView(){ + if (vWeakReference!=null){ + vWeakReference.clear(); + vWeakReference = null; + System.gc(); + } + } + + public V getView(){ + if (vWeakReference!=null){ + return vWeakReference.get(); + } + return null; + } + + public abstract CONTRACT getContract(); + + public abstract M getModel(); +} diff --git a/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentView.java b/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentView.java new file mode 100644 index 0000000..4e6d80a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Base/BaseFragmentView.java @@ -0,0 +1,32 @@ +package com.sipai.jspatrol.Base; + +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +/** + * created by lvliming on 2020/3/23 + */ +public abstract class BaseFragmentView

extends Fragment { + protected P p; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + p = getPresenter(); + p.bindView(this); + } + + public abstract CONTRACT getContract(); + + public abstract P getPresenter(); + + public void error(Exception e){} + + @Override + public void onDestroy() { + super.onDestroy(); + p.unBindView(); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Base/BaseModel.java b/app/src/main/java/com/sipai/jspatrol/Base/BaseModel.java new file mode 100644 index 0000000..c02e29a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Base/BaseModel.java @@ -0,0 +1,14 @@ +package com.sipai.jspatrol.Base; + +/** + * created by lvliming on 2020/3/23 + */ +public abstract class BaseModel

{ + protected P p; + + public BaseModel(P p) { + this.p = p; + } + + public abstract CONTRACT getContract(); +} diff --git a/app/src/main/java/com/sipai/jspatrol/Base/BasePresenter.java b/app/src/main/java/com/sipai/jspatrol/Base/BasePresenter.java new file mode 100644 index 0000000..f1b0dac --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Base/BasePresenter.java @@ -0,0 +1,41 @@ +package com.sipai.jspatrol.Base; + +import java.lang.ref.WeakReference; + +/** + * created by lvliming on 2020/3/23 + */ +public abstract class BasePresenter { + protected M m; + //绑定View层弱引用 + private WeakReference vWeakReference; + + public BasePresenter() { + m = getModel(); + } + + public void bindView(V v){ + vWeakReference = new WeakReference<>(v); + } + + public void unBindView(){ + if (vWeakReference!=null){ + vWeakReference.clear(); + vWeakReference = null; + System.gc(); + } + } + + //获取View,P — V + public V getView(){ + if(vWeakReference!=null){ + return vWeakReference.get(); + } + return null; + } + + //获取子类具体契约(Model层和View层协商的共同业务) + public abstract CONTRACT getContract(); + + public abstract M getModel(); +} diff --git a/app/src/main/java/com/sipai/jspatrol/Base/BaseView.java b/app/src/main/java/com/sipai/jspatrol/Base/BaseView.java new file mode 100644 index 0000000..c038488 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Base/BaseView.java @@ -0,0 +1,40 @@ +package com.sipai.jspatrol.Base; + +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +/** + * created by lvliming on 2020/3/23 + */ +public abstract class BaseView

extends AppCompatActivity { + protected P p; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + //弱引用 + p = getPresenter(); + //绑定 + p.bindView(this); + + } + //从子类获取具体契约 + protected abstract P getPresenter(); + + //让P层做什么需求 + public abstract CONTRACT getContract(); + + //如果Presenter层出现了异常,需要告知View层 + public void error(Exception e){ + + } + + @Override + protected void onDestroy() { + super.onDestroy(); + //解除绑定 + p.unBindView(); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Alarm.java b/app/src/main/java/com/sipai/jspatrol/Bean/Alarm.java new file mode 100644 index 0000000..4be5850 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Alarm.java @@ -0,0 +1,135 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * created by lvliming on 2020/11/9 + */ +public class Alarm implements Serializable { + private String id; + private String alarmlvl; + private String alarmtime; + private String alarmtype; + private String alarmvalue; + private String describe; + private String status; + private String recovertime; + private String workOrderId; + private String company; + private String processSection; + private String pointCode; + private String pointName; + private String alarmTypeName; + + public String getPointCode() { + return pointCode; + } + + public void setPointCode(String pointCode) { + this.pointCode = pointCode; + } + + public String getPointName() { + return pointName; + } + + public void setPointName(String pointName) { + this.pointName = pointName; + } + + public String getAlarmTypeName() { + return alarmTypeName; + } + + public void setAlarmTypeName(String alarmTypeName) { + this.alarmTypeName = alarmTypeName; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAlarmlvl() { + return alarmlvl; + } + + public void setAlarmlvl(String alarmlvl) { + this.alarmlvl = alarmlvl; + } + + public String getAlarmtime() { + return alarmtime; + } + + public void setAlarmtime(String alarmtime) { + this.alarmtime = alarmtime; + } + + public String getAlarmtype() { + return alarmtype; + } + + public void setAlarmtype(String alarmtype) { + this.alarmtype = alarmtype; + } + + public String getAlarmvalue() { + return alarmvalue; + } + + public void setAlarmvalue(String alarmvalue) { + this.alarmvalue = alarmvalue; + } + + public String getDescribe() { + return describe; + } + + public void setDescribe(String describe) { + this.describe = describe; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getRecovertime() { + return recovertime; + } + + public void setRecovertime(String recovertime) { + this.recovertime = recovertime; + } + + public String getWorkOrderId() { + return workOrderId; + } + + public void setWorkOrderId(String workOrderId) { + this.workOrderId = workOrderId; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public String getProcessSection() { + return processSection; + } + + public void setProcessSection(String processSection) { + this.processSection = processSection; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Area.java b/app/src/main/java/com/sipai/jspatrol/Bean/Area.java new file mode 100644 index 0000000..f5a9947 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Area.java @@ -0,0 +1,89 @@ +package com.sipai.jspatrol.Bean; + +/** + * Created by lvliming on 2017/10/23. + */ + +public class Area { + private String _bizname,bizid,code,id,insdt,insuser,name,pid,remark,status; + + public String get_bizname() { + return _bizname; + } + + public void set_bizname(String _bizname) { + this._bizname = _bizname; + } + + public String getBizid() { + return bizid; + } + + public void setBizid(String bizid) { + this.bizid = bizid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/BaseEntity.java b/app/src/main/java/com/sipai/jspatrol/Bean/BaseEntity.java new file mode 100644 index 0000000..131ed51 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/BaseEntity.java @@ -0,0 +1,9 @@ +package com.sipai.jspatrol.Bean; + +/** + * created by lvliming on 2020/3/23 + */ +public class BaseEntity { + private int code; + private String result; +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Biz.java b/app/src/main/java/com/sipai/jspatrol/Bean/Biz.java new file mode 100644 index 0000000..212ba9e --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Biz.java @@ -0,0 +1,142 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +public class Biz extends BaseEntity implements Serializable{ + private String id; + private String name; + private String logopic; + private String _typename; + private String address; + private String power; + private String technics; + private String location; + private String leader; + private String tel; + private String frehint; + private String mainpic; + private String defaultprddbname; + private String bizid; + private String pid; + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getBizid() { + return bizid; + } + + public void setBizid(String bizid) { + this.bizid = bizid; + } + + public String getFrehint() { + return frehint; + } + + public void setFrehint(String frehint) { + this.frehint = frehint; + } + + public String get_typename() { + return _typename; + } + + public void set_typename(String _typename) { + this._typename = _typename; + } + + public String getId() { + return id; + } + + public String getLogopic() { + return logopic; + } + + public String getName() { + return name; + } + + public void setId(String id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setLogopic(String logopic) { + this.logopic = logopic; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPower() { + return power; + } + + public void setPower(String power) { + this.power = power; + } + + public String getTechnics() { + return technics; + } + + public void setTechnics(String technics) { + this.technics = technics; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getLeader() { + return leader; + } + + public void setLeader(String leader) { + this.leader = leader; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + public String getMainpic() { + return mainpic; + } + + public void setMainpic(String mainpic) { + this.mainpic = mainpic; + } + + public String getDefaultprddbname() { + return defaultprddbname; + } + + public void setDefaultprddbname(String defaultprddbname) { + this.defaultprddbname = defaultprddbname; + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/ChartData.java b/app/src/main/java/com/sipai/jspatrol/Bean/ChartData.java new file mode 100644 index 0000000..2b11bf0 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/ChartData.java @@ -0,0 +1,51 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +public class ChartData implements Serializable { + private String name; + private String name1; + private Object[] x; + private Object[] y; + private Object[] y2; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getName1() { + return name1; + } + + public void setName1(String name1) { + this.name1 = name1; + } + + public Object[] getX() { + return x; + } + + public void setX(Object[] x) { + this.x = x; + } + + public Object[] getY() { + return y; + } + + public void setY(Object[] y) { + this.y = y; + } + + public Object[] getY2() { + return y2; + } + + public void setY2(Object[] y2) { + this.y2 = y2; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Detail.java b/app/src/main/java/com/sipai/jspatrol/Bean/Detail.java new file mode 100644 index 0000000..16a1308 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Detail.java @@ -0,0 +1,75 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/3/26. + */ + +public class Detail implements Serializable { + private String id,problem,handledetail,detailsupplement,handledt,processsectionid,equipmentids,faultlibraryid; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getProblem() { + return problem; + } + + public void setProblem(String problem) { + this.problem = problem; + } + + public String getHandledetail() { + return handledetail; + } + + public void setHandledetail(String handledetail) { + this.handledetail = handledetail; + } + + public String getDetailsupplement() { + return detailsupplement; + } + + public void setDetailsupplement(String detailsupplement) { + this.detailsupplement = detailsupplement; + } + + public String getHandledt() { + return handledt; + } + + public void setHandledt(String handledt) { + this.handledt = handledt; + } + + public String getProcesssectionid() { + return processsectionid; + } + + public void setProcesssectionid(String processsectionid) { + this.processsectionid = processsectionid; + } + + public String getEquipmentids() { + return equipmentids; + } + + public void setEquipmentids(String equipmentids) { + this.equipmentids = equipmentids; + } + + public String getFaultlibraryid() { + return faultlibraryid; + } + + public void setFaultlibraryid(String faultlibraryid) { + this.faultlibraryid = faultlibraryid; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/EquList.java b/app/src/main/java/com/sipai/jspatrol/Bean/EquList.java new file mode 100644 index 0000000..d156fb5 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/EquList.java @@ -0,0 +1,449 @@ +package com.sipai.jspatrol.Bean; + + +import java.io.Serializable; +import java.util.List; + +public class EquList implements Serializable { + private String areaid; + private String assetClass; + private String assetclassid; + private String assetnumber; + private String bizid; + private String company; + private String currentmanageflag; + private String equipmentClass; + private String equipmentLevel; + private String equipmentPid; + private String equipmentSpecification; + private String equipmentTypeNumber; + private String equipmentcardid; + private String equipmentclassid; + private String equipmentlevelid; + private String equipmentmanufacturer; + private String equipmentmodel; + private String equipmentname; + private String equipmentstatus; + private String equipmentvalue; + private String geographyarea; + private String id; + private String insdt; + private String insuser; + private String leavefactorynumber; + private String maintenancecondition; + private String majorparameter; + private String nowtotaldepreciation; + private String pid; + private String processSection; + private String processsectionid; + private String productiondate; + private String purchasedate; + private String ratedcurrent; + private String ratedpower; + private String ratedvoltage; + private String remark; + private String residualvalue; + private String responsibledepartment; + private String servicephone; + private String specification; + private String sql; + private String supplierid; + private String totaltime; + private String useage; + private String usedate; + private String where; + private String equipmentStatusManagement; + private List measuringpoints; + + public String getEquipmentStatusManagement() { + return equipmentStatusManagement; + } + + public void setEquipmentStatusManagement(String equipmentStatusManagement) { + this.equipmentStatusManagement = equipmentStatusManagement; + } + + public String getAreaid() { + return areaid; + } + + public void setAreaid(String areaid) { + this.areaid = areaid; + } + + public String getAssetClass() { + return assetClass; + } + + public void setAssetClass(String assetClass) { + this.assetClass = assetClass; + } + + public String getAssetclassid() { + return assetclassid; + } + + public void setAssetclassid(String assetclassid) { + this.assetclassid = assetclassid; + } + + public String getAssetnumber() { + return assetnumber; + } + + public void setAssetnumber(String assetnumber) { + this.assetnumber = assetnumber; + } + + public String getBizid() { + return bizid; + } + + public void setBizid(String bizid) { + this.bizid = bizid; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public String getCurrentmanageflag() { + return currentmanageflag; + } + + public void setCurrentmanageflag(String currentmanageflag) { + this.currentmanageflag = currentmanageflag; + } + + public String getEquipmentClass() { + return equipmentClass; + } + + public void setEquipmentClass(String equipmentClass) { + this.equipmentClass = equipmentClass; + } + + public String getEquipmentLevel() { + return equipmentLevel; + } + + public void setEquipmentLevel(String equipmentLevel) { + this.equipmentLevel = equipmentLevel; + } + + public String getEquipmentPid() { + return equipmentPid; + } + + public void setEquipmentPid(String equipmentPid) { + this.equipmentPid = equipmentPid; + } + + public String getEquipmentSpecification() { + return equipmentSpecification; + } + + public void setEquipmentSpecification(String equipmentSpecification) { + this.equipmentSpecification = equipmentSpecification; + } + + public String getEquipmentTypeNumber() { + return equipmentTypeNumber; + } + + public void setEquipmentTypeNumber(String equipmentTypeNumber) { + this.equipmentTypeNumber = equipmentTypeNumber; + } + + public String getEquipmentcardid() { + return equipmentcardid; + } + + public void setEquipmentcardid(String equipmentcardid) { + this.equipmentcardid = equipmentcardid; + } + + public String getEquipmentclassid() { + return equipmentclassid; + } + + public void setEquipmentclassid(String equipmentclassid) { + this.equipmentclassid = equipmentclassid; + } + + public String getEquipmentlevelid() { + return equipmentlevelid; + } + + public void setEquipmentlevelid(String equipmentlevelid) { + this.equipmentlevelid = equipmentlevelid; + } + + public String getEquipmentmanufacturer() { + return equipmentmanufacturer; + } + + public void setEquipmentmanufacturer(String equipmentmanufacturer) { + this.equipmentmanufacturer = equipmentmanufacturer; + } + + public String getEquipmentmodel() { + return equipmentmodel; + } + + public void setEquipmentmodel(String equipmentmodel) { + this.equipmentmodel = equipmentmodel; + } + + public String getEquipmentname() { + return equipmentname; + } + + public void setEquipmentname(String equipmentname) { + this.equipmentname = equipmentname; + } + + public String getEquipmentstatus() { + return equipmentstatus; + } + + public void setEquipmentstatus(String equipmentstatus) { + this.equipmentstatus = equipmentstatus; + } + + public String getEquipmentvalue() { + return equipmentvalue; + } + + public void setEquipmentvalue(String equipmentvalue) { + this.equipmentvalue = equipmentvalue; + } + + public String getGeographyarea() { + return geographyarea; + } + + public void setGeographyarea(String geographyarea) { + this.geographyarea = geographyarea; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getLeavefactorynumber() { + return leavefactorynumber; + } + + public void setLeavefactorynumber(String leavefactorynumber) { + this.leavefactorynumber = leavefactorynumber; + } + + public String getMaintenancecondition() { + return maintenancecondition; + } + + public void setMaintenancecondition(String maintenancecondition) { + this.maintenancecondition = maintenancecondition; + } + + public String getMajorparameter() { + return majorparameter; + } + + public void setMajorparameter(String majorparameter) { + this.majorparameter = majorparameter; + } + + public String getNowtotaldepreciation() { + return nowtotaldepreciation; + } + + public void setNowtotaldepreciation(String nowtotaldepreciation) { + this.nowtotaldepreciation = nowtotaldepreciation; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getProcessSection() { + return processSection; + } + + public void setProcessSection(String processSection) { + this.processSection = processSection; + } + + public String getProcesssectionid() { + return processsectionid; + } + + public void setProcesssectionid(String processsectionid) { + this.processsectionid = processsectionid; + } + + public String getProductiondate() { + return productiondate; + } + + public void setProductiondate(String productiondate) { + this.productiondate = productiondate; + } + + public String getPurchasedate() { + return purchasedate; + } + + public void setPurchasedate(String purchasedate) { + this.purchasedate = purchasedate; + } + + public String getRatedcurrent() { + return ratedcurrent; + } + + public void setRatedcurrent(String ratedcurrent) { + this.ratedcurrent = ratedcurrent; + } + + public String getRatedpower() { + return ratedpower; + } + + public void setRatedpower(String ratedpower) { + this.ratedpower = ratedpower; + } + + public String getRatedvoltage() { + return ratedvoltage; + } + + public void setRatedvoltage(String ratedvoltage) { + this.ratedvoltage = ratedvoltage; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getResidualvalue() { + return residualvalue; + } + + public void setResidualvalue(String residualvalue) { + this.residualvalue = residualvalue; + } + + public String getResponsibledepartment() { + return responsibledepartment; + } + + public void setResponsibledepartment(String responsibledepartment) { + this.responsibledepartment = responsibledepartment; + } + + public String getServicephone() { + return servicephone; + } + + public void setServicephone(String servicephone) { + this.servicephone = servicephone; + } + + public String getSpecification() { + return specification; + } + + public void setSpecification(String specification) { + this.specification = specification; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getSupplierid() { + return supplierid; + } + + public void setSupplierid(String supplierid) { + this.supplierid = supplierid; + } + + public String getTotaltime() { + return totaltime; + } + + public void setTotaltime(String totaltime) { + this.totaltime = totaltime; + } + + public String getUseage() { + return useage; + } + + public void setUseage(String useage) { + this.useage = useage; + } + + public String getUsedate() { + return usedate; + } + + public void setUsedate(String usedate) { + this.usedate = usedate; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } + + public List getMeasuringpoints() { + return measuringpoints; + } + + public void setMeasuringpoints(List measuringpoints) { + this.measuringpoints = measuringpoints; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Fault.java b/app/src/main/java/com/sipai/jspatrol/Bean/Fault.java new file mode 100644 index 0000000..f7371a8 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Fault.java @@ -0,0 +1,505 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/2/26. + */ + +public class Fault implements Serializable{ + private String abnormityDescription; + private String bizId; + private Biz biz; + private String equipmentIds; + private String equipmentNames; + private String remark; + private String sumitMan; + private String actualFinishDate; + private int actualMoney; + private String assistantedid; + private String changeParts; + private String company; + private String companyid; + private String contactids; + private String defectLevel; + private String delayReason; + private String detailNumber; + private EquList equipmentCard; + private String equipmentId; + private String id; + private String insdt; + private String insuser; + private int judgemaintainerstaff; + private int judgeresult; + private String maintainerid; + private String maintainplanid; + private String maintenance; + private String maintenanceMan; + private String maintenanceWay; + private String maintenanceid; + private int planConsumeTime; + private String planMoney; + private String plannedenddt; + private String problemcontent; + private String problemresult; + private String problemtypeid; + private String problemTypeNames; + private ProcessSection processSection; + private String processSectionId; + private String processdefid; + private String processid; + private String solver; + private String solvetime; + private String sql; + private String startDate; + private String status; + private String submittime; + private String type; + private String where; + private String todoTask; + private String taskId; + private String equipmentOpinion; + private String processInstanceId; + private String materialOpinion; + private String qualityOpinion; + + public String getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTodoTask() { + return todoTask; + } + + public void setTodoTask(String todoTask) { + this.todoTask = todoTask; + } + + public String getProblemTypeNames() { + return problemTypeNames; + } + + public void setProblemTypeNames(String problemTypeNames) { + this.problemTypeNames = problemTypeNames; + } + + public String getAbnormityDescription() { + return abnormityDescription; + } + + public void setAbnormityDescription(String abnormityDescription) { + this.abnormityDescription = abnormityDescription; + } + + public String getBizId() { + return bizId; + } + + public void setBizId(String bizId) { + this.bizId = bizId; + } + + public Biz getBiz() { + return biz; + } + + public void setBiz(Biz biz) { + this.biz = biz; + } + + public String getEquipmentIds() { + return equipmentIds; + } + + public void setEquipmentIds(String equipmentIds) { + this.equipmentIds = equipmentIds; + } + + public String getEquipmentNames() { + return equipmentNames; + } + + public void setEquipmentNames(String equipmentNames) { + this.equipmentNames = equipmentNames; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSumitMan() { + return sumitMan; + } + + public void setSumitMan(String sumitMan) { + this.sumitMan = sumitMan; + } + + public String getActualFinishDate() { + return actualFinishDate; + } + + public void setActualFinishDate(String actualFinishDate) { + this.actualFinishDate = actualFinishDate; + } + + public int getActualMoney() { + return actualMoney; + } + + public void setActualMoney(int actualMoney) { + this.actualMoney = actualMoney; + } + + public String getAssistantedid() { + return assistantedid; + } + + public void setAssistantedid(String assistantedid) { + this.assistantedid = assistantedid; + } + + public String getChangeParts() { + return changeParts; + } + + public void setChangeParts(String changeParts) { + this.changeParts = changeParts; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public String getCompanyid() { + return companyid; + } + + public void setCompanyid(String companyid) { + this.companyid = companyid; + } + + public String getContactids() { + return contactids; + } + + public void setContactids(String contactids) { + this.contactids = contactids; + } + + public String getDefectLevel() { + return defectLevel; + } + + public void setDefectLevel(String defectLevel) { + this.defectLevel = defectLevel; + } + + public String getDelayReason() { + return delayReason; + } + + public void setDelayReason(String delayReason) { + this.delayReason = delayReason; + } + + public String getDetailNumber() { + return detailNumber; + } + + public void setDetailNumber(String detailNumber) { + this.detailNumber = detailNumber; + } + + public EquList getEquipmentCard() { + return equipmentCard; + } + + public void setEquipmentCard(EquList equipmentCard) { + this.equipmentCard = equipmentCard; + } + + public String getEquipmentId() { + return equipmentId; + } + + public void setEquipmentId(String equipmentId) { + this.equipmentId = equipmentId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public int getJudgemaintainerstaff() { + return judgemaintainerstaff; + } + + public void setJudgemaintainerstaff(int judgemaintainerstaff) { + this.judgemaintainerstaff = judgemaintainerstaff; + } + + public int getJudgeresult() { + return judgeresult; + } + + public void setJudgeresult(int judgeresult) { + this.judgeresult = judgeresult; + } + + public String getMaintainerid() { + return maintainerid; + } + + public void setMaintainerid(String maintainerid) { + this.maintainerid = maintainerid; + } + + public String getMaintainplanid() { + return maintainplanid; + } + + public void setMaintainplanid(String maintainplanid) { + this.maintainplanid = maintainplanid; + } + + public String getMaintenance() { + return maintenance; + } + + public void setMaintenance(String maintenance) { + this.maintenance = maintenance; + } + + public String getMaintenanceMan() { + return maintenanceMan; + } + + public void setMaintenanceMan(String maintenanceMan) { + this.maintenanceMan = maintenanceMan; + } + + public String getMaintenanceWay() { + return maintenanceWay; + } + + public void setMaintenanceWay(String maintenanceWay) { + this.maintenanceWay = maintenanceWay; + } + + public String getMaintenanceid() { + return maintenanceid; + } + + public void setMaintenanceid(String maintenanceid) { + this.maintenanceid = maintenanceid; + } + + public int getPlanConsumeTime() { + return planConsumeTime; + } + + public void setPlanConsumeTime(int planConsumeTime) { + this.planConsumeTime = planConsumeTime; + } + + public String getPlanMoney() { + return planMoney; + } + + public void setPlanMoney(String planMoney) { + this.planMoney = planMoney; + } + + public String getPlannedenddt() { + return plannedenddt; + } + + public void setPlannedenddt(String plannedenddt) { + this.plannedenddt = plannedenddt; + } + + public String getProblemcontent() { + return problemcontent; + } + + public void setProblemcontent(String problemcontent) { + this.problemcontent = problemcontent; + } + + public String getProblemresult() { + return problemresult; + } + + public void setProblemresult(String problemresult) { + this.problemresult = problemresult; + } + + public String getProblemtypeid() { + return problemtypeid; + } + + public void setProblemtypeid(String problemtypeid) { + this.problemtypeid = problemtypeid; + } + + public ProcessSection getProcessSection() { + return processSection; + } + + public void setProcessSection(ProcessSection processSection) { + this.processSection = processSection; + } + + public String getProcessSectionId() { + return processSectionId; + } + + public void setProcessSectionId(String processSectionId) { + this.processSectionId = processSectionId; + } + + public String getProcessdefid() { + return processdefid; + } + + public void setProcessdefid(String processdefid) { + this.processdefid = processdefid; + } + + public String getProcessid() { + return processid; + } + + public void setProcessid(String processid) { + this.processid = processid; + } + + public String getSolver() { + return solver; + } + + public void setSolver(String solver) { + this.solver = solver; + } + + public String getSolvetime() { + return solvetime; + } + + public void setSolvetime(String solvetime) { + this.solvetime = solvetime; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getSubmittime() { + return submittime; + } + + public void setSubmittime(String submittime) { + this.submittime = submittime; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } + + public String getMaterialOpinion() { + return materialOpinion; + } + + public void setMaterialOpinion(String materialOpinion) { + this.materialOpinion = materialOpinion; + } + + public String getQualityOpinion() { + return qualityOpinion; + } + + public void setQualityOpinion(String qualityOpinion) { + this.qualityOpinion = qualityOpinion; + } + + public String getEquipmentOpinion() { + return equipmentOpinion; + } + + public void setEquipmentOpinion(String equipmentOpinion) { + this.equipmentOpinion = equipmentOpinion; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/FaultFlow.java b/app/src/main/java/com/sipai/jspatrol/Bean/FaultFlow.java new file mode 100644 index 0000000..1b152e3 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/FaultFlow.java @@ -0,0 +1,70 @@ +package com.sipai.jspatrol.Bean; + +/** + * created by lvliming on 2020/12/14 + */ +public class FaultFlow { + private String id; + private String files; + private String processid; + private String record; + private String taskName; + private String insdt; + private User user; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getFiles() { + return files; + } + + public void setFiles(String files) { + this.files = files; + } + + public String getProcessid() { + return processid; + } + + public void setProcessid(String processid) { + this.processid = processid; + } + + public String getRecord() { + return record; + } + + public void setRecord(String record) { + this.record = record; + } + + public String getTaskName() { + return taskName; + } + + public void setTaskName(String taskName) { + this.taskName = taskName; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/FileForDL.java b/app/src/main/java/com/sipai/jspatrol/Bean/FileForDL.java new file mode 100644 index 0000000..95b955c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/FileForDL.java @@ -0,0 +1,27 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * created by lvliming on 2019/12/28 + */ +public class FileForDL implements Serializable { + private String id; + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/InfoSel.java b/app/src/main/java/com/sipai/jspatrol/Bean/InfoSel.java new file mode 100644 index 0000000..f4bca70 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/InfoSel.java @@ -0,0 +1,26 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * created by lvliming on 2019/7/10 + */ +public class InfoSel implements Serializable { + private String id,text; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/InputPoint.java b/app/src/main/java/com/sipai/jspatrol/Bean/InputPoint.java new file mode 100644 index 0000000..b900dd3 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/InputPoint.java @@ -0,0 +1,211 @@ +package com.sipai.jspatrol.Bean; + +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolEqu; + +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; + +/** + * created by lvliming on 2019/8/12 + */ +public class InputPoint extends LitePalSupport implements Serializable { + private String alarmmax; + private String alarmmin; + private String biztype; + private String sid; + private String measuredt; + private String mpointcode; + private String parmname; + private String parmvalue; + private int sel; + private String signalType; + private String sql; + private String unit; + private String valuemeaning; + private String where; + private String pid; + private String type; + private String patrolPointId; + private String patrolRecordId; + private String equipmentId; + private String finishDt; + private ProPatrolPoint proPatrolPoint; + private PatrolEqu patrolEqu; + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public int getSel() { + return sel; + } + + public void setSel(int sel) { + this.sel = sel; + } + + public String getValuemeaning() { + return valuemeaning; + } + + public void setValuemeaning(String valuemeaning) { + this.valuemeaning = valuemeaning; + } + + public String getBiztype() { + return biztype; + } + + public void setBiztype(String biztype) { + this.biztype = biztype; + } + + public String getMpointcode() { + return mpointcode; + } + + public void setMpointcode(String mpointcode) { + this.mpointcode = mpointcode; + } + + public String getAlarmmax() { + return alarmmax; + } + + public void setAlarmmax(String alarmmax) { + this.alarmmax = alarmmax; + } + + public String getAlarmmin() { + return alarmmin; + } + + public void setAlarmmin(String alarmmin) { + this.alarmmin = alarmmin; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getMeasuredt() { + return measuredt; + } + + public void setMeasuredt(String measuredt) { + this.measuredt = measuredt; + } + + public String getParmname() { + return parmname; + } + + public void setParmname(String parmname) { + this.parmname = parmname; + } + + public String getParmvalue() { + return parmvalue; + } + + public void setParmvalue(String parmvalue) { + this.parmvalue = parmvalue; + } + + public String getSignalType() { + return signalType; + } + + public void setSignalType(String signalType) { + this.signalType = signalType; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPatrolPointId() { + return patrolPointId; + } + + public void setPatrolPointId(String patrolPointId) { + this.patrolPointId = patrolPointId; + } + + public String getPatrolRecordId() { + return patrolRecordId; + } + + public void setPatrolRecordId(String patrolRecordId) { + this.patrolRecordId = patrolRecordId; + } + + public String getEquipmentId() { + return equipmentId; + } + + public void setEquipmentId(String equipmentId) { + this.equipmentId = equipmentId; + } + + public String getFinishDt() { + return finishDt; + } + + public void setFinishDt(String finishDt) { + this.finishDt = finishDt; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } + + public ProPatrolPoint getProPatrolPoint() { + return proPatrolPoint; + } + + public void setProPatrolPoint(ProPatrolPoint proPatrolPoint) { + this.proPatrolPoint = proPatrolPoint; + } + + public PatrolEqu getPatrolEqu() { + return patrolEqu; + } + + public void setPatrolEqu(PatrolEqu patrolEqu) { + this.patrolEqu = patrolEqu; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/LoginInfo.java b/app/src/main/java/com/sipai/jspatrol/Bean/LoginInfo.java new file mode 100644 index 0000000..3a63244 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/LoginInfo.java @@ -0,0 +1,43 @@ +package com.sipai.jspatrol.Bean; + +/** + * created by lvliming on 2020/3/23 + */ +public class LoginInfo extends BaseEntity { + private User user; + private String reason; + private boolean status; + + public LoginInfo() { + } + + public LoginInfo(User user, String reason, boolean status) { + this.user = user; + this.reason = reason; + this.status = status; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/MainTab.java b/app/src/main/java/com/sipai/jspatrol/Bean/MainTab.java new file mode 100644 index 0000000..ecc2cf1 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/MainTab.java @@ -0,0 +1,34 @@ +package com.sipai.jspatrol.Bean; + +/** + * created by lvliming on 2020/11/3 + */ +public class MainTab { + private String id; + private String name; + private String sname; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSname() { + return sname; + } + + public void setSname(String sname) { + this.sname = sname; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Maintenance.java b/app/src/main/java/com/sipai/jspatrol/Bean/Maintenance.java new file mode 100644 index 0000000..55d1fa2 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Maintenance.java @@ -0,0 +1,181 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/3/28. + */ + +public class Maintenance implements Serializable { + private String detailsupplement; + private String equipmentNames; + private String equipmentids; + private String faultLibraryName; + private String faultlibraryid; + private String handledetail; + private String handledt; + private String id; + private String insdt; + private String insuser; + private String insuserName; + private MaintenanceDetail maintenanceDetail; + private String maintenancedetailid; + private String problem; + private String processSectionName; + private String processsectionid; + private String sql; + private String taskdefinitionkey; + private String where; + + public String getDetailsupplement() { + return detailsupplement; + } + + public void setDetailsupplement(String detailsupplement) { + this.detailsupplement = detailsupplement; + } + + public String getEquipmentNames() { + return equipmentNames; + } + + public void setEquipmentNames(String equipmentNames) { + this.equipmentNames = equipmentNames; + } + + public String getEquipmentids() { + return equipmentids; + } + + public void setEquipmentids(String equipmentids) { + this.equipmentids = equipmentids; + } + + public String getFaultLibraryName() { + return faultLibraryName; + } + + public void setFaultLibraryName(String faultLibraryName) { + this.faultLibraryName = faultLibraryName; + } + + public String getFaultlibraryid() { + return faultlibraryid; + } + + public void setFaultlibraryid(String faultlibraryid) { + this.faultlibraryid = faultlibraryid; + } + + public String getHandledetail() { + return handledetail; + } + + public void setHandledetail(String handledetail) { + this.handledetail = handledetail; + } + + public String getHandledt() { + return handledt; + } + + public void setHandledt(String handledt) { + this.handledt = handledt; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getInsuserName() { + return insuserName; + } + + public void setInsuserName(String insuserName) { + this.insuserName = insuserName; + } + + public MaintenanceDetail getMaintenanceDetail() { + return maintenanceDetail; + } + + public void setMaintenanceDetail(MaintenanceDetail maintenanceDetail) { + this.maintenanceDetail = maintenanceDetail; + } + + public String getMaintenancedetailid() { + return maintenancedetailid; + } + + public void setMaintenancedetailid(String maintenancedetailid) { + this.maintenancedetailid = maintenancedetailid; + } + + public String getProblem() { + return problem; + } + + public void setProblem(String problem) { + this.problem = problem; + } + + public String getProcessSectionName() { + return processSectionName; + } + + public void setProcessSectionName(String processSectionName) { + this.processSectionName = processSectionName; + } + + public String getProcesssectionid() { + return processsectionid; + } + + public void setProcesssectionid(String processsectionid) { + this.processsectionid = processsectionid; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getTaskdefinitionkey() { + return taskdefinitionkey; + } + + public void setTaskdefinitionkey(String taskdefinitionkey) { + this.taskdefinitionkey = taskdefinitionkey; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/MaintenanceDetail.java b/app/src/main/java/com/sipai/jspatrol/Bean/MaintenanceDetail.java new file mode 100644 index 0000000..537b057 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/MaintenanceDetail.java @@ -0,0 +1,397 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/3/28. + */ + +public class MaintenanceDetail implements Serializable { + private String actualFinishDate; + private int actualMoney; + private String assistantedid; + private String changeParts; + private Biz company; + private String companyid; + private String contactids; + private String defectLevel; + private String delayReason; + private String detailNumber; + private String equipmentCard; + private String equipmentId; + private String id; + private String insdt; + private String insertUser; + private String insuser; + private int judgemaintainerstaff; + private int judgeresult; + private String maintainerid; + private String maintainplanid; + private String maintenance; + private String maintenanceMan; + private String maintenanceWay; + private String maintenanceid; + private int planConsumeTime; + private int planMoney; + private String plannedenddt; + private String problemTypeNames; + private String problemcontent; + private String problemresult; + private String problemtypeid; + private String processSection; + private String processSectionId; + private String processdefid; + private String processid; + private String solver; + private String solvetime; + private String sql; + private String startDate; + private String status; + private String submittime; + private String type; + private String where; + + public String getActualFinishDate() { + return actualFinishDate; + } + + public void setActualFinishDate(String actualFinishDate) { + this.actualFinishDate = actualFinishDate; + } + + public int getActualMoney() { + return actualMoney; + } + + public void setActualMoney(int actualMoney) { + this.actualMoney = actualMoney; + } + + public String getAssistantedid() { + return assistantedid; + } + + public void setAssistantedid(String assistantedid) { + this.assistantedid = assistantedid; + } + + public String getChangeParts() { + return changeParts; + } + + public void setChangeParts(String changeParts) { + this.changeParts = changeParts; + } + + public Biz getCompany() { + return company; + } + + public void setCompany(Biz company) { + this.company = company; + } + + public String getCompanyid() { + return companyid; + } + + public void setCompanyid(String companyid) { + this.companyid = companyid; + } + + public String getContactids() { + return contactids; + } + + public void setContactids(String contactids) { + this.contactids = contactids; + } + + public String getDefectLevel() { + return defectLevel; + } + + public void setDefectLevel(String defectLevel) { + this.defectLevel = defectLevel; + } + + public String getDelayReason() { + return delayReason; + } + + public void setDelayReason(String delayReason) { + this.delayReason = delayReason; + } + + public String getDetailNumber() { + return detailNumber; + } + + public void setDetailNumber(String detailNumber) { + this.detailNumber = detailNumber; + } + + public String getEquipmentCard() { + return equipmentCard; + } + + public void setEquipmentCard(String equipmentCard) { + this.equipmentCard = equipmentCard; + } + + public String getEquipmentId() { + return equipmentId; + } + + public void setEquipmentId(String equipmentId) { + this.equipmentId = equipmentId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsertUser() { + return insertUser; + } + + public void setInsertUser(String insertUser) { + this.insertUser = insertUser; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public int getJudgemaintainerstaff() { + return judgemaintainerstaff; + } + + public void setJudgemaintainerstaff(int judgemaintainerstaff) { + this.judgemaintainerstaff = judgemaintainerstaff; + } + + public int getJudgeresult() { + return judgeresult; + } + + public void setJudgeresult(int judgeresult) { + this.judgeresult = judgeresult; + } + + public String getMaintainerid() { + return maintainerid; + } + + public void setMaintainerid(String maintainerid) { + this.maintainerid = maintainerid; + } + + public String getMaintainplanid() { + return maintainplanid; + } + + public void setMaintainplanid(String maintainplanid) { + this.maintainplanid = maintainplanid; + } + + public String getMaintenance() { + return maintenance; + } + + public void setMaintenance(String maintenance) { + this.maintenance = maintenance; + } + + public String getMaintenanceMan() { + return maintenanceMan; + } + + public void setMaintenanceMan(String maintenanceMan) { + this.maintenanceMan = maintenanceMan; + } + + public String getMaintenanceWay() { + return maintenanceWay; + } + + public void setMaintenanceWay(String maintenanceWay) { + this.maintenanceWay = maintenanceWay; + } + + public String getMaintenanceid() { + return maintenanceid; + } + + public void setMaintenanceid(String maintenanceid) { + this.maintenanceid = maintenanceid; + } + + public int getPlanConsumeTime() { + return planConsumeTime; + } + + public void setPlanConsumeTime(int planConsumeTime) { + this.planConsumeTime = planConsumeTime; + } + + public int getPlanMoney() { + return planMoney; + } + + public void setPlanMoney(int planMoney) { + this.planMoney = planMoney; + } + + public String getPlannedenddt() { + return plannedenddt; + } + + public void setPlannedenddt(String plannedenddt) { + this.plannedenddt = plannedenddt; + } + + public String getProblemTypeNames() { + return problemTypeNames; + } + + public void setProblemTypeNames(String problemTypeNames) { + this.problemTypeNames = problemTypeNames; + } + + public String getProblemcontent() { + return problemcontent; + } + + public void setProblemcontent(String problemcontent) { + this.problemcontent = problemcontent; + } + + public String getProblemresult() { + return problemresult; + } + + public void setProblemresult(String problemresult) { + this.problemresult = problemresult; + } + + public String getProblemtypeid() { + return problemtypeid; + } + + public void setProblemtypeid(String problemtypeid) { + this.problemtypeid = problemtypeid; + } + + public String getProcessSection() { + return processSection; + } + + public void setProcessSection(String processSection) { + this.processSection = processSection; + } + + public String getProcessSectionId() { + return processSectionId; + } + + public void setProcessSectionId(String processSectionId) { + this.processSectionId = processSectionId; + } + + public String getProcessdefid() { + return processdefid; + } + + public void setProcessdefid(String processdefid) { + this.processdefid = processdefid; + } + + public String getProcessid() { + return processid; + } + + public void setProcessid(String processid) { + this.processid = processid; + } + + public String getSolver() { + return solver; + } + + public void setSolver(String solver) { + this.solver = solver; + } + + public String getSolvetime() { + return solvetime; + } + + public void setSolvetime(String solvetime) { + this.solvetime = solvetime; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getSubmittime() { + return submittime; + } + + public void setSubmittime(String submittime) { + this.submittime = submittime; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Measuringpoint.java b/app/src/main/java/com/sipai/jspatrol/Bean/Measuringpoint.java new file mode 100644 index 0000000..da3aaff --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Measuringpoint.java @@ -0,0 +1,186 @@ +package com.sipai.jspatrol.Bean; + +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolEqu; + +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; + +/** + * Created by lvliming on 2017/10/24. + */ + +public class Measuringpoint extends LitePalSupport implements Serializable { + private String sid; + private String name; + private String unit; + private String value; + private String _icon; + private String cvalue; + private String scadacode; + private String date; + private String month; + private String day; + private String time; + private String alarmmax; + private String alarmmin; + private String valuemeaning; + private String userid; + private String unitId; + private ProPatrolPoint proPatrolPoint; + private PatrolEqu patrolEqu; + + public String getUnitId() { + return unitId; + } + + public void setUnitId(String unitId) { + this.unitId = unitId; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public String getAlarmmax() { + return alarmmax; + } + + public void setAlarmmax(String alarmmax) { + this.alarmmax = alarmmax; + } + + public String getAlarmmin() { + return alarmmin; + } + + public void setAlarmmin(String alarmmin) { + this.alarmmin = alarmmin; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public String getDay() { + return day; + } + + public void setDay(String day) { + this.day = day; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getScadacode() { + return scadacode; + } + + public void setScadacode(String scadacode) { + this.scadacode = scadacode; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + private String type; + + public String get_icon() { + return _icon; + } + + public void set_icon(String _icon) { + this._icon = _icon; + } + + public String getCvalue() { + return cvalue; + } + + public void setCvalue(String cvalue) { + this.cvalue = cvalue; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getValuemeaning() { + return valuemeaning; + } + + public void setValuemeaning(String valuemeaning) { + this.valuemeaning = valuemeaning; + } + + public ProPatrolPoint getProPatrolPoint() { + return proPatrolPoint; + } + + public void setProPatrolPoint(ProPatrolPoint proPatrolPoint) { + this.proPatrolPoint = proPatrolPoint; + } + + public PatrolEqu getPatrolEqu() { + return patrolEqu; + } + + public void setPatrolEqu(PatrolEqu patrolEqu) { + this.patrolEqu = patrolEqu; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Message.java b/app/src/main/java/com/sipai/jspatrol/Bean/Message.java new file mode 100644 index 0000000..39124e5 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Message.java @@ -0,0 +1,42 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * created by lvliming on 2020/8/15 + */ +public class Message implements Serializable { + private String id,content,redflag,sdt; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getRedflag() { + return redflag; + } + + public void setRedflag(String redflag) { + this.redflag = redflag; + } + + public String getSdt() { + return sdt; + } + + public void setSdt(String sdt) { + this.sdt = sdt; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Nodes.java b/app/src/main/java/com/sipai/jspatrol/Bean/Nodes.java new file mode 100644 index 0000000..0186030 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Nodes.java @@ -0,0 +1,64 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; +import java.util.List; + +/** + * created by lvliming on 2020/12/20 + */ +public class Nodes implements Serializable { + private List nodes; + private String id; + private String text; + private String type; + private String sel; + private String mpid; + + public String getMpid() { + return mpid; + } + + public void setMpid(String mpid) { + this.mpid = mpid; + } + + public List getNodes() { + return nodes; + } + + public void setNodes(List nodes) { + this.nodes = nodes; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getSel() { + return sel; + } + + public void setSel(String sel) { + this.sel = sel; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Patrol.java b/app/src/main/java/com/sipai/jspatrol/Bean/Patrol.java new file mode 100644 index 0000000..0515614 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Patrol.java @@ -0,0 +1,196 @@ +package com.sipai.jspatrol.Bean; + +import org.litepal.LitePal; +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; +import java.util.List; + +/** + * Created by lvliming on 2018/12/17. + */ + +public class Patrol extends LitePalSupport implements Serializable{ + private String bizid,company,content,endTime,sid,insdt,insuser,name,patrolArea,patrolAreaId,patrolModelId,patrolPlanId, + startTime,status,type,workResult,worker,workerId; + private String actFinishTime; + private PatrolModel patrolModel; + private String patrolType; + private List patrolRecordPatrolRoutes; + + public String getBizid() { + return bizid; + } + + public void setBizid(String bizid) { + this.bizid = bizid; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPatrolArea() { + return patrolArea; + } + + public void setPatrolArea(String patrolArea) { + this.patrolArea = patrolArea; + } + + public String getPatrolAreaId() { + return patrolAreaId; + } + + public void setPatrolAreaId(String patrolAreaId) { + this.patrolAreaId = patrolAreaId; + } + + public String getPatrolModelId() { + return patrolModelId; + } + + public void setPatrolModelId(String patrolModelId) { + this.patrolModelId = patrolModelId; + } + + public String getPatrolPlanId() { + return patrolPlanId; + } + + public void setPatrolPlanId(String patrolPlanId) { + this.patrolPlanId = patrolPlanId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getWorkResult() { + return workResult; + } + + public void setWorkResult(String workResult) { + this.workResult = workResult; + } + + public String getWorker() { + return worker; + } + + public void setWorker(String worker) { + this.worker = worker; + } + + public String getWorkerId() { + return workerId; + } + + public void setWorkerId(String workerId) { + this.workerId = workerId; + } + + public PatrolModel getPatrolModel() { + return patrolModel; + } + + public void setPatrolModel(PatrolModel patrolModel) { + this.patrolModel = patrolModel; + } + + public String getPatrolType() { + return patrolType; + } + + public void setPatrolType(String patrolType) { + this.patrolType = patrolType; + } + + public String getActFinishTime() { + return actFinishTime; + } + + public void setActFinishTime(String actFinishTime) { + this.actFinishTime = actFinishTime; + } + + public List getPatrolRecordPatrolRoutes() { + return LitePal.where("patrolRecordId = ?",sid).find(ProPatrolPoint.class); + } + + public void setPatrolRecordPatrolRoutes(List patrolRecordPatrolRoutes) { + this.patrolRecordPatrolRoutes = patrolRecordPatrolRoutes; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/PatrolLocation.java b/app/src/main/java/com/sipai/jspatrol/Bean/PatrolLocation.java new file mode 100644 index 0000000..67ba8d2 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/PatrolLocation.java @@ -0,0 +1,49 @@ +package com.sipai.jspatrol.Bean; + +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/4/19. + */ + +public class PatrolLocation extends LitePalSupport implements Serializable { + + private String latitude; + private String longitude; + private String insdt; + private String userid; + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/PatrolModel.java b/app/src/main/java/com/sipai/jspatrol/Bean/PatrolModel.java new file mode 100644 index 0000000..2ef89d5 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/PatrolModel.java @@ -0,0 +1,69 @@ +package com.sipai.jspatrol.Bean; + +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/2/19. + */ + +public class PatrolModel extends LitePalSupport implements Serializable { + private String sid,active,bizId,defaultFlag,name,type,where; + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public String getBizId() { + return bizId; + } + + public void setBizId(String bizId) { + this.bizId = bizId; + } + + public String getDefaultFlag() { + return defaultFlag; + } + + public void setDefaultFlag(String defaultFlag) { + this.defaultFlag = defaultFlag; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/PatrolPointContent.java b/app/src/main/java/com/sipai/jspatrol/Bean/PatrolPointContent.java new file mode 100644 index 0000000..89cab61 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/PatrolPointContent.java @@ -0,0 +1,136 @@ +package com.sipai.jspatrol.Bean; + +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolEqu; + +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; + +/** + * created by lvliming on 2019/8/27 + */ +public class PatrolPointContent extends LitePalSupport implements Serializable { + private ProPatrolPoint proPatrolPoint; + private PatrolEqu patrolEqu; + private String sid,contents,contentsDetail,status; + private String pid; + private String type; + private String patrolPointId; + private String patrolRecordId; + private String equipmentId; + private String insdt; + private String insuser; + private String finishDt; + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getContents() { + return contents; + } + + public void setContents(String contents) { + this.contents = contents; + } + + public String getContentsDetail() { + return contentsDetail; + } + + public void setContentsDetail(String contentsDetail) { + this.contentsDetail = contentsDetail; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public ProPatrolPoint getProPatrolPoint() { + return proPatrolPoint; + } + + public void setProPatrolPoint(ProPatrolPoint proPatrolPoint) { + this.proPatrolPoint = proPatrolPoint; + } + + public PatrolEqu getPatrolEqu() { + return patrolEqu; + } + + public void setPatrolEqu(PatrolEqu patrolEqu) { + this.patrolEqu = patrolEqu; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPatrolPointId() { + return patrolPointId; + } + + public void setPatrolPointId(String patrolPointId) { + this.patrolPointId = patrolPointId; + } + + public String getPatrolRecordId() { + return patrolRecordId; + } + + public void setPatrolRecordId(String patrolRecordId) { + this.patrolRecordId = patrolRecordId; + } + + public String getEquipmentId() { + return equipmentId; + } + + public void setEquipmentId(String equipmentId) { + this.equipmentId = equipmentId; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getFinishDt() { + return finishDt; + } + + public void setFinishDt(String finishDt) { + this.finishDt = finishDt; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Picture.java b/app/src/main/java/com/sipai/jspatrol/Bean/Picture.java new file mode 100644 index 0000000..598a371 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Picture.java @@ -0,0 +1,28 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/3/25. + */ + +public class Picture implements Serializable { + private String abspath; + private String id; + + public String getAbspath() { + return abspath; + } + + public void setAbspath(String abspath) { + this.abspath = abspath; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/PointLongValue.java b/app/src/main/java/com/sipai/jspatrol/Bean/PointLongValue.java new file mode 100644 index 0000000..b3355e5 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/PointLongValue.java @@ -0,0 +1,40 @@ +package com.sipai.jspatrol.Bean; + +public class PointLongValue { + private Long date; + private String name; + private String unit; + private String value; + + public Long getDate() { + return date; + } + + public void setDate(Long date) { + this.date = date; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/ProPatrolPoint.java b/app/src/main/java/com/sipai/jspatrol/Bean/ProPatrolPoint.java new file mode 100644 index 0000000..00a5725 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/ProPatrolPoint.java @@ -0,0 +1,349 @@ +package com.sipai.jspatrol.Bean; + +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolEqu; + +import org.litepal.LitePal; +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; +import java.util.List; + +/** + * Created by lvliming on 2019/2/20. + */ + +public class ProPatrolPoint extends LitePalSupport implements Serializable { + private String patrolRecordPatrolRouteId; + private String active; + private String bizId; + private String sid; + private String resultId; + private String insdt; + private String insuser; + private String latitude; + private String longitude; + private String modbusFig; + private String modbusFigId; + private String morder; + private String name; + private String patrolContent; + private ProcessSection processSection; + private String processSectionId; + private String processSectionName; + private String readOrWrite; + private String register; + private String remark; + private String sql; + private String type; + private String unit; + private String where; + private String status; + private String taskId; + private String taskType; + private String pointType; + private String workerId; + private String workerName; + private String finishDt; + private String patrolPointId; + private String patrolRecordId; + private List patrolContentsRecords; + private List patrolMeasurePointRecords; + private List patrolRecordPatrolEquipments; + private Patrol patrol; + + public String getPatrolRecordPatrolRouteId() { + return patrolRecordPatrolRouteId; + } + + public void setPatrolRecordPatrolRouteId(String patrolRecordPatrolRouteId) { + this.patrolRecordPatrolRouteId = patrolRecordPatrolRouteId; + } + + public String getPatrolPointId() { + return patrolPointId; + } + + public void setPatrolPointId(String patrolPointId) { + this.patrolPointId = patrolPointId; + } + + public String getPatrolRecordId() { + return patrolRecordId; + } + + public void setPatrolRecordId(String patrolRecordId) { + this.patrolRecordId = patrolRecordId; + } + + public String getResultId() { + return resultId; + } + + public void setResultId(String resultId) { + this.resultId = resultId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public String getBizId() { + return bizId; + } + + public void setBizId(String bizId) { + this.bizId = bizId; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getModbusFig() { + return modbusFig; + } + + public void setModbusFig(String modbusFig) { + this.modbusFig = modbusFig; + } + + public String getModbusFigId() { + return modbusFigId; + } + + public void setModbusFigId(String modbusFigId) { + this.modbusFigId = modbusFigId; + } + + public String getMorder() { + return morder; + } + + public void setMorder(String morder) { + this.morder = morder; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPatrolContent() { + return patrolContent; + } + + public void setPatrolContent(String patrolContent) { + this.patrolContent = patrolContent; + } + + public ProcessSection getProcessSection() { + return processSection; + } + + public void setProcessSection(ProcessSection processSection) { + this.processSection = processSection; + } + + public String getProcessSectionId() { + return processSectionId; + } + + public void setProcessSectionId(String processSectionId) { + this.processSectionId = processSectionId; + } + + public String getReadOrWrite() { + return readOrWrite; + } + + public void setReadOrWrite(String readOrWrite) { + this.readOrWrite = readOrWrite; + } + + public String getRegister() { + return register; + } + + public void setRegister(String register) { + this.register = register; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } + + public String getProcessSectionName() { + return processSectionName; + } + + public void setProcessSectionName(String processSectionName) { + this.processSectionName = processSectionName; + } + + public String getTaskType() { + return taskType; + } + + public void setTaskType(String taskType) { + this.taskType = taskType; + } + + public String getPointType() { + return pointType; + } + + public void setPointType(String pointType) { + this.pointType = pointType; + } + + public String getWorkerId() { + return workerId; + } + + public void setWorkerId(String workerId) { + this.workerId = workerId; + } + + public String getFinishDt() { + return finishDt; + } + + public void setFinishDt(String finishDt) { + this.finishDt = finishDt; + } + + public List getPatrolContentsRecords() { + return LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",sid,taskId,"").find(PatrolPointContent.class); + } + + public void setPatrolContentsRecords(List patrolContentsRecords) { + this.patrolContentsRecords = patrolContentsRecords; + } + + public List getPatrolMeasurePointRecords() { + return LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",sid,taskId,"").find(InputPoint.class); + } + + public void setPatrolMeasurePointRecords(List patrolMeasurePointRecords) { + this.patrolMeasurePointRecords = patrolMeasurePointRecords; + } + + public List getPatrolRecordPatrolEquipments() { + return LitePal.where("patrolPointId = ? and patrolRecordId = ?",sid,taskId).find(PatrolEqu.class); + } + + public void setPatrolRecordPatrolEquipments(List patrolRecordPatrolEquipments) { + this.patrolRecordPatrolEquipments = patrolRecordPatrolEquipments; + } + + public Patrol getPatrol() { + return patrol; + } + + public void setPatrol(Patrol patrol) { + this.patrol = patrol; + } + + public String getWorkerName() { + return workerName; + } + + public void setWorkerName(String workerName) { + this.workerName = workerName; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/ProcessSection.java b/app/src/main/java/com/sipai/jspatrol/Bean/ProcessSection.java new file mode 100644 index 0000000..80fdcf8 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/ProcessSection.java @@ -0,0 +1,93 @@ +package com.sipai.jspatrol.Bean; + +import org.litepal.crud.LitePalSupport; + +import java.io.Serializable; + +/** + * Created by lvliming on 2019/2/20. + */ + +public class ProcessSection extends LitePalSupport implements Serializable { + private String code; + private String sid; + private String insdt; + private String insuser; + private String name; + private String pid; + private String sname; + private String sql; + private String where; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getSname() { + return sname; + } + + public void setSname(String sname) { + this.sname = sname; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Roles.java b/app/src/main/java/com/sipai/jspatrol/Bean/Roles.java new file mode 100644 index 0000000..978cd92 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Roles.java @@ -0,0 +1,54 @@ +package com.sipai.jspatrol.Bean; + +/** + * created by lvliming on 2020/3/23 + */ +public class Roles { + private String id; + private String description; + private String name; + private String bizid; + private String serial; + private int morder; + public void setId(String id) { + this.id = id; + } + public String getId() { + return id; + } + + public void setDescription(String description) { + this.description = description; + } + public String getDescription() { + return description; + } + + public void setName(String name) { + this.name = name; + } + public String getName() { + return name; + } + + public void setBizid(String bizid) { + this.bizid = bizid; + } + public String getBizid() { + return bizid; + } + + public void setSerial(String serial) { + this.serial = serial; + } + public String getSerial() { + return serial; + } + + public void setMorder(int morder) { + this.morder = morder; + } + public int getMorder() { + return morder; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/Statement.java b/app/src/main/java/com/sipai/jspatrol/Bean/Statement.java new file mode 100644 index 0000000..e2a3c28 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/Statement.java @@ -0,0 +1,88 @@ +package com.sipai.jspatrol.Bean; + +/** + * created by lvliming on 2021/3/18 + */ +public class Statement { + private String id; + private String inputusername; + private String insdt; + private String rptdt; + private String rptname; + private String rptsetId; + private String unitId; + private String upsdt; + private String meno; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInputusername() { + return inputusername; + } + + public void setInputusername(String inputusername) { + this.inputusername = inputusername; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getRptdt() { + return rptdt; + } + + public void setRptdt(String rptdt) { + this.rptdt = rptdt; + } + + public String getRptname() { + return rptname; + } + + public void setRptname(String rptname) { + this.rptname = rptname; + } + + public String getRptsetId() { + return rptsetId; + } + + public void setRptsetId(String rptsetId) { + this.rptsetId = rptsetId; + } + + public String getUnitId() { + return unitId; + } + + public void setUnitId(String unitId) { + this.unitId = unitId; + } + + public String getUpsdt() { + return upsdt; + } + + public void setUpsdt(String upsdt) { + this.upsdt = upsdt; + } + + public String getMeno() { + return meno; + } + + public void setMeno(String meno) { + this.meno = meno; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/User.java b/app/src/main/java/com/sipai/jspatrol/Bean/User.java new file mode 100644 index 0000000..3e5a8c2 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/User.java @@ -0,0 +1,240 @@ +package com.sipai.jspatrol.Bean; + +import java.io.Serializable; +import java.util.List; + +/** + * created by lvliming on 2020/3/23 + * 人员 + */ +public class User extends BaseEntity implements Serializable { + private UserDetail userDetail; + private String sex; + private String currentip; + private String pid; + private String caption; + private String syncflag; + private String password; + private String insuser; + private int morder; + private String cardid; + private String officeroom; + private String id; + private int pri; + private String lastlogintime; + private String officephone; + private String useremail; + private String roles; + private String name; + private String pname; + private String active; + private double totaltime; + private String themeclass; + private String serial; + private int lgnum; + private String token; + private String patrolTypeId; + private String nfc; + private String subTask; + + public String getSubTask() { + return subTask; + } + + public void setSubTask(String subTask) { + this.subTask = subTask; + } + + public String getPatrolTypeId() { + return patrolTypeId; + } + + public void setPatrolTypeId(String patrolTypeId) { + this.patrolTypeId = patrolTypeId; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public void setUserDetail(UserDetail userDetail) { + this.userDetail = userDetail; + } + public UserDetail getUserDetail() { + return userDetail; + } + + public void setSex(String sex) { + this.sex = sex; + } + public String getSex() { + return sex; + } + + public void setCurrentip(String currentip) { + this.currentip = currentip; + } + public String getCurrentip() { + return currentip; + } + + public void setPid(String pid) { + this.pid = pid; + } + public String getPid() { + return pid; + } + + public void setCaption(String caption) { + this.caption = caption; + } + public String getCaption() { + return caption; + } + + public void setSyncflag(String syncflag) { + this.syncflag = syncflag; + } + public String getSyncflag() { + return syncflag; + } + + public void setPassword(String password) { + this.password = password; + } + public String getPassword() { + return password; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + public String getInsuser() { + return insuser; + } + + public void setMorder(int morder) { + this.morder = morder; + } + public int getMorder() { + return morder; + } + + public void setCardid(String cardid) { + this.cardid = cardid; + } + public String getCardid() { + return cardid; + } + + public void setOfficeroom(String officeroom) { + this.officeroom = officeroom; + } + public String getOfficeroom() { + return officeroom; + } + + public void setId(String id) { + this.id = id; + } + public String getId() { + return id; + } + + public void setPri(int pri) { + this.pri = pri; + } + public int getPri() { + return pri; + } + + public void setLastlogintime(String lastlogintime) { + this.lastlogintime = lastlogintime; + } + public String getLastlogintime() { + return lastlogintime; + } + + public void setOfficephone(String officephone) { + this.officephone = officephone; + } + public String getOfficephone() { + return officephone; + } + + public void setUseremail(String useremail) { + this.useremail = useremail; + } + public String getUseremail() { + return useremail; + } + + public String getRoles() { + return roles; + } + + public void setRoles(String roles) { + this.roles = roles; + } + + public void setName(String name) { + this.name = name; + } + public String getName() { + return name; + } + + public void setPname(String pname) { + this.pname = pname; + } + public String getPname() { + return pname; + } + + public void setActive(String active) { + this.active = active; + } + public String getActive() { + return active; + } + + public void setTotaltime(double totaltime) { + this.totaltime = totaltime; + } + public double getTotaltime() { + return totaltime; + } + + public void setThemeclass(String themeclass) { + this.themeclass = themeclass; + } + public String getThemeclass() { + return themeclass; + } + + public void setSerial(String serial) { + this.serial = serial; + } + public String getSerial() { + return serial; + } + + public void setLgnum(int lgnum) { + this.lgnum = lgnum; + } + public int getLgnum() { + return lgnum; + } + + public String getNfc() { + return nfc; + } + + public void setNfc(String nfc) { + this.nfc = nfc; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/UserDetail.java b/app/src/main/java/com/sipai/jspatrol/Bean/UserDetail.java new file mode 100644 index 0000000..15bcc87 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/UserDetail.java @@ -0,0 +1,47 @@ +package com.sipai.jspatrol.Bean; + +/** + * created by lvliming on 2020/3/23 + */ +public class UserDetail { + private String id; + private String icon; + private String userid; + private String insdt; + private String insuser; + public void setId(String id) { + this.id = id; + } + public String getId() { + return id; + } + + public void setIcon(String icon) { + this.icon = icon; + } + public String getIcon() { + return icon; + } + + public void setUserid(String userid) { + this.userid = userid; + } + public String getUserid() { + return userid; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + public String getInsdt() { + return insdt; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + public String getInsuser() { + return insuser; + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Bean/WaterQualityList.java b/app/src/main/java/com/sipai/jspatrol/Bean/WaterQualityList.java new file mode 100644 index 0000000..d02bbaf --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Bean/WaterQualityList.java @@ -0,0 +1,275 @@ +package com.sipai.jspatrol.Bean; + +public class WaterQualityList { + private String id; + private String scadacode; + private String name; + private String picid; + private String posx; + private String posy; + private String mpid; + private String insuser; + private String cvalue; + private String insdt; + private String unit; + private String cvaluetime; + private String opccode; + private String opcserverid; + private String dataserverid; + private String _icon; + private String ownerid; + private String txt; + private String fsize; + private int accuracy; + private double _cleposx; + private double _cleposy; + private String type; + private String ipsever; + private String port; + private String slaveid; + private String order32; + private String register; + private String value; + private String info; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getIpsever() { + return ipsever; + } + + public void setIpsever(String ipsever) { + this.ipsever = ipsever; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getSlaveid() { + return slaveid; + } + + public void setSlaveid(String slaveid) { + this.slaveid = slaveid; + } + + public String getOrder32() { + return order32; + } + + public void setOrder32(String order32) { + this.order32 = order32; + } + + public String getRegister() { + return register; + } + + public void setRegister(String register) { + this.register = register; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } + + public String getCvaluetime() { + return cvaluetime; + } + + public void setCvaluetime(String cvaluetime) { + this.cvaluetime = cvaluetime; + } + + public String getOpccode() { + return opccode; + } + + public void setOpccode(String opccode) { + this.opccode = opccode; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPicid() { + return picid; + } + + public void setPicid(String picid) { + this.picid = picid; + } + + public String getPosx() { + return posx; + } + + public void setPosx(String posx) { + this.posx = posx; + } + + public String getPosy() { + return posy; + } + + public void setPosy(String posy) { + this.posy = posy; + } + + public String getMpid() { + return mpid; + } + + public void setMpid(String mpid) { + this.mpid = mpid; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getCvalue() { + return cvalue; + } + + public void setCvalue(String cvalue) { + this.cvalue = cvalue; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getScadacode() { + return scadacode; + } + + public void setScadacode(String scadacode) { + this.scadacode = scadacode; + } + + public String getOpcserverid() { + return opcserverid; + } + + public void setOpcserverid(String opcserverid) { + this.opcserverid = opcserverid; + } + + public String getDataserverid() { + return dataserverid; + } + + public void setDataserverid(String dataserverid) { + this.dataserverid = dataserverid; + } + + public String get_icon() { + return _icon; + } + + public void set_icon(String _icon) { + this._icon = _icon; + } + + public String getOwnerid() { + return ownerid; + } + + public void setOwnerid(String ownerid) { + this.ownerid = ownerid; + } + + public String getTxt() { + return txt; + } + + public void setTxt(String txt) { + this.txt = txt; + } + + public String getFsize() { + return fsize; + } + + public void setFsize(String fsize) { + this.fsize = fsize; + } + + public int getAccuracy() { + return accuracy; + } + + public void setAccuracy(int accuracy) { + this.accuracy = accuracy; + } + + public double get_cleposx() { + return _cleposx; + } + + public void set_cleposx(double _cleposx) { + this._cleposx = _cleposx; + } + + public double get_cleposy() { + return _cleposy; + } + + public void set_cleposy(double _cleposy) { + this._cleposy = _cleposy; + } +} + diff --git a/app/src/main/java/com/sipai/jspatrol/Equ/EquCardActivity.java b/app/src/main/java/com/sipai/jspatrol/Equ/EquCardActivity.java new file mode 100644 index 0000000..5b8fc2d --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Equ/EquCardActivity.java @@ -0,0 +1,120 @@ +package com.sipai.jspatrol.Equ; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.ViewPager; + +import com.gigamole.navigationtabstrip.NavigationTabStrip; +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Equ.Equfrgment.EquDetailFragment; +import com.sipai.jspatrol.Equ.Equfrgment.EquDocumentFragment; +import com.sipai.jspatrol.Equ.Equfrgment.EquFaultListFragment; +import com.sipai.jspatrol.Equ.Equfrgment.EquMaintainFragment; +import com.sipai.jspatrol.R; + +import java.util.ArrayList; +import java.util.List; + +public class EquCardActivity extends AppCompatActivity { + private NavigationTabStrip tab; + private String[] tab_title = {"设备详情","维修记录","保养记录","测量点"}; + private ViewPager vp; + private EquList equ; + + public static void actionStart(Context context, EquList equList){ + Intent intent = new Intent(context, EquCardActivity.class); + intent.putExtra("equ",equList); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_equ_card); + init(); + initView(); + } + + private void init() { + if (getIntent().getSerializableExtra("equ")!=null){ + equ = (EquList) getIntent().getSerializableExtra("equ"); + } + } + + private void initView() { + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("设备详情"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + tab = findViewById(R.id.moudle_equ_detail_tab); + tab.setTitles(tab_title); + tab.setTabIndex(0); + tab.setOnTabStripSelectedIndexListener(new NavigationTabStrip.OnTabStripSelectedIndexListener() { + @Override + public void onStartTabSelected(String title, int index) { + vp.setCurrentItem(index); + } + + @Override + public void onEndTabSelected(String title, int index) { + + } + }); + vp = findViewById(R.id.moudle_equ_detail_vp); + final List list = new ArrayList<>(); + list.add(new EquDetailFragment()); + list.add(new EquFaultListFragment()); + list.add(new EquMaintainFragment()); + list.add(new EquDocumentFragment()); + vp.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) { + + @NonNull + @Override + public Fragment getItem(int position) { + return list.get(position); + } + + @Override + public int getCount() { + return list.size(); + } + + + }); + vp.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + tab.setTabIndex(position); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + } + + public EquList getEquList(){ + return equ; + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Equ/EquDetailActivity.java b/app/src/main/java/com/sipai/jspatrol/Equ/EquDetailActivity.java new file mode 100644 index 0000000..861e45f --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Equ/EquDetailActivity.java @@ -0,0 +1,153 @@ +package com.sipai.jspatrol.Equ; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.ProMonitoring.MeasurePointsAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.SharedPreferencesData; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class EquDetailActivity extends AppCompatActivity { + private SharedPreferencesData sharedpre; + private HashMap map_base = new HashMap<>(); + private String mServer; + private TextView tv_name,tv_areaid,tv_equcardid,tv_equtype,tv_ps,tv_equmf,tv_company; + private EquList equ; + private RecyclerView rc_view; + private LinearLayoutManager manager; + private MeasurePointsAdapter pointsAdapter; + private List measuringpoints = new ArrayList<>(); + + public static void actionStart(Context context, EquList equList){ + Intent intent = new Intent(context, EquDetailActivity.class); + intent.putExtra("equ",equList); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_equ_detail); + init(); + initView(); + getEquPoints(); + } + + private void getEquPoints() { + HashMap map = new HashMap<>(); + map.put("equipmentId",equ.getId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEquPoints_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + measuringpoints = parseMeasuringPoints(res); + if (measuringpoints.size()>0){ + updatePoints(); + } + } + }); + } + + private void updatePoints() { + if (!EquDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + pointsAdapter = new MeasurePointsAdapter(EquDetailActivity.this,measuringpoints); + rc_view.setAdapter(pointsAdapter); + } + }); + } + } + + private List parseMeasuringPoints(String res) { + List points = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray arrayPoint = jsonObject.getJSONArray("mPoint4APP"); + for (int a=0;a edts; + private EquList sel_equ; + private ProcessSection sel_ps; + private static final int ASSETCLASS = 101; + private static final int EQUTYPENUM = 102; + private static final int EQUCLASS = 103; + private static final int EQUSPECIFICATION = 104; + private static final int EQULEVEL = 105; + private static final int PERTAINTOEQU = 106; + private static final int SELPS = 8;//选择工艺段 + + public static void actionStart(Context context){ + Intent intent = new Intent(context, EquInsertActivity.class); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_equ_insert); + init(); + initView(); + } + + private void initView() { + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("新增设备"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + edts = new ArrayList<>(); + tv_company = findViewById(R.id.moudle_equ_insert_tv_company); + tv_company.setText(mBizName); + tv_processSection = findViewById(R.id.moudle_equ_insert_tv_processsection); + tv_processSection.setOnClickListener(this); + edt_equno = findViewById(R.id.moudle_equ_insert_edt_equno); + edt_equname = findViewById(R.id.moudle_equ_insert_edt_equname); + tv_asset = findViewById(R.id.moudle_equ_insert_tv_asset); + tv_asset.setOnClickListener(this); + tv_equtypenum = findViewById(R.id.moudle_equ_insert_tv_equtypenum); + tv_equtypenum.setOnClickListener(this); + tv_equclass = findViewById(R.id.moudle_equ_insert_tv_equclass); + tv_equclass.setOnClickListener(this); + tv_equspecification = findViewById(R.id.moudle_equ_insert_tv_equspecification); + tv_equspecification.setOnClickListener(this); + tv_equlevel = findViewById(R.id.moudle_equ_insert_tv_equlevel); + tv_equlevel.setOnClickListener(this); + tv_pertain_to_equ = findViewById(R.id.moudle_equ_insert_tv_pertain_to_equ); + tv_pertain_to_equ.setOnClickListener(this); + edt_assetnumber = findViewById(R.id.moudle_equ_insert_edt_assetnumber); + edt_assetvalue = findViewById(R.id.moudle_equ_insert_edt_assetvalue); + edt_ratedpower = findViewById(R.id.moudle_equ_insert_edt_ratedpower); + edt_pro_charge = findViewById(R.id.moudle_equ_insert_edt_pro_charge); + edt_cost_of_labor = findViewById(R.id.moudle_equ_insert_edt_cost_of_labor); + edt_residual_rate = findViewById(R.id.moudle_equ_insert_edt_residual_rate); + edt_installation_date = findViewById(R.id.moudle_equ_insert_edt_installation_date); + btn_save = findViewById(R.id.moudle_equ_insert_btn_save); + btn_save.setOnClickListener(this); + sp_status = findViewById(R.id.moudle_equ_insert_sp_status); + edts.add(edt_equno); + edts.add(edt_equname); + final String[] status = getResources().getStringArray(R.array.equ_status); + ArrayAdapter arrayAdapter = new ArrayAdapter(this, R.layout.item_normal_little_spin, R.id.moudle_normal_little_spin_tv_title,status); + sp_status.setAdapter(arrayAdapter); + sp_status.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + st_status = String.valueOf(position); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode){ + case ASSETCLASS: + if (resultCode==RESULT_OK){ + InfoSel item = (InfoSel) data.getSerializableExtra("sel"); + st_asset = item.getId(); + UpdateTv(tv_asset,item.getText()); + } + break; + case EQUTYPENUM: + if (resultCode==RESULT_OK){ + InfoSel item = (InfoSel) data.getSerializableExtra("sel"); + st_equtypenum = item.getId(); + UpdateTv(tv_equtypenum,item.getText()); + } + break; + case EQUCLASS: + if (resultCode==RESULT_OK){ + InfoSel item = (InfoSel) data.getSerializableExtra("sel"); + st_equclass = item.getId(); + UpdateTv(tv_equclass,item.getText()); + } + break; + case EQUSPECIFICATION: + if (resultCode==RESULT_OK){ + InfoSel item = (InfoSel) data.getSerializableExtra("sel"); + st_equspecification = item.getId(); + UpdateTv(tv_equspecification,item.getText()); + } + break; + case EQULEVEL: + if (resultCode==RESULT_OK){ + InfoSel item = (InfoSel) data.getSerializableExtra("sel"); + st_equlevel = item.getId(); + UpdateTv(tv_equlevel,item.getText()); + } + break; + case PERTAINTOEQU: + if (resultCode==RESULT_OK){ + EquList sel_equ = (EquList) data.getSerializableExtra("sel"); + st_pertain_to_equ = sel_equ.getId(); + UpdateTv(tv_pertain_to_equ,sel_equ.getEquipmentname()); + } + break; + case SELPS: + if (resultCode == RESULT_OK) { + sel_ps = (ProcessSection) data.getSerializableExtra("ps"); + UpdateTv(tv_processSection, sel_ps.getName()); + pSectionId = sel_ps.getSid(); + } + break; + } + } + + private void UpdateTv(final TextView tv, final String text) { + runOnUiThread(new Runnable() { + @Override + public void run() { + tv.setText(text); + } + }); + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_equ_insert_tv_asset: + Intent intent = new Intent(EquInsertActivity.this, SelActivity.class); + intent.putExtra("type","assetclass"); + startActivityForResult(intent,ASSETCLASS); + break; + case R.id.moudle_equ_insert_tv_equtypenum: + Intent intent_equtypenum = new Intent(EquInsertActivity.this, SelActivity.class); + intent_equtypenum.putExtra("type","equtypenum"); + startActivityForResult(intent_equtypenum,EQUTYPENUM); + break; + case R.id.moudle_equ_insert_tv_equclass: + Intent intent_equclass = new Intent(EquInsertActivity.this, SelActivity.class); + intent_equclass.putExtra("type","equclass"); + startActivityForResult(intent_equclass,EQUCLASS); + break; + case R.id.moudle_equ_insert_tv_equspecification: + Intent intent_equspecification = new Intent(EquInsertActivity.this, SelActivity.class); + intent_equspecification.putExtra("type","equspecification"); + startActivityForResult(intent_equspecification,EQUSPECIFICATION); + break; + case R.id.moudle_equ_insert_tv_equlevel: + Intent intent_equlevel = new Intent(EquInsertActivity.this, SelActivity.class); + intent_equlevel.putExtra("type","equlevel"); + startActivityForResult(intent_equlevel,EQULEVEL); + break; + case R.id.moudle_equ_insert_tv_pertain_to_equ: + Intent intent_pertain = new Intent(EquInsertActivity.this, PertainToEquSelActivity.class); + intent_pertain.putExtra("psectionId",pSectionId); + startActivityForResult(intent_pertain,PERTAINTOEQU); + break; + case R.id.moudle_equ_insert_tv_processsection: + Intent intent_sel_ps = new Intent(EquInsertActivity.this, SingleChoiceActivity.class); + intent_sel_ps.putExtra("mark","ps"); + startActivityForResult(intent_sel_ps,SELPS); + break; + case R.id.moudle_equ_insert_btn_save: + if (!isEdtEmpty()) { + isRepeated(); +// subEquInfo(); + } + break; + } + } + + private void isRepeated() { + PersistentCookieStore myCookieStore = new PersistentCookieStore(this); + RequestParams params = new RequestParams(); + params.put("equipmentcardid",edt_equno.getText().toString()); + AsyncHttpClient client = new AsyncHttpClient(); + client.setCookieStore(myCookieStore); + client.post(mServer + "equipment/checkExist.do?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + super.onSuccess(response); + try { + JSONObject jsonObject = new JSONObject(response); + if (jsonObject.optBoolean("valid")){ + subEquInfo(); + }else { + idRepeated(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFailure(Throwable error) { + super.onFailure(error); + String a = error.toString(); + if(!EquInsertActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(EquInsertActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("连接失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + isRepeated(); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + @Override + public void onFinish() { + super.onFinish(); + } + + }); + } + + private void idRepeated() { + if (!EquInsertActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(EquInsertActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("设备编号重复,请修改后提交") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private boolean isEdtEmpty() { + for (int i=0;i equLists = new ArrayList<>(); + private EquSingleChoiceAdapter equAdapter; + private LinearLayoutManager manager; + private ImageView civ; + private ImageView iv_add; + private NfcAdapter nfcAdapter; + // 是否支持NFC功能的标签 + private boolean isNFC_support = false; + private PendingIntent pendingIntent; + private IntentFilter[] mFilters; + private String[][] mTechLists; + private static final int REQUEST_CODE_SCAN = 23; + + public static void actionStart(Context context){ + Intent intent = new Intent(context, EquSearchActivity.class); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_equ_search); + init(); + initView(); + checkNFC(); + startSearch(); + } + + private void checkNFC() { + // 获取nfc适配器,判断设备是否支持NFC功能 + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + if (nfcAdapter == null) { + Toast.makeText(this, getResources().getString(R.string.no_nfc), + Toast.LENGTH_SHORT).show(); + } else if (!nfcAdapter.isEnabled()) { + Toast.makeText(this, getResources().getString(R.string.open_nfc), + Toast.LENGTH_SHORT).show(); + } + pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, + getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); + ndef.addCategory("*/*"); + mFilters = new IntentFilter[]{ndef};// 过滤器 + mTechLists = new String[][]{ + new String[]{MifareClassic.class.getName()}, + new String[]{NfcA.class.getName()}};// 允许扫描的标签类型 + } + + @Override + protected void onResume() { + super.onResume(); + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + isNFC_support = !(nfcAdapter == null || !nfcAdapter.isEnabled()); + if (isNFC_support) { + nfcAdapter.enableForegroundDispatch(this, pendingIntent, mFilters, + mTechLists); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) { + // 注意这个if中的代码几乎不会进来,因为刚刚在上一行代码开启了监听NFC连接,下一行代码马上就收到了NFC连接的intent,这种几率很小 + // 处理该intent + String result = processIntent(getIntent()); + searchSingleEqu(result); + } + } + } + + private void initView() { + civ = findViewById(R.id.moudle_equ_search_civ); + civ.setOnClickListener(this); + iv_back = findViewById(R.id.moudle_equ_search_iv_back); + iv_back.setOnClickListener(this); + edt_name = findViewById(R.id.moudle_equ_search_edt_equname); + tv_search = findViewById(R.id.moudle_equ_search_tv_search); + tv_search.setOnClickListener(this); + rc_list = findViewById(R.id.moudle_equ_search_rc); + refreshLayout = findViewById(R.id.moudle_equ_search_refresh); + refreshLayout.setColorSchemeResources(R.color.blue); + refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + startSearch(); + } + }); + } + + private void init() { + SharedPreferences sharedPre = this.getSharedPreferences("config", 0); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + mBizName = sharedPre.getString("bizname", ""); + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_equ_search_iv_back: + finish(); + break; + case R.id.moudle_equ_search_tv_search: + startSearch(); + break; + case R.id.moudle_equ_search_civ: + Intent intent = new Intent(EquSearchActivity.this, CaptureActivity.class); + /*ZxingConfig是配置类 + *可以设置是否显示底部布局,闪光灯,相册, + * 是否播放提示音 震动 + * 设置扫描框颜色等 + * 也可以不传这个参数 + * */ + ZxingConfig config = new ZxingConfig(); + config.setPlayBeep(true);//是否播放扫描声音 默认为true + config.setShake(true);//是否震动 默认为true + config.setDecodeBarCode(true);//是否扫描条形码 默认为true + config.setFullScreenScan(false);//是否全屏扫描 默认为true 设为false则只会在扫描框中扫描 + intent.putExtra(Constant.INTENT_ZXING_CONFIG, config); + startActivityForResult(intent, REQUEST_CODE_SCAN); + break; + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + // 扫描二维码/条码回传 + if (requestCode == REQUEST_CODE_SCAN && resultCode == RESULT_OK) { + if (data != null) { + String content = data.getStringExtra(Constant.CODED_CONTENT); + searchSingleEqu(content); + } + } + } + + /** + * 获取tab标签中的内容 + * + * @param intent + * @return + */ + @SuppressLint("NewApi") + private String processIntent(Intent intent) { + Parcelable[] rawmsgs = intent + .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); + if (rawmsgs != null) { + NdefMessage msg = (NdefMessage) rawmsgs[0]; + NdefRecord[] records = msg.getRecords(); + String resultStr = new String(records[0].getPayload()); + return resultStr; + } else { + return "error"; + } + } + + @Override + protected void onPause() { + super.onPause(); + if (nfcAdapter != null && nfcAdapter.isEnabled()) { + // 当前Activity如果不在手机的最前端,就停止NFC设备连接的监听 + stopNFC_Listener(); + } + } + + private void stopNFC_Listener() { + // 停止监听NFC设备是否连接 + nfcAdapter.disableForegroundDispatch(this); + } + + @Override + protected void onNewIntent(Intent intent) { + // TODO Auto-generated method stub + // 当前app正在前端界面运行,这个时候有intent发送过来,那么系统就会调用onNewIntent回调方法,将intent传送过来 + // 我们只需要在这里检验这个intent是否是NFC相关的intent,如果是,就调用处理方法 + super.onNewIntent(intent); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { + String result = processIntent(intent); + searchSingleEqu(result); + } + } + + private void startSearch() { + if (edt_name.getText()!=null&&!edt_name.getText().toString().isEmpty()){ + name = edt_name.getText().toString(); + } + judgeRefresh(); + searchEqu(name); + } + + private void judgeRefresh() { + if (!EquSearchActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!refreshLayout.isRefreshing()){ + refreshLayout.setRefreshing(true); + } + } + }); + } + } + + /** + * 搜索设备 + * @param name + */ + private void searchEqu(String name) { + HashMap map = new HashMap<>(); + map.put("companyId",mBizid); + map.put("search_name",name); + map.put("processSectionId",sel_ps_id); + map.put("rows","50"); + map.put("page","1"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEQULISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!EquSearchActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + Toast.makeText(EquSearchActivity.this, "失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("total")&&res.contains("rows")) { + equLists = parseEqu(res); + } + updateEquList(); + } + }); + } + + + /** + * 搜索单个设备 + * @param id + */ + private void searchSingleEqu(String id) { + HashMap map = new HashMap<>(); + map.put("id",id); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETSINGLEEQU_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!EquSearchActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + Toast.makeText(EquSearchActivity.this, "失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("total")&&res.contains("rows")) { + equLists = parseEqu(res); + if (equLists.size()>0){ + EquCardActivity.actionStart(EquSearchActivity.this,equLists.get(0)); +// EquDetailActivity.actionStart(EquSearchActivity.this,equLists.get(0)); + }else { + showToast("未搜到该设备!"); + } + } + } + }); + } + + private void showToast(String s) { + if (!EquSearchActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(EquSearchActivity.this, s, Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void updateEquList() { + if (!EquSearchActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + equAdapter = new EquSingleChoiceAdapter(EquSearchActivity.this, equLists, new EquSingleChoiceAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + EquCardActivity.actionStart(EquSearchActivity.this,equLists.get(position)); +// EquDetailActivity.actionStart(EquSearchActivity.this,equLists.get(position)); + } + }); + rc_list.setAdapter(equAdapter); + manager = new LinearLayoutManager(EquSearchActivity.this); + rc_list.setLayoutManager(manager); + } + }); + } + } + + private List parseEqu(String res) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = jsonObject.getJSONArray("rows"); + for (int i=0;i points = new ArrayList<>(); + for (int a=0;a map_base = new HashMap<>(); + private String mServer; + private TextView tv_name,tv_areaid,tv_equcardid,tv_equtype,tv_ps,tv_equmf,tv_company,tv_abc,tv_type,tv_assetnumber,tv_equstatus; + private EquList equ; + private RecyclerView rc_view; + private LinearLayoutManager manager; + private MeasurePointsAdapter pointsAdapter; + private List measuringpoints = new ArrayList<>(); + private String mBizid; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_equ_detail,container,false); + init(); + initView(view); +// getEquPoints(); + return view; + } + + private void init() { + EquCardActivity equcard = (EquCardActivity) getActivity(); + equ = equcard.getEquList(); + sharedpre = new SharedPreferencesData(getActivity()); + map_base = sharedpre.getAll(); + mServer = map_base.get("mServer"); + SharedPreferences sharedPre = getActivity().getSharedPreferences("config", 0); + mBizid = sharedPre.getString("bizid", ""); + } + + private void initView(View view) { + tv_name = view.findViewById(R.id.moudle_equ_detail_tv_equipmentname); + tv_name.setText(equ.getEquipmentname()); + tv_equstatus = view.findViewById(R.id.moudle_equ_detail_tv_equstatus); + tv_equstatus.setText(equ.getEquipmentStatusManagement()); + tv_areaid = view.findViewById(R.id.moudle_equ_detail_tv_areaid); + tv_areaid.setText(equ.getAreaid()); + tv_abc = view.findViewById(R.id.moudle_equ_detail_tv_abc); + tv_abc.setText(equ.getEquipmentLevel()); + tv_assetnumber = view.findViewById(R.id.moudle_equ_detail_tv_assetnumber); + tv_assetnumber.setText(equ.getAssetnumber()); + tv_equcardid = view.findViewById(R.id.moudle_equ_detail_tv_equipmentcardid); + tv_equcardid.setText(equ.getEquipmentcardid()); + tv_equtype = view.findViewById(R.id.moudle_equ_detail_tv_equtype); + tv_equtype.setText(equ.getEquipmentTypeNumber()); + tv_ps = view.findViewById(R.id.moudle_equ_detail_tv_ps); + tv_ps.setText(equ.getProcessSection()); + tv_equmf = view.findViewById(R.id.moudle_equ_detail_tv_equmf); + tv_equmf.setText(equ.getEquipmentmanufacturer()); + tv_company = view.findViewById(R.id.moudle_equ_detail_tv_company); + tv_company.setText(equ.getCompany()); + tv_type = view.findViewById(R.id.moudle_equ_detail_tv_type); + tv_type.setText(equ.getEquipmentClass()); + rc_view = view.findViewById(R.id.moudle_equ_detail_rc_point); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + } + + private void getEquPoints() { + HashMap map = new HashMap<>(); + map.put("equipmentId",equ.getId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEquPoints_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + measuringpoints = parseMeasuringPoints(res); + if (measuringpoints.size()>0){ + updatePoints(); + } + } + }); + } + + private void updatePoints() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + pointsAdapter = new MeasurePointsAdapter(getActivity(),measuringpoints); + rc_view.setAdapter(pointsAdapter); + } + }); + } + } + + private List parseMeasuringPoints(String res) { + List points = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray arrayPoint = jsonObject.getJSONArray("mPoint4APP"); + for (int a=0;a map_base = new HashMap<>(); + private String mServer; + private EquList equ; + private String mBizid; + private int page = 1; + private EmptyLayout emptyLayout; + private SwipeRefreshLayout refresh; + private RecyclerView rc_view; + private LinearLayoutManager manager; + private MeasurePointsAdapter pointsAdapter; + private List measuringpoints = new ArrayList<>(); + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_equ_document,container,false); + init(); + initView(view); +// getDocuments(); + return view; + } + + private void init() { + EquCardActivity equcard = (EquCardActivity) getActivity(); + equ = equcard.getEquList(); + sharedpre = new SharedPreferencesData(getActivity()); + map_base = sharedpre.getAll(); + mServer = map_base.get("mServer"); + SharedPreferences sharedPre = getActivity().getSharedPreferences("config", 0); + mBizid = sharedPre.getString("bizid", ""); + } + + @Override + public void onResume() { + super.onResume(); + getEquPoints(); +// getDocuments(); + } + + private void initView(View view) { + emptyLayout = view.findViewById(R.id.moudle_equ_doc_ui_empty); + rc_view = view.findViewById(R.id.moudle_equ_doc_rc_point); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + refresh = view.findViewById(R.id.moudle_equ_doc_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getEquPoints(); + } + }); + } + + + private void getEquPoints() { + HashMap map = new HashMap<>(); + map.put("equipmentId",equ.getId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEquPoints_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + measuringpoints = parseMeasuringPoints(res); + if (measuringpoints.size()>0){ + updatePoints(); + }else { + showEmpty(); + } + } + }); + } + + private void showEmpty() { + if (isAdded()) { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + rc_view.setVisibility(View.GONE); + emptyLayout.setVisibility(View.VISIBLE); + } + }); + } + } + } + + private void updatePoints() { + if (isAdded()) { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + rc_view.setVisibility(View.VISIBLE); + emptyLayout.setVisibility(View.GONE); + pointsAdapter = new MeasurePointsAdapter(getActivity(), measuringpoints); + rc_view.setAdapter(pointsAdapter); + } + }); + } + } + } + + private List parseMeasuringPoints(String res) { + List points = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray arrayPoint = jsonObject.getJSONArray("mPoint4APP"); + for (int a=0;a map_base = new HashMap<>(); + private String mServer; + private String mBizid; + private EquList equ; + private EditText tvstartdate,tvenddate; + private int year,month,day,hour,minute,lastday,lastmonth; + private int page = 1; + private List faults = new ArrayList<>(); + private DoneFaultAdapter doneFaultAdapter; + private LinearLayoutManager manager; + private SuperRecyclerView rc_view; + private SwipeRefreshLayout refresh; + private EmptyLayout emptyLayout; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + init(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_equ_fault_list,container,false); + initView(view); + getFaultList(); + return view; + } + + private void initView(View view) { + tvstartdate=(EditText)view.findViewById(R.id.moudle_equ_fault_list_edt_sd); + tvstartdate.setCursorVisible(false); + tvstartdate.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //创建DatePickerDialog对象 + if (event.getAction() == MotionEvent.ACTION_DOWN) { + MyDatePickerDialog dpd = new MyDatePickerDialog(getActivity(), Datelistener, year, month, day); + dpd.show();//显示DatePickerDialog组件 + } + return false; + } + }); + tvenddate=(EditText)view.findViewById(R.id.moudle_equ_fault_list_edt_ed); + tvenddate.setCursorVisible(false); + tvenddate.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //创建DatePickerDialog对象 + if (event.getAction() == MotionEvent.ACTION_DOWN) { + MyDatePickerDialog dpd = new MyDatePickerDialog(getActivity(), Datelistener, year, month, day); + dpd.show();//显示DatePickerDialog组件 + } + return false; + } + }); + if (day==1){ + if (month!=0) { + Calendar calendar = Calendar.getInstance(Locale.CHINA); + calendar.set(Calendar.MONTH, month - 1); + int tday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year + "-" + (month) + "-" + lastday + " " + hour + ":" + minute)); + }else{ + Calendar calendar = Calendar.getInstance(Locale.CHINA); + calendar.set(Calendar.MONTH, 11); + int tday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + tvstartdate.setText(DateFormatUtils.DateFormatMinString((year-1) + "-" + 12 + "-" + lastday + " " + hour + ":" + minute)); + } + }else { + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year + "-" + (lastmonth + 1) + "-" + lastday + " " + hour + ":" + minute)); + } + tvenddate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + rc_view = view.findViewById(R.id.moudle_equ_fault_list_rc); + emptyLayout = view.findViewById(R.id.moudle_equ_fault_list_ui_empty); + refresh = view.findViewById(R.id.moudle_equ_fault_list_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + page = 1; + getFaultList(); + } + }); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + rc_view.setRefreshEnabled(false); + rc_view.setLoadMoreEnabled(true); + rc_view.setLoadingListener(new SuperRecyclerView.LoadingListener() { + @Override + public void onRefresh() { + + } + + @Override + public void onLoadMore() { + page = page+1; + getFaultList(); + } + }); +// rc_view.addItemDecoration(SuperDivider.newBitmapDivider()); + } + + + private void init() { + EquCardActivity equcard = (EquCardActivity) getActivity(); + equ = equcard.getEquList(); + sharedpre = new SharedPreferencesData(getActivity()); + map_base = sharedpre.getAll(); + mServer = map_base.get("mServer"); + SharedPreferences sharedPre = getActivity().getSharedPreferences("config", 0); + mBizid = sharedPre.getString("bizid", ""); + //初始化Calendar日历对象 + Calendar mycalendar=Calendar.getInstance(Locale.CHINA); + Date mydate=new Date(); //获取当前日期Date对象 + mycalendar.setTime(mydate);////为Calendar对象设置时间为当前日期 + year=mycalendar.get(Calendar.YEAR); //获取Calendar对象中的年 + month=mycalendar.get(Calendar.MONTH);//获取Calendar对象中的月 + day=mycalendar.get(Calendar.DAY_OF_MONTH);//获取这个月的第几天 + lastday=getBeforeDay(mycalendar).get(Calendar.DAY_OF_MONTH); + lastmonth=getBeforeDay(mycalendar).get(Calendar.MONTH); + hour=mycalendar.get(Calendar.HOUR_OF_DAY);//获取这个月的第几天 + minute=mycalendar.get(Calendar.MINUTE);//获取这个月的第几天 + } + + private void getFaultList() { + isShowRefresh(); + HashMap map = new HashMap<>(); + map.put("type", GlobalVal.Fault_Type); + map.put("rows","20"); + map.put("page",String.valueOf(page)); + map.put("search_code",mBizid); + map.put("processSectionId",equ.getProcesssectionid()); + map.put("equipmentId",equ.getId()); + map.put("status", GlobalVal.Fault_Status_Finish); + map.put("beginTimeStore",tvstartdate.getText().toString()); + map.put("endTimeStore",tvenddate.getText().toString()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEquFaults_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + showError(a); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (page==1) { + faults = parseFault(res); + ifShowTheEmpty(); + setAdapter(); + }else { + List list = parseFault(res); + if (list.size()>0) { + faults.addAll(list); + updateLoadMore(); + }else { + noMore(); + } + } + } + }); + } + + private void isShowRefresh() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (page==1) { + if (!refresh.isRefreshing()) { + refresh.setRefreshing(true); + } + } + } + }); + } + } + + private void showError(String a) { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + Toast.makeText(getActivity(), ""+a, Toast.LENGTH_SHORT).show(); + } + }); + } + } + + /* +是否显示暂无数据布局 + */ + private void ifShowTheEmpty() { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (faults.size() == 0) { + emptyLayout.setVisibility(View.VISIBLE); + rc_view.setVisibility(View.GONE); + } else { + emptyLayout.setVisibility(View.GONE); + rc_view.setVisibility(View.VISIBLE); + } + } + }); + } + } + + private void updateLoadMore() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + rc_view.completeLoadMore(); + doneFaultAdapter.notifyDataSetChanged(); + } + }); + } + } + + private void noMore() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(getActivity(), "这次是真没有了~", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private List parseFault(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray dones = new JSONArray(jsonObject.getString("content1")); + for (int i=0;i0) { + JSONObject area = new JSONObject(dones.getJSONObject(i).opt("processSection").toString()); + ProcessSection proc = new ProcessSection(); + proc.setSid(area.optString("id")); + proc.setName(area.optString("name")); + done_fault.setProcessSection(proc); + }else { + ProcessSection proc = new ProcessSection(); + proc.setSid(""); + proc.setName(""); + done_fault.setProcessSection(proc); + } + done_fault.setProblemTypeNames(dones.getJSONObject(i).opt("problemTypeNames").toString()); + done_fault.setProblemcontent(dones.getJSONObject(i).opt("problemcontent").toString()); + done_fault.setPlanMoney(dones.getJSONObject(i).opt("planMoney").toString()); + if (dones.getJSONObject(i).opt("equipmentCard")!=null&&dones.getJSONObject(i).opt("equipmentCard").toString().length()>0&&!dones.getJSONObject(i).opt("equipmentCard").toString().equals("null")) { + EquList card = new EquList(); + JSONObject equ = new JSONObject(dones.getJSONObject(i).opt("equipmentCard").toString()); + card.setEquipmentname(equ.opt("equipmentname").toString()); + card.setEquipmentcardid(equ.opt("equipmentcardid").toString()); + done_fault.setEquipmentCard(card); + }else { + EquList card = new EquList(); + card.setEquipmentname(""); + card.setEquipmentcardid(""); + done_fault.setEquipmentCard(card); + } + if (dones.getJSONObject(i).opt("insertUser")!=null&&!dones.getJSONObject(i).optString("insertUser").equals("null")&&dones.getJSONObject(i).optString("insertUser").length()>0) { + JSONObject capt = new JSONObject(dones.getJSONObject(i).optString("insertUser")); + done_fault.setInsuser(capt.optString("caption")); + }else { + done_fault.setInsuser(""); + } + done_fault.setTodoTask("任务完成"); + done_fault.setInsdt(dones.getJSONObject(i).optString("insdt")); + done_fault.setEquipmentOpinion(dones.getJSONObject(i).optString("equipmentOpinion")); + done_fault.setPlanMoney(dones.getJSONObject(i).optString("planMoney")); + done_fault.setPlannedenddt(dones.getJSONObject(i).optString("plannedenddt")); + done_fault.setMaterialOpinion(dones.getJSONObject(i).optString("materialOpinion")); + done_fault.setQualityOpinion(dones.getJSONObject(i).optString("qualityOpinion")); + list.add(done_fault); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } + + private void setAdapter() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + doneFaultAdapter = new DoneFaultAdapter(getActivity(),faults); + rc_view.setAdapter(doneFaultAdapter); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + } + }); + } + } + + public class MyDatePickerDialog extends DatePickerDialog { + + public MyDatePickerDialog(Context context, OnDateSetListener callBack, + int year, int month, int day) { + super(context, callBack, year, month, day); + // TODO Auto-generated constructor stub + } + @Override + protected void onStop() { + //super.onStop();//防止onDateSet执行两次 + + } + } + + private DatePickerDialog.OnDateSetListener Datelistener=new DatePickerDialog.OnDateSetListener() { + @Override + public void onDateSet(DatePicker view, int myyear, int monthOfYear, int dayOfMonth) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + year=myyear; + month=monthOfYear; + day=dayOfMonth; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + TimePickerDialog dpd=new TimePickerDialog(getActivity(),Timelistener,hour,minute,true); + dpd.show();//显示DatePickerDialog组件 + } + }; + + private TimePickerDialog.OnTimeSetListener Timelistener=new TimePickerDialog.OnTimeSetListener() { + @Override + public void onTimeSet(TimePicker view, int hours, int minutes) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + hour=hours; + minute=minutes; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + if(tvstartdate.isFocused()){ + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + }else if(tvenddate.isFocused()){ + tvenddate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + } + getFaultList(); + } + }; + + /** + * 获取当前时间的前一周 + * @param cl + * @return + */ + private static Calendar getBeforeDay(Calendar cl){ + //使用roll方法进行向前回滚 + //cl.roll(Calendar.DATE, -1); + //使用set方法直接进行设置 + int day = cl.get(Calendar.DATE); + cl.set(Calendar.DATE, day-7); + return cl; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Equ/Equfrgment/EquMaintainFragment.java b/app/src/main/java/com/sipai/jspatrol/Equ/Equfrgment/EquMaintainFragment.java new file mode 100644 index 0000000..c5a98b2 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Equ/Equfrgment/EquMaintainFragment.java @@ -0,0 +1,431 @@ +package com.sipai.jspatrol.Equ.Equfrgment; + +import android.app.DatePickerDialog; +import android.app.TimePickerDialog; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.TimePicker; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.Bean.ProcessSection; +import com.sipai.jspatrol.Equ.EquCardActivity; +import com.sipai.jspatrol.Fault.adapter.DoneFaultAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.DateFormatUtils; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.SharedPreferencesData; +import com.sipai.ui.EmptyLayout; +import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView; +import com.superrecycleview.superlibrary.utils.SuperDivider; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +/** + * created by lvliming on 2020/10/22 + */ +public class EquMaintainFragment extends Fragment { + private SharedPreferencesData sharedpre; + private HashMap map_base = new HashMap<>(); + private String mServer; + private EquList equ; + private String mBizid; + private EditText tvstartdate,tvenddate; + private int year,month,day,hour,minute,lastday,lastmonth; + private int page = 1; + private List faults = new ArrayList<>(); + private DoneFaultAdapter doneFaultAdapter; + private LinearLayoutManager manager; + private SuperRecyclerView rc_view; + private SwipeRefreshLayout refresh; + private EmptyLayout emptyLayout; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + init(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_equ_maintain,container,false); + initView(view); + getMaintainList(); + return view; + } + + private void initView(View view) { + tvstartdate=(EditText)view.findViewById(R.id.moudle_equ_maintains_edt_sd); + tvstartdate.setCursorVisible(false); + tvstartdate.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //创建DatePickerDialog对象 + if (event.getAction() == MotionEvent.ACTION_DOWN) { + MyDatePickerDialog dpd = new MyDatePickerDialog(getActivity(), Datelistener, year, month, day); + dpd.show();//显示DatePickerDialog组件 + } + return false; + } + }); + tvenddate=(EditText)view.findViewById(R.id.moudle_equ_maintains_edt_ed); + tvenddate.setCursorVisible(false); + tvenddate.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //创建DatePickerDialog对象 + if (event.getAction() == MotionEvent.ACTION_DOWN) { + MyDatePickerDialog dpd = new MyDatePickerDialog(getActivity(), Datelistener, year, month, day); + dpd.show();//显示DatePickerDialog组件 + } + return false; + } + }); + if (day==1){ + if (month!=0) { + Calendar calendar = Calendar.getInstance(Locale.CHINA); + calendar.set(Calendar.MONTH, month - 1); + int tday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year + "-" + (month) + "-" + lastday + " " + hour + ":" + minute)); + }else{ + Calendar calendar = Calendar.getInstance(Locale.CHINA); + calendar.set(Calendar.MONTH, 11); + int tday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + tvstartdate.setText(DateFormatUtils.DateFormatMinString((year-1) + "-" + 12 + "-" + lastday + " " + hour + ":" + minute)); + } + }else { + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year + "-" + (lastmonth + 1) + "-" + lastday + " " + hour + ":" + minute)); + } + tvenddate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + rc_view = view.findViewById(R.id.moudle_equ_maintains_rc); + emptyLayout = view.findViewById(R.id.moudle_equ_maintains_ui_empty); + refresh = view.findViewById(R.id.moudle_equ_maintains_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + page = 1; + getMaintainList(); + } + }); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + rc_view.setRefreshEnabled(false); + rc_view.setLoadMoreEnabled(true); + rc_view.setLoadingListener(new SuperRecyclerView.LoadingListener() { + @Override + public void onRefresh() { + + } + + @Override + public void onLoadMore() { + page = page+1; + getMaintainList(); + } + }); + rc_view.addItemDecoration(SuperDivider.newBitmapDivider()); + } + + + private void init() { + EquCardActivity equcard = (EquCardActivity) getActivity(); + equ = equcard.getEquList(); + sharedpre = new SharedPreferencesData(getActivity()); + map_base = sharedpre.getAll(); + mServer = map_base.get("mServer"); + SharedPreferences sharedPre = getActivity().getSharedPreferences("config", 0); + mBizid = sharedPre.getString("bizid", ""); + //初始化Calendar日历对象 + Calendar mycalendar=Calendar.getInstance(Locale.CHINA); + Date mydate=new Date(); //获取当前日期Date对象 + mycalendar.setTime(mydate);////为Calendar对象设置时间为当前日期 + year=mycalendar.get(Calendar.YEAR); //获取Calendar对象中的年 + month=mycalendar.get(Calendar.MONTH);//获取Calendar对象中的月 + day=mycalendar.get(Calendar.DAY_OF_MONTH);//获取这个月的第几天 + lastday=getBeforeDay(mycalendar).get(Calendar.DAY_OF_MONTH); + lastmonth=getBeforeDay(mycalendar).get(Calendar.MONTH); + hour=mycalendar.get(Calendar.HOUR_OF_DAY);//获取这个月的第几天 + minute=mycalendar.get(Calendar.MINUTE);//获取这个月的第几天 + } + + private void getMaintainList() { + isShowRefresh(); + HashMap map = new HashMap<>(); + map.put("type", GlobalVal.Maintain_Type); + map.put("rows","20"); + map.put("page",String.valueOf(page)); + map.put("search_code",mBizid); + map.put("processSectionId",equ.getProcesssectionid()); + map.put("equipmentId",equ.getId()); + map.put("status", GlobalVal.Fault_Status_Finish); + map.put("beginTimeStore",tvstartdate.getText().toString()); + map.put("endTimeStore",tvenddate.getText().toString()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEquMaintains_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + showError(a); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (page==1) { + faults = parseFault(res); + ifShowTheEmpty(); + setAdapter(); + }else { + List list = parseFault(res); + if (list.size()>0) { + faults.addAll(list); + updateLoadMore(); + }else { + noMore(); + } + } + } + }); + } + + private void isShowRefresh() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (page==1) { + if (!refresh.isRefreshing()) { + refresh.setRefreshing(true); + } + } + } + }); + } + } + + private void showError(String a) { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + Toast.makeText(getActivity(), ""+a, Toast.LENGTH_SHORT).show(); + } + }); + } + } + + /* +是否显示暂无数据布局 + */ + private void ifShowTheEmpty() { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (faults.size() == 0) { + emptyLayout.setVisibility(View.VISIBLE); + rc_view.setVisibility(View.GONE); + } else { + emptyLayout.setVisibility(View.GONE); + rc_view.setVisibility(View.VISIBLE); + } + } + }); + } + } + + private void updateLoadMore() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + rc_view.completeLoadMore(); + doneFaultAdapter.notifyDataSetChanged(); + } + }); + } + } + + private void noMore() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(getActivity(), "这次是真没有了~", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private List parseFault(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray dones = new JSONArray(jsonObject.getString("content1")); + for (int i=0;i0) { + JSONObject area = new JSONObject(dones.getJSONObject(i).opt("processSection").toString()); + ProcessSection proc = new ProcessSection(); + proc.setSid(area.optString("id")); + proc.setName(area.optString("name")); + done_fault.setProcessSection(proc); + }else { + ProcessSection proc = new ProcessSection(); + proc.setSid(""); + proc.setName(""); + done_fault.setProcessSection(proc); + } + done_fault.setProblemTypeNames(dones.getJSONObject(i).opt("problemTypeNames").toString()); + done_fault.setProblemcontent(dones.getJSONObject(i).opt("problemcontent").toString()); + done_fault.setPlanMoney(dones.getJSONObject(i).opt("planMoney").toString()); + if (dones.getJSONObject(i).opt("equipmentCard")!=null&&dones.getJSONObject(i).opt("equipmentCard").toString().length()>0&&!dones.getJSONObject(i).opt("equipmentCard").toString().equals("null")) { + EquList card = new EquList(); + JSONObject equ = new JSONObject(dones.getJSONObject(i).opt("equipmentCard").toString()); + card.setEquipmentname(equ.opt("equipmentname").toString()); + card.setEquipmentcardid(equ.opt("equipmentcardid").toString()); + done_fault.setEquipmentCard(card); + }else { + EquList card = new EquList(); + card.setEquipmentname(""); + card.setEquipmentcardid(""); + done_fault.setEquipmentCard(card); + } + if (dones.getJSONObject(i).opt("insertUser")!=null&&!dones.getJSONObject(i).optString("insertUser").equals("null")&&dones.getJSONObject(i).optString("insertUser").length()>0) { + JSONObject capt = new JSONObject(dones.getJSONObject(i).optString("insertUser")); + done_fault.setInsuser(capt.optString("caption")); + }else { + done_fault.setInsuser(""); + } + done_fault.setTodoTask("任务完成"); + done_fault.setInsdt(dones.getJSONObject(i).optString("insdt")); + done_fault.setEquipmentOpinion(dones.getJSONObject(i).optString("equipmentOpinion")); + done_fault.setPlanMoney(dones.getJSONObject(i).optString("planMoney")); + done_fault.setPlannedenddt(dones.getJSONObject(i).optString("plannedenddt")); + done_fault.setMaterialOpinion(dones.getJSONObject(i).optString("materialOpinion")); + done_fault.setQualityOpinion(dones.getJSONObject(i).optString("qualityOpinion")); + list.add(done_fault); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } + + private void setAdapter() { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + doneFaultAdapter = new DoneFaultAdapter(getActivity(),faults); + rc_view.setAdapter(doneFaultAdapter); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + } + }); + } + } + + public class MyDatePickerDialog extends DatePickerDialog { + + public MyDatePickerDialog(Context context, OnDateSetListener callBack, + int year, int month, int day) { + super(context, callBack, year, month, day); + // TODO Auto-generated constructor stub + } + @Override + protected void onStop() { + //super.onStop();//防止onDateSet执行两次 + + } + } + + private DatePickerDialog.OnDateSetListener Datelistener=new DatePickerDialog.OnDateSetListener() { + @Override + public void onDateSet(DatePicker view, int myyear, int monthOfYear, int dayOfMonth) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + year=myyear; + month=monthOfYear; + day=dayOfMonth; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + TimePickerDialog dpd=new TimePickerDialog(getActivity(),Timelistener,hour,minute,true); + dpd.show();//显示DatePickerDialog组件 + } + }; + + private TimePickerDialog.OnTimeSetListener Timelistener=new TimePickerDialog.OnTimeSetListener() { + @Override + public void onTimeSet(TimePicker view, int hours, int minutes) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + hour=hours; + minute=minutes; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + if(tvstartdate.isFocused()){ + tvstartdate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + }else if(tvenddate.isFocused()){ + tvenddate.setText(DateFormatUtils.DateFormatMinString(year+"-"+(month+1)+"-"+day+" "+hour+":"+minute)); + } + getMaintainList(); + } + }; + + /** + * 获取当前时间的前一周 + * @param cl + * @return + */ + private static Calendar getBeforeDay(Calendar cl){ + //使用roll方法进行向前回滚 + //cl.roll(Calendar.DATE, -1); + //使用set方法直接进行设置 + int day = cl.get(Calendar.DATE); + cl.set(Calendar.DATE, day-7); + return cl; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Equ/PertainToEquSelActivity.java b/app/src/main/java/com/sipai/jspatrol/Equ/PertainToEquSelActivity.java new file mode 100644 index 0000000..08b6f0d --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Equ/PertainToEquSelActivity.java @@ -0,0 +1,290 @@ +package com.sipai.jspatrol.Equ; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.loopj.android.http.AsyncHttpClient; +import com.loopj.android.http.AsyncHttpResponseHandler; +import com.loopj.android.http.PersistentCookieStore; +import com.loopj.android.http.RequestParams; +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.R; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class PertainToEquSelActivity extends AppCompatActivity { + private EditText edt_equname; + private Button btn_search; + private RecyclerView rc_view; + private SwipeRefreshLayout refresh; + private LinearLayoutManager manager; + private PertainToEquSelAdapter equAdapter; + private List equs = new ArrayList<>(); + private EquList sel_item; + private String st_pSectionId = ""; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_pertain_to_equ_sel); + init(); + initView(); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("所属设备选择"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + edt_equname = findViewById(R.id.moudle_pertain_to_equ_sel_edt_equname); + btn_search = findViewById(R.id.moudle_pertain_to_equ_sel_btn_search); + rc_view = findViewById(R.id.moudle_pertain_to_equ_sel_rc); + manager = new LinearLayoutManager(PertainToEquSelActivity.this); + rc_view.setLayoutManager(manager); + equAdapter = new PertainToEquSelAdapter(equs, PertainToEquSelActivity.this, new PertainToEquSelAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + sel_item = equs.get(position); + Intent intent = new Intent(); + intent.putExtra("sel",sel_item); + setResult(RESULT_OK,intent); + finish(); + } + }); + rc_view.setAdapter(equAdapter); + refresh = findViewById(R.id.moudle_pertain_to_equ_sel_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getEquList(); + } + }); + } + + private void getEquList() { + showRefresh(); + String getsearch = ""; + if (edt_equname.getText()!=null&&!edt_equname.getText().toString().isEmpty()){ + getsearch = edt_equname.getText().toString(); + } + PersistentCookieStore myCookieStore = new PersistentCookieStore(this); + RequestParams params = new RequestParams(); + params.put("page", "1"); + params.put("rows", "100"); + params.put("companyId",mBizid); + params.put("pSectionId",st_pSectionId); + params.put("search_name", getsearch); + AsyncHttpClient client = new AsyncHttpClient(); + client.setCookieStore(myCookieStore); + client.post(mServer + "equipment/getList4APP.do?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + super.onSuccess(response); + String res = response; + equs=getData(response); + UpDateUI(); + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFailure(Throwable error) { + super.onFailure(error); + String a = error.toString(); + if(!PertainToEquSelActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (refresh.isRefreshing()){ + refresh.setRefreshing(false); + } + new SweetAlertDialog(PertainToEquSelActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("设备列表获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getEquList(); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + @Override + public void onFinish() { + super.onFinish(); + } + + }); + } + + private void showRefresh() { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!refresh.isRefreshing()){ + refresh.setRefreshing(true); + } + } + }); + } + + private void UpDateUI() { + if (!PertainToEquSelActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (refresh.isRefreshing()){ + refresh.setRefreshing(false); + } + if(equs!=null){ + manager = new LinearLayoutManager(PertainToEquSelActivity.this); + rc_view.setLayoutManager(manager); + equAdapter = new PertainToEquSelAdapter(equs, PertainToEquSelActivity.this, new PertainToEquSelAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + sel_item = equs.get(position); + Intent intent = new Intent(); + intent.putExtra("sel",sel_item); + setResult(RESULT_OK,intent); + finish(); + } + }); + rc_view.setAdapter(equAdapter); + } + } + }); + + } + } + + private List getData(String response) { + List list = new ArrayList(); + try{ + JSONObject jsonObject = new JSONObject(response); + JSONArray array = new JSONArray(jsonObject.optString("rows")); + for (int i=0;i { + private List list; + private Context context; + private onRecyclerViewItemClick mOnRvItemClick; + + public PertainToEquSelAdapter(List list, Context context, onRecyclerViewItemClick mOnRvItemClick) { + this.list = list; + this.context = context; + this.mOnRvItemClick = mOnRvItemClick; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item ,parent,false); + final ViewHolder holder = new ViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + EquList item = list.get(position); + holder.tv_name.setText(item.getEquipmentname()); + holder.tv_cardId.setText(item.getEquipmentcardid()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + TextView tv_name,tv_cardId; + View root; + public ViewHolder(@NonNull View itemView) { + super(itemView); + root = itemView; + tv_name = itemView.findViewById(R.id.name); + tv_cardId = itemView.findViewById(R.id.info); + root.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (mOnRvItemClick != null) + mOnRvItemClick.onItemClick(v, getAdapterPosition()); + } + } + + /** + * item点击接口 + */ + public interface onRecyclerViewItemClick { + void onItemClick(View v, int position); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Equ/SelActivity.java b/app/src/main/java/com/sipai/jspatrol/Equ/SelActivity.java new file mode 100644 index 0000000..870040f --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Equ/SelActivity.java @@ -0,0 +1,434 @@ +package com.sipai.jspatrol.Equ; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.loopj.android.http.AsyncHttpClient; +import com.loopj.android.http.AsyncHttpResponseHandler; +import com.loopj.android.http.PersistentCookieStore; +import com.loopj.android.http.RequestParams; +import com.sipai.jspatrol.Bean.InfoSel; +import com.sipai.jspatrol.R; + +import org.json.JSONArray; +import org.json.JSONException; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class SelActivity extends AppCompatActivity { + private String type = ""; + private List list = new ArrayList<>(); + private InfoSel sel_item; + private RecyclerView rc_view; + private SelAdapter adapter; + private LinearLayoutManager manager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sel); + init(); + initView(); + intentVisit(); + } + + private void intentVisit() { + if (type.equals("assetclass")){ + getAssetClass(); + }else if (type.equals("equtypenum")){ + getEquTypeNum(); + }else if (type.equals("equclass")){ + getEquClass(); + }else if (type.equals("equspecification")){ + getEquSpecification(); + }else if (type.equals("equlevel")){ + getEquLevel(); + } + } + + /** + * 设备级别 + */ + private void getEquLevel() { + PersistentCookieStore myCookieStore = new PersistentCookieStore(this); + RequestParams params = new RequestParams(); + AsyncHttpClient client = new AsyncHttpClient(); + client.setCookieStore(myCookieStore); + client.post(mServer + "equipment/equipmentLevel/getEquipmentLevelForSelect.do?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + super.onSuccess(response); + list = parseData(response); + UpdateUI(); + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFailure(Throwable error) { + super.onFailure(error); + String a = error.toString(); + if(!SelActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(SelActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("资产类型列表获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getEquLevel(); + } + }).show(); + } + }); + } + } + + @Override + public void onFinish() { + super.onFinish(); + } + + }); + } + + /** + * 设备规格 + */ + private void getEquSpecification() { + PersistentCookieStore myCookieStore = new PersistentCookieStore(this); + RequestParams params = new RequestParams(); + AsyncHttpClient client = new AsyncHttpClient(); + client.setCookieStore(myCookieStore); + client.post(mServer + "equipment/equipmentSpecification/getEquipmentSpecificationForSelect.do?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + super.onSuccess(response); + list = parseData(response); + UpdateUI(); + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFailure(Throwable error) { + super.onFailure(error); + String a = error.toString(); + if(!SelActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(SelActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("资产类型列表获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getEquSpecification(); + } + }).show(); + } + }); + } + } + + @Override + public void onFinish() { + super.onFinish(); + } + + }); + } + + /** + * 设备类型 + */ + private void getEquClass() { + PersistentCookieStore myCookieStore = new PersistentCookieStore(this); + RequestParams params = new RequestParams(); + AsyncHttpClient client = new AsyncHttpClient(); + client.setCookieStore(myCookieStore); + client.post(mServer + "equipment/equipmentClass/getEquipmentClassForSelect.do?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + super.onSuccess(response); + Log.i("assetClass", "onSuccess: "+response); + list = parseData(response); + UpdateUI(); + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFailure(Throwable error) { + super.onFailure(error); + String a = error.toString(); + if(!SelActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(SelActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("资产类型列表获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getEquClass(); + } + }).show(); + } + }); + } + } + + @Override + public void onFinish() { + super.onFinish(); + } + + }); + } + + /** + * 设备型号 + */ + private void getEquTypeNum() { + PersistentCookieStore myCookieStore = new PersistentCookieStore(this); + RequestParams params = new RequestParams(); + AsyncHttpClient client = new AsyncHttpClient(); + client.setCookieStore(myCookieStore); + client.post(mServer + "equipment/equipmentTypeNumber/getEquipmentTypeNumberForSelect.do?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + super.onSuccess(response); + Log.i("assetClass", "onSuccess: "+response); + list = parseData(response); + UpdateUI(); + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFailure(Throwable error) { + super.onFailure(error); + String a = error.toString(); + if(!SelActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(SelActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("资产类型列表获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getEquTypeNum(); + } + }).show(); + } + }); + } + } + + @Override + public void onFinish() { + super.onFinish(); + } + + }); + } + + /** + * 资产类型 + */ + private void getAssetClass() { + PersistentCookieStore myCookieStore = new PersistentCookieStore(this); + RequestParams params = new RequestParams(); +// params.put("search_code", mBizid); +// params.put("rows", "100"); +// params.put("page", "1"); + AsyncHttpClient client = new AsyncHttpClient(); + client.setCookieStore(myCookieStore); + client.post(mServer + "equipment/assetClass/getAssetClassForSelect.do?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + super.onSuccess(response); + Log.i("assetClass", "onSuccess: "+response); + list = parseData(response); + UpdateUI(); + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFailure(Throwable error) { + super.onFailure(error); + String a = error.toString(); + if(!SelActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(SelActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("资产类型列表获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getAssetClass(); + } + }).show(); + } + }); + } + } + + @Override + public void onFinish() { + super.onFinish(); + } + + }); + } + + private void UpdateUI() { + runOnUiThread(new Runnable() { + @Override + public void run() { + manager = new LinearLayoutManager(SelActivity.this); + rc_view.setLayoutManager(manager); + adapter = new SelAdapter(SelActivity.this, list, new SelAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + sel_item = list.get(position); + Intent intent = new Intent(); + intent.putExtra("sel",sel_item); + setResult(RESULT_OK,intent); + finish(); + } + }); + rc_view.setAdapter(adapter); + } + }); + } + + private List parseData(String response) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(response); + for (int i=0;i { + private Context mContext; + private List list; + private onRecyclerViewItemClick mOnRvItemClick; + + public SelAdapter(Context mContext, List list, onRecyclerViewItemClick mOnRvItemClick) { + this.mContext = mContext; + this.list = list; + this.mOnRvItemClick = mOnRvItemClick; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.moudle_item_sel,parent,false); + ViewHolder holder = new ViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + InfoSel item = list.get(position); + holder.tv_name.setText(item.getText()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + View tview; + TextView tv_name; + public ViewHolder(View itemView) { + super(itemView); + tview = itemView; + tv_name = itemView.findViewById(R.id.moudle_item_sel_tv_name); + tview.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (mOnRvItemClick != null) + mOnRvItemClick.onItemClick(v, getAdapterPosition()); + } + } + /** + * item点击接口 + */ + public interface onRecyclerViewItemClick { + void onItemClick(View v, int position); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/DoingFaultDetailActivity.java b/app/src/main/java/com/sipai/jspatrol/Fault/DoingFaultDetailActivity.java new file mode 100644 index 0000000..dc590c5 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/DoingFaultDetailActivity.java @@ -0,0 +1,1470 @@ +package com.sipai.jspatrol.Fault; + +import android.app.DatePickerDialog; +import android.app.Dialog; +import android.app.TimePickerDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.graphics.Color; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.Message; +import android.provider.MediaStore; +import android.util.Log; +import android.view.Display; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.TimePicker; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.FileProvider; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.hitomi.tilibrary.transfer.TransferConfig; +import com.hitomi.tilibrary.transfer.Transferee; +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.Bean.Maintenance; +import com.sipai.jspatrol.Bean.Picture; +import com.sipai.jspatrol.Bean.ProcessSection; +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.BuildConfig; +import com.sipai.jspatrol.Fault.adapter.PicAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.vansz.glideimageloader.GlideImageLoader; + +import net.bither.util.NativeUtil; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class DoingFaultDetailActivity extends AppCompatActivity implements View.OnClickListener{ + + private Fault mFault; + private Button btn_sign_in,btn_sub; + //异常详情 + private TextView tv_area,tv_equ_detail,tv_content,tv_date,tv_man; + private LinearLayout ll_equ; + //实施详情 + private TextView tv_show_area,tv_show_equ,tv_show_description,tv_show_content,tv_show_remark,tv_show_date,tv_show_man; + private RecyclerView rc_show; + private LinearLayout ll_show; + //编辑模块 + private EditText edt_question_description,edt_dispose_content,edt_maintenance_date; + private TextView tv_processsection,tv_equ,tv_receiver; + private LinearLayout ll_edit; + private List areas = new ArrayList<>(); + private EquList sel_equ; + private ProcessSection sel_ps; + private String sel_equs_id = ""; + private List receivers = new ArrayList<>(); + private List sel_receivers = new ArrayList<>(); + private String st_sel_receiver_id = ""; + private static final int SEND_RECEIVERS = 131; + private String mseriverip; + private Calendar cal; + private int year,month,day,hour,minute; + private RecyclerView rc_fault_pic; + private List pics = new ArrayList<>(); + private List pics_show = new ArrayList<>(); + private PicAdapter picAdapter; + private LinearLayoutManager stmanager; + private GridView gv_pic; + private Dialog ddialog; + private SweetAlertDialog pDialog; + private static final int UPIMG = 10; + private final int PHOTO_REQUEST_CAREMA = 1;// 拍照 + private final int PHOTO_REQUEST_GALLERY = 2;// 从相册中选择private static final String PHOTO_FILE_NAME = "temp_photo.jpg"; + private static final int SELEQU = 104; + private static final int SELPS = 8;//选择工艺段 + // 获取sd卡根目录地址,并创建图片父目录文件对象和文件的对象; + private List> datas; + private GridViewAddImgesAdpter gridViewAddImgesAdpter; + String file_str = Environment.getExternalStorageDirectory().getPath(); + File mars_file = new File(file_str + "/my_camera"); + File file_go = new File(file_str + "/my_camera/"+System.currentTimeMillis()+".jpg"); + private final String IMAGE_DIR = Environment.getExternalStorageDirectory() + "/gridview/"; + private Transferee transferee; + private Spinner etrepairway; + private String[] repway = {"in","out"}; + private EditText edt_actualMoney; + private EditText edt_workinghours; + private TextView tv_planMoney; + private String pc_id,pc_processid,pc_handledetail,pc_taskid,pc_unitid,pc_businessid,pc_taskdefinitionkey; + private Button btn_big_sub; + + public static void actionStart(Context context, Fault fault){ + Intent intent = new Intent(context, DoingFaultDetailActivity.class); + intent.putExtra("fault",fault); + context.startActivity(intent); + } + + private Handler handler = new Handler(){ + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what){ + case UPIMG: + photoPath(msg.obj.toString()); + break; + } + } + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_doing_fault_detail); + init(); + getNowData(); + initView(); + if (!mFault.getTodoTask().contains("验收")) { + getReceiver(); +// //修改后获取故障详情 +// showDefectAdjust(); + } + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + getDetail(); + } + }, 1000); + } + + private void getReceiver() { + HashMap map = new HashMap<>(); + map.put("search_pid",mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETUSERLISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + if (!DoingFaultDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("人员列表获取失败,请重试!") + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getReceiver(); + } + }).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + receivers = parseReceiver(res); + } + }); + } + + private List parseReceiver(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.getString("rows")); + for (int i=0;i map = new HashMap<>(); + map.put("maintenanceDetailId",mFault.getId()); + map.put("tbName","tb_maintenance_problem_fille"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetFaultTodoPics_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + loadPicFail(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pics = getPicData(res); + updatePic(); + } + }); + } + + private void loadPicFail(IOException e) { + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(DoingFaultDetailActivity.this, "图片获取失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void updatePic() { + if (!DoingFaultDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (pics.size()>0) { + List ivUrls = new ArrayList<>(); + for (int i=0;i map = new HashMap<>(); + map.put("masterId",id); + map.put("tbName","tb_maintenance_file"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetSubDetailPics_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + loadPicFail(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pics_show = getSubPicData(res); + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (pics_show.size() > 0) { + List ivUrls = new ArrayList<>(); + for (int i=0;i0) { +// picAdapter = new PicAdapter(pics_show, DoingFaultDetailActivity.this); +// rc_show.setAdapter(picAdapter); +// stmanager = new LinearLayoutManager(DoingFaultDetailActivity.this); +// stmanager.setOrientation(LinearLayoutManager.HORIZONTAL); +// rc_show.setLayoutManager(stmanager); +// }else { +// rc_show.setVisibility(View.GONE); +// } +// } +// }); +// } +// +// @Override +// public void onStart() { +// super.onStart(); +// } +// +// @Override +// public void onFinish() { +// super.onFinish(); +// } +// +// @Override +// public void onFailure(final Throwable error) { +// super.onFailure(error); +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// Toast.makeText(DoingFaultDetailActivity.this, "图片获取失败:"+error.toString(), Toast.LENGTH_SHORT).show(); +// } +// }); +// +// } +// }); + } + + private List getSubPicData(String response) { + List list = new ArrayList<>(); + try { + JSONArray aNews = new JSONArray(response); + for (int i=0;i getPicData(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.get("content1").toString()); + for (int i=0;i(); + gv_pic = findViewById(R.id.moudle_doing_fault_detail_gv_pic); + gridViewAddImgesAdpter = new GridViewAddImgesAdpter(datas, this); + gv_pic.setAdapter(gridViewAddImgesAdpter); + gv_pic.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int position, long id) { + showdialog(); + } + }); + + //实施内容显示 + ll_show = findViewById(R.id.moudle_doing_fault_detail_ll_show); + etrepairway=(Spinner)findViewById(R.id.rp_imp_sp_repairway);//是否委外 + String[] cates=getResources().getStringArray(R.array.repairway); + ArrayAdapter adaptergroup=new ArrayAdapter(this, R.layout.item_normal_little_spin, R.id.moudle_normal_little_spin_tv_title,cates); + etrepairway.setAdapter(adaptergroup); + etrepairway.setSelection(0);//默认选择第一种维修方式 + tv_show_area = findViewById(R.id.moudle_doing_fault_detail_tv_show_processsection); + tv_show_equ = findViewById(R.id.moudle_doing_fault_detail_tv_show_equ); + tv_show_description = findViewById(R.id.moudle_doing_fault_detail_tv_show_question_description); + tv_show_content = findViewById(R.id.moudle_doing_fault_detail_tv_show_dispose_content); + tv_show_remark = findViewById(R.id.moudle_doing_fault_detail_tv_show_content_added); + tv_show_date = findViewById(R.id.moudle_doing_fault_detail_tv_show_maintenance_date); + tv_show_man = findViewById(R.id.moudle_doing_fault_detail_tv_show_receiver); + rc_show = findViewById(R.id.moudle_doing_fault_detail_rc_show_pic); + transferee = Transferee.getDefault(this); + if (mFault!=null&&mFault.getId()!=null){ + tv_area.setText(mFault.getProcessSection().getName()); + if (mFault.getEquipmentCard()!=null&&!mFault.getEquipmentCard().getEquipmentname().equals("")) { + tv_equ_detail.setText(mFault.getEquipmentCard().getEquipmentname()); + }else { +// tv_equ_detail.setVisibility(View.GONE); + ll_equ.setVisibility(View.GONE); + } + tv_content.setText(mFault.getProblemcontent()); + tv_planMoney.setText(mFault.getPlanMoney()); +// tv_remark.setText(mFault.getProblemTypeNames()); + tv_date.setText(mFault.getInsdt().substring(5,16)); + tv_man.setText(mFault.getInsuser()); + tv_processsection.setText(sel_ps.getName()); + tv_equ.setText(sel_equ.getEquipmentname()); + if (mFault.getTodoTask()!=null){ + if (mFault.getTodoTask().equals("待签收")){ + btn_sub.setVisibility(View.GONE); + btn_big_sub.setVisibility(View.GONE); + ll_edit.setVisibility(View.GONE); + ll_show.setVisibility(View.GONE); + }else if (mFault.getTodoTask().contains("执行")){ + btn_sign_in.setVisibility(View.GONE); + ll_show.setVisibility(View.GONE); + }else if (mFault.getTodoTask().contains("验收")||mFault.getTodoTask().contains("完成")){ + btn_sub.setVisibility(View.GONE); + btn_big_sub.setVisibility(View.GONE); + btn_sign_in.setVisibility(View.GONE); + ll_edit.setVisibility(View.GONE); + ll_show.setVisibility(View.VISIBLE); + getSubDetail(); + } + } + } + + } + + /* + 获取执行的详情 + */ + private void getSubDetail() { + HashMap map = new HashMap<>(); + map.put("id",mFault.getId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetSubDetail_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(DoingFaultDetailActivity.this, "数据获取失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + if(res.contains("fail")) { + showFailDialog(); + }else { + JSONObject jsonObject = new JSONObject(res); + JSONArray aNews = new JSONArray(jsonObject.opt("content1").toString()); + showDetail(aNews); + String businessid = jsonObject.opt("businessUnitHandleId").toString(); + getSubDetailPic(businessid); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + }); + } + + private void showFailDialog() { + if (!DoingFaultDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("工单获取失败,请重试!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void showDetail(final JSONArray arry) { + try { + JSONObject obj = arry.getJSONObject(0); + final Maintenance item = new Maintenance(); + item.setId(obj.opt("id").toString()); + item.setProblem(obj.opt("problem").toString()); + item.setHandledetail(obj.opt("handledetail").toString()); + item.setDetailsupplement(obj.opt("detailsupplement").toString()); + item.setFaultLibraryName(obj.opt("faultLibraryName").toString()); + item.setInsdt(obj.opt("insdt").toString()); + item.setProcessSectionName(obj.opt("processSectionName").toString()); + item.setInsuserName(obj.opt("insuserName").toString()); + item.setEquipmentNames(obj.opt("equipmentNames").toString()); + runOnUiThread(new Runnable() { + @Override + public void run() { + tv_show_area.setText(item.getProcessSectionName()); + tv_show_equ.setText(mFault.getEquipmentCard().getEquipmentname()); + tv_show_description.setText(item.getProblem()); + tv_show_content.setText(item.getHandledetail()); + tv_show_remark.setText(item.getDetailsupplement()); + tv_show_date.setText(item.getInsdt().substring(5,16)); + tv_show_man.setText(item.getInsuserName()); + } + }); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + /** + * 选择图片对话框 + */ + public void showdialog() { + View localView = LayoutInflater.from(this).inflate( + R.layout.dialog_add_picture, null); + TextView tv_camera = (TextView) localView.findViewById(R.id.tv_camera); + TextView tv_gallery = (TextView) localView.findViewById(R.id.tv_gallery); + TextView tv_cancel = (TextView) localView.findViewById(R.id.tv_cancel); + ddialog = new Dialog(this, R.style.custom_dialog); + ddialog.setContentView(localView); + ddialog.getWindow().setGravity(Gravity.BOTTOM); + // 设置全屏 + WindowManager windowManager = getWindowManager(); + Display display = windowManager.getDefaultDisplay(); + WindowManager.LayoutParams lp = ddialog.getWindow().getAttributes(); + lp.width = display.getWidth(); // 设置宽度 + ddialog.getWindow().setAttributes(lp); + ddialog.show(); + tv_cancel.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + ddialog.dismiss(); + } + }); + + tv_camera.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + ddialog.dismiss(); + // 拍照 + camera(); + } + }); + + tv_gallery.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + ddialog.dismiss(); + // 从系统相册选取照片 + gallery(); + } + }); + } + + public void photoPath(String path) { + Map map=new HashMap<>(); + map.put("path",path); + datas.add(map); + gridViewAddImgesAdpter.notifyDataSetChanged(); + } + + /** + * 拍照 + */ + public void camera() { + Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){ + try { + File file = createOriImageFile(); + file_go = file; + if (file != null) { + Uri imgUriOri = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID+ ".fileProvider", file); + cameraIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);//设置Action为拍照 + cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imgUriOri); + startActivityForResult(cameraIntent, 0x1); + } + } catch (IOException e) { + e.printStackTrace(); + } + }else { + if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { + if (!mars_file.exists()) { + mars_file.mkdirs(); + } + // 并设置拍照的存在方式为外部存储和存储的路径; + cameraIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);//设置Action为拍照 + cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file_go)); + //跳转到拍照界面; + startActivityForResult(cameraIntent, 0x1); + } else { + Toast.makeText(DoingFaultDetailActivity.this, "请先安装好sd卡", Toast.LENGTH_LONG).show(); + } + } + } + + /** + * 创建原图像保存的文件 + * + * @return + * @throws IOException + */ + private File createOriImageFile() throws IOException { + String imgNameOri = "nk_" + new SimpleDateFormat( + "yyyyMMdd_HHmmss").format(new Date()); + File pictureDirOri = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath() + "/my_camera"); + if (!pictureDirOri.exists()) { + pictureDirOri.mkdirs(); + } + File image = File.createTempFile( + imgNameOri, /* prefix */ + ".jpg", /* suffix */ + pictureDirOri /* directory */ + ); + String imgPathOri = image.getAbsolutePath(); + return image; + } + + /** + * 判断sdcard是否被挂载 + */ + public boolean hasSdcard() { + return Environment.getExternalStorageState().equals( + Environment.MEDIA_MOUNTED); + } + + + /** + * 从相册获取2 + */ + public void gallery() { + Intent intent = new Intent( + Intent.ACTION_PICK, + MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + startActivityForResult(intent, PHOTO_REQUEST_GALLERY); + } + + + private DatePickerDialog.OnDateSetListener Datelistener=new DatePickerDialog.OnDateSetListener() + { + @Override + public void onDateSet(DatePicker view, int myyear, int monthOfYear, int dayOfMonth) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + year=myyear; + month=monthOfYear; + day=dayOfMonth; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + TimePickerDialog dpd=new TimePickerDialog(DoingFaultDetailActivity.this,Timelistener,hour,minute,true); + dpd.show();//显示DatePickerDialog组件 + } + }; + private TimePickerDialog.OnTimeSetListener Timelistener=new TimePickerDialog.OnTimeSetListener() + { + @Override + public void onTimeSet(TimePicker view, int hours, int minutes) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + hour=hours; + minute=minutes; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + String smonth = ""; + String sday = ""; + String shour = ""; + String smin = "00"; + //在TextView上显示日期 + if (month<9){ + smonth = "0"+String.valueOf(month+1); + }else { + smonth = String.valueOf(month+1); + } + if (day<10){ + sday = "0"+String.valueOf(day); + }else { + sday = String.valueOf(day); + } + if (hour<10){ + shour = "0"+String.valueOf(hour); + }else { + shour = String.valueOf(hour); + } + //在TextView上显示日期 + if(edt_maintenance_date.isFocused()){ + edt_maintenance_date.setText(year+"-"+smonth+"-"+sday+" "+shour+":"+"00:00"); + } + } + }; + + @Override + public void onClick(View view) { + switch (view.getId()){ + case R.id.moudle_doing_fault_detail_btn_sign_in: + SignInFault(); + break; + case R.id.moudle_doing_fault_detail_btn_sub: + List edts = new ArrayList<>(); + edts.add(edt_question_description); + edts.add(edt_dispose_content); +// edts.add(edt_maintenance_date); + Boolean istrue = isEditTextEmpty(edts); + if (!istrue){ + subDoingFault(); + } + break; + case R.id.moudle_doing_fault_detail_btn_big_sub: + List edtas = new ArrayList<>(); + edtas.add(edt_question_description); + edtas.add(edt_dispose_content); + Boolean isatrue = isEditTextEmpty(edtas); + if (!isatrue){ + subDoingFault(); + } + break; + case R.id.moudle_doing_fault_detail_tv_processsection: + Intent intent_sel_ps = new Intent(DoingFaultDetailActivity.this, SingleChoiceActivity.class); + intent_sel_ps.putExtra("mark","ps"); + startActivityForResult(intent_sel_ps,SELPS); + break; + case R.id.moudle_doing_fault_detail_tv_equ: + Intent intent_sel_equ = new Intent(DoingFaultDetailActivity.this, SingleChoiceActivity.class); + intent_sel_equ.putExtra("mark","equ"); + if (sel_ps!=null) { + intent_sel_equ.putExtra("psId",sel_ps.getSid()); + } + startActivityForResult(intent_sel_equ, SELEQU); + break; + case R.id.moudle_doing_fault_detail_tv_receiver: + if (receivers.size()>0) { + Intent intent_man = new Intent(DoingFaultDetailActivity.this, PersonSelectorActivity.class); + intent_man.putExtra("users", (Serializable) receivers); + startActivityForResult(intent_man,SEND_RECEIVERS); + }else { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("暂未配置接收人") + .show(); + } + }); + } + break; + } + } + + /* + 获取提交缺陷执行时所需提交的部分参数 + */ + private void getHandleDetail() { + HashMap map = new HashMap<>(); + map.put("taskId",mFault.getTaskId()); + map.put("processInstanceId",mFault.getProcessInstanceId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetPar_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(DoingFaultDetailActivity.this, "流程数据获取失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + subDoingFaultFail(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = new JSONArray(jsonObject.opt("content1").toString()); + pc_id = array.getJSONObject(0).optString("id"); + pc_processid = array.getJSONObject(0).optString("processid"); + pc_handledetail = array.getJSONObject(0).optString("handledetail"); + pc_taskid = array.getJSONObject(0).optString("taskid"); + pc_unitid = array.getJSONObject(0).optString("unitid"); + if (pc_unitid.isEmpty()){ + pc_unitid = "handle"; + } + pc_businessid = array.getJSONObject(0).optString("businessid"); + pc_taskdefinitionkey = array.getJSONObject(0).optString("taskdefinitionkey"); + updateProcess(); + } catch (JSONException e) { + e.printStackTrace(); + subDoingFaultFail(); + } + } + }); + } + + /** + * 更新流程 + */ + private void updateProcess() { + HashMap map = new HashMap<>(); + map.put("businessid",pc_businessid); + map.put("handledetail",edt_dispose_content.getText().toString()); + map.put("id",pc_id); + map.put("processid",pc_processid); + map.put("targetusers",st_sel_receiver_id); + map.put("taskdefinitionkey",pc_taskdefinitionkey); + map.put("taskid",pc_taskid); + map.put("unitid",pc_unitid); + map.put("routeNum","0"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.UpdateProcess_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + subDoingFaultFail(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String resa = response.body().string(); + pDialogHide(); + try { + JSONObject jsonObject = new JSONObject(resa); + String res = jsonObject.opt("res").toString(); + if (res.equals("1")) { + subDoingFaultSuccess(); + } else { + subDoingFaultFail(); + } + }catch (Exception e){ + + } + } + }); + } + + /* + 提交实施内容 + */ + private void subDoingFault() { + String actualMoney = ""; + if (edt_actualMoney.getText()!=null&&edt_actualMoney.getText().toString().length()>0){ + actualMoney = edt_actualMoney.getText().toString(); + } + String workinghours = ""; + if (edt_workinghours.getText()!=null&&edt_workinghours.getText().toString().length()>0){ + workinghours = edt_workinghours.getText().toString(); + } + HashMap map = new HashMap<>(); + map.put("id",mFault.getId()); + map.put("targetusers",st_sel_receiver_id); + if (edt_question_description.getText()!=null&&!edt_question_description.getText().toString().isEmpty()) { + map.put("problemcontent", edt_question_description.getText().toString());//故障描述 + } + map.put("actualMoney",actualMoney);//实际费用 + map.put("workinghours",workinghours);//工时 + map.put("maintenanceWay",repway[etrepairway.getSelectedItemPosition()]);//是否委外 + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.SubImp_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + subDoingFaultFail(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String resa = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(resa); + String res = jsonObject.opt("res").toString(); + if (res.equals("1")){ + if (datas.size()>0){ + subDoingFaultPics(jsonObject.optString("id")); + }else { + pDialogHide(); + getHandleDetail(); + } + }else { + pDialogHide(); + subDoingFaultFail(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + }); + } + + private void subDoingFaultPics(String id) { + pDialogshow(); + HashMap map = new HashMap<>(); + map.put("masterId",id); + map.put("tbName","tb_maintenance_file"); + map.put("nameSpace","MaintenanceFile"); + String picMark = "filelist"; + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpSubPics(map,mServer, MethodURL.SubPic_Method,picMark,datas)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + picSubFail(id); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("suc")){ + getHandleDetail(); + }else { + picSubFail(id); + } + } + }); + } + + private void picSubFail(String id) { + if (!DoingFaultDetailActivity.this.isFinishing()){ + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("图片上传失败") + .setConfirmText("重新上传") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + subDoingFaultPics(id); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + } + + private void subDoingFaultSuccess() { + if (!DoingFaultDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("上传成功") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + private void subDoingFaultFail() { + if (!DoingFaultDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("提交失败,请重试") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void pDialogHide() { + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!DoingFaultDetailActivity.this.isFinishing()) { + pDialog.hide(); + } + } + }); + } + } + + private void pDialogshow() { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!DoingFaultDetailActivity.this.isFinishing()){ + pDialog.show(); + } + } + }); + } + + private Boolean isEditTextEmpty(final List edts) { + Boolean isEmpty = false; + for (int i=0;i0){}else { + final EditText edt_sel = edts.get(i); + runOnUiThread(new Runnable() { + @Override + public void run() { + edt_sel.setError("请填写内容"); + } + }); + isEmpty = true; + } + } + return isEmpty; + } + + private void SignInFault() { + HashMap map = new HashMap<>(); + map.put("taskId",mFault.getTaskId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.SignIn_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + signFail(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.equals("1")){ + SubSuccess(); + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + btn_sign_in.setVisibility(View.GONE); + btn_sub.setVisibility(View.VISIBLE); + btn_big_sub.setVisibility(View.VISIBLE); + ll_edit.setVisibility(View.VISIBLE); + } + }); + } + }else { + signFail(); + } + } + }); + } + + private void signFail() { + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(DoingFaultDetailActivity.this, "签收失败", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void SubSuccess() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("签收成功") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + + private void SubFail() { + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(DoingFaultDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("签收失败,请重试") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + case SELPS: + if (resultCode == RESULT_OK) { + sel_ps = (ProcessSection) data.getSerializableExtra("ps"); + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + showText(sel_ps.getName(), tv_processsection); + } + }); + } + } + break; + case SELEQU: + if (resultCode == RESULT_OK) { + sel_equ = (EquList) data.getSerializableExtra("equ"); + if (!DoingFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + sel_equs_id = sel_equ.getId(); + showText(sel_equ.getEquipmentname(), tv_equ); +// if (sel_equ.getEquipmentcardid().equals(mFault.getEquipmentCard().getEquipmentcardid())) { +// sel_equs_id = sel_equ.getId(); +// showText(sel_equ.getEquipmentname(), tv_equ); +// }else { +// new SweetAlertDialog(DoingFaultDetailActivity.this,SweetAlertDialog.WARNING_TYPE) +// .setTitleText("提示") +// .setContentText("检测到您所选设备与维修设备不符,请确认后重新选择!") +// .setConfirmText("确定") +// .show(); +// } + } + }); + } + } + break; + case SEND_RECEIVERS: + if (resultCode == RESULT_OK) { + sel_receivers = (List) data.getSerializableExtra("sel"); + String suser = ""; + st_sel_receiver_id = ""; + if (sel_receivers.size() > 0) { + for (int i = 0; i < sel_receivers.size(); i++) { + if (i == 0) { + suser = sel_receivers.get(i).getCaption(); + st_sel_receiver_id = sel_receivers.get(i).getId(); + } else if (0 0) { + showText(st,tv_receiver); + } + } + }); + } + break; + case PHOTO_REQUEST_GALLERY: + // 从相册返回的数据 + if (data != null) { + // 得到图片的全路径 + Uri uri = data.getData(); + String[] proj = {MediaStore.Images.Media.DATA}; + //好像是android多媒体数据库的封装接口,具体的看Android文档 + Cursor cursor = managedQuery(uri, proj, null, null, null); + //按我个人理解 这个是获得用户选择的图片的索引值 + int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); + //将光标移至开头 ,这个很重要,不小心很容易引起越界 + cursor.moveToFirst(); + //最后根据索引值获取图片路径 + String path = cursor.getString(column_index); + uploadImage(path); + } + break; + case PHOTO_REQUEST_CAREMA: + if (resultCode != RESULT_CANCELED) { + // 从相机返回的数据 + if (hasSdcard()) { + if (file_go != null) { + uploadImage(file_go.getPath()); + } else { + Toast.makeText(this, "相机异常请稍后再试!", Toast.LENGTH_SHORT).show(); + } + } else { + Toast.makeText(this, "未找到存储卡,无法存储照片!", Toast.LENGTH_SHORT).show(); + } + } + break; + } + } + + /** + * 上传图片 + * + * @param path + */ + private void uploadImage(final String path) { + new Thread() { + @Override + public void run() { + if (new File(path).exists()) { + Log.d("images", "源文件存在" + path); + } else { + Log.d("images", "源文件不存在" + path); + } + + File dir = new File(IMAGE_DIR); + if (!dir.exists()) { + dir.mkdir(); + } + final File file = new File(dir + "/temp_photo" + System.currentTimeMillis() + ".jpg"); + NativeUtil.compressBitmap(path, file.getAbsolutePath(), 50); + if (file.exists()) { + Log.d("images", "压缩后的文件存在" + file.getAbsolutePath()); + } else { + Log.d("images", "压缩后的不存在" + file.getAbsolutePath()); + } + Message message = new Message(); + message.what = UPIMG; + message.obj = file.getAbsolutePath(); + handler.sendMessage(message); + + } + }.start(); + + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private String mGroup; + public void init(){ + SharedPreferences sharedPre=getSharedPreferences("config", MODE_PRIVATE); + mServer=sharedPre.getString("server", ""); + mUsername=sharedPre.getString("username", ""); + mPassword=sharedPre.getString("password", ""); + mUserid=sharedPre.getString("userid", ""); + mCaption=sharedPre.getString("caption", ""); + mBizid=sharedPre.getString("bizid", ""); + mseriverip=sharedPre.getString("serverip", ""); + mGroup=sharedPre.getString("group", ""); + if (getIntent().getSerializableExtra("fault")!=null){ + mFault = (Fault) getIntent().getSerializableExtra("fault"); + sel_ps = mFault.getProcessSection(); + sel_equ = mFault.getEquipmentCard(); + sel_equs_id = mFault.getEquipmentCard().getId(); + } + } + + private void showText(final String st, final TextView tv) { + runOnUiThread(new Runnable() { + @Override + public void run() { + tv.setText(st); + } + }); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + transferee.destroy(); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/DoneFaultActivity.java b/app/src/main/java/com/sipai/jspatrol/Fault/DoneFaultActivity.java new file mode 100644 index 0000000..6969a67 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/DoneFaultActivity.java @@ -0,0 +1,62 @@ +package com.sipai.jspatrol.Fault; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.R; + +public class DoneFaultActivity extends AppCompatActivity { + private Fault mFault; + private TextView tv_area,tv_equ,tv_fault_content,tv_date,tv_sub_man,tv_dispose_content,tv_content_added; + + public static void actionStart(Context context, Fault fault){ + Intent intent = new Intent(context, DoneFaultActivity.class); + intent.putExtra("fault",fault); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_done_fault); + init(); + initView(); + } + + private void init() { + if (getIntent().getSerializableExtra("fault")!=null){ + mFault = (Fault) getIntent().getSerializableExtra("fault"); + } + } + + private void initView() { + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("缺陷详情"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + tv_area = findViewById(R.id.moudle_done_fault_tv_area); + tv_area.setText(mFault.getProcessSection().getName()); + tv_equ = findViewById(R.id.moudle_done_fault_tv_equ_name); + tv_equ.setText(mFault.getEquipmentCard().getEquipmentname()); + tv_fault_content = findViewById(R.id.moudle_done_fault_tv_fault_content); + tv_fault_content.setText(mFault.getProblemcontent()); + tv_date = findViewById(R.id.moudle_done_fault_tv_date); + tv_date.setText(mFault.getInsdt().substring(0,16)); + tv_sub_man = findViewById(R.id.moudle_done_fault_tv_man); + tv_sub_man.setText(mFault.getInsuser()); + tv_dispose_content = findViewById(R.id.moudle_done_fault_tv_show_dispose_content); +// tv_dispose_content.setText(mFault.); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/EquSingleChoiceAdapter.java b/app/src/main/java/com/sipai/jspatrol/Fault/EquSingleChoiceAdapter.java new file mode 100644 index 0000000..8b8cb39 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/EquSingleChoiceAdapter.java @@ -0,0 +1,97 @@ +package com.sipai.jspatrol.Fault; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * Created by lvliming on 2018/7/22. + */ + +public class EquSingleChoiceAdapter extends RecyclerView.Adapter { + private Context mContext; + private List list; + private onRecyclerViewItemClick mOnRvItemClick; + + public EquSingleChoiceAdapter(Context mContext, List list, onRecyclerViewItemClick mOnRvItemClick) { + this.mContext = mContext; + this.list = list; + this.mOnRvItemClick = mOnRvItemClick; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_equ_single_choice,parent,false); + ViewHolder holder = new ViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + EquList equ = list.get(position); + if (equ.getEquipmentmanufacturer()!=null&&!equ.getEquipmentmanufacturer().isEmpty()) { + holder.tv_manufacturer.setText(equ.getEquipmentmanufacturer()); + }else { + holder.tv_manufacturer.setText("厂商暂未录入"); + } + holder.tv_equipmentStatusManagement.setText(equ.getEquipmentStatusManagement()); + if (equ.getEquipmentStatusManagement().equals("在用")){ + holder.tv_equipmentStatusManagement.setBackground(mContext.getResources().getDrawable(R.drawable.bg_layout_shape_green)); + holder.tv_equipmentStatusManagement.setTextColor(mContext.getResources().getColor(R.color.green06)); + }else { + holder.tv_equipmentStatusManagement.setBackground(mContext.getResources().getDrawable(R.drawable.bg_layout_shape_gray)); + holder.tv_equipmentStatusManagement.setTextColor(mContext.getResources().getColor(R.color.gray)); + } + holder.tv_equipmentClass.setText(equ.getEquipmentClass()); + holder.tv_model.setText(equ.getEquipmentmodel()); + holder.tv_equipmentLevel.setText(equ.getEquipmentLevel()); + holder.tv_name.setText(equ.getEquipmentname()); + holder.tv_cardid.setText(equ.getEquipmentcardid()); + holder.tv_ps.setText(equ.getProcessSection()); + holder.tv_model.setText(equ.getEquipmentTypeNumber()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + View tview; + TextView tv_manufacturer,tv_name,tv_cardid,tv_ps,tv_equipmentStatusManagement,tv_equipmentLevel,tv_equipmentClass,tv_model; + public ViewHolder(View itemView) { + super(itemView); + tview = itemView; + tv_manufacturer = (TextView) itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_equipmentmanufacturer); + tv_name = (TextView) itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_name); + tv_cardid = (TextView) itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_cardid); + tv_ps = itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_ps); + tv_equipmentStatusManagement = itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_equipmentStatusManagement); + tv_equipmentLevel = itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_equipmentLevel); + tv_equipmentClass = itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_equipmentclass); + tv_model = itemView.findViewById(R.id.moudle_item_equ_single_choice_tv_equipmentmodel); + tview.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (mOnRvItemClick != null) + mOnRvItemClick.onItemClick(v, getAdapterPosition()); + } + } + /** + * item点击接口 + */ + public interface onRecyclerViewItemClick { + void onItemClick(View v, int position); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/FaultFlowChartActivity.java b/app/src/main/java/com/sipai/jspatrol/Fault/FaultFlowChartActivity.java new file mode 100644 index 0000000..5283199 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/FaultFlowChartActivity.java @@ -0,0 +1,207 @@ +package com.sipai.jspatrol.Fault; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.Bean.FaultFlow; +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.Fault.adapter.FaultFlowAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.DateFormatUtils; +import com.sipai.jspatrol.utils.OKHttpUtils; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class FaultFlowChartActivity extends AppCompatActivity { + private Fault mFault; + private List flows = new ArrayList<>(); + private SwipeRefreshLayout refreshLayout; + private RecyclerView rc; + private LinearLayoutManager manager; + private FaultFlowAdapter adapter; + + public static void actionStart(Context context, Fault fault){ + Intent intent = new Intent(context, FaultFlowChartActivity.class); + intent.putExtra("fault",fault); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_fault_flow_chart); + init(); + initView(); + getFlow(); + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private String mGroup; + public void init(){ + SharedPreferences sharedPre=getSharedPreferences("config", MODE_PRIVATE); + mServer=sharedPre.getString("server", ""); + mUsername=sharedPre.getString("username", ""); + mPassword=sharedPre.getString("password", ""); + mUserid=sharedPre.getString("userid", ""); + mCaption=sharedPre.getString("caption", ""); + mBizid=sharedPre.getString("bizid", ""); + mGroup=sharedPre.getString("group", ""); + if (getIntent().getSerializableExtra("fault")!=null){ + mFault = (Fault) getIntent().getSerializableExtra("fault"); + } + } + + private void initView() { + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("处理流程"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + refreshLayout = findViewById(R.id.moudle_fault_flow_chart_refresh); + refreshLayout.setColorSchemeResources(R.color.blue); + refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getFlow(); + } + }); + rc = findViewById(R.id.moudle_fault_flow_chart_rc); + manager = new LinearLayoutManager(this); + rc.setLayoutManager(manager); + } + + private void getFlow() { + if (!refreshLayout.isRefreshing()) { + showRefresh(); + } + HashMap map = new HashMap<>(); + map.put("id",mFault.getId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetMaintenanceFlowChart_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + hideRefresh(); + if (!FaultFlowChartActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(FaultFlowChartActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("流程图获取失败,请重试!") + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getFlow(); + } + }).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + hideRefresh(); + flows = parseFlow(res); + updateFlow(); + } + }); + } + + private void showRefresh() { + if (!FaultFlowChartActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(true); + } + }); + } + } + + private void hideRefresh() { + if (!FaultFlowChartActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + } + }); + } + } + + private void updateFlow() { + if (!FaultFlowChartActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + adapter = new FaultFlowAdapter(FaultFlowChartActivity.this,flows); + rc.setAdapter(adapter); + } + }); + } + } + + private List parseFlow(String res) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(res); + for (int i=0;i> datas; + private Context context; + private LayoutInflater inflater; + /** + * 可以动态设置最多上传几张,之后就不显示+号了,用户也无法上传了 + * 默认9张 + */ + private int maxImages = 4; + + public GridViewAddImgesAdpter(List> datas, Context context) { + this.datas = datas; + this.context = context; + inflater = LayoutInflater.from(context); + } + + /** + * 获取最大上传张数 + * + * @return + */ + public int getMaxImages() { + return maxImages; + } + + /** + * 设置最大上传张数 + * + * @param maxImages + */ + public void setMaxImages(int maxImages) { + this.maxImages = maxImages; + } + + /** + * 让GridView中的数据数目加1最后一个显示+号 + * + * @return 返回GridView中的数量 + */ + @Override + public int getCount() { + int count = datas == null ? 1 : datas.size() + 1; + if (count >= maxImages) { + return datas.size(); + } else { + return count; + } + } + + @Override + public Object getItem(int position) { + return null; + } + + @Override + public long getItemId(int position) { + return 0; + } + + public void notifyDataSetChanged(List> datas) { + this.datas = datas; + this.notifyDataSetChanged(); + + } + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + + + ViewHolder viewHolder = null; + if (convertView == null) { + convertView = inflater.inflate(R.layout.item_published_grida, parent, false); + viewHolder = new ViewHolder(convertView); + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + if (datas != null && position < datas.size()) { + final File file = new File(datas.get(position).get("path").toString()); + Glide.with(context) + .load(file) + .priority(Priority.HIGH) + .into(viewHolder.ivimage); +// viewHolder.ivimage.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// Intent intent = new Intent(v.getContext(),PreviewActivity.class); +// intent.putExtra("url",datas.get(position).get("path").toString()); +// v.getContext().startActivity(intent); +// } +// }); + viewHolder.btdel.setVisibility(View.VISIBLE); + viewHolder.btdel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (file.exists()) { + file.delete(); + } + datas.remove(position); + notifyDataSetChanged(); + } + }); +// viewHolder.btadd.setVisibility(View.VISIBLE); +// viewHolder.btadd.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// Intent intent = new Intent(v.getContext(),PreviewActivity.class); +// intent.putExtra("url",datas.get(position).get("path").toString()); +// v.getContext().startActivity(intent); +// } +// }); + } else { + + Glide.with(context) + .load(R.mipmap.image_add1) + .priority(Priority.HIGH) + .centerCrop() + .into(viewHolder.ivimage); + viewHolder.ivimage.setScaleType(ImageView.ScaleType.FIT_XY); + viewHolder.btdel.setVisibility(View.GONE); +// viewHolder.btadd.setVisibility(View.GONE); + } + + return convertView; + + } + + public class ViewHolder { + public final ImageView ivimage; +// public final Button btadd; + public final Button btdel; + public final View root; + + public ViewHolder(View root) { + ivimage = (ImageView) root.findViewById(R.id.iv_image); + btdel = (Button) root.findViewById(R.id.bt_del); +// btadd = (Button) root.findViewById(R.id.bt_add); + this.root = root; + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/NewFaultActivity.java b/app/src/main/java/com/sipai/jspatrol/Fault/NewFaultActivity.java new file mode 100644 index 0000000..a2c9c8c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/NewFaultActivity.java @@ -0,0 +1,1203 @@ +package com.sipai.jspatrol.Fault; + +import android.app.Dialog; +import android.app.PendingIntent; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.net.Uri; +import android.nfc.NdefMessage; +import android.nfc.NdefRecord; +import android.nfc.NfcAdapter; +import android.nfc.tech.MifareClassic; +import android.nfc.tech.NfcA; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.Message; +import android.os.Parcelable; +import android.provider.MediaStore; +import android.provider.Settings; +import android.util.Log; +import android.view.Display; +import android.view.Gravity; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.FileProvider; + +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Bean.ProcessSection; +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.BuildConfig; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.RandomStringUtils; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; + +import net.bither.util.NativeUtil; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +import static com.sipai.jspatrol.utils.Global.GlobalVal.Type_Equipment; +import static com.sipai.jspatrol.utils.Global.GlobalVal.Type_Facilities; +import static com.sipai.jspatrol.utils.Global.GlobalVal.Type_Run; + +public class NewFaultActivity extends AppCompatActivity implements View.OnClickListener { + private String mServer; + private String mUsername; + private String mPwd; + private String androidId = ""; + private String mUserid; + private String mCaption; + private String mBizid, mBizName; + private NfcAdapter nfcAdapter; + private PendingIntent pendingIntent; + private IntentFilter[] mFilters; + private String[][] mTechLists; + private boolean isFirst = true; + private String mark = ""; + private String equid = ""; + // 是否支持NFC功能的标签 + private boolean isNFC_support = false; + private Boolean isbox = false; + private final static int SCANNIN_GREQUEST_CODE = 1; + private final static int FAILESUB = 101; + private final static int SUCCESSSUB = 102; + private static final int FAILE_RECEIVERS = 11; + private static final int SUCCESS_RECEIVERS = 12; + private static final int SEND_RECEIVERS = 13; + private static final int SELCONTENT = 14; + private List processSections = new ArrayList<>(); + private static List> mData; + private TextView tv_equ_name, tv_equ_cardno; + private TextView tv_factory, tv_sub_man, tv_receiver; + private EditText edt_fault_description; + private String alarm_description = ""; + private Button btn_sub; + private List receivers = new ArrayList<>(); + private List sel_receivers = new ArrayList<>(); + private String st_sel_receiver_id = ""; + private TextView tv_sel_equ; + private static final int SELEQU = 104; + private static final int SELPS = 8;//选择工艺段 + private GridView gv_pic; + // 获取sd卡根目录地址,并创建图片父目录文件对象和文件的对象; + String file_str = Environment.getExternalStorageDirectory().getPath(); + File mars_file = new File(file_str + "/my_camera"); + File file_go = new File(file_str + "/my_camera/" + System.currentTimeMillis() + ".jpg"); + private List> datas; + private GridViewAddImgesAdpter gridViewAddImgesAdpter; + private final int PHOTO_REQUEST_CAREMA = 111;// 拍照 + private final int PHOTO_REQUEST_GALLERY = 222;// 从相册中选择private static final String PHOTO_FILE_NAME = "temp_photo.jpg"; + private final String IMAGE_DIR = Environment.getExternalStorageDirectory() + "/gridview/"; + private static final int UPIMG = 1; + private String type = "reportEqu";//设备通知单 + private String formId = "";//异常通知单id + private Dialog ddialog; + private String planid = ""; + private String pointid = ""; + private String pid = ""; + private TextView tv_fault_description; + private List contents = new ArrayList<>(); + private String st_fault_content; + private String token; + private String id; + private TextView tv_ps;//工艺段 + private EquList sel_equ; + private ProcessSection sel_ps; + private List equLists = new ArrayList<>(); + private EditText edt_remark; + private String remark = ""; + private Spinner sp_type; + private String sel_type = Type_Run;; + private ArrayAdapter typeAdapter; + private List st_type = new ArrayList<>(); + private LinearLayout ll_equ; + + public static void actionStart(Context context, String pointid, String planid, String pointTaskid) { + Intent intent = new Intent(context, NewFaultActivity.class); + intent.putExtra("pointid", pointid); + intent.putExtra("planid", planid); + intent.putExtra("pointTaskid", pointTaskid); + context.startActivity(intent); + } + + public static void alarmStart(Context context, String des) { + Intent intent = new Intent(context, NewFaultActivity.class); + intent.putExtra("alarm", des); + context.startActivity(intent); + } + + private Handler handler = new Handler() { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { + case UPIMG: + photoPath(msg.obj.toString()); + break; + case SUCCESSSUB: + if (!NewFaultActivity.this.isFinishing()) { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("上传成功") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + break; + case FAILESUB: + if (!NewFaultActivity.this.isFinishing()) { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("异常上传失败,请重试!") + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + SubContent(); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + break; + case SUCCESS_RECEIVERS: + + break; + case FAILE_RECEIVERS: + if (!NewFaultActivity.this.isFinishing()) { +// showFailureReceiver(); + } + break; + } + } + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_new_fault); + init(); + initView(); + initNFC(); + getReceivers(); + } + + /** + * 获取厂区人员 + */ + private void getReceivers() { + HashMap map = new HashMap<>(); + map.put("unitId",mBizid); + map.put("search_name",""); + map.put("sort","id"); + map.put("type",sel_type); + OKHttpUtils.OKCall(map, mServer, MethodURL.GETPartUserList_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("人员列表获取失败,请重试!") + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getReceivers(); + } + }).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("html")){ + login("receiver"); + }else { + receivers = parseReceiver(res); + } + } + }); + } + + private List parseReceiver(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.getString("rows")); + for (int i=0;i map = new HashMap<>(); + map.put("j_username",mUsername); + map.put("j_password",mPwd); + map.put("androidId",androidId); + map.put("verCode","64368180"); + OKHttpUtils.OKCall(map,mServer,MethodURL.Login_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String result = GlobalVal.NET_ERROR; + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String result = response.body().string(); + Log.i("IPatrolService", "onResponse: "+result); + if (mark.equals("receiver")){ + getReceivers(); + } + } + }); + } + + private void initNFC() { + //nfc初始化 + pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, + getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); + ndef.addCategory("*/*"); + mFilters = new IntentFilter[]{ndef};// 过滤器 + mTechLists = new String[][]{ + new String[]{MifareClassic.class.getName()}, + new String[]{NfcA.class.getName()}};// 允许扫描的标签类型 + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("异常上报"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + tv_factory = findViewById(R.id.moudle_new_fault_tv_biz); + tv_factory.setText(mBizName); + ll_equ = findViewById(R.id.moudle_new_fault_ll_equ); + ll_equ.setVisibility(View.GONE); + sp_type = findViewById(R.id.moudle_new_fault_sp_type); + typeAdapter = new ArrayAdapter(NewFaultActivity.this,R.layout.item_spin,R.id.tv_sp,st_type); + sp_type.setAdapter(typeAdapter); + sp_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + if (position==0){ + sel_type = Type_Run; + ll_equ.setVisibility(View.GONE); + }else if(position==1){ + sel_type = Type_Equipment; + ll_equ.setVisibility(View.VISIBLE); + }else if(position==2){ + sel_type = Type_Facilities; + } + getReceivers(); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + tv_sub_man = findViewById(R.id.moudle_new_fault_tv_sub_man); + tv_sub_man.setText(mCaption); + tv_ps = findViewById(R.id.moudle_new_fault_tv_ps); + tv_ps.setOnClickListener(this); + tv_receiver = findViewById(R.id.moudle_new_fault_tv_receiver); + tv_receiver.setOnClickListener(this); + edt_fault_description = findViewById(R.id.moudle_new_fault_edt_fault_description); + if (alarm_description!=null&&alarm_description.length()>0){ + edt_fault_description.setText(alarm_description); + } + tv_equ_name = findViewById(R.id.moudle_new_fault_tv_equ_name); + tv_equ_cardno = findViewById(R.id.moudle_new_fault_tv_equ_cardno); + btn_sub = findViewById(R.id.moudle_new_fault_btn_sub); + btn_sub.setOnClickListener(this); + tv_sel_equ = findViewById(R.id.moudle_new_fault_tv_sel_equ); + tv_sel_equ.setOnClickListener(this); + edt_remark = findViewById(R.id.moudle_new_fault_edt_fault_remark); + gv_pic = findViewById(R.id.moudle_new_fault_gv_pic); + datas = new ArrayList<>(); + gridViewAddImgesAdpter = new GridViewAddImgesAdpter(datas, this); + gv_pic.setAdapter(gridViewAddImgesAdpter); + gv_pic.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int position, long id) { + showdialog(); + } + }); + tv_fault_description = findViewById(R.id.moudle_new_fault_tv_fault_description); +// tv_fault_description.setOnClickListener(this); + } + + private ProgressDialog myProgressDialog = null;//进度条 + + //显示进度提示 + public void showProgress(final String title, final String msg) { + runOnUiThread(new Runnable() { + @Override + public void run() { + try { + if (myProgressDialog != null) { + myProgressDialog.cancel(); + } + myProgressDialog = ProgressDialog.show(NewFaultActivity.this, title, msg); + myProgressDialog.setCancelable(true); + } catch (Exception e) { + } finally { + } + } + }); + } + + //取消进度提示 + public void cancelProgress() { + runOnUiThread(new Runnable() { + @Override + public void run() { + try { + if (myProgressDialog != null) { + myProgressDialog.dismiss(); + myProgressDialog.cancel(); + } + } catch (Exception e) { + } finally { + } + } + }); + } + + private void init() { + st_type = new ArrayList<>(); + st_type.add("运行异常"); + st_type.add("设备异常"); + st_type.add("设施异常"); + sel_type = Type_Run; + SharedPreferences sharedPre = this.getSharedPreferences("config", 0); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPwd=sharedPre.getString("password", ""); + androidId = Settings.System.getString( + getContentResolver(), Settings.Secure.ANDROID_ID);//10.0以后获取不到UUID,用androidId来代表唯一性 + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + mBizName = sharedPre.getString("bizname", ""); + token = sharedPre.getString("token", ""); + id = RandomStringUtils.getStrNumRandom(16); + if (getIntent().getStringExtra("planid") != null) { + planid = getIntent().getStringExtra("planid"); + } + if (getIntent().getStringExtra("pointid") != null) { + pointid = getIntent().getStringExtra("pointid"); + } + if (getIntent().getStringExtra("pointTaskid") != null) { + pid = getIntent().getStringExtra("pointTaskid"); + } + if (getIntent().getStringExtra("alarm") != null) { + alarm_description = getIntent().getStringExtra("alarm"); + } + } + + public void photoPath(String path) { + Map map = new HashMap<>(); + map.put("path", path); + datas.add(map); + gridViewAddImgesAdpter.notifyDataSetChanged(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + case SEND_RECEIVERS: + if (resultCode == RESULT_OK) { + sel_receivers = (List) data.getSerializableExtra("sel"); + String suser = ""; + st_sel_receiver_id = ""; + if (sel_receivers.size() > 0) { + for (int i = 0; i < sel_receivers.size(); i++) { + if (i == 0) { + suser = sel_receivers.get(i).getCaption(); + st_sel_receiver_id = sel_receivers.get(i).getId(); + } else if (0 0) { + showText(st,tv_receiver); + } + } + }); + } + break; + case SELCONTENT: + if (resultCode == RESULT_OK){ + String result = data.getStringExtra("sel"); + st_fault_content = st_fault_content+" "+result; + runOnUiThread(new Runnable() { + @Override + public void run() { + edt_fault_description.setText(st_fault_content); + } + }); + } + break; + case PHOTO_REQUEST_GALLERY: + if (resultCode == RESULT_OK) { + // 从相册返回的数据 + if (data != null) { + // 得到图片的全路径 + Uri uri = data.getData(); + String[] proj = {MediaStore.Images.Media.DATA}; + //好像是android多媒体数据库的封装接口,具体的看Android文档 + Cursor cursor = managedQuery(uri, proj, null, null, null); + //按我个人理解 这个是获得用户选择的图片的索引值 + int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); + //将光标移至开头 ,这个很重要,不小心很容易引起越界 + cursor.moveToFirst(); + //最后根据索引值获取图片路径 + String path = cursor.getString(column_index); + uploadImage(path); + } + } + break; + case PHOTO_REQUEST_CAREMA: + if (resultCode != RESULT_CANCELED) { + // 从相机返回的数据 + if (hasSdcard()) { + if (file_go != null) { + uploadImage(file_go.getPath()); + } else { + Toast.makeText(this, "相机异常请稍后再试!", Toast.LENGTH_SHORT).show(); + } + } else { + Toast.makeText(this, "未找到存储卡,无法存储照片!", Toast.LENGTH_SHORT).show(); + } + } + + break; + case SELEQU: + if (resultCode == RESULT_OK) { + sel_equ = (EquList) data.getSerializableExtra("equ"); + updateEquInfo(); + } + break; + case SELPS: + if (resultCode == RESULT_OK) { + sel_ps = (ProcessSection) data.getSerializableExtra("ps"); + updatePsInfo(); + } + break; + case SCANNIN_GREQUEST_CODE: + if (resultCode == RESULT_OK) { + Bundle bundle = data.getExtras(); + String result = bundle.getString("result"); + if (result != null && !result.isEmpty()) { + showinfobyNFC(result); + } else { + ErrorMessage(); + } + } + break; + } + } + + private void updatePsInfo() { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + tv_ps.setText(sel_ps.getName()); + } + }); + } + } + + private void updateEquInfo() { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + tv_equ_cardno.setText(sel_equ.getEquipmentcardid()); + tv_equ_name.setText(sel_equ.getEquipmentname()); + } + }); + } + } + + /** + * 压缩图片 + * + * @param path + */ + private void uploadImage(final String path) { + new Thread() { + @Override + public void run() { + if (new File(path).exists()) { + Log.d("images", "源文件存在" + path); + } else { + Log.d("images", "源文件不存在" + path); + } + + File dir = new File(IMAGE_DIR); + if (!dir.exists()) { + dir.mkdir(); + } + final File file = new File(dir + "/temp_photo" + System.currentTimeMillis() + ".jpg"); + NativeUtil.compressBitmap(path, file.getAbsolutePath(), 50); + if (file.exists()) { + Log.d("images", "压缩后的文件存在" + file.getAbsolutePath()); + } else { + Log.d("images", "压缩后的不存在" + file.getAbsolutePath()); + } + Message message = new Message(); + message.what = UPIMG; + message.obj = file.getAbsolutePath(); + handler.sendMessage(message); + + } + }.start(); + + } + + private void showText(final String st, final TextView tv) { + runOnUiThread(new Runnable() { + @Override + public void run() { + tv.setText(st); + } + }); + } + + private void ErrorMessage() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("二维码信息错误") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + isNFC_support = !(nfcAdapter == null || !nfcAdapter.isEnabled()); + if (isNFC_support) { + nfcAdapter.enableForegroundDispatch(this, pendingIntent, mFilters, + mTechLists); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) { + // 注意这个if中的代码几乎不会进来,因为刚刚在上一行代码开启了监听NFC连接,下一行代码马上就收到了NFC连接的intent,这种几率很小 + // 处理该intent + String result = processIntent(getIntent()); + if (result != null && !result.equals("error")) { + showinfobyNFC(result); + } + } + } + + } + + private Boolean isLongPressKey = false; + + public boolean onKeyDown(int keyCode, KeyEvent event) { + switch (keyCode) { + case KeyEvent.KEYCODE_VOLUME_UP: + if (event.getRepeatCount() == 0) { + event.startTracking(); + isLongPressKey = false; + } else { + isLongPressKey = true; + } + return true; + case KeyEvent.KEYCODE_VOLUME_DOWN: + Toast.makeText(this, "减小音量", Toast.LENGTH_SHORT).show(); + return false; + } + return super.onKeyDown(keyCode, event); + } + + @Override + protected void onPause() { + super.onPause(); + if (nfcAdapter != null && nfcAdapter.isEnabled()) { + // 当前Activity如果不在手机的最前端,就停止NFC设备连接的监听 + stopNFC_Listener(); + } + } + + private void stopNFC_Listener() { + // 停止监听NFC设备是否连接 + nfcAdapter.disableForegroundDispatch(this); + } + + @Override + protected void onNewIntent(Intent intent) { + // 当前app正在前端界面运行,这个时候有intent发送过来,那么系统就会调用onNewIntent回调方法,将intent传送过来 + // 我们只需要在这里检验这个intent是否是NFC相关的intent,如果是,就调用处理方法 + super.onNewIntent(intent); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { + String result = processIntent(intent); + if (result != null && !result.equals("error")) { + showinfobyNFC(result); + } + } + } + + private void showinfobyNFC(String id) { + searchEqu(id); + } + + /** + * 搜索设备 + * @param name + */ + private void searchEqu(String name) { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NewFaultActivity.this, "设备查询中...", Toast.LENGTH_LONG).show(); + } + }); + } + HashMap map = new HashMap<>(); + map.put("unitId",mBizid); + map.put("equipmentId",name); + map.put("search_name",""); + map.put("processSectionId",""); + map.put("rows","30"); + map.put("page","1"); + map.put("sort","id"); + map.put("order","desc"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEQULISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NewFaultActivity.this, "失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("total")&&res.contains("rows")) { + equLists = parseEqu(res); + } + if (equLists.size()>0){ + sel_equ = equLists.get(0); + updateEquInfo(); + }else { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NewFaultActivity.this, "失败:系统中暂未找到该设备!", Toast.LENGTH_LONG).show(); + } + }); + } + } + } + }); + } + + + private List parseEqu(String res) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = jsonObject.getJSONArray("rows"); + for (int i=0;i0) { + if (sel_type==Type_Equipment){ + if (sel_equ!=null&&!sel_equ.getId().isEmpty()){ + SubContent(); + }else { + showToast("设备不能为空"); + } + }else { + SubContent(); + } + + }else { + showToast("接收人不能为空"); + } + } else { + runOnUiThread(new Runnable() { + @Override + public void run() { + edt_fault_description.setError("不可为空"); + } + }); + } + break; + case R.id.moudle_new_fault_tv_receiver: + if (receivers.size() > 0) { + Intent intent_man = new Intent(NewFaultActivity.this, PersonSelectorActivity.class); + intent_man.putExtra("users", (Serializable) receivers); + startActivityForResult(intent_man, SEND_RECEIVERS); + } else { + if (!NewFaultActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("暂未配置接收人") + .show(); + } + }); + } + } + break; + case R.id.moudle_new_fault_tv_sel_equ: + Intent intent_sel_equ = new Intent(NewFaultActivity.this, SingleChoiceActivity.class); + intent_sel_equ.putExtra("mark","equ"); + if (sel_ps!=null) { + intent_sel_equ.putExtra("psId", sel_ps.getSid()); + } + startActivityForResult(intent_sel_equ, SELEQU); + break; + } + } + + private void showToast(String s) { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NewFaultActivity.this, s, Toast.LENGTH_LONG).show(); + } + }); + } + } + + private void noSetContent() { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("暂未配置异常内容列表,请配置后再选择!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + + private void SubContent() { + showProgress("", "数据上传中..."); + if (edt_remark.getText()!=null&&!edt_remark.getText().toString().isEmpty()){ + remark = edt_remark.getText().toString(); + } + HashMap map = new HashMap<>(); + map.put("id",id); + map.put("status", ""); + map.put("bizId",mBizid); + if (sel_ps!=null&&sel_ps.getSid()!=null) { + map.put("processSectionId", sel_ps.getSid()); + } + map.put("type", sel_type); + if (sel_equ!=null&&sel_equ.getId()!=null){ + map.put("equipmentIds", sel_equ.getId()); + map.put("equipname", sel_equ.getEquipmentname()); + } + map.put("libraryId", ""); + map.put("abnormityDescription", edt_fault_description.getText().toString()); + map.put("remark", remark); + map.put("solvername", sel_receivers.get(0).getCaption()); + map.put("receiveUserId", sel_receivers.get(0).getId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.SubFault_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + cancelProgress(); + Message message = new Message(); + message.what = FAILESUB; + handler.sendMessage(message); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.optString("res").toString().equals("1")){ + if (datas.size()>0) { + SubPic(); + }else { + cancelProgress(); + successSub(); + } + }else { + cancelProgress(); + Message message = new Message(); + message.what = FAILESUB; + handler.sendMessage(message); + } + } catch (JSONException e) { + e.printStackTrace(); + Message message = new Message(); + message.what = FAILESUB; + handler.sendMessage(message); + } + } + }); + } + + private void SubPic() { + HashMap map = new HashMap<>(); +// map.put("file_id",String.valueOf(datas.size())); + map.put("masterId",id); + map.put("tbName","tb_maintenance_problem_fille"); + map.put("nameSpace","maintenance"); + String picMark = "filelist"; + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpSubPics(map,mServer, MethodURL.SubPic_Method,picMark,datas)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + cancelProgress(); + picSubFail(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + cancelProgress(); + if (res.contains("suc")){ + successSub(); + }else { + picSubFail(); + } + } + }); + } + + private void picSubFail() { + if (!NewFaultActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("图片上传失败") + .setConfirmText("重新上传") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + SubPic(); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + private void successSub() { + if (!NewFaultActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("上传成功") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + /** + * 选择图片对话框 + */ + public void showdialog() { + View localView = LayoutInflater.from(this).inflate( + R.layout.dialog_add_picture, null); + TextView tv_camera = (TextView) localView.findViewById(R.id.tv_camera); + TextView tv_gallery = (TextView) localView.findViewById(R.id.tv_gallery); + TextView tv_cancel = (TextView) localView.findViewById(R.id.tv_cancel); + ddialog = new Dialog(this, R.style.custom_dialog); + ddialog.setContentView(localView); + ddialog.getWindow().setGravity(Gravity.BOTTOM); + // 设置全屏 + WindowManager windowManager = getWindowManager(); + Display display = windowManager.getDefaultDisplay(); + WindowManager.LayoutParams lp = ddialog.getWindow().getAttributes(); + lp.width = display.getWidth(); // 设置宽度 + ddialog.getWindow().setAttributes(lp); + ddialog.show(); + tv_cancel.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View arg0) { + ddialog.dismiss(); + } + }); + + tv_camera.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + ddialog.dismiss(); + // 拍照 + camera(); + } + }); + + tv_gallery.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + ddialog.dismiss(); + // 从系统相册选取照片 + gallery(); + } + }); + } + + + /** + * 拍照 + */ + public void camera() { + Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + try { + File file = createOriImageFile(); + file_go = file; + if (file != null) { + Uri imgUriOri = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID + ".fileProvider", file); + cameraIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);//设置Action为拍照 + cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imgUriOri); + startActivityForResult(cameraIntent, PHOTO_REQUEST_CAREMA); + } + } catch (IOException e) { + e.printStackTrace(); + } + } else { + if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { + if (!mars_file.exists()) { + mars_file.mkdirs(); + } + // 并设置拍照的存在方式为外部存储和存储的路径; + cameraIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);//设置Action为拍照 + cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file_go)); + //跳转到拍照界面; + startActivityForResult(cameraIntent, PHOTO_REQUEST_CAREMA); + } else { + Toast.makeText(NewFaultActivity.this, "请先安装好sd卡", Toast.LENGTH_LONG).show(); + } + } + } + + /** + * 创建原图像保存的文件 + * + * @return + * @throws IOException + */ + private File createOriImageFile() throws IOException { + String imgNameOri = "bk_" + new SimpleDateFormat( + "yyyyMMdd_HHmmss").format(new Date()); + File pictureDirOri = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath() + "/my_camera"); + if (!pictureDirOri.exists()) { + pictureDirOri.mkdirs(); + } + File image = File.createTempFile( + imgNameOri, /* prefix */ + ".jpg", /* suffix */ + pictureDirOri /* directory */ + ); + String imgPathOri = image.getAbsolutePath(); + return image; + } + + /** + * 判断sdcard是否被挂载 + */ + public boolean hasSdcard() { + return Environment.getExternalStorageState().equals( + Environment.MEDIA_MOUNTED); + } + + + /** + * 从相册获取2 + */ + public void gallery() { + Intent intent = new Intent( + Intent.ACTION_PICK, + MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + startActivityForResult(intent, PHOTO_REQUEST_GALLERY); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/NewFaultDetailActivity.java b/app/src/main/java/com/sipai/jspatrol/Fault/NewFaultDetailActivity.java new file mode 100644 index 0000000..7365e5d --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/NewFaultDetailActivity.java @@ -0,0 +1,638 @@ +package com.sipai.jspatrol.Fault; + +import android.app.DatePickerDialog; +import android.app.TimePickerDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.TimePicker; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.hitomi.tilibrary.transfer.TransferConfig; +import com.hitomi.tilibrary.transfer.Transferee; +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.Bean.Picture; +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.Fault.adapter.PicAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.vansz.glideimageloader.GlideImageLoader; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class NewFaultDetailActivity extends AppCompatActivity implements View.OnClickListener{ + private TextView tv_company,tv_processsection,tv_abnormitydescription,tv_remark,tv_equs,tv_sub_man,tv_sub_time; + private LinearLayout ll_equ; + private LinearLayout ll_todo;//生成缺陷 + private TextView tv_receiver,tv_fault_type; + private Spinner sp_dispose_type; + private String st_dispose_type; + private String is_make_todo = ""; + private String st_sel_receiver_id = ""; + private EditText edt_complete_date; + private Fault mfault; + private List receivers = new ArrayList<>(); + private List sel_receivers = new ArrayList<>(); + private static final int SEND_RECEIVERS = 131; + private Calendar cal; + private int year,month,day,hour,minute; + private String mseriverip; + private RecyclerView rc_pic; + private List pics = new ArrayList<>(); + private PicAdapter picAdapter; + private LinearLayoutManager stmanager; + private Button btn_sub; + private SweetAlertDialog pDialog; + private ImageView iv; + private Transferee transferee; + private EditText edt_planMoney; + private String planMoney = ""; + + + public static void actionStart(Context context, Fault fault, String todo){ + Intent intent = new Intent(context, NewFaultDetailActivity.class); + intent.putExtra("fault",fault); + intent.putExtra("todo",todo); + context.startActivity(intent); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_new_fault_detail); + init(); + getNowData(); + initView(); + initData(); + getPic(); + if (is_make_todo.equals("yes")){ + ll_todo.setVisibility(View.VISIBLE); + getReceiver(); + }else { + ll_todo.setVisibility(View.GONE); + } + } + + private void getPic() { + HashMap map = new HashMap<>(); + map.put("masterId",mfault.getId()); + map.put("tbName","tb_maintenance_problem_fille"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetFaultPics_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + loadPicFail(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pics = getPicData(res); + updatePic(); + } + }); + } + + private void loadPicFail(IOException e) { + if (!NewFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NewFaultDetailActivity.this, "图片获取失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void updatePic() { + if (!NewFaultDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (pics.size()>0) { + List ivUrls = new ArrayList<>(); + for (int i=0;i getPicData(String response) { + List list = new ArrayList<>(); + try { + JSONArray aNews = new JSONArray(response); + for (int i=0;i map = new HashMap<>(); + map.put("search_pid",mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETUSERLISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + if (!NewFaultDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("人员列表获取失败,请重试!") + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getReceiver(); + } + }).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + receivers = parseReceiver(res); + } + }); +// PersistentCookieStore myCookieStore = new PersistentCookieStore(this); +// RequestParams params = new RequestParams(); +// params.put("search_pid",mBizid); +// params.put("rows","1000"); +// AsyncHttpClient client = new AsyncHttpClient(); +// client.setCookieStore(myCookieStore); +// client.post(mServer+"user/getUsers.do?", params, new AsyncHttpResponseHandler() { +// @Override +// public void onSuccess(String response) { +// receivers = parseReceiver(response); +// } +// +// @Override +// public void onStart() { +// super.onStart(); +// } +// +// @Override +// public void onFinish() { +// super.onFinish(); +// } +// +// @Override +// public void onFailure(final Throwable error) { +// super.onFailure(error); +// +// } +// }); + } + + private List parseReceiver(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.getString("rows")); + for (int i=0;i0){ + runOnUiThread(new Runnable() { + @Override + public void run() { + tv_company.setText(mfault.getBiz().getName()); + tv_processsection.setText(mfault.getProcessSection().getName()); + tv_abnormitydescription.setText(mfault.getAbnormityDescription()); + tv_remark.setText(mfault.getRemark()); + tv_equs.setText(mfault.getEquipmentNames()); + tv_sub_man.setText(mfault.getInsuser()); + tv_sub_time.setText(mfault.getInsdt().substring(5, 16)); + } + }); + } + } + + private void initView(){ + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("异常详情"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setTitleText("数据上传中..."); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + tv_company = findViewById(R.id.moudle_new_fault_detail_tv_company); + tv_processsection = findViewById(R.id.moudle_new_fault_detail_tv_processsection); + tv_abnormitydescription = findViewById(R.id.moudle_new_fault_detail_tv_abnormitydescription); + tv_remark = findViewById(R.id.moudle_new_fault_detail_tv_remark); + ll_equ = findViewById(R.id.moudle_new_fault_detail_ll_equ); + tv_equs = findViewById(R.id.moudle_new_fault_detail_tv_equs); + tv_sub_man = findViewById(R.id.moudle_new_fault_detail_tv_sub_man); + tv_sub_time = findViewById(R.id.moudle_new_fault_detail_tv_sub_time); + ll_todo = findViewById(R.id.moudle_new_fault_detail_ll_todo); + sp_dispose_type = findViewById(R.id.moudle_new_fault_detail_sp); + final String[] repairtypes = getResources().getStringArray(R.array.dispose_type); + ArrayAdapter repairtypeAdapter = new ArrayAdapter(this, R.layout.item_normal_little_spin, R.id.moudle_normal_little_spin_tv_title, repairtypes); + sp_dispose_type.setAdapter(repairtypeAdapter); + sp_dispose_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + st_dispose_type = String.valueOf(position); + } + + @Override + public void onNothingSelected(AdapterView parent) { + st_dispose_type = "0"; + } + }); + edt_complete_date = findViewById(R.id.moudle_new_fault_detail_edt_complete_date); + edt_complete_date.setOnClickListener(this); + //在TextView上显示日期 + String smonth = ""; + String sday = ""; + String shour = ""; + String smin = "00"; + //在TextView上显示日期 + if (month<9){ + smonth = "0"+String.valueOf(month+1); + }else { + smonth = String.valueOf(month+1); + } + if (day<10){ + sday = "0"+String.valueOf(day); + }else { + sday = String.valueOf(day); + } + if (hour<10){ + shour = "0"+String.valueOf(hour); + }else { + shour = String.valueOf(hour); + } + transferee = Transferee.getDefault(this); + edt_complete_date.setText(year+"-"+smonth+"-"+sday+" "+shour+":"+"00:00"); + edt_complete_date.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + //创建DatePickerDialog对象 + if (event.getAction() == MotionEvent.ACTION_DOWN) { + DatePickerDialog dpd = new DatePickerDialog(NewFaultDetailActivity.this, Datelistener, year, month, day); + dpd.show();//显示DatePickerDialog组件 + } + return false; + } + }); + edt_planMoney = findViewById(R.id.moudle_new_fault_detail_edt_planMoney); + tv_receiver = findViewById(R.id.moudle_new_fault_detail_tv_receiver); + tv_receiver.setOnClickListener(this); + tv_fault_type = findViewById(R.id.moudle_new_fault_detail_tv_fault_type); + tv_fault_type.setOnClickListener(this); + btn_sub = findViewById(R.id.moudle_new_fault_detail_btn_sub); + btn_sub.setOnClickListener(this); + rc_pic = findViewById(R.id.moudle_new_fault_detail_rc_pic); +// picAdapter = new PicAdapter(pics,NewFaultDetailActivity.this); +// rc_pic.setAdapter(picAdapter); + stmanager = new LinearLayoutManager(NewFaultDetailActivity.this); + stmanager.setOrientation(LinearLayoutManager.HORIZONTAL); + rc_pic.setLayoutManager(stmanager); + } + + private DatePickerDialog.OnDateSetListener Datelistener=new DatePickerDialog.OnDateSetListener() + { + @Override + public void onDateSet(DatePicker view, int myyear, int monthOfYear, int dayOfMonth) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + year=myyear; + month=monthOfYear; + day=dayOfMonth; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + TimePickerDialog dpd=new TimePickerDialog(NewFaultDetailActivity.this,Timelistener,hour,minute,true); + dpd.show();//显示DatePickerDialog组件 + } + }; + private TimePickerDialog.OnTimeSetListener Timelistener=new TimePickerDialog.OnTimeSetListener() + { + @Override + public void onTimeSet(TimePicker view, int hours, int minutes) { + //修改year、month、day的变量值,以便以后单击按钮时,DatePickerDialog上显示上一次修改后的值 + hour=hours; + minute=minutes; + //更新日期 + updateDate(); + } + //当DatePickerDialog关闭时,更新日期显示 + private void updateDate() + { + //在TextView上显示日期 + String smonth = ""; + String sday = ""; + String shour = ""; + String smin = "00"; + //在TextView上显示日期 + if (month<9){ + smonth = "0"+String.valueOf(month+1); + }else { + smonth = String.valueOf(month+1); + } + if (day<10){ + sday = "0"+String.valueOf(day); + }else { + sday = String.valueOf(day); + } + if (hour<10){ + shour = "0"+String.valueOf(hour); + }else { + shour = String.valueOf(hour); + } + //在TextView上显示日期 + if(edt_complete_date.isFocused()){ + edt_complete_date.setText(year+"-"+smonth+"-"+sday+" "+shour+":"+"00:00"); + } + } + }; + + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private String mGroup; + private String role; + public void init(){ + SharedPreferences sharedPre=getSharedPreferences("config", MODE_PRIVATE); + role = sharedPre.getString("role",""); + mServer=sharedPre.getString("server", ""); + mseriverip=sharedPre.getString("serverip", ""); + mUsername=sharedPre.getString("username", ""); + mPassword=sharedPre.getString("password", ""); + mUserid=sharedPre.getString("userid", ""); + mCaption=sharedPre.getString("caption", ""); + mBizid=sharedPre.getString("bizid", ""); + mGroup=sharedPre.getString("group", ""); + mfault = (Fault) getIntent().getSerializableExtra("fault"); + is_make_todo = getIntent().getStringExtra("todo"); + } + + @Override + public void onClick(View view) { + switch (view.getId()){ + case R.id.moudle_new_fault_detail_edt_complete_date: + break; + case R.id.moudle_new_fault_detail_tv_receiver: + if (receivers.size()>0) { + Intent intent = new Intent(NewFaultDetailActivity.this, PersonSelectorActivity.class); + intent.putExtra("users", (Serializable) receivers); + startActivityForResult(intent,SEND_RECEIVERS); + }else { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("暂未配置接收人") + .show(); + } + }); + } + break; + case R.id.moudle_new_fault_detail_tv_fault_type: + break; + case R.id.moudle_new_fault_detail_btn_sub: + sub(); + break; + } + } + + private void pDialogHide() { + if (!NewFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.hide(); + } + }); + } + } + + private void pDialogshow() { + if (!NewFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.show(); + } + }); + } + } + + /* + 生成缺陷 + */ + private void sub() { + pDialogshow(); + if (edt_planMoney.getText()!=null&&!edt_planMoney.getText().toString().isEmpty()){ + planMoney = edt_planMoney.getText().toString(); + } + HashMap map = new HashMap<>(); + map.put("maintenanceWay",st_dispose_type); + map.put("plannedenddt",edt_complete_date.getText().toString()); + map.put("solver",st_sel_receiver_id); + map.put("planMoney",planMoney); + map.put("problemtypeid",""); + map.put("ids",mfault.getId()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.IssuedFault_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + pDialogHide(); + if (!NewFaultDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NewFaultDetailActivity.this, "生成缺陷失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pDialogHide(); + if (res.equals("1")||res.equals("2")){ + SubSuccess(); + }else { + SubFail(); + } + } + }); + } + + private void SubFail() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("上传失败,请重试") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + + private void SubSuccess() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(NewFaultDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("上传成功") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + case SEND_RECEIVERS: + if (resultCode == RESULT_OK) { + sel_receivers = (List) data.getSerializableExtra("sel"); + String suser = ""; + st_sel_receiver_id = ""; + if (sel_receivers.size() > 0) { + for (int i = 0; i < sel_receivers.size(); i++) { + if (i == 0) { + suser = sel_receivers.get(i).getCaption(); + st_sel_receiver_id = sel_receivers.get(i).getId(); + } else if (0 0) { + tv_receiver.setText(st); + } + } + }); + break; + } + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/PSSingleChoiceAdapter.java b/app/src/main/java/com/sipai/jspatrol/Fault/PSSingleChoiceAdapter.java new file mode 100644 index 0000000..e015eb3 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/PSSingleChoiceAdapter.java @@ -0,0 +1,71 @@ +package com.sipai.jspatrol.Fault; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.ProcessSection; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * Created by lvliming on 2018/7/22. + */ + +public class PSSingleChoiceAdapter extends RecyclerView.Adapter { + private Context mContext; + private List list; + private onRecyclerViewItemClick mOnRvItemClick; + + public PSSingleChoiceAdapter(Context mContext, List list, onRecyclerViewItemClick mOnRvItemClick) { + this.mContext = mContext; + this.list = list; + this.mOnRvItemClick = mOnRvItemClick; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_ps_single_choice,parent,false); + ViewHolder holder = new ViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + ProcessSection item = list.get(position); + holder.tv_name.setText(item.getName()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + View tview; + TextView tv_name; + public ViewHolder(View itemView) { + super(itemView); + tview = itemView; + tv_name = itemView.findViewById(R.id.moudle_item_ps_single_choice_tv_name); + tview.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (mOnRvItemClick != null) + mOnRvItemClick.onItemClick(v, getAdapterPosition()); + } + } + /** + * item点击接口 + */ + public interface onRecyclerViewItemClick { + void onItemClick(View v, int position); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/PersonSelectorActivity.java b/app/src/main/java/com/sipai/jspatrol/Fault/PersonSelectorActivity.java new file mode 100644 index 0000000..29f7dc7 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/PersonSelectorActivity.java @@ -0,0 +1,152 @@ +package com.sipai.jspatrol.Fault; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.Fault.adapter.PersonSelectorAdapter; +import com.sipai.jspatrol.R; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class PersonSelectorActivity extends AppCompatActivity { + private List users = new ArrayList<>(); + private List search_users = new ArrayList<>(); + private List sel_users = new ArrayList<>(); + private RecyclerView rc_view; + private PersonSelectorAdapter adapter; + private LinearLayoutManager manager; + private ImageView iv_search; + private EditText edt_name; + private String sel_mark; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_person_selector); + init(); + initView(); + } + + private void initView() { + ImageView btn_back = (ImageView) findViewById(R.id.moudle_ps_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + TextView tv_save = (TextView) findViewById(R.id.moudle_ps_tv_save); + tv_save.setText("保存"); + tv_save.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + sel_users.clear(); + Map map1 = adapter.getMap(); + for (int i = map1.size()-1; 0<=i; i--) { + if (map1.get(i)) { + Log.d("TAG", "你选了第:" + i + "项"); + if (sel_mark.equals("all")) { + sel_users.add(users.get(i)); + }else { + sel_users.add(search_users.get(i)); + } + } + } + Intent intent = new Intent(); + intent.putExtra("sel", (Serializable) sel_users); + setResult(RESULT_OK,intent); + finish(); + } + }); + iv_search = findViewById(R.id.moudle_ps_iv_search); + edt_name = findViewById(R.id.moudle_ps_edt_name); + edt_name.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (!s.toString().isEmpty()) { + checkUsers(String.valueOf(s)); + }else { + showAll(); + } + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + rc_view = findViewById(R.id.moudle_person_selector_rc); + adapter = new PersonSelectorAdapter(users,PersonSelectorActivity.this); + rc_view.setAdapter(adapter); + manager = new LinearLayoutManager(this); + rc_view.setLayoutManager(manager); + sel_mark = "all"; + } + + private void showAll() { + if (!PersonSelectorActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + sel_mark = "all"; + adapter = new PersonSelectorAdapter(users,PersonSelectorActivity.this); + rc_view.setAdapter(adapter); + } + }); + } + } + + private void checkUsers(String s) { + search_users = new ArrayList<>(); + for (int i=0;i) getIntent().getSerializableExtra("users"); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/SingleChoiceActivity.java b/app/src/main/java/com/sipai/jspatrol/Fault/SingleChoiceActivity.java new file mode 100644 index 0000000..ae57447 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/SingleChoiceActivity.java @@ -0,0 +1,355 @@ +package com.sipai.jspatrol.Fault; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.Bean.ProcessSection; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class SingleChoiceActivity extends AppCompatActivity implements View.OnClickListener { + private ImageView iv_back; + private EditText edt_name; + private TextView tv_search; + private String mark = ""; + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid, mBizName; + private String name = ""; + private String sel_ps_id = ""; + private RecyclerView rc_list; + private SwipeRefreshLayout refreshLayout; + private List equLists = new ArrayList<>(); + private PSSingleChoiceAdapter psAdapter; + private EquSingleChoiceAdapter equAdapter; + private LinearLayoutManager manager; + private List processSections = new ArrayList<>(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_single_choice); + init(); + initView(); + startSearch(); + } + + private void initView() { + iv_back = findViewById(R.id.moudle_single_choice_iv_back); + iv_back.setOnClickListener(this); + edt_name = findViewById(R.id.moudle_single_choice_edt_equname); + tv_search = findViewById(R.id.moudle_single_choice_tv_search); + tv_search.setOnClickListener(this); + rc_list = findViewById(R.id.moudle_single_choice_rc); + refreshLayout = findViewById(R.id.moudle_single_choice_refresh); + refreshLayout.setColorSchemeResources(R.color.blue); + refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + startSearch(); + } + }); + } + + private void init() { + SharedPreferences sharedPre = this.getSharedPreferences("config", 0); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + mBizName = sharedPre.getString("bizname", ""); + if (getIntent().getStringExtra("mark")!=null&&!getIntent().getStringExtra("mark").isEmpty()){ + mark = getIntent().getStringExtra("mark"); + } + if (getIntent().getStringExtra("psId")!=null&&!getIntent().getStringExtra("psId").isEmpty()){ + sel_ps_id = getIntent().getStringExtra("psId"); + } + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_single_choice_iv_back: + finish(); + break; + case R.id.moudle_single_choice_tv_search: + startSearch(); + break; + } + } + + private void startSearch() { + if (edt_name.getText()!=null&&!edt_name.getText().toString().isEmpty()){ + name = edt_name.getText().toString(); + } + judgeRefresh(); + if (mark.equals("equ")) { + searchEqu(name); + }else if(mark.equals("ps")){ + searchPS(name); + } + } + + private void judgeRefresh() { + if (!SingleChoiceActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!refreshLayout.isRefreshing()){ + refreshLayout.setRefreshing(true); + } + } + }); + } + } + + /** + * 搜索工艺段 + * @param name + */ + private void searchPS(String name) { + HashMap map = new HashMap<>(); + map.put("search_code",mBizid); + map.put("search_name",name); + map.put("rows","300"); + map.put("page","1"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETPSLISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!SingleChoiceActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + Toast.makeText(SingleChoiceActivity.this, "失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("total")&&res.contains("rows")) { + processSections = parsePS(res); + } + updatePSList(); + } + }); + } + + private void updatePSList() { + if (!SingleChoiceActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + psAdapter = new PSSingleChoiceAdapter(SingleChoiceActivity.this, processSections, new PSSingleChoiceAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + Intent intent = new Intent(); + intent.putExtra("ps",processSections.get(position)); + setResult(RESULT_OK,intent); + finish(); + } + }); + rc_list.setAdapter(psAdapter); + manager = new LinearLayoutManager(SingleChoiceActivity.this); + rc_list.setLayoutManager(manager); + } + }); + } + } + + private List parsePS(String res) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = jsonObject.getJSONArray("rows"); + for (int i=0;i map = new HashMap<>(); + map.put("companyId",mBizid); + map.put("equipmentName",name); + map.put("processSectionId",sel_ps_id); + map.put("rows","30"); + map.put("page","1"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETEQULISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!SingleChoiceActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + Toast.makeText(SingleChoiceActivity.this, "失败:" + e.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("total")&&res.contains("rows")) { + equLists = parseEqu(res); + } + updateEquList(); + } + }); + } + + private void updateEquList() { + if (!SingleChoiceActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + equAdapter = new EquSingleChoiceAdapter(SingleChoiceActivity.this, equLists, new EquSingleChoiceAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + Intent intent = new Intent(); + intent.putExtra("ppid",equLists.get(position).getId()); + intent.putExtra("class","equ"); + intent.putExtra("equ",equLists.get(position)); + setResult(RESULT_OK,intent); + finish(); + } + }); + rc_list.setAdapter(equAdapter); + manager = new LinearLayoutManager(SingleChoiceActivity.this); + rc_list.setLayoutManager(manager); + } + }); + } + } + + private List parseEqu(String res) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = jsonObject.getJSONArray("rows"); + for (int i=0;i points = new ArrayList<>(); + for (int a=0;a { + private List data; + private Context context; + private onSwipeListener mOnSwipeListener; + + public DoingFaultAdapter(Context context, List data) { + super(context, data); + this.data = data; + this.context = context; + } + + @Override + protected void convert(final BaseViewHolder holder, Fault item, final int position) { + item = data.get(position); + ((SwipeMenuLayout)holder.itemView).setIos(false).setLeftSwipe(true); + final Fault finalItem = item; + holder.setOnClickListener(R.id.moudle_item_doing_fault_ll_all, new View.OnClickListener() { + @Override + public void onClick(View view) { + if (finalItem.getTodoTask()!=null) { + if (finalItem.getTodoTask().contains("维修确认")) { +// Toast.makeText(context, "工单验收完善中,敬请期待...", Toast.LENGTH_SHORT).show(); + FaultFlowChartActivity.actionStart(context, finalItem); + } else { +// if (finalItem.getTodoTask().contains("维修确认")||finalItem.getTodoTask().contains("班长")){ +//// Toast.makeText(context, "工单审核中...", Toast.LENGTH_SHORT).show(); +// FaultFlowChartActivity.actionStart(context, finalItem); +// }else { + DoingFaultDetailActivity.actionStart(context, finalItem); +// } + } + } + } + }); + if (item.getProcessSection().getName()!=null&&!item.getProcessSection().getName().equals("")){ + holder.setVisible(R.id.moudle_item_doing_fault_tv_area,true); + holder.setText(R.id.moudle_item_doing_fault_tv_area,item.getProcessSection().getName()); + }else { + holder.setVisible(R.id.moudle_item_doing_fault_tv_area,false); + } + if (item.getProblemcontent()!=null&&!item.getProblemcontent().isEmpty()) { + holder.setText(R.id.moudle_item_doing_fault_tv_content, item.getProblemcontent()); + }else { + holder.setText(R.id.moudle_item_doing_fault_tv_content, ""); + } + if (item.getProblemTypeNames()!=null&&item.getProblemTypeNames().length()>0) { + holder.setText(R.id.moudle_item_doing_fault_tv_remark,item.getProblemTypeNames()); + }else { + holder.setVisible(R.id.moudle_item_doing_fault_tv_remark,false); + } + if (item.getEquipmentCard()!=null&&!item.getEquipmentCard().getEquipmentname().equals("")){ + holder.setVisible(R.id.moudle_item_doing_fault_tv_equ,true); + holder.setText(R.id.moudle_item_doing_fault_tv_equ,item.getEquipmentCard().getEquipmentname()); + }else { + holder.setVisible(R.id.moudle_item_doing_fault_tv_equ,false); + } + if (item.getInsdt()!=null&&item.getInsdt().length()>16) { + holder.setText(R.id.moudle_item_doing_fault_tv_date,item.getInsdt().substring(5, 16)); + }else { + holder.setText(R.id.moudle_item_doing_fault_tv_date,""); + } + if (item.getInsuser()!=null&&!item.getInsuser().isEmpty()) { + holder.setText(R.id.moudle_item_doing_fault_tv_man, item.getInsuser()); + }else { + holder.setText(R.id.moudle_item_doing_fault_tv_man, ""); + } + if (item.getTodoTask()!=null) { + if (item.getTodoTask().equals("待签收")) { + holder.setText(R.id.moudle_item_doing_fault_tv_todotask, item.getTodoTask()); + holder.setTextColor(R.id.moudle_item_doing_fault_tv_todotask, context.getResources().getColor(R.color.error_red)); +// holder.setVisible(R.id.moudle_item_doing_fault_btn_make_fault, false); + } else { + holder.setText(R.id.moudle_item_doing_fault_tv_todotask, item.getTodoTask()); + } + } +// holder.setOnClickListener(R.id.moudle_item_doing_fault_btn_make_fault, new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// if (null!=mOnSwipeListener){ +// mOnSwipeListener.onFault(position); +// ((SwipeMenuLayout) holder.itemView).smoothClose(); +// } +// } +// }); +// holder.setOnClickListener(R.id.moudle_item_doing_fault_btn_delete, new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// if (null!=mOnSwipeListener){ +// mOnSwipeListener.onDel(position); +// ((SwipeMenuLayout) holder.itemView).smoothClose(); +// } +// } +// }); + } + + @Override + protected int getItemViewLayoutId(int position, Fault item) { + return R.layout.item_doing_fault; + } + + /** + * 和Activity通信的接口 + */ + public interface onSwipeListener { + void onFault(int pos); + + void onDel(int pos); + } + + public onSwipeListener getOnDelListener() { + return mOnSwipeListener; + } + + public void setOnDelListener(onSwipeListener mOnDelListener) { + this.mOnSwipeListener = mOnDelListener; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/adapter/DoneFaultAdapter.java b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/DoneFaultAdapter.java new file mode 100644 index 0000000..99324d1 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/DoneFaultAdapter.java @@ -0,0 +1,72 @@ +package com.sipai.jspatrol.Fault.adapter; + +import android.content.Context; +import android.view.View; + +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.Fault.FaultFlowChartActivity; +import com.sipai.jspatrol.R; +import com.superrecycleview.superlibrary.adapter.BaseViewHolder; +import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter; + +import java.util.List; + +/** + * Created by lvliming on 2019/3/19. + */ + +public class DoneFaultAdapter extends SuperBaseAdapter { + private List data; + private Context context; + + public DoneFaultAdapter(Context context, List data) { + super(context, data); + this.data = data; + this.context = context; + } + + @Override + protected void convert(BaseViewHolder holder, Fault item, final int position) { + item = data.get(position); + final Fault finalItem = item; + holder.setOnClickListener(R.id.moudle_item_done_fault_ll_all, new View.OnClickListener() { + @Override + public void onClick(View view) { +// DoneFaultActivity.actionStart(context,finalItem); +// Toast.makeText(context, "工单详情完善中,敬请期待...", Toast.LENGTH_SHORT).show(); + FaultFlowChartActivity.actionStart(context, finalItem); + } + }); + if (item.getProcessSection().getName()!=null&&!item.getProcessSection().getName().equals("")){ + holder.setVisible(R.id.moudle_item_done_fault_tv_area,true); + holder.setVisible(R.id.moudle_item_done_fault_ll_area,true); + holder.setText(R.id.moudle_item_done_fault_tv_area,item.getProcessSection().getName()); + }else { + holder.setVisible(R.id.moudle_item_done_fault_ll_area,false); + holder.setVisible(R.id.moudle_item_done_fault_tv_area,false); + } + holder.setText(R.id.moudle_item_done_fault_tv_content,item.getProblemcontent()); + if (item.getProblemTypeNames()!=null&&item.getProblemTypeNames().length()>0) { + holder.setText(R.id.moudle_item_done_fault_tv_remark,item.getProblemTypeNames()); + }else { + holder.setVisible(R.id.moudle_item_done_fault_tv_remark,false); + } + if (item.getEquipmentCard()!=null&&!item.getEquipmentCard().getEquipmentname().equals("")){ + holder.setVisible(R.id.moudle_item_done_fault_tv_equ,true); + holder.setText(R.id.moudle_item_done_fault_tv_equ,item.getEquipmentCard().getEquipmentname()); + }else { + holder.setVisible(R.id.moudle_item_done_fault_tv_equ,false); + } + if (item.getInsdt().length()>16) { + holder.setText(R.id.moudle_item_done_fault_tv_date,item.getInsdt().substring(5, 16)); + }else { + holder.setText(R.id.moudle_item_done_fault_tv_date,""); + } + holder.setText(R.id.moudle_item_done_fault_tv_man,item.getInsuser()); + } + + @Override + protected int getItemViewLayoutId(int position, Fault item) { + return R.layout.item_done_fault; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/adapter/FaultFlowAdapter.java b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/FaultFlowAdapter.java new file mode 100644 index 0000000..1db72a4 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/FaultFlowAdapter.java @@ -0,0 +1,39 @@ +package com.sipai.jspatrol.Fault.adapter; + +import android.content.Context; + +import com.sipai.jspatrol.Bean.FaultFlow; +import com.sipai.jspatrol.R; +import com.superrecycleview.superlibrary.adapter.BaseViewHolder; +import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter; + +import java.util.List; + +/** + * created by lvliming on 2020/12/14 + */ +public class FaultFlowAdapter extends SuperBaseAdapter { + private Context context; + private List list; + + public FaultFlowAdapter(Context context, List data) { + super(context, data); + this.context = context; + this.list = data; + } + + @Override + protected void convert(BaseViewHolder holder, FaultFlow item, int position) { + item = list.get(position); + holder.setText(R.id.moudle_item_fault_flow_tv_num,String.valueOf(position+1)); + holder.setText(R.id.moudle_item_fault_flow_tv_title,item.getTaskName()); + holder.setText(R.id.moudle_item_fault_flow_tv_content,item.getRecord()); + holder.setText(R.id.moudle_item_fault_flow_tv_time,item.getInsdt()); +// holder.setText(R.id.moudle_item_fault_flow_tv_num,String.valueOf(position+1)); + } + + @Override + protected int getItemViewLayoutId(int position, FaultFlow item) { + return R.layout.item_fault_flow; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/adapter/NewFaultAdapter.java b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/NewFaultAdapter.java new file mode 100644 index 0000000..36fd98c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/NewFaultAdapter.java @@ -0,0 +1,98 @@ +package com.sipai.jspatrol.Fault.adapter; + +import android.content.Context; +import android.view.View; + +import com.mcxtzhang.swipemenulib.SwipeMenuLayout; +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.Fault.NewFaultDetailActivity; +import com.sipai.jspatrol.R; +import com.superrecycleview.superlibrary.adapter.BaseViewHolder; +import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter; + +import java.util.List; + +/** + * Created by lvliming on 2019/2/27. + */ + +public class NewFaultAdapter extends SuperBaseAdapter { + private List data; + private Context context; + private onSwipeListener mOnSwipeListener; + + public NewFaultAdapter(Context context, List data) { + super(context, data); + this.data = data; + this.context = context; + } + + @Override + protected void convert(final BaseViewHolder holder, Fault item, final int position) { + item = data.get(position); + ((SwipeMenuLayout)holder.itemView).setIos(false).setLeftSwipe(true); + final Fault finalItem = item; + holder.setOnClickListener(R.id.moudle_item_new_fault_ll_all, new View.OnClickListener() { + @Override + public void onClick(View view) { + NewFaultDetailActivity.actionStart(context,finalItem,"no"); + } + }); + holder.setText(R.id.moudle_item_new_fault_tv_area,item.getProcessSection().getName()); + holder.setText(R.id.moudle_item_new_fault_tv_content,item.getAbnormityDescription()); + if (item.getRemark()!=null&&item.getRemark().length()>0) { + holder.setText(R.id.moudle_item_new_fault_tv_remark,item.getRemark()); + }else { + holder.setVisible(R.id.moudle_item_new_fault_tv_remark,false); + } + if (item.getEquipmentNames()!=null){ + holder.setText(R.id.moudle_item_new_fault_tv_equ,item.getEquipmentNames()); + } + if (item.getInsdt().length()>16) { + holder.setText(R.id.moudle_item_new_fault_tv_date,item.getInsdt().substring(5, 16)); + }else { + holder.setText(R.id.moudle_item_new_fault_tv_date,""); + } + holder.setText(R.id.moudle_item_new_fault_tv_man,item.getInsuser()); + holder.setOnClickListener(R.id.moudle_item_new_fault_btn_make_fault, new View.OnClickListener() { + @Override + public void onClick(View view) { + if (null!=mOnSwipeListener){ + mOnSwipeListener.onFault(position); + ((SwipeMenuLayout) holder.itemView).smoothClose(); + } + } + }); + holder.setOnClickListener(R.id.moudle_item_new_fault_btn_delete, new View.OnClickListener() { + @Override + public void onClick(View view) { + if (null!=mOnSwipeListener){ + mOnSwipeListener.onDel(position); + ((SwipeMenuLayout) holder.itemView).smoothClose(); + } + } + }); + } + + /** + * 和Activity通信的接口 + */ + public interface onSwipeListener { + void onFault(int pos); + + void onDel(int pos); + } + + public onSwipeListener getOnDelListener() { + return mOnSwipeListener; + } + + public void setOnDelListener(onSwipeListener mOnDelListener) { + this.mOnSwipeListener = mOnDelListener; + } + + @Override + protected int getItemViewLayoutId(int position, Fault item) { + return R.layout.item_new_fault; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/adapter/PersonSelectorAdapter.java b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/PersonSelectorAdapter.java new file mode 100644 index 0000000..01e265e --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/PersonSelectorAdapter.java @@ -0,0 +1,147 @@ +package com.sipai.jspatrol.Fault.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.R; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by lvliming on 2019/3/24. + */ + +public class PersonSelectorAdapter extends RecyclerView.Adapter implements View.OnClickListener{ + //数据源 + private List list; + private Context context; + //是否显示单选框 + private boolean isshowBox = true; + //存储勾选框状态的map集合 + private Map map = new HashMap<>(); + //接口实例 + private RecyclerViewOnItemClickListener onItemClickListener; + + public PersonSelectorAdapter(List list, Context context) { + this.list = list; + this.context = context; + initMap(); + } + //初始化map集合,默认不选中 + private void initMap() { + for (int i=0;i getMap() { + return map; + } + + //接口回调设置点击事件 + public interface RecyclerViewOnItemClickListener { + //点击事件 + void onItemClickListener(View view, int position); + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Fault/adapter/PicAdapter.java b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/PicAdapter.java new file mode 100644 index 0000000..8825feb --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Fault/adapter/PicAdapter.java @@ -0,0 +1,80 @@ +package com.sipai.jspatrol.Fault.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.bumptech.glide.Glide; +import com.sipai.jspatrol.Bean.Picture; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * Created by lvliming on 2019/3/25. + */ + +public class PicAdapter extends RecyclerView.Adapter { + private List list; + private Context context; + private PicAdapterOnClickListener mlistener; + + public PicAdapter(List list, Context context, PicAdapterOnClickListener listener) { + this.list = list; + this.context = context; + this.mlistener = listener; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_show_pic,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); +// viewHolder.pic.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// int position = viewHolder.getAdapterPosition(); +// Intent intent = new Intent(context,PictureDetailActivity.class); +// intent.putExtra("url",list.get(position).getAbspath()); +// context.startActivity(intent); +// } +// }); + return viewHolder; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + Picture item = list.get(position); + Glide.with(context).load(item.getAbspath()).into(holder.iv); + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + ImageView iv; + View pic; + public ViewHolder(View itemView) { + super(itemView); + pic = itemView; + iv = itemView.findViewById(R.id.moudle_item_show_pic_iv); + iv.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (mlistener!=null){ + mlistener.onItemClick(v,getAdapterPosition()); + } + } + } + + public interface PicAdapterOnClickListener{ + void onItemClick(View v,int position); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Flutter/FlutterTestActivity.java b/app/src/main/java/com/sipai/jspatrol/Flutter/FlutterTestActivity.java new file mode 100644 index 0000000..f2a5044 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Flutter/FlutterTestActivity.java @@ -0,0 +1,24 @@ +package com.sipai.jspatrol.Flutter; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.widget.FrameLayout; + + +public class FlutterTestActivity extends AppCompatActivity { + private FrameLayout fl; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // 通过FlutterView引入Flutter编写的页面 +// View flutterView = Flutter.createView(this, getLifecycle(), "调转"); +// FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); +// addContentView(flutterView, layout); + +// FragmentTransaction tx = getSupportFragmentManager().beginTransaction(); +// tx.replace(R.id.fl_container,Flutter.createFragment("调转")); +// tx.commit(); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Loading/LoadingActivity.java b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingActivity.java new file mode 100644 index 0000000..de20753 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingActivity.java @@ -0,0 +1,675 @@ +package com.sipai.jspatrol.Loading; + +import android.Manifest; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.database.sqlite.SQLiteDatabase; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.util.Log; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.core.content.FileProvider; + +import com.sipai.jspatrol.Base.ActivityCollector; +import com.sipai.jspatrol.Base.BaseView; +import com.sipai.jspatrol.Bean.Biz; +import com.sipai.jspatrol.Bean.LoginInfo; +import com.sipai.jspatrol.BuildConfig; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.Login.LoginActivity; +import com.sipai.jspatrol.Main.MainActivity; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.EncryptUtils; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.RandomStringUtils; +import com.sipai.jspatrol.utils.SharedPreferencesData; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.litepal.LitePal; +import org.xutils.x; + +import java.io.File; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class LoadingActivity extends BaseView { + + private String mServer; + private String mServerIP; + private String mUserid; + private String mPwd; + private String mBizid; + private String mBizName; + private String mUsername; + private String lcversion; + private String androidId = ""; + private String apkname, vercod; + private ProgressDialog progressDialog; + private String BASE_URL = "CPELM_APK/"; + private String Nowurl = ""; + private String[] permissions = {Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.INTERNET, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE}; + List mPermissionList = new ArrayList<>(); + private final int mRequestCode = 100;//权限请求码 + private static final int GET_UNKNOWN_APP_SOURCES = 321; + private static final int RESULT_PRE = 123; + private HashMap map = new HashMap<>(); + private int times = 0; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_loading); + ActivityCollector.addActivity(this); + init(); +// SQLiteDatabase db = LitePal.getDatabase(); + } + + @Override + protected void onResume() { + super.onResume(); + initPermissions(); + } + + @Override + protected LoadingPresenter getPresenter() { + return new LoadingPresenter(); + } + + @Override + public LoadingContract.View getContract() { + return new LoadingContract.View() { + @Override + public void handlerResult(LoginInfo item) { + if (item != null) { + if (item.isStatus()) { + saveLoginInfo(item); +// registerXG(); + getComList(item); + } else { + ToLogin(); + } + } else { + ToLogin(); + } + } + + @Override + public void handlerComResult(String result, String t) { + if (result.equals(GlobalVal.RESULT_SUCCESS)) { + List bizs = parseBiz(t); + if (bizs.size() > 0) { + if (bizs.size()==1){ + mBizid = bizs.get(0).getBizid(); + mBizName = bizs.get(0).getName(); + }else if (mBizName==null||mBizName.isEmpty()){ + mBizid = bizs.get(0).getBizid(); + mBizName = bizs.get(0).getName(); + } + } + saveBizlist(LoadingActivity.this, "response", mBizid, mBizName, t); + MainActivity.actionStart(LoadingActivity.this); + finish(); + } else { + ToLogin(); + } + } + }; + } + + + private List parseBiz(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i = 0; i < array.length(); i++) { + Biz item = new Biz(); + item.setId(array.getJSONObject(i).optString("id")); + item.setBizid(array.getJSONObject(i).optString("id")); + item.setName(array.getJSONObject(i).optString("text")); + if (item.getName().contains("一车")){ + mBizid = item.getBizid(); + mBizName = item.getName(); + } + list.add(item); + } + } catch (JSONException e) { + e.printStackTrace(); + return list; + } + return list; + } + + private void getComList(LoginInfo item) { + map = new HashMap<>(); + p.getContract().requestComList(LoadingActivity.this, map, mServer, MethodURL.ComList_Method, item.getUser().getToken()); + } + + private void saveBizlist(Context context, String response, String bizid, String bizname, String t) { + //获取SharedPreferences对象 + SharedPreferences sharedPre = context.getSharedPreferences("config", MODE_PRIVATE); + //获取Editor对象 + SharedPreferences.Editor editor = sharedPre.edit(); + editor.putString("bizlist", response); + editor.putString("bizid", bizid); + editor.putString("bizname", bizname); + editor.putString("biz", t); + //提交 + editor.commit(); + } + + private void saveLoginInfo(LoginInfo item) { + SharedPreferencesData sharedPreferencesData = new SharedPreferencesData(this); + Map map = new HashMap<>(); + map.put("userid", item.getUser().getId()); + map.put("caption", item.getUser().getCaption()); + map.put("name", item.getUser().getName()); + map.put("totaltime", String.valueOf(Math.round(item.getUser().getTotaltime()))); + map.put("lastlogintime", item.getUser().getLastlogintime()); + map.put("nfc", item.getUser().getNfc()); + map.put("subtask", item.getUser().getSubTask()); + sharedPreferencesData.saveInfo(map); + } + + private void init() { + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + mServer = sharedPre.getString("server", ""); + mServerIP = sharedPre.getString("serverip", ""); + mUserid = sharedPre.getString("userid", ""); + mPwd = sharedPre.getString("password", ""); + mBizid = sharedPre.getString("bizid", ""); + mBizName = sharedPre.getString("bizname", ""); + mUsername = sharedPre.getString("username", ""); + lcversion = getLocalVersionName(this); + TelephonyManager tm = (TelephonyManager) LoadingActivity.this.getSystemService(TELEPHONY_SERVICE); +// mtyb = android.os.Build.BRAND;// 手机品牌 +// mtype = android.os.Build.MODEL; // 手机型号 +// imei = tm.getDeviceId();//uuid + androidId = Settings.System.getString( + getContentResolver(), Settings.Secure.ANDROID_ID);//10.0以后获取不到UUID,用androidId来代表唯一性 + } + + private void check() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (!Settings.canDrawOverlays(this)) { + if (!LoadingActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); + startActivityForResult(intent, 350); + } + }); + } + } else { + final int nWelcomeScreenDisplay = 1000; + if (mServer != null && !mServer.isEmpty()) { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + checkAPKVersion(); + } + }, nWelcomeScreenDisplay); + } else { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ToLogin(); + } + }, nWelcomeScreenDisplay); + } + } + + } else { + final int nWelcomeScreenDisplay = 1000; + if (mServer != null && !mServer.isEmpty()) { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + checkAPKVersion(); +// login(); + } + }, nWelcomeScreenDisplay); + } else { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ToLogin(); + } + }, nWelcomeScreenDisplay); + } + } + } + + /** + * 检测服务器APK版本 + */ + private void checkAPKVersion() { + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.Check_Apk_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + login(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(res); + if (res != null && !res.isEmpty()) { + apkname = jsonObject.getString("ApkName"); + int ind = apkname.lastIndexOf("-"); + int end = apkname.lastIndexOf("."); + vercod = apkname.substring(ind + 1, end); + BASE_URL = getString(R.string.appflag) + "_APK/"; + Nowurl = mServer + BASE_URL + apkname; + if (Double.valueOf(lcversion) < Double.valueOf(vercod)) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(LoadingActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到有新版本,是否更新?") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + String path = Environment.getExternalStorageDirectory() + "/" + getString(R.string.appflag) + "/" + getString(R.string.appflag) + "_APK/"; + downloadFile(Nowurl, path); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + login(); + } + }).show(); + + } + }); + + } else { + login(); + } + } + } catch (Exception e) { + login(); + } + } + }); + } + + private void downloadFile(String nowurl, String path) { + File filep = new File(path); + if (!filep.exists()) { + filep.mkdirs(); + } + filep = null; + progressDialog = new ProgressDialog(this); + org.xutils.http.RequestParams requestParams = new org.xutils.http.RequestParams(nowurl); + requestParams.setAutoRename(false); + requestParams.setSaveFilePath(path + apkname); + x.http().get(requestParams, new org.xutils.common.Callback.ProgressCallback() { + @Override + public void onWaiting() { + } + + @Override + public void onStarted() { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(LoadingActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + + } + + @Override + public void onLoading(long total, long current, boolean isDownloading) { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + progressDialog.setProgressNumberFormat(""); + + progressDialog.setMax((int) total); + progressDialog.setProgress((int) current); + } + + + @Override + public void onSuccess(File result) { + Toast.makeText(LoadingActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + //下载成功,file为下载好的APk文件 + File file = result; + Log.d("xutil", "下载成功"); + //安装apk的方法 + installAPK(file); + } + + @Override + public void onError(Throwable ex, boolean isOnCallback) { + ex.printStackTrace(); + Toast.makeText(LoadingActivity.this, "下载失败,请检查网络和SD卡", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + login(); + } + + @Override + public void onCancelled(CancelledException cex) { + } + + @Override + public void onFinished() { + } + }); + } + + private void login() { + if (mUsername != null && !mUsername.isEmpty() && mPwd != null && !mPwd.isEmpty()) { + map = new HashMap<>(); + String p_pwd = ""; + String vcode = ""; + String code = RandomStringUtils.getRandomStr(1,4); + try { + vcode = "64368180"; + vcode = "64368180"+code; + vcode = EncryptUtils.encrypt(vcode).replace("\n",""); + code = EncryptUtils.encrypt(code).replace("\n",""); + vcode = URLEncoder.encode(vcode,"UTF-8"); + code = URLEncoder.encode(code,"UTF-8"); + p_pwd = URLEncoder.encode(mPwd,"UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } + map.put("j_password",p_pwd); + map.put("j_username",mUsername); + map.put("androidId",androidId); + map.put("verCode",vcode); + map.put("code",code); + p.getContract().requestData(LoadingActivity.this,map,mServer, MethodURL.Login_Method); + } else { + ToLogin(); + } + } + + private void ToLogin() { + Intent intent = new Intent(LoadingActivity.this, LoginActivity.class); + startActivity(intent); + finish(); + } + + private void initPermissions() { + if (Build.VERSION.SDK_INT >= 26) { + boolean isAllowed = getPackageManager().canRequestPackageInstalls(); + if (isAllowed) { + for (int i = 0; i < permissions.length; i++) { + if (ContextCompat.checkSelfPermission(this, permissions[i]) != PackageManager.PERMISSION_GRANTED) { + mPermissionList.add(permissions[i]);//添加还未授予的权限 + } + } + // 权限是否已经 授权 GRANTED---授权 DINIED---拒绝 + if (mPermissionList.size() > 0) { + // 如果没有授予该权限,就去提示用户请求 + ActivityCompat.requestPermissions(this, permissions, mRequestCode); + } else { + check(); + } + } else { + //无权限 申请权限 + showInstallAPKDialog(); + } + } else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + for (int i = 0; i < permissions.length; i++) { + if (ContextCompat.checkSelfPermission(this, permissions[i]) != PackageManager.PERMISSION_GRANTED) { + mPermissionList.add(permissions[i]);//添加还未授予的权限 + } + } + // 权限是否已经 授权 GRANTED---授权 DINIED---拒绝 + if (mPermissionList.size() > 0) { + // 如果没有授予该权限,就去提示用户请求 + ActivityCompat.requestPermissions(this, permissions, mRequestCode); + } else { + check(); + } + } else { + check(); + } +// check(); + } + } + + /** + * 获取本地软件版本号名称 + */ + public static String getLocalVersionName(Context ctx) { + String localVersion = ""; + try { + PackageInfo packageInfo = ctx.getApplicationContext() + .getPackageManager() + .getPackageInfo(ctx.getPackageName(), 0); + localVersion = packageInfo.versionName; +// LogUtil.d("TAG", "本软件的版本号。。" + localVersion); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return localVersion; + } + + private void showInstallAPKDialog() { + if (!LoadingActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(LoadingActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到暂无APP安装权限,请前往开启,以便检测最新版本!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + //将用户引导至安装未知应用界面。 + Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES); + startActivityForResult(intent, GET_UNKNOWN_APP_SOURCES); + } + }).show(); + } + }); + } + } + + private void showHaveNewAPKDialog(final String durl) { + if (!LoadingActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(LoadingActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到有新版本,请更新") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + String path = Environment.getExternalStorageDirectory() + "/" + getString(R.string.app_flag) + "/" + getString(R.string.app_flag) + "_APK/"; +// downloadFile(durl, path); + } + }) + .show(); + } + }); + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + boolean hasPermissionDismiss = false;//有权限没有通过 + if (mRequestCode == requestCode) { + for (int i = 0; i < grantResults.length; i++) { + if (grantResults[i] == -1) { + hasPermissionDismiss = true; + } + } + if (hasPermissionDismiss) { + // 用户还是想用我的 APP 的 + // 提示用户去应用设置界面手动开启权限 + showDialogTipUserGoToAppSettting(); + } else { + if (times == 0) { + times = times + 1; + check(); + } + } + } + } + + // 提示用户去应用设置界面手动开启权限 + + private void showDialogTipUserGoToAppSettting() { + if (!LoadingActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(LoadingActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("部分权限不可用") + .setContentText("请在-应用设置-权限-中,点击允许") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + goToAppSetting(); + } + }).show(); + } + }); + } + } + + // 跳转到当前应用的设置界面 + private void goToAppSetting() { + Intent intent = new Intent(); + + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getPackageName(), null); + intent.setData(uri); + startActivityForResult(intent, RESULT_PRE); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + case 0: + if (resultCode == RESULT_OK) { + } else { + LoginNow(); + } + break; +// case GET_UNKNOWN_APP_SOURCES: +// initPermissions(); +// break; + case RESULT_PRE: + if (resultCode == RESULT_OK) { + LoginNow(); + } + break; + case 350: + check(); + break; + } + } + + /** + * 登录 + */ + private void LoginNow() { + if (mUsername != null && !mUsername.isEmpty() && mPwd != null && !mPwd.isEmpty()) { + map = new HashMap<>(); + String p_pwd = ""; + String vcode = ""; + String code = RandomStringUtils.getRandomStr(1,4); + try { + vcode = "64368180"; + vcode = "64368180"+code; + vcode = EncryptUtils.encrypt(vcode).replace("\n",""); + code = EncryptUtils.encrypt(code).replace("\n",""); + vcode = URLEncoder.encode(vcode,"UTF-8"); + code = URLEncoder.encode(code,"UTF-8"); + p_pwd = URLEncoder.encode(mPwd,"UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } + map.put("j_password",p_pwd); + map.put("j_username",mUsername); + map.put("androidId",androidId); + map.put("verCode",vcode); + map.put("code",code); + p.getContract().requestData(LoadingActivity.this,map,mServer, MethodURL.Login_Method); + } else { + ToLogin(); + } + } + + /** + * 开启安装APK页面的逻辑 + * + * @param file 要安装的APK文件 + */ + private void installAPK(File file) { + Intent intent = new Intent(Intent.ACTION_VIEW); + //版本在7.0以上是不能直接通过uri访问的 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { +// File file = (new File(apkPath)); + // 由于没有在Activity环境下启动Activity,设置下面的标签 + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + //参数1 上下文, 参数2 Provider主机地址 和配置文件中保持一致 参数3 共享的文件 + Uri apkUri = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID + ".fileProvider", file); + //添加这一句表示对目标应用临时授权该Uri所代表的文件 + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); + } else { + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setDataAndType(Uri.fromFile(file), + "application/vnd.android.package-archive"); + } + startActivity(intent); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + ActivityCollector.removeActivity(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Loading/LoadingContract.java b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingContract.java new file mode 100644 index 0000000..cb8c806 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingContract.java @@ -0,0 +1,40 @@ +package com.sipai.jspatrol.Loading; + + +import android.content.Context; + +import com.sipai.jspatrol.Bean.BaseEntity; + +import java.util.HashMap; + +/** + * created by lvliming on 2020/3/23 + */ +public interface LoadingContract { + + interface Model{ + void executeData(Context context, HashMap map, String server, String url) throws Exception; + + void executeComData(Context context, HashMap map, String server, String url,String token) throws Exception; + } + + interface View{ + void handlerResult(T t); + + void handlerComResult(String result,String bizs); + } + + interface Presenter{ + //登录请求 + void requestData(Context context, HashMap map, String server, String url); + + //登录结果响应 + void responseResult(T t); + + //厂区列表请求 + void requestComList(Context context, HashMap map, String server, String url,String token); + + //厂区请求结果响应 + void responseComResult(String result,String biz); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Loading/LoadingModel.java b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingModel.java new file mode 100644 index 0000000..530ddfc --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingModel.java @@ -0,0 +1,161 @@ +package com.sipai.jspatrol.Loading; + +import android.content.Context; + +import com.sipai.jspatrol.Base.BaseModel; +import com.sipai.jspatrol.Bean.LoginInfo; +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.HashMap; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +/** + * created by lvliming on 2019/9/11 + */ +public class LoadingModel extends BaseModel { + public LoadingModel(LoadingPresenter loginPresenter){ + super(loginPresenter); + } + + @Override + public LoadingContract.Model getContract() { + return new LoadingContract.Model() { + @Override + public void executeData(Context context, HashMap map, String server, String url) throws Exception { + CookiesManager.clearCookie(context); + OKHttpUtils.OKCallGet(map,server,url).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String result = GlobalVal.NET_ERROR; + LoginInfo item = new LoginInfo(); + if (result.equals(GlobalVal.NET_ERROR)) { + item.setStatus(false); + }else if (result.equals(GlobalVal.DATA_ERROR)){ + item.setStatus(false); + }else { + item = parseData(result); + } + p.getContract().responseResult(item); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String result = response.body().string(); + if (result!=null&&!result.isEmpty()&&!result.contains("html")){ +// res = result; + LoginInfo item = new LoginInfo(); + if (result.equals(GlobalVal.NET_ERROR)) { + item.setStatus(false); + }else if (result.equals(GlobalVal.DATA_ERROR)){ + item.setStatus(false); + }else if(result.contains("该设备未关联")){ + item.setStatus(false); + item.setReason("该设备未关联该用户!请至平台关联!"); + }else { + item = parseData(result); + } + p.getContract().responseResult(item); + }else { + result = GlobalVal.DATA_ERROR; + LoginInfo item = new LoginInfo(); + if (result.equals(GlobalVal.NET_ERROR)) { + item.setStatus(false); + }else if (result.equals(GlobalVal.DATA_ERROR)){ + item.setStatus(false); + }else { + item = parseData(result); + } + p.getContract().responseResult(item); + } + } + }); + } + + @Override + public void executeComData(Context context, HashMap map, String server, String url, String token) throws Exception { + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,server,url)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String result = GlobalVal.NET_ERROR; + String bizs = ""; + p.getContract().responseComResult(result,bizs); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res!=null&&!res.isEmpty()&&!res.contains("html")){ + p.getContract().responseComResult(GlobalVal.RESULT_SUCCESS,res); + }else { + p.getContract().responseComResult(GlobalVal.DATA_ERROR,res); + } + } + }); + } + }; + } + + private LoginInfo parseData(String result) { + LoginInfo info = new LoginInfo(); + User user = new User(); + try { + JSONObject jsonObject = new JSONObject(result); + String res = jsonObject.optString("res"); + if (jsonObject.optString("Access_Token") != null && !jsonObject.optString("Access_Token").isEmpty()) { + user.setToken(jsonObject.optString("Access_Token")); + } else { + user.setToken(""); + } + if (jsonObject.getBoolean("status")) { + JSONObject json = new JSONObject(res); + user.setCaption(json.optString("caption")); + user.setName(json.optString("name")); + user.setId(json.optString("id")); + if (json.optString("totaltime")!=null&&!json.optString("totaltime").isEmpty()) { + user.setTotaltime(Double.parseDouble(json.optString("totaltime"))); + }else { + user.setTotaltime(0); + } + user.setLastlogintime(json.optString("lastlogintime")); + if (json.optString("dept") != null && !json.optString("dept").isEmpty()) { + JSONObject jsonob = new JSONObject(json.optString("dept")); + if (jsonob.optString("patrolTypeId") != null && !jsonob.optString("patrolTypeId").isEmpty()) { + user.setPatrolTypeId(jsonob.optString("patrolTypeId")); + } + } else { + user.setPatrolTypeId("P"); + } + if (json.optString("roles").contains("管理员")){ + user.setNfc("true"); + }else { + user.setNfc("false"); + } + if (json.optString("roles").contains("提交")){ + user.setSubTask("true"); + }else { + user.setSubTask("false"); + } + + info.setUser(user); + info.setStatus(true); + } else { + info.setStatus(false); + info.setReason("登录失败"); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return info; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Loading/LoadingPresenter.java b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingPresenter.java new file mode 100644 index 0000000..7b6ee73 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Loading/LoadingPresenter.java @@ -0,0 +1,52 @@ +package com.sipai.jspatrol.Loading; + +import android.content.Context; + +import com.sipai.jspatrol.Base.BasePresenter; +import com.sipai.jspatrol.Bean.LoginInfo; + +import java.util.HashMap; + +/** + * created by lvliming on 2019/9/11 + */ +public class LoadingPresenter extends BasePresenter { + + @Override + public LoadingContract.Presenter getContract() { + return new LoadingContract.Presenter(){ + @Override + public void requestData(Context context, HashMap map, String server, String url) { + try { + m.getContract().executeData(context,map,server,url); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @Override + public void responseResult(LoginInfo item) { + getView().getContract().handlerResult(item); + } + + @Override + public void requestComList(Context context, HashMap map, String server, String url, String token) { + try { + m.getContract().executeComData(context,map,server,url,token); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @Override + public void responseComResult(String result,String bizs) { + getView().getContract().handlerComResult(result,bizs); + } + }; + } + + @Override + public LoadingModel getModel() { + return new LoadingModel(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Loading/LoginActivity.java b/app/src/main/java/com/sipai/jspatrol/Loading/LoginActivity.java new file mode 100644 index 0000000..41c4204 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Loading/LoginActivity.java @@ -0,0 +1,648 @@ +package com.sipai.jspatrol.Loading; + +import android.Manifest; +import android.app.Dialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.os.Build; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.Window; +import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import com.loopj.android.http.AsyncHttpClient; +import com.loopj.android.http.AsyncHttpResponseHandler; +import com.loopj.android.http.RequestParams; +import com.sipai.jspatrol.Bean.Biz; +import com.sipai.jspatrol.Patrol.ProPatrolTaskListActivity; +import com.sipai.jspatrol.utils.DoubleClickUtils.DoubleHandler; +import com.sipai.jspatrol.utils.DoubleClickUtils.DoubleManager; +import com.sipai.jspatrol.utils.DoubleClickUtils.DoubleRunnable; +import com.sipai.jspatrol.utils.DoubleClickUtils.OnDoubleClickListener; +import com.sipai.jspatrol.R; + + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; + + + +public class LoginActivity extends AppCompatActivity implements OnClickListener { + protected static final String TAG = "LoginInActivity"; + private LinearLayout mLoginLinearLayout; // 登录内容的容器 + private LinearLayout mUserIdLinearLayout; // 将下拉弹出窗口在此容器下方显示 + private Animation mTranslate; // 位移动画 + private Dialog mLoginingDlg; // 显示正在登录的Dialog + private EditText mNameEditText; // 登录ID编辑框 + private EditText mPwdEditText; // 登录密码编辑框 + private Button mLoginButton; // 登录按钮 + private String mNameString; + private String mPwdString; + private String mBizid = ""; + private String mCaption; + private String mUserName; + private String mUserid; + private String patrolTypeId;//运行组别 + private String totaltime; + private String token; + private String role_id; + private String role_name; + private String role_description; + private String role_serial; + private String mBizName; + private List bizList = new ArrayList<>(); + private String mServer = ""; + private String mGroup; + private String lcversion = ""; + public static final int REQUSET = 1; + private DoubleManager keyDoubleManager = null; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + initView(); + mServer=getSharedPreferences("config", MODE_PRIVATE).getString("server", ""); + setListener(); + initialvar(); + mLoginLinearLayout.startAnimation(mTranslate); // Y轴水平移动 + /*获取上次登录的用户名和密码*/ + if (!getSharedPreferences("config", MODE_PRIVATE).getString("username", "").equals("")) { + mNameString = getSharedPreferences("config", MODE_PRIVATE).getString("username", ""); + } + if (!getSharedPreferences("config", MODE_PRIVATE).getString("password", "").equals("")) { + mPwdString = getSharedPreferences("config", MODE_PRIVATE).getString("password", ""); + } + if (!getSharedPreferences("config", MODE_PRIVATE).getString("userid", "").equals("")) { + mUserid = getSharedPreferences("config", MODE_PRIVATE).getString("userid", ""); + } + if (!getSharedPreferences("config", MODE_PRIVATE).getString("caption", "").equals("")) { + mCaption = getSharedPreferences("config", MODE_PRIVATE).getString("caption", ""); + } + + mNameEditText.setText(mNameString); + initPermissions(); + } + + private void initPermissions() { + /* + 动态申请网络权限 + */ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + List permissionList = new ArrayList<>(); + if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + permissionList.add(Manifest.permission.ACCESS_COARSE_LOCATION); + permissionList.add(Manifest.permission.REQUEST_INSTALL_PACKAGES); + permissionList.add(Manifest.permission.READ_PHONE_STATE); + permissionList.add(Manifest.permission.ACCESS_WIFI_STATE); + permissionList.add(Manifest.permission.ACCESS_NETWORK_STATE); + permissionList.add(Manifest.permission.WAKE_LOCK); + permissionList.add(Manifest.permission.VIBRATE); + permissionList.add(Manifest.permission.READ_CONTACTS); + permissionList.add(Manifest.permission.WRITE_CONTACTS); + permissionList.add(Manifest.permission.RECEIVE_BOOT_COMPLETED); + permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); + permissionList.add(Manifest.permission.WRITE_SETTINGS); + permissionList.add(Manifest.permission.RESTART_PACKAGES); + permissionList.add(Manifest.permission.BROADCAST_STICKY); + permissionList.add(Manifest.permission.KILL_BACKGROUND_PROCESSES); + permissionList.add(Manifest.permission.GET_TASKS); + permissionList.add(Manifest.permission.READ_LOGS); + permissionList.add(Manifest.permission.BLUETOOTH); + permissionList.add(Manifest.permission.BATTERY_STATS); + permissionList.add(Manifest.permission.VIBRATE); + permissionList.add(Manifest.permission.CAMERA); + permissionList.add(Manifest.permission.DISABLE_KEYGUARD); + permissionList.add(Manifest.permission.WAKE_LOCK); + permissionList.add(Manifest.permission.SYSTEM_ALERT_WINDOW); + permissionList.add(Manifest.permission.NFC); + } + if (!permissionList.isEmpty()) { + String[] permissions = permissionList.toArray(new String[permissionList.size()]); + ActivityCompat.requestPermissions(this, permissions, 1212); + } + } + } + + /** + * 获取本地软件版本号名称 + */ + public static String getLocalVersionName(Context ctx) { + String localVersion = ""; + try { + PackageInfo packageInfo = ctx.getApplicationContext() + .getPackageManager() + .getPackageInfo(ctx.getPackageName(), 0); + localVersion = packageInfo.versionName; + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return localVersion; + } + + @Override + protected void onDestroy() { + super.onDestroy(); + } + + public String getMacAddress() { + // start get mac address + WifiManager wifiMan = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); + if (wifiMan != null) { + WifiInfo wifiInf = wifiMan.getConnectionInfo(); + if (wifiInf != null && wifiInf.getMacAddress() != null) { + // 48位,如FA:34:7C:6D:E4:D7 + return wifiInf.getMacAddress(); + } + } + return null; + } + + private void setListener() { + mNameEditText.addTextChangedListener(new TextWatcher() { + + public void onTextChanged(CharSequence s, int start, int before, + int count) { + mNameString = s.toString(); + } + + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + } + + public void afterTextChanged(Editable s) { + } + }); + mPwdEditText.addTextChangedListener(new TextWatcher() { + + public void onTextChanged(CharSequence s, int start, int before, + int count) { + mPwdString = s.toString(); + } + + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + } + + public void afterTextChanged(Editable s) { + } + }); + mLoginButton.setOnClickListener(this); + } + + private void initView() { +// mNameEditText = findViewById(R.id.login_edtId); +// mPwdEditText = findViewById(R.id.login_edtPwd); +// mLoginButton = findViewById(R.id.login_btnLogin); + mLoginLinearLayout = findViewById(R.id.login_linearLayout); + mUserIdLinearLayout = findViewById(R.id.userId_LinearLayout); + mTranslate = AnimationUtils.loadAnimation(this, R.anim.my_translate); // 初始化动画对象 + TextView tv_lc_version = findViewById(R.id.tv_version); + lcversion = getLocalVersionName(this); + tv_lc_version.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (keyDoubleManager == null) { + keyDoubleManager = new DoubleManager(new DoubleRunnable(new DoubleHandler(new OnDoubleClickListener() { + @Override + public void onSinglePress() { + } + + @Override + public void onDoublePress() { +// Intent intent = new Intent(LoginInActivity.this, SettingActivity.class); +// startActivity(intent); + } + }))); + } + keyDoubleManager.start(); + } + }); + if (lcversion != null && !lcversion.isEmpty()) { + tv_lc_version.setText("版本号:V" + lcversion); + } + initLoginingDlg(); + } + + + /* 初始化正在登录对话框 */ + private void initLoginingDlg() { + + mLoginingDlg = new Dialog(this, R.style.loginingDlg); + mLoginingDlg.setContentView(R.layout.logining_dlg); + + Window window = mLoginingDlg.getWindow(); + WindowManager.LayoutParams params = window.getAttributes(); + // 获取和mLoginingDlg关联的当前窗口的属性,从而设置它在屏幕中显示的位置 + + // 获取屏幕的高宽 + DisplayMetrics dm = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(dm); + int cxScreen = dm.widthPixels; + int cyScreen = dm.heightPixels; + + int height = (int) getResources().getDimension( + R.dimen.loginingdlg_height);// 高42dp + int lrMargin = (int) getResources().getDimension( + R.dimen.loginingdlg_lr_margin); // 左右边沿10dp + int topMargin = (int) getResources().getDimension( + R.dimen.loginingdlg_top_margin); // 上沿20dp + + params.y = ((cyScreen - height) / 2) + topMargin; // -199 + /* 对话框默认位置在屏幕中心,所以x,y表示此控件到"屏幕中心"的偏移量 */ + + params.width = cxScreen; + params.height = height; + // width,height表示mLoginingDlg的实际大小 + + mLoginingDlg.setCanceledOnTouchOutside(true); // 设置点击Dialog外部任意区域关闭Dialog + } + + /* 显示正在登录对话框 */ + private void showLoginingDlg() { + if (!LoginActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (mLoginingDlg != null) + mLoginingDlg.show(); + } + }); + } + } + + /* 关闭正在登录对话框 */ + private void closeLoginingDlg() { + if (!LoginActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (mLoginingDlg != null && mLoginingDlg.isShowing()) + mLoginingDlg.dismiss(); + } + }); + } + } + + @Override + public void onClick(View v) { + switch (v.getId()) { +// case R.id.login_btnLogin: +// showLoginingDlg(); // 显示"正在登录"对话框,因为此Demo没有登录到web服务器,所以效果可能看不出.可以结合情况使用 +// attemptLogin(LoginActivity.this); +// break; + default: + break; + } + + } + + /* 退出此Activity时保存users */ + @Override + public void onPause() { + super.onPause(); + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + // TODO Auto-generated method stub + if (keyCode == KeyEvent.KEYCODE_BACK) { + sign_out(); + } + return false; + } + + public void attemptLogin(Context context) { + if (mServer.equals("")) { + closeLoginingDlg();// 关闭对话框 + Toast.makeText(LoginActivity.this, "未设置服务器IP地址", Toast.LENGTH_SHORT).show(); + return; + } + // Reset errors. + mNameEditText.setError(null); + mPwdEditText.setError(null); + if (mNameEditText.getText() != null) { + mUserName = mNameEditText.getText().toString(); + } else { + runOnUiThread(new Runnable() { + @Override + public void run() { + mNameEditText.setError("请填写用户名"); + } + }); + return; + } + if (mPwdEditText.getText() != null) { + mPwdString = mPwdEditText.getText().toString(); + } else { + runOnUiThread(new Runnable() { + @Override + public void run() { + mPwdEditText.setError("不能为空"); + } + }); + return; + } + if (mUserName != null && !mUserName.isEmpty() && mPwdString != null && !mPwdString.isEmpty()) { + validateLogin(mUserName, mPwdString, mBizid, mGroup);//验证用户名密码 + } else { + Toast.makeText(LoginActivity.this, "用户名或密码不能为空!", Toast.LENGTH_SHORT).show(); + } + } + + private String[] permissions = {Manifest.permission.READ_PHONE_STATE}; + + private void validateLogin(String user, final String password, String bizid, String group) { + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(mNameEditText.getWindowToken(), 0); + imm.hideSoftInputFromWindow(mPwdEditText.getWindowToken(), 0); + final String username = user; + final String passwords = password; +// CookieUtils.clearCookie(this); + RequestParams params = new RequestParams(); + params.put("j_username", user); + params.put("j_password", password); + params.put("verCode", "64368180"); + + AsyncHttpClient client = new AsyncHttpClient(); + client.setTimeout(5000); +// CookieUtils.saveCookie(client, this); + client.post(mServer + "SIPAIIS_Base/j_spring_security_check?", params, new AsyncHttpResponseHandler() { + @Override + public void onSuccess(String response) { + if (response != null && response.length() > 0) { + try { + JSONObject jsonObject = new JSONObject(response); + String res = jsonObject.optString("res"); + token = jsonObject.optString("Access_Token"); + if (jsonObject.getBoolean("status")) { + JSONObject json = new JSONObject(res); + mCaption = json.optString("caption"); + mUserName = json.optString("name"); + mUserid = json.optString("id"); + totaltime = json.optString("totaltime"); + if (json.optString("dept")!=null&&!json.optString("dept").isEmpty()) { + JSONObject jsonob = new JSONObject(json.optString("dept")); + if (jsonob.optString("patrolTypeId")!=null&&!jsonob.optString("patrolTypeId").isEmpty()) { + patrolTypeId = jsonob.optString("patrolTypeId"); + } + }else { + patrolTypeId = "P"; + } + JSONArray roles = new JSONArray(json.opt("roles").toString()); + for (int i=0;i 0) { + bizList = getData(response); + if (bizList.size() > 0) { + mBizid = bizList.get(0).getId(); + mBizName = bizList.get(0).getName(); + } + mBizid = "blgworkshop1"; + mBizName = "白龙港一车间"; + saveBizlist(LoginActivity.this, response, mBizid, mBizName); + Intent intent = new Intent(LoginActivity.this, ProPatrolTaskListActivity.class); + startActivity(intent); + finish(); + } + } + + @Override + public void onFailure(Throwable e) { + closeLoginingDlg();// 关闭对话框 + Toast.makeText(LoginActivity.this, getString(R.string.error_incorrect_connection), Toast.LENGTH_SHORT).show(); + } + + @Override + public void onStart() { + super.onStart(); + } + + @Override + public void onFinish() { + super.onFinish(); + } + }); + } + + private List getData(String response) { + List listres = new ArrayList(); + try { + JSONArray aNews = new JSONArray(response); + if (aNews != null && aNews.length() > 0) { + for (int i = 0; i < aNews.length(); i++) { + Biz item = new Biz(); + item.setId(aNews.getJSONObject(i).get("id").toString()); + item.setName(aNews.getJSONObject(i).get("text").toString()); + item.setBizid(aNews.getJSONObject(i).get("id").toString()); + listres.add(item); + } + } + } catch (JSONException ex) { + Log.e("JSON Error: ", ex.toString()); + } + + return listres; + } + + private void saveBizlist(Context context, String response, String bizid, String bizname) { + //获取SharedPreferences对象 + SharedPreferences sharedPre = context.getSharedPreferences("config", MODE_PRIVATE); + //获取Editor对象 + Editor editor = sharedPre.edit(); + editor.putString("bizlist", response); + editor.putString("bizid", bizid); + editor.putString("bizname", bizname); + //提交 + editor.commit(); + } + + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + // TODO Auto-generated method stub + super.onActivityResult(requestCode, resultCode, data); + //requestCode标示请求的标示 resultCode表示有数据 + if (requestCode == LoginActivity.REQUSET && resultCode == RESULT_OK) { + initialvar(); + /* 获取已经保存好的用户密码 */ +// userlist(mBizid,mGroup); + + } + } + + @Override + protected void onResume() { +// userlist(mBizid,mGroup); + super.onResume(); + initialvar(); + } + + private void initialvar() { + if (!getSharedPreferences("config", MODE_PRIVATE).getString("bizid", "").equals("")) { + mBizid = getSharedPreferences("config", MODE_PRIVATE).getString("bizid", ""); + } + if (!getSharedPreferences("config", MODE_PRIVATE).getString("server", "").equals("")) { + mServer = getSharedPreferences("config", MODE_PRIVATE).getString("server", ""); + } + if (!getSharedPreferences("config", MODE_PRIVATE).getString("group", "").equals("")) { + mGroup = getSharedPreferences("config", MODE_PRIVATE).getString("group", ""); + } + } + + private void sign_out() { + SweetAlertDialog dia = new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE); + dia.setCanceledOnTouchOutside(true); + dia.setTitleText("确定登出?").setConfirmText("确认").setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + finish(); + } + }).setCancelText("取消").setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Login/LoginActivity.java b/app/src/main/java/com/sipai/jspatrol/Login/LoginActivity.java new file mode 100644 index 0000000..b541bd2 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Login/LoginActivity.java @@ -0,0 +1,517 @@ +package com.sipai.jspatrol.Login; + +import static com.sipai.jspatrol.utils.RxCaptcha.TYPE.NUMBER; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.graphics.Color; +import android.os.Bundle; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.text.InputType; +import android.view.View; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +import com.kyleduo.switchbutton.SwitchButton; +import com.sipai.jspatrol.Base.ActivityCollector; +import com.sipai.jspatrol.Base.BaseView; +import com.sipai.jspatrol.Bean.Biz; +import com.sipai.jspatrol.Bean.LoginInfo; +import com.sipai.jspatrol.Main.MainActivity; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.setting.SettingActivity; +import com.sipai.jspatrol.utils.EncryptUtils; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.utils.ProgressForAll; +import com.sipai.jspatrol.utils.RandomStringUtils; +import com.sipai.jspatrol.utils.RxCaptcha; +import com.sipai.jspatrol.utils.SharedPreferencesData; + +import org.json.JSONArray; +import org.json.JSONException; + +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class LoginActivity extends BaseView implements View.OnClickListener { + private EditText edt_name,edt_pwd; + private SwitchButton sb_network; + private Button btn_login,btn_setting; + private String ip_in_plant = "", ip_off_site = "";//厂内,厂外ip地址 + private String mServer = ""; + private String mServerIp = ""; + private static final int SET_IP = 121; + private SharedPreferencesData sharedpre; + + private HashMap map = new HashMap<>(); + private HashMap map_base = new HashMap<>(); + private String androidId = ""; + private String mBizid = ""; + private String mBizName; + private String lcversion; + private TextView tv_version; + private ImageView iv_eye; + private Boolean isOpen = false; + private ImageView iv_code; + private EditText edt_code; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + ActivityCollector.addActivity(this); + init(); + initView(); + TelephonyManager tm = (TelephonyManager) LoginActivity.this.getSystemService(TELEPHONY_SERVICE); +// mtyb = android.os.Build.BRAND;// 手机品牌 +// mtype = android.os.Build.MODEL; // 手机型号 +// imei = tm.getDeviceId();//uuid + androidId = Settings.System.getString( + getContentResolver(), Settings.Secure.ANDROID_ID);//10.0以后获取不到UUID,用androidId来代表唯一性 + } + + private void initView() { + edt_name = findViewById(R.id.moudle_login_edt_name); + edt_pwd = findViewById(R.id.moudle_login_edt_pwd); + sb_network = findViewById(R.id.moudle_login_sb_network); + sb_network.setTextColor(getResources().getColor(R.color.white)); + btn_login = findViewById(R.id.moudle_login_btn_login); + btn_login.setOnClickListener(this); + btn_setting = findViewById(R.id.moudle_login_btn_setting); + btn_setting.setOnClickListener(this); + tv_version = findViewById(R.id.tv_version); + tv_version.setText("版本号:V"+lcversion); + if (ip_off_site.length() < 3 && ip_in_plant.length() < 3) { + showNoIpDialog(); + } else { + setSweetButton(); + } + iv_eye = findViewById(R.id.moudle_iv_eye); + iv_eye.setColorFilter(getResources().getColor(R.color.gray)); + iv_eye.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(isOpen){ + edt_pwd.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD); + iv_eye.setColorFilter(getResources().getColor(R.color.gray)); + isOpen = !isOpen; + }else { + edt_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + iv_eye.setColorFilter(getResources().getColor(R.color.white)); + isOpen = !isOpen; + } + } + }); + edt_code = findViewById(R.id.moudle_login_edt_code); + iv_code = findViewById(R.id.moudle_iv_code); + iv_code.setOnClickListener(this); + refreshCode(); + } + + private void refreshCode() { + RxCaptcha.build() + .backColor(0xffffff) + .codeLength(4) + .fontSize(60) + .lineNumber(2) + .size(200, 70) + .type(NUMBER) + .into(iv_code); + } + + private void showMsgFinish() { + runOnUiThread(new Runnable() { + @Override + public void run() { + ProgressForAll.cancelProgress(); + } + }); + } + + private void showMsgDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + ProgressForAll.showProgress(LoginActivity.this,"","登录中..."); + } + }); + } + + private void init() { + sharedpre = new SharedPreferencesData(this); + map_base = sharedpre.getAll(); + ip_in_plant = map_base.get("ip_in_plant"); + ip_off_site = map_base.get("ip_off_site"); + mServer = map_base.get("mServer"); + mServerIp = map_base.get("mServerIp"); + lcversion = getLocalVersionName(this); + } + + /** + * 获取本地软件版本号名称 + */ + public static String getLocalVersionName(Context ctx) { + String localVersion = ""; + try { + PackageInfo packageInfo = ctx.getApplicationContext() + .getPackageManager() + .getPackageInfo(ctx.getPackageName(), 0); + localVersion = packageInfo.versionName; +// LogUtil.d("TAG", "本软件的版本号。。" + localVersion); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return localVersion; + } + + + private void setSweetButton() { + if (mServerIp != null && mServerIp.length() > 3) { + if (ip_in_plant.equals(mServerIp)) { + sb_network.setChecked(true); + } else { + sb_network.setChecked(false); + mServerIp = ip_off_site; + } + } else { + if (ip_in_plant.length()>3){ + mServerIp = ip_in_plant; + sb_network.setChecked(true); + }else if (ip_off_site.length()>3){ + mServerIp = ip_off_site; + sb_network.setChecked(false); + } + } + mServer = "http://" + mServerIp + "/"; + final HashMap server_map = new HashMap<>(); + server_map.put("server",mServer); + server_map.put("serverip",mServerIp); + sharedpre.saveInfo(server_map); + init(); + if (ip_in_plant.length()<4||ip_off_site.length()<4){ + sb_network.setEnabled(false); + }else { + sb_network.setEnabled(true); + } + sb_network.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (isChecked) { + mServerIp = ip_in_plant; + mServer = "http://" + mServerIp + "/"; + server_map.clear(); + server_map.put("server",mServer); + server_map.put("serverip",mServerIp); + sharedpre.saveInfo(server_map); + init(); + } else { + mServerIp = ip_off_site; + mServer = "http://" + mServerIp + "/"; + server_map.clear(); + server_map.put("server",mServer); + server_map.put("serverip",mServerIp); + sharedpre.saveInfo(server_map); + init(); + } + } + }); + } + }); + } + + private void showNoIpDialog() { + if (!LoginActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(LoginActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到APP暂未设置IP地址,若不设置则无法进行下一步操作!") + .setConfirmText("设置") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + Intent intent = new Intent(LoginActivity.this, SettingActivity.class); + startActivityForResult(intent, SET_IP); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + @Override + protected LoginPresenter getPresenter() { + return new LoginPresenter(); + } + + private void saveBizlist(Context context, String response, String bizid, String bizname,String t) { + //获取SharedPreferences对象 + SharedPreferences sharedPre = context.getSharedPreferences("config", MODE_PRIVATE); + //获取Editor对象 + SharedPreferences.Editor editor = sharedPre.edit(); + editor.putString("bizlist", response); + editor.putString("bizid", bizid); + editor.putString("bizname", bizname); + editor.putString("biz",t); + //提交 + editor.commit(); + } + + @Override + public LoginContract.View getContract() { + return new LoginContract.View(){ + @Override + public void handlerResult(LoginInfo item) { + if (item!=null){ + if (item.isStatus()){ + saveLoginInfo(item); + getComList(item); + }else { + showMsgFinish(); + if (item.getReason()!=null&&!item.getReason().isEmpty()) { + failLogin(item.getReason()); + }else { + failLogin("登录请求失败!"); + } + } + }else { + showMsgFinish(); + showError("登录请求失败!"); + } + } + + @Override + public void handlerComResult(String result,String t) { + showMsgFinish(); + if (result.equals(GlobalVal.RESULT_SUCCESS)) { + List bizs = parseBiz(t); + if (bizs.size()>0) { + if (bizs.size()==1){ + mBizid = bizs.get(0).getBizid(); + mBizName = bizs.get(0).getName(); + }else if (mBizid.isEmpty()){ + mBizid = bizs.get(0).getBizid(); + mBizName = bizs.get(0).getName(); + } + saveBizlist(LoginActivity.this, "response", mBizid, mBizName,t); + MainActivity.actionStart(LoginActivity.this); + + }else { + showError("未关联厂区,无法登录"); + } + }else { + showError("登录失败"); + } + } + }; + } + + private List parseBiz(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i=0;i(); + showMsgDialog(); + p.getContract().requestComList(LoginActivity.this,map,mServer, MethodURL.ComList_Method,item.getUser().getToken()); + } + + private void saveLoginInfo(LoginInfo item) { + SharedPreferencesData sharedPreferencesData = new SharedPreferencesData(this); + Map map = new HashMap<>(); + map.put("userid",item.getUser().getId()); + map.put("caption",item.getUser().getCaption()); + map.put("name",item.getUser().getName()); + map.put("totaltime",String.valueOf(Math.round(item.getUser().getTotaltime()))); + map.put("lastlogintime",item.getUser().getLastlogintime()); + map.put("username",edt_name.getText().toString()); + map.put("password",edt_pwd.getText().toString()); + map.put("token",item.getUser().getToken()); + map.put("nfc", item.getUser().getNfc()); + map.put("subtask", item.getUser().getSubTask()); + sharedPreferencesData.saveInfo(map); + } + + private void failLogin(final String reason) { + if (!LoginActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(LoginActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("提示") + .setContentText(reason) + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void showError(String s) { + if (!LoginActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(LoginActivity.this, s, Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_login_btn_login: + if (edt_code.getText()!=null&&!edt_code.getText().toString().isEmpty()&&edt_code.getText().toString().equals(RxCaptcha.build().getCode())) { + String st_name = ""; + String st_pwd = ""; + if (judgeString(mServer,"服务器地址")){ + if (edt_name.getText()!=null&&!edt_name.getText().toString().isEmpty()){ + st_name = edt_name.getText().toString(); + }else { + showCannotNull(edt_name); + } + if (edt_pwd.getText()!=null&&!edt_pwd.getText().toString().isEmpty()){ + st_pwd = edt_pwd.getText().toString(); + }else { + showCannotNull(edt_pwd); + } + if (!st_name.isEmpty()&&!st_pwd.isEmpty()) { + toLogin(st_name, st_pwd); + } + } + }else { + Toast.makeText(this, "验证码错误", Toast.LENGTH_LONG).show(); + refreshCode(); + } + break; + case R.id.moudle_login_btn_setting: + Intent intent = new Intent(LoginActivity.this,SettingActivity.class); + startActivityForResult(intent,SET_IP); + break; + } + } + + private void showCannotNull(final EditText edt) { + if (!LoginActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + edt.setError("不能为空"); + } + }); + } + } + + private void toLogin(String name, String pwd) { + String p_pwd = ""; + String vcode = ""; + String code = RandomStringUtils.getRandomStr(1,4); + try { + vcode = "64368180"; + vcode = "64368180"+code; + vcode = EncryptUtils.encrypt(vcode).replace("\n",""); + code = EncryptUtils.encrypt(code).replace("\n",""); + vcode = URLEncoder.encode(vcode,"UTF-8"); + code = URLEncoder.encode(code,"UTF-8"); + p_pwd = URLEncoder.encode(pwd,"UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } + map.put("j_password",p_pwd); + map.put("j_username",name); + map.put("androidId",androidId); + map.put("verCode",vcode); + map.put("code",code); + showMsgDialog(); + p.getContract().requestData(LoginActivity.this,map,mServer, MethodURL.Login_Method); + } + + + private boolean judgeString(String st, final String notice) { + if (st!=null&&!st.isEmpty()){ + return true; + }else { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(LoginActivity.this, notice+"不能为空", Toast.LENGTH_SHORT).show(); + } + }); + return false; + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (resultCode==RESULT_OK){ + switch (requestCode){ + case SET_IP: + init(); + if (ip_off_site.length() < 2 || ip_in_plant.length() < 2) { + showNoIpDialog(); + } else { + setSweetButton(); + } + break; + } + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + ActivityCollector.removeActivity(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Login/LoginContract.java b/app/src/main/java/com/sipai/jspatrol/Login/LoginContract.java new file mode 100644 index 0000000..ca79f65 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Login/LoginContract.java @@ -0,0 +1,39 @@ +package com.sipai.jspatrol.Login; + +import android.content.Context; + +import com.sipai.jspatrol.Bean.BaseEntity; + +import java.util.HashMap; + +/** + * created by lvliming on 2019/9/11 + */ +public interface LoginContract { + + interface Model{ + void executeData(Context context, HashMap map, String server, String url) throws Exception; + + void executeComData(Context context, HashMap map, String server, String url,String token) throws Exception; + } + + interface View{ + void handlerResult(T t); + + void handlerComResult(String result,String bizs); + } + + interface Presenter{ + //登录请求 + void requestData(Context context, HashMap map, String server, String url); + + //登录结果响应 + void responseResult(T t); + + //厂区列表请求 + void requestComList(Context context, HashMap map, String server, String url,String token); + + //厂区请求结果响应 + void responseComResult(String result,String biz); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Login/LoginModel.java b/app/src/main/java/com/sipai/jspatrol/Login/LoginModel.java new file mode 100644 index 0000000..aca29ae --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Login/LoginModel.java @@ -0,0 +1,153 @@ +package com.sipai.jspatrol.Login; + +import android.content.Context; + +import com.sipai.jspatrol.Base.BaseModel; +import com.sipai.jspatrol.Bean.LoginInfo; +import com.sipai.jspatrol.Bean.User; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.HashMap; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +/** + * created by lvliming on 2019/9/11 + */ +public class LoginModel extends BaseModel { + +// private OKHttpUtils.RequestCallBack requestCallBack; + + public LoginModel(LoginPresenter loginPresenter) { + super(loginPresenter); + } + + @Override + public LoginContract.Model getContract() { + return new LoginContract.Model() { + @Override + public void executeData(Context context, HashMap map, String server, String url) throws Exception { + CookiesManager.clearCookie(context); + OKHttpUtils.OKCallGet(map,server,url).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String result = GlobalVal.NET_ERROR; + LoginInfo item = new LoginInfo(); + if (result.equals(GlobalVal.NET_ERROR)) { + item.setStatus(false); + }else if (result.equals(GlobalVal.DATA_ERROR)){ + item.setStatus(false); + }else { + item = parseData(result); + } + p.getContract().responseResult(item); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String result = response.body().string(); + if (result!=null&&!result.isEmpty()&&!result.contains("html")){ + LoginInfo item = new LoginInfo(); + if(result.contains("该设备未关联")){ + item.setStatus(false); + item.setReason("该设备未关联该用户!请至平台关联!"); + }else { + item = parseData(result); + } + p.getContract().responseResult(item); + }else { + LoginInfo item = new LoginInfo(); + item.setStatus(false); + item.setReason(result); + p.getContract().responseResult(item); + } + } + }); + } + + @Override + public void executeComData(Context context, HashMap map, String server, String url, String token) throws Exception { + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,server,url)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String result = GlobalVal.NET_ERROR; + String bizs = ""; + p.getContract().responseComResult(result,bizs); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res!=null&&!res.isEmpty()&&!res.contains("html")){ + p.getContract().responseComResult(GlobalVal.RESULT_SUCCESS,res); + }else { + p.getContract().responseComResult(GlobalVal.DATA_ERROR,res); + } + } + }); + } + }; + } + + private LoginInfo parseData(String result) { + LoginInfo info = new LoginInfo(); + User user = new User(); + try { + JSONObject jsonObject = new JSONObject(result); + String res = jsonObject.optString("res"); + if (jsonObject.optString("Access_Token") != null && !jsonObject.optString("Access_Token").isEmpty()) { + user.setToken(jsonObject.optString("Access_Token")); + } else { + user.setToken(""); + } + if (jsonObject.getBoolean("status")) { + JSONObject json = new JSONObject(res); + user.setCaption(json.optString("caption")); + user.setName(json.optString("name")); + user.setId(json.optString("id")); + if (!json.optString("totaltime").isEmpty()) { + user.setTotaltime(Double.parseDouble(json.optString("totaltime"))); + }else { + user.setTotaltime(0); + } + user.setLastlogintime(json.optString("lastlogintime")); + if (json.optString("dept") != null && !json.optString("dept").isEmpty()) { + JSONObject jsonob = new JSONObject(json.optString("dept")); + if (jsonob.optString("patrolTypeId") != null && !jsonob.optString("patrolTypeId").isEmpty()) { + user.setPatrolTypeId(jsonob.optString("patrolTypeId")); + } + } else { + user.setPatrolTypeId("P"); + } + if (json.optString("roles").contains("管理员")){ + user.setNfc("true"); + }else { + user.setNfc("false"); + } + if (json.optString("roles").contains("提交")){ + user.setSubTask("true"); + }else { + user.setSubTask("false"); + } + info.setUser(user); + info.setStatus(true); + } else { + info.setStatus(false); + info.setReason(res); + } + } catch (JSONException e) { + e.printStackTrace(); + info.setStatus(false); + info.setReason(e.toString()); + } + return info; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Login/LoginPresenter.java b/app/src/main/java/com/sipai/jspatrol/Login/LoginPresenter.java new file mode 100644 index 0000000..977c408 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Login/LoginPresenter.java @@ -0,0 +1,52 @@ +package com.sipai.jspatrol.Login; + +import android.content.Context; + +import com.sipai.jspatrol.Base.BasePresenter; +import com.sipai.jspatrol.Bean.LoginInfo; + +import java.util.HashMap; + +/** + * created by lvliming on 2019/9/11 + */ +public class LoginPresenter extends BasePresenter { + + @Override + public LoginContract.Presenter getContract() { + return new LoginContract.Presenter(){ + @Override + public void requestData(Context context,HashMap map, String server, String url) { + try { + m.getContract().executeData(context,map,server,url); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @Override + public void responseResult(LoginInfo item) { + getView().getContract().handlerResult(item); + } + + @Override + public void requestComList(Context context, HashMap map, String server, String url, String token) { + try { + m.getContract().executeComData(context,map,server,url,token); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @Override + public void responseComResult(String result,String bizs) { + getView().getContract().handlerComResult(result,bizs); + } + }; + } + + @Override + public LoginModel getModel() { + return new LoginModel(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/MainActivity.java b/app/src/main/java/com/sipai/jspatrol/Main/MainActivity.java new file mode 100644 index 0000000..de05eb2 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/MainActivity.java @@ -0,0 +1,139 @@ +package com.sipai.jspatrol.Main; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; + +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.sipai.jspatrol.Base.ActivityCollector; +import com.sipai.jspatrol.Main.fragment.faultfragment.FaultFragment; +import com.sipai.jspatrol.Main.fragment.fifthFragment.FifthFragment; +import com.sipai.jspatrol.Main.fragment.mainfragment.MainFragment; +import com.sipai.jspatrol.Main.fragment.promFragment.ProMFragment; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.Service.IPatrolService; +import com.sipai.jspatrol.background.locationservice.LocationService; + +public class MainActivity extends AppCompatActivity implements View.OnClickListener { + private FrameLayout fl; + private RelativeLayout rl_main,rl_fault,rl_pro,rl_self; + private ImageView iv_main,iv_fault,iv_pro,iv_self; + private TextView tv_main,tv_fault,tv_pro,tv_self; + + public static void actionStart(Context context){ + Intent inent = new Intent(context,MainActivity.class); + context.startActivity(inent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + ActivityCollector.addActivity(this); + initView(); + startPatrolService(); + replaceFragment(new MainFragment()); + } + + private void startPatrolService() { + Intent intent = new Intent(MainActivity.this, IPatrolService.class); + startService(intent); + Intent intent_b = new Intent(MainActivity.this, LocationService.class); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + //android8.0以上通过startForegroundService启动service + startForegroundService(intent_b); + }else{ + startService(intent_b); + } + } + + /** + * 初始化控件 + */ + private void initView() { + fl = findViewById(R.id.moudle_main_fl); + rl_main = findViewById(R.id.moudle_main_activity_rl_main); + rl_main.setOnClickListener(this); + rl_fault = findViewById(R.id.moudle_main_activity_rl_falut); + rl_fault.setOnClickListener(this); + rl_pro = findViewById(R.id.moudle_main_activity_rl_pro); + rl_pro.setOnClickListener(this); + rl_self = findViewById(R.id.moudle_main_activity_rl_self); + rl_self.setOnClickListener(this); + iv_main = findViewById(R.id.moudle_main_activity_iv_main); + iv_fault = findViewById(R.id.moudle_main_activity_iv_falut); + iv_pro = findViewById(R.id.moudle_main_activity_iv_pro); + iv_self = findViewById(R.id.moudle_main_activity_iv_self); + tv_main = findViewById(R.id.moudle_main_activity_tv_main); + tv_fault = findViewById(R.id.moudle_main_activity_tv_falut); + tv_pro = findViewById(R.id.moudle_main_activity_tv_pro); + tv_self = findViewById(R.id.moudle_main_activity_tv_self); + changeTab(tv_main); + iv_main.setImageResource(R.mipmap.moudle_tab_main_full); + } + + private void changeTab(TextView tv) { + iv_main.setImageResource(R.mipmap.moudle_tab_main_empty); + iv_fault.setImageResource(R.mipmap.moudle_tab_fault_empty); + iv_pro.setImageResource(R.mipmap.moudle_tab_pro_empty); + iv_self.setImageResource(R.mipmap.moudle_tab_self_empty); + tv_main.setTextColor(getResources().getColor(R.color.tab_text_gray)); + tv_fault.setTextColor(getResources().getColor(R.color.tab_text_gray)); + tv_pro.setTextColor(getResources().getColor(R.color.tab_text_gray)); + tv_self.setTextColor(getResources().getColor(R.color.tab_text_gray)); + tv.setTextColor(getResources().getColor(R.color.black)); + } + + private void replaceFragment(Fragment fragment){ + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction transaction = fragmentManager.beginTransaction(); + transaction.replace(R.id.moudle_main_fl,fragment); + transaction.commit(); + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_main_activity_rl_main: + replaceFragment(new MainFragment()); + changeTab(tv_main); + iv_main.setImageResource(R.mipmap.moudle_tab_main_full); + break; + case R.id.moudle_main_activity_rl_falut: + replaceFragment(new FaultFragment()); + changeTab(tv_fault); + iv_fault.setImageResource(R.mipmap.moudle_tab_fault_full); + break; + case R.id.moudle_main_activity_rl_pro: + replaceFragment(new ProMFragment()); + changeTab(tv_pro); + iv_pro.setImageResource(R.mipmap.moudle_tab_pro_full); + break; + case R.id.moudle_main_activity_rl_self: + replaceFragment(new FifthFragment()); + changeTab(tv_self); + iv_self.setImageResource(R.mipmap.moudle_tab_self_full); + break; + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + ActivityCollector.removeActivity(this); + Intent intent = new Intent(MainActivity.this, IPatrolService.class); + stopService(intent); + Intent intent_b = new Intent(MainActivity.this, LocationService.class); + stopService(intent_b); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragment.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragment.java new file mode 100644 index 0000000..3bc8573 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragment.java @@ -0,0 +1,755 @@ +package com.sipai.jspatrol.Main.fragment.faultfragment; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.net.Uri; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.Base.BaseFragmentView; +import com.sipai.jspatrol.Bean.Biz; +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Bean.Fault; +import com.sipai.jspatrol.Bean.ProcessSection; +import com.sipai.jspatrol.Fault.NewFaultActivity; +import com.sipai.jspatrol.Fault.NewFaultDetailActivity; +import com.sipai.jspatrol.Fault.adapter.DoingFaultAdapter; +import com.sipai.jspatrol.Fault.adapter.DoneFaultAdapter; +import com.sipai.jspatrol.Fault.adapter.NewFaultAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.GuideMenuUrl; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.Webv.GuideMenuActivity; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.ProgressForAll; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; +import com.sipai.ui.EmptyLayout; +import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView; +import com.superrecycleview.superlibrary.utils.SuperDivider; +import com.tencent.smtt.sdk.CookieManager; +import com.tencent.smtt.sdk.CookieSyncManager; +import com.tencent.smtt.sdk.DownloadListener; +import com.tencent.smtt.sdk.ValueCallback; +import com.tencent.smtt.sdk.WebChromeClient; +import com.tencent.smtt.sdk.WebView; +import com.tencent.smtt.sdk.WebViewClient; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +/** + * created by lvliming on 2019/9/16 + */ +public class FaultFragment extends BaseFragmentView implements View.OnClickListener{ + private EditText edt_search; + private TextView tv_sub; + private TextView tv_all,tv_subed,tv_doing,tv_com; + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid, mBizName; + private List faults = new ArrayList<>(); + private NewFaultAdapter newAdapter; + private DoingFaultAdapter doingFaultAdapter; + private DoneFaultAdapter doneFaultAdapter; + private LinearLayoutManager manager; + private SuperRecyclerView rc_view; + private SwipeRefreshLayout refresh; + private EmptyLayout emptyLayout; + private String type = "2"; + private int page = 1; + + //待办所用控件 + private String url; + private String name; + private WebView webView; + private String cookies; + private String fileabspath = ""; + private ProgressDialog progressDialog; + private ValueCallback mUploadMessage; + private ValueCallback uploadMessage; // 用于5.0以上 + final static int FILE_SELECTED = 4; + public static final int REQUEST_SELECT_FILE = 100; + private TextView tv_backlog,tv_faultlist,tv_wwlist; + + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_fault,container,false); + init(); + initView(view); + return view; + } + + private void init() { + SharedPreferences sharedPre = getActivity().getSharedPreferences("config", 0); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + mBizName = sharedPre.getString("bizname", ""); + url = GuideMenuUrl.url_backlog; + } + + private void initView(View view) { + //异常模块控件 + edt_search = view.findViewById(R.id.moudle_fg_fault_edt_search); + tv_sub = view.findViewById(R.id.moudle_fg_fault_tv_sub); + tv_sub.setOnClickListener(this); + tv_all = view.findViewById(R.id.moudle_fg_fault_tv_all); + tv_all.setOnClickListener(this); + tv_subed = view.findViewById(R.id.moudle_fg_fault_tv_subed); + tv_subed.setOnClickListener(this); + tv_doing = view.findViewById(R.id.moudle_fg_fault_tv_doing); + tv_doing.setOnClickListener(this); + tv_com = view.findViewById(R.id.moudle_fg_fault_tv_com); + tv_com.setOnClickListener(this); + emptyLayout = view.findViewById(R.id.moudle_fg_fault_ui_empty); + refresh = view.findViewById(R.id.moudle_fg_fault_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + page = 1; + getFaultList(type); + } + }); + rc_view = view.findViewById(R.id.moudle_fg_fault_rc); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + rc_view.setRefreshEnabled(false); + rc_view.setLoadMoreEnabled(true); + rc_view.setLoadingListener(new SuperRecyclerView.LoadingListener() { + @Override + public void onRefresh() { + + } + + @Override + public void onLoadMore() { + page = page+1; + getFaultList(type); + } + }); + rc_view.addItemDecoration(SuperDivider.newBitmapDivider()); + edt_search.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + getFaultList(type); + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + + //待办模块控件 + tv_backlog = view.findViewById(R.id.moudle_fault_tv_backlog); + tv_backlog.setOnClickListener(this); + tv_faultlist = view.findViewById(R.id.moudle_fault_tv_fault_list); + tv_faultlist.setOnClickListener(this); + tv_wwlist = view.findViewById(R.id.moudle_fault_tv_ww_list); + tv_wwlist.setOnClickListener(this); + webView = (WebView) view.findViewById(R.id.moudle_backlog_webview); + webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setAllowFileAccess(true); + webView.getSettings().setDomStorageEnabled(true); + //设置自适应屏幕,两者合用 + webView.getSettings().setUseWideViewPort(true); //将图片调整到适合webview的大小 + webView.getSettings().setLoadWithOverviewMode(true); // 缩放至屏幕的大小 + //缩放操作 + webView.getSettings().setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 + webView.getSettings().setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 + webView.getSettings().setDisplayZoomControls(false); //隐藏原生的缩放控件 + webView.getSettings().setDefaultTextEncodingName("utf-8"); + webView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView webView, String s) { + return super.shouldOverrideUrlLoading(webView, s); + } + + @Override + public void onPageStarted(WebView webView, String s, Bitmap bitmap) { + super.onPageStarted(webView, s, bitmap); + showMsgDialog(); + } + + @Override + public void onPageFinished(WebView webView, String s) { + super.onPageFinished(webView, s); + showMsgFinish(); + } + }); + webView.setWebChromeClient(new WebChromeClient() { + public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { + mUploadMessage = uploadMsg; + if (mUploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + getActivity().startActivityForResult( + Intent.createChooser(intent, "open"), + FILE_SELECTED); + } + } + + @Override + public boolean onShowFileChooser(WebView webView, ValueCallback valueCallback, FileChooserParams fileChooserParams) { + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } + + uploadMessage = valueCallback; + if (uploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + getActivity().startActivityForResult( + Intent.createChooser(intent, "open"), + REQUEST_SELECT_FILE); + } + return true; + } + }); + cookies = CookiesManager.getCookieText(getActivity()); + synCookies(mServer, cookies); + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + webView.setDownloadListener(new DownloadListener() { + @Override + public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimeType, final long contentLength) { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(getActivity(), SweetAlertDialog.NORMAL_TYPE) + .setTitleText("下载附件?") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + long caca = contentLength; + Uri uri = Uri.parse(url); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + +// downloadBySystem(url, contentDisposition, mimeType); + sweetAlertDialog.dismissWithAnimation(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + } + }); + } + + @Override + public void onResume() { + super.onResume(); +// getFaultList(type); + } + + private void showMsgFinish() { + if (isAdded()) { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + ProgressForAll.cancelProgress(); + } + }); + } + } + } + + private void showMsgDialog() { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + ProgressForAll.showProgress(getActivity(),"","页面加载中..."); + } + }); + } + } + + public void synCookies(String url, String cookies) { + CookieSyncManager.createInstance(getActivity().getApplicationContext()); + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.setAcceptCookie(true); + cookieManager.setCookie(url, cookies); + CookieSyncManager.getInstance().sync(); + } + + + @Override + public FaultFragmentContract.View getContract() { + return null; + } + + @Override + public FaultFragmentPresenter getPresenter() { + return new FaultFragmentPresenter(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_fault_tv_backlog: + webView.loadUrl(mServer + MethodURL.PJ_Base + GuideMenuUrl.url_backlog); + changeColor(tv_backlog); + break; + case R.id.moudle_fault_tv_fault_list: + webView.loadUrl(mServer + MethodURL.PJ_Base + GuideMenuUrl.url_faultlist+"unitId="+mBizid); + changeColor(tv_faultlist); + break; + case R.id.moudle_fault_tv_ww_list: + webView.loadUrl(mServer + MethodURL.PJ_Base + GuideMenuUrl.url_wwlist+"unitId="+mBizid); + changeColor(tv_wwlist); + break; + case R.id.moudle_fg_fault_tv_sub: +// NewFaultActivity.actionStart(getActivity(),"","",""); + GuideMenuActivity.actionStart(getActivity(), GuideMenuUrl.url_subfault+"unitId="+mBizid, GuideMenuUrl.name_subfault); + break; + case R.id.moudle_fg_fault_tv_all: + changeColor(tv_all); + break; + case R.id.moudle_fg_fault_tv_subed: + changeColor(tv_subed); + type = "2"; + getFaultList(type); + break; + case R.id.moudle_fg_fault_tv_doing: + changeColor(tv_doing); + type = "0"; + getFaultList(type); + break; + case R.id.moudle_fg_fault_tv_com: + changeColor(tv_com); + type = "1"; + getFaultList(type); + break; + } + } + + private void getFaultList(String type) { + isShowRefresh(); + String search_content = ""; + if (edt_search.getText()!=null&&!edt_search.getText().toString().isEmpty()){ + search_content = edt_search.getText().toString(); + } + HashMap map = new HashMap<>(); + map.put("type",type); + map.put("page",String.valueOf(page)); + map.put("rows","15"); + map.put("bizid",mBizid); + map.put("userid",mUserid); + map.put("day","120"); + map.put("search_name",search_content); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetFaultList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + showError(a); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (page==1) { + faults = parseFault(res, type); + ifShowTheEmpty(); + setAdapter(type); + }else { + List list = parseFault(res, type); + if (list.size()>0) { + faults.addAll(list); + updateLoadMore(); + }else { + noMore(); + } + } + + } + }); + } + + private void updateLoadMore() { + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + rc_view.completeLoadMore(); + if (type.equals("2")){ + newAdapter.notifyDataSetChanged(); + }else if (type.equals("0")){ + doingFaultAdapter.notifyDataSetChanged(); + }else if (type.equals("1")){ + doneFaultAdapter.notifyDataSetChanged(); + } + } + }); + } + } + } + + private void noMore() { + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(getActivity(), "这次是真没有了~", Toast.LENGTH_SHORT).show(); + } + }); + } + } + } + + private void isShowRefresh() { + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (page==1) { + if (!refresh.isRefreshing()) { + refresh.setRefreshing(true); + } + } + } + }); + } + } + } + + private void showError(String a) { + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + Toast.makeText(getActivity(), ""+a, Toast.LENGTH_SHORT).show(); + } + }); + } + } + } + + /* + 是否显示暂无数据布局 + */ + private void ifShowTheEmpty() { + if (isAdded()){ + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (faults.size() == 0) { + emptyLayout.setVisibility(View.VISIBLE); + rc_view.setVisibility(View.GONE); + } else { + emptyLayout.setVisibility(View.GONE); + rc_view.setVisibility(View.VISIBLE); + } + } + }); + } + } + } + + private void setAdapter(String type) { + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + if (type.equals("2")){ + newAdapter = new NewFaultAdapter(getActivity(), faults); + newAdapter.setOnDelListener(new NewFaultAdapter.onSwipeListener() { + @Override + public void onFault(int pos) { + if (pos >= 0 && pos < faults.size()) { + NewFaultDetailActivity.actionStart(getActivity(),faults.get(pos),"yes"); + } + } + @Override + public void onDel(int pos) { + if (pos >= 0 && pos < faults.size()) { +// DelNewFault(faults.get(pos).getId()); + } + } + }); + rc_view.setAdapter(newAdapter); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + + }else if (type.equals("0")){ + doingFaultAdapter = new DoingFaultAdapter(getActivity(),faults); + doingFaultAdapter.setOnDelListener(new DoingFaultAdapter.onSwipeListener() { + @Override + public void onFault(int pos) { + if (pos >= 0 && pos < faults.size()) { + Toast.makeText(getActivity(), "执行" + faults.get(pos).getProblemcontent(), Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onDel(int pos) { + if (pos >= 0 && pos < faults.size()) { + Toast.makeText(getActivity(), "删除" + pos, Toast.LENGTH_SHORT).show(); + } + } + }); + rc_view.setAdapter(doingFaultAdapter); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + }else if (type.equals("1")){ + doneFaultAdapter = new DoneFaultAdapter(getActivity(),faults); + rc_view.setAdapter(doneFaultAdapter); + manager = new LinearLayoutManager(getActivity()); + rc_view.setLayoutManager(manager); + } + } + }); + } + } + } + + private List parseFault(String response, String type) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + if (type.equals("2")){ + JSONArray news = new JSONArray(jsonObject.optString("content1")); + for (int i=0;i0) { + JSONObject comp = new JSONObject(news.getJSONObject(i).opt("company").toString()); + Biz biz = new Biz(); + biz.setId(comp.optString("id")); + biz.setName(comp.optString("name")); + new_fault.setBiz(biz); + }else { + Biz biz = new Biz(); + biz.setId(""); + biz.setName(""); + new_fault.setBiz(biz); + } + if (news.getJSONObject(i).opt("processSection")!=null&&!news.getJSONObject(i).opt("processSection").toString().equals("null")&&news.getJSONObject(i).opt("processSection").toString().length()>0) { + JSONObject area = new JSONObject(news.getJSONObject(i).opt("processSection").toString()); + ProcessSection proc = new ProcessSection(); + proc.setSid(area.optString("id")); + proc.setName(area.optString("name")); + new_fault.setProcessSection(proc); + }else { + ProcessSection proc = new ProcessSection(); + proc.setSid(""); + proc.setName(""); + new_fault.setProcessSection(proc); + } + new_fault.setRemark(news.getJSONObject(i).opt("remark").toString()); + new_fault.setInsdt(news.getJSONObject(i).opt("insdt").toString()); + if (news.getJSONObject(i).opt("insertUser")!=null&&!news.getJSONObject(i).opt("insertUser").toString().equals("null")&&news.getJSONObject(i).opt("insertUser").toString().length()>0) { + JSONObject capt = new JSONObject(news.getJSONObject(i).opt("insertUser").toString()); + new_fault.setInsuser(capt.optString("caption")); + }else { + new_fault.setInsuser(""); + } + new_fault.setEquipmentIds(news.getJSONObject(i).opt("equipmentIds").toString()); + new_fault.setEquipmentNames(news.getJSONObject(i).opt("equipmentNames").toString()); + list.add(new_fault); + } + }else if (type.equals("0")) { + JSONArray doings = new JSONArray(jsonObject.getString("content1")); + for (int i=0;i0) { + JSONObject area = new JSONObject(doings.getJSONObject(i).opt("processSection").toString()); + ProcessSection proc = new ProcessSection(); + proc.setSid(area.optString("id")); + proc.setName(area.optString("name")); + doing_fault.setProcessSection(proc); + }else { + ProcessSection proc = new ProcessSection(); + proc.setSid(""); + proc.setName(""); + doing_fault.setProcessSection(proc); + } + doing_fault.setProblemTypeNames(doings.getJSONObject(i).opt("problemTypeNames").toString()); + doing_fault.setProblemcontent(doings.getJSONObject(i).opt("problemcontent").toString()); + doing_fault.setPlanMoney(doings.getJSONObject(i).opt("planMoney").toString()); + if (doings.getJSONObject(i).opt("equipmentCard")!=null&&doings.getJSONObject(i).opt("equipmentCard").toString().length()>0&&!doings.getJSONObject(i).opt("equipmentCard").toString().equals("null")) { + EquList card = new EquList(); + JSONObject equ = new JSONObject(doings.getJSONObject(i).opt("equipmentCard").toString()); + card.setEquipmentname(equ.opt("equipmentname").toString()); + card.setEquipmentcardid(equ.opt("equipmentcardid").toString()); + card.setId(equ.optString("id")); + doing_fault.setEquipmentCard(card); + }else { + EquList card = new EquList(); + card.setId(""); + card.setEquipmentname(""); + card.setEquipmentcardid(""); + doing_fault.setEquipmentCard(card); + } + if (doings.getJSONObject(i).opt("insertUser")!=null&&!doings.getJSONObject(i).opt("insertUser").toString().equals("null")&&doings.getJSONObject(i).opt("insertUser").toString().length()>0) { + JSONObject capt = new JSONObject(doings.getJSONObject(i).opt("insertUser").toString()); + doing_fault.setInsuser(capt.getString("caption")); + }else { + doing_fault.setInsuser(""); + } + if (doings.getJSONObject(i).opt("todoTask")!=null&&!doings.getJSONObject(i).opt("todoTask").toString().equals("null")&&doings.getJSONObject(i).opt("todoTask").toString().length()>0) { + JSONArray todos = new JSONArray(doings.getJSONObject(i).opt("todoTask").toString()); + JSONObject capt = new JSONObject(todos.get(0).toString()); + JSONObject todo = new JSONObject(capt.opt("task").toString()); + if (todo.opt("status")!=null&&todo.opt("status").toString().length()>0){ + if (todo.opt("status").toString().contains("handle")){ + if (todo.optString("name").contains("验收")){ + doing_fault.setTaskId(todo.opt("id").toString()); + doing_fault.setTodoTask("验收中"); + }else { + if (capt.opt("assigneeUser")!=null&&!capt.opt("assigneeUser").toString().equals("null")&&capt.opt("assigneeUser").toString().length()>0) { + doing_fault.setTaskId(todo.opt("id").toString()); + doing_fault.setTodoTask("执行中"); + }else { + doing_fault.setTaskId(todo.opt("id").toString()); + doing_fault.setTodoTask("待签收"); + } + } + }else if (todo.opt("status").toString().contains("audit")){ + doing_fault.setTaskId(todo.optString("id")); + doing_fault.setTodoTask(todo.optString("name")); + } + } + JSONObject pine = new JSONObject(capt.opt("processInstance").toString()); + doing_fault.setProcessInstanceId(pine.opt("id").toString()); + } + doing_fault.setInsdt(doings.getJSONObject(i).opt("insdt").toString()); + doing_fault.setPlannedenddt(doings.getJSONObject(i).opt("plannedenddt").toString()); + list.add(doing_fault); + } + }else if (type.equals("1")) { + JSONArray dones = new JSONArray(jsonObject.getString("content1")); + for (int i=0;i0) { + JSONObject area = new JSONObject(dones.getJSONObject(i).opt("processSection").toString()); + ProcessSection proc = new ProcessSection(); + proc.setSid(area.optString("id")); + proc.setName(area.optString("name")); + done_fault.setProcessSection(proc); + }else { + ProcessSection proc = new ProcessSection(); + proc.setSid(""); + proc.setName(""); + done_fault.setProcessSection(proc); + } + done_fault.setProblemTypeNames(dones.getJSONObject(i).opt("problemTypeNames").toString()); + done_fault.setProblemcontent(dones.getJSONObject(i).opt("problemcontent").toString()); + done_fault.setPlanMoney(dones.getJSONObject(i).opt("planMoney").toString()); + if (dones.getJSONObject(i).opt("equipmentCard")!=null&&dones.getJSONObject(i).opt("equipmentCard").toString().length()>0&&!dones.getJSONObject(i).opt("equipmentCard").toString().equals("null")) { + EquList card = new EquList(); + JSONObject equ = new JSONObject(dones.getJSONObject(i).opt("equipmentCard").toString()); + card.setEquipmentname(equ.opt("equipmentname").toString()); + card.setEquipmentcardid(equ.opt("equipmentcardid").toString()); + done_fault.setEquipmentCard(card); + }else { + EquList card = new EquList(); + card.setEquipmentname(""); + card.setEquipmentcardid(""); + done_fault.setEquipmentCard(card); + } + if (dones.getJSONObject(i).opt("insertUser")!=null&&!dones.getJSONObject(i).optString("insertUser").equals("null")&&dones.getJSONObject(i).optString("insertUser").length()>0) { + JSONObject capt = new JSONObject(dones.getJSONObject(i).optString("insertUser")); + done_fault.setInsuser(capt.optString("caption")); + }else { + done_fault.setInsuser(""); + } + done_fault.setTodoTask("任务完成"); + done_fault.setInsdt(dones.getJSONObject(i).optString("insdt")); + done_fault.setEquipmentOpinion(dones.getJSONObject(i).optString("equipmentOpinion")); + done_fault.setPlanMoney(dones.getJSONObject(i).optString("planMoney")); + done_fault.setPlannedenddt(dones.getJSONObject(i).optString("plannedenddt")); + done_fault.setMaterialOpinion(dones.getJSONObject(i).optString("materialOpinion")); + done_fault.setQualityOpinion(dones.getJSONObject(i).optString("qualityOpinion")); + list.add(done_fault); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } + + private void changeColor(TextView tv) { + tv_backlog.setTextColor(getResources().getColor(R.color.gray03)); + tv_faultlist.setTextColor(getResources().getColor(R.color.gray03)); + tv_wwlist.setTextColor(getResources().getColor(R.color.gray03)); + tv.setTextColor(getResources().getColor(R.color.text_blue)); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentContract.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentContract.java new file mode 100644 index 0000000..1d5579a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentContract.java @@ -0,0 +1,22 @@ +package com.sipai.jspatrol.Main.fragment.faultfragment; + + +import com.sipai.jspatrol.Bean.BaseEntity; + +/** + * created by lvliming on 2019/9/16 + */ +public interface FaultFragmentContract { + + interface Model{ + + } + + interface View{ + + } + + interface Presenter{ + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentModel.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentModel.java new file mode 100644 index 0000000..30376f1 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentModel.java @@ -0,0 +1,18 @@ +package com.sipai.jspatrol.Main.fragment.faultfragment; + + +import com.sipai.jspatrol.Base.BaseFragmentModel; + +/** + * created by lvliming on 2019/9/16 + */ +public class FaultFragmentModel extends BaseFragmentModel { + public FaultFragmentModel(FaultFragmentPresenter mainFragmentPresenter) { + super(mainFragmentPresenter); + } + + @Override + public FaultFragmentContract.Model getContract() { + return null; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentPresenter.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentPresenter.java new file mode 100644 index 0000000..271a28d --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/faultfragment/FaultFragmentPresenter.java @@ -0,0 +1,19 @@ +package com.sipai.jspatrol.Main.fragment.faultfragment; + + +import com.sipai.jspatrol.Base.BaseFragmentPresenter; + +/** + * created by lvliming on 2019/9/16 + */ +public class FaultFragmentPresenter extends BaseFragmentPresenter { + @Override + public FaultFragmentContract.Presenter getContract() { + return null; + } + + @Override + public FaultFragmentModel getModel() { + return new FaultFragmentModel(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragment.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragment.java new file mode 100644 index 0000000..05500e4 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragment.java @@ -0,0 +1,233 @@ +package com.sipai.jspatrol.Main.fragment.fifthFragment; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.sipai.jspatrol.Base.ActivityCollector; +import com.sipai.jspatrol.Base.BaseFragmentView; +import com.sipai.jspatrol.Login.LoginActivity; +import com.sipai.jspatrol.NFC.NFCGuideActivity; +import com.sipai.jspatrol.Patrol.ProPatrolTaskListActivity; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.Service.IPatrolService; +import com.sipai.jspatrol.URL.GuideMenuUrl; +import com.sipai.jspatrol.Webv.GuideMenuActivity; +import com.sipai.jspatrol.Webv.GuideMenuLandscapeActivity; +import com.sipai.jspatrol.background.locationservice.LocationService; +import com.sipai.jspatrol.utils.SharedPreferencesData; + +import java.util.HashMap; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +import static android.content.Context.MODE_PRIVATE; + +/** + * created by lvliming on 2019/9/16 + */ +public class FifthFragment extends BaseFragmentView implements View.OnClickListener { + private SharedPreferencesData sharedpre; + private HashMap map_base = new HashMap<>(); + private String mServer; + private String ip_in_plant = "", ip_off_site = "";//厂内,厂外ip地址 + private String mCaption; + private String mBizid; + private String mTotaltime; + private String mLastlogintime; + private String nfc; + private RelativeLayout rl_screen; + private TextView tv_name,tv_totaltime,tv_lastlogin; + private LinearLayout ll_about,ll_switch,ll_exit,ll_video; + private Button btn_sub,btn_catch; + private TextView tv_shift_record; + + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_fifth,container,false); + init(); + initView(view); + return view; + } + + private void initView(View view) { + tv_name = view.findViewById(R.id.moudle_fifth_fg_tv_name); + showText(tv_name,mCaption); + tv_totaltime = view.findViewById(R.id.moudle_fifth_fg_tv_totaltime); + showText(tv_totaltime,"登录时长: "+mTotaltime+" 小时"); + tv_lastlogin = view.findViewById(R.id.moudle_fifth_fg_tv_lastlogin); + showText(tv_lastlogin,"上次登录: "+mLastlogintime); + ll_about = view.findViewById(R.id.moudle_fifth_fg_ll_about); + ll_about.setOnClickListener(this); + ll_switch = view.findViewById(R.id.moudle_fifth_fg_ll_switch); + ll_switch.setOnClickListener(this); + ll_exit = view.findViewById(R.id.moudle_fifth_fg_ll_exit); + ll_exit.setOnClickListener(this); + ll_video = view.findViewById(R.id.moudle_fifth_fg_ll_nfc); + ll_video.setOnClickListener(this); + if (!nfc.equals("true")){ + ll_video.setVisibility(View.GONE); + } + btn_sub = view.findViewById(R.id.moudle_fifth_fg_btn_sub); + btn_sub.setOnClickListener(this); + btn_catch = view.findViewById(R.id.moudle_fifth_fg_btn_catch); + btn_catch.setOnClickListener(this); + tv_shift_record = view.findViewById(R.id.moudle_fifth_fg_tv_shift_record); + tv_shift_record.setOnClickListener(this); + } + + private void showText(final TextView tv, String st) { + if (tv!=null&&st!=null){ + if (st.isEmpty()){ + st = ""; + } + if (!getActivity().isFinishing()){ + final String finalSt = st; + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + tv.setText(finalSt); + } + }); + } + } + } + + private void init() { + sharedpre = new SharedPreferencesData(getActivity()); + map_base = sharedpre.getAll(); + ip_in_plant = map_base.get("ip_in_plant"); + ip_off_site = map_base.get("ip_off_site"); + mServer = map_base.get("mServer"); + mCaption = map_base.get("mCaption"); + mTotaltime = map_base.get("mTotaltime"); + mLastlogintime = map_base.get("mLastlogintime"); + SharedPreferences sharedPre=getActivity().getSharedPreferences("config", MODE_PRIVATE); + mBizid = sharedPre.getString("bizid", ""); + nfc=sharedPre.getString("nfc", ""); + } + + @Override + public FifthFragmentContract.View getContract() { + return null; + } + + @Override + public FifthFragmentPresenter getPresenter() { + return new FifthFragmentPresenter(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_fifth_fg_tv_shift_record: + GuideMenuLandscapeActivity.actionStart(getActivity(), GuideMenuUrl.url_shift_record+"?unitId="+mBizid, GuideMenuUrl.name_shift_record); + break; + case R.id.moudle_fifth_fg_btn_sub: + GuideMenuActivity.actionStart(getActivity(), GuideMenuUrl.url_sub+"?unitId="+mBizid, GuideMenuUrl.name_sub); + break; + case R.id.moudle_fifth_fg_btn_catch: + GuideMenuActivity.actionStart(getActivity(), GuideMenuUrl.url_catch+"?unitId="+mBizid, GuideMenuUrl.name_catch); + break; + case R.id.moudle_fifth_fg_ll_about: +// Intent intent = new Intent(getActivity(), AboutOfSoftwareActivity.class); +// startActivity(intent); + break; + case R.id.moudle_fifth_fg_ll_switch: + showDialog("switch"); + break; + case R.id.moudle_fifth_fg_ll_exit: + showDialog("exit"); + break; + case R.id.moudle_fifth_fg_ll_nfc: + if (nfc.equals("true")){ + Intent intent = new Intent(getActivity(), NFCGuideActivity.class); + startActivity(intent); + }else { + showToast("请联系管理员开放此权限"); + } + +// Intent intent_video = new Intent(getActivity(), CameraListActivity.class); +// startActivity(intent_video); +// Intent intent_video = new Intent(getActivity(), HKWSActivity.class); +// startActivity(intent_video); + break; + } + } + + private void showToast(String s) { + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(getActivity(), s, Toast.LENGTH_LONG).show(); + } + }); + } + } + + private void showDialog(String st) { + if (!getActivity().isFinishing()){ + if (st.equals("switch")){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(getActivity(), SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("是否确认切换用户?") + .setConfirmText("切换") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + sharedpre.removePwd(); + getActivity().finish(); + Intent intent = new Intent(getActivity(), LoginActivity.class); + getActivity().startActivity(intent); + } + }).setCancelText("取消").show(); + } + }); + }else if (st.equals("exit")){ + new SweetAlertDialog(getActivity(), SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("是否确认退出?") + .setConfirmText("退出") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + Intent intent = new Intent(getActivity(), IPatrolService.class); + getActivity().stopService(intent); + Intent intent_loc = new Intent(getActivity(), LocationService.class); + getActivity().stopService(intent_loc); + sweetAlertDialog.dismissWithAnimation(); + ActivityCollector.finishAll(); + } + }).setCancelText("取消").show(); + } + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentContract.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentContract.java new file mode 100644 index 0000000..3eecea9 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentContract.java @@ -0,0 +1,22 @@ +package com.sipai.jspatrol.Main.fragment.fifthFragment; + + +import com.sipai.jspatrol.Bean.BaseEntity; + +/** + * created by lvliming on 2019/9/16 + */ +public interface FifthFragmentContract { + + interface Model{ + + } + + interface View{ + + } + + interface Presenter{ + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentModel.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentModel.java new file mode 100644 index 0000000..c7aac4a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentModel.java @@ -0,0 +1,18 @@ +package com.sipai.jspatrol.Main.fragment.fifthFragment; + + +import com.sipai.jspatrol.Base.BaseFragmentModel; + +/** + * created by lvliming on 2019/9/16 + */ +public class FifthFragmentModel extends BaseFragmentModel { + public FifthFragmentModel(FifthFragmentPresenter mainFragmentPresenter) { + super(mainFragmentPresenter); + } + + @Override + public FifthFragmentContract.Model getContract() { + return null; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentPresenter.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentPresenter.java new file mode 100644 index 0000000..8de68a3 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/fifthFragment/FifthFragmentPresenter.java @@ -0,0 +1,19 @@ +package com.sipai.jspatrol.Main.fragment.fifthFragment; + + +import com.sipai.jspatrol.Base.BaseFragmentPresenter; + +/** + * created by lvliming on 2019/9/16 + */ +public class FifthFragmentPresenter extends BaseFragmentPresenter { + @Override + public FifthFragmentContract.Presenter getContract() { + return null; + } + + @Override + public FifthFragmentModel getModel() { + return new FifthFragmentModel(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragment.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragment.java new file mode 100644 index 0000000..72bfc0b --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragment.java @@ -0,0 +1,801 @@ +package com.sipai.jspatrol.Main.fragment.mainfragment; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.gigamole.navigationtabstrip.NavigationTabStrip; +import com.sipai.jspatrol.Alarm.AlarmListActivity; +import com.sipai.jspatrol.Base.BaseFragmentView; +import com.sipai.jspatrol.Bean.Biz; +import com.sipai.jspatrol.Bean.MainTab; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.Bean.Message; +import com.sipai.jspatrol.Bean.Patrol; +import com.sipai.jspatrol.Bean.PatrolModel; +import com.sipai.jspatrol.Equ.EquSearchActivity; +import com.sipai.jspatrol.Fault.NewFaultActivity; +import com.sipai.jspatrol.Message.MessageAdapter; +import com.sipai.jspatrol.MonitorScreen.MonitorScreenListActivity; +import com.sipai.jspatrol.Patrol.ProPatrolTaskListActivity; +import com.sipai.jspatrol.PointAnalysis.SelPointListActivity; +import com.sipai.jspatrol.PointAnalysis.SolutionListActivity; +import com.sipai.jspatrol.ProMonitoring.MeasurePointsAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.Service.IPatrolService; +import com.sipai.jspatrol.Statement.StatementTypeActivity; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.Webv.GuideMenuActivity; +import com.sipai.jspatrol.URL.GuideMenuUrl; +import com.sipai.jspatrol.utils.BroadCastManager; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.SharedPreferencesData; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; +import com.sipai.ui.EmptyLayout; +import com.sipai.ui.bizPopWindow.CustomListPopupWindow; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.FormBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +import static android.content.Context.MODE_PRIVATE; +import static com.sipai.jspatrol.Service.IPatrolService.update_biz; + +/** + * created by lvliming on 2020/6/16 + * 主页 + */ +public class MainFragment extends BaseFragmentView implements View.OnClickListener, CustomListPopupWindow.ItemClickCallBack { + private SharedPreferencesData sharedpre; + private HashMap map_key_msg = new HashMap<>(); + private HashMap map_base = new HashMap<>(); + private String mServer; + private String mUserid; + private String ip_in_plant = "", ip_off_site = "";//厂内,厂外ip地址 + private SweetAlertDialog pDialog; + private RelativeLayout rl_patrol,rl_equ_search; + private BroadcastReceiver mReceiver,pointReceiver; + private List patrols = new ArrayList<>(); + private TextView tv_duration, tv_task_name; + private TextView tv_all, tv_unsub, tv_sub; + private String all; + private String unsub; + private String sub; + private List msgs = new ArrayList<>(); + private RecyclerView rc_msg; + private MessageAdapter msgAdapter; + private LinearLayoutManager manager; + private RelativeLayout rl_file,rl_wz,rl_backlog,rl_alarm,rl_statement,rl_monitor_screen,rl_sel_point,rl_solution; + private TextView tv_biz; + CustomListPopupWindow mPopupWindow; + private CustomListPopupWindow.ItemClickCallBack mCallBack; + private String mCheckedUId=""; + private Context mContext; + private String bizs; + private List bizList = new ArrayList<>(); + private String mBizName; + private String mBizid; + private NavigationTabStrip tab; +// private List tab_title = Arrays.asList(new String[]{"进水", "出水", "液位"}); + private String[] tab_title; + private List mainTabs = new ArrayList<>(); + private List points = new ArrayList<>(); + private MeasurePointsAdapter pointlistadapter; + private EmptyLayout emptyLayout; + private List daily_patrols = new ArrayList<>(); + private String patrolType; + + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_main, container, false); + mCallBack=this; + mContext=getActivity(); + init(); + initView(view); + initBroadcast(); + getTab(); + return view; + } + + @Override + public void onResume() { + super.onResume(); + getPatrolTask(); + } + + private void getTab() { + HashMap map = new HashMap<>(); + map.put("unitId",mBizid); + OKHttpUtils.OKCall(map, mServer, MethodURL.GetMainTab_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + showDialog("标签获取失败,请重试"); + noPoint(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("code")&&res.contains("msg")&&res.contains("result")){ + mainTabs = parseMainTab(res); + if (mainTabs.size()>0){ + tab_title = new String[mainTabs.size()]; + for (int i=0;i0){ + tab.setTabIndex(0); + getTabPointList(mainTabs.get(0).getId()); + } + } + }); + } + } + } + + private List parseMainTab(String res) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = jsonObject.getJSONArray("result"); + for (int i=0;i map = new HashMap<>(); + map.put("page","1"); + map.put("rows","50"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetMsgList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); +// showError(a); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("rows")&&res.contains("total")){ + msgs = parseMsgs(res); + updateMsgs(); + } + } + }); + } + + private void updateMsgs() { + if (isAdded()) { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (msgs.size() > 0) { + manager = new LinearLayoutManager(getActivity()); + rc_msg.setLayoutManager(manager); + msgAdapter = new MessageAdapter(msgs); + rc_msg.setAdapter(msgAdapter); + } + } + }); + } + } + } + + private List parseMsgs(String res) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = jsonObject.getJSONArray("rows"); + if (array.length()>0){ + for (int i=0;i0) { + pointlistadapter.setData(points); + updateNValue(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void updateNValue() { + if (isAdded()&&!getActivity().isFinishing()){ + getActivity().runOnUiThread(()->{ + pointlistadapter.notifyDataSetChanged(); + }); + } + } + + @Override + public void callBack(Biz biz) { + mCheckedUId=biz.getBizid(); + final String name = biz.getName(); + saveBizid(getActivity(),mCheckedUId,name); + if (isAdded()) { + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + tv_biz.setText(name); + mPopupWindow.dismiss(); + } + }); + } + } + getTab(); + } + + private void saveBizid(Context context,String bizid, String name) { + //获取SharedPreferences对象 + SharedPreferences sharedPre=context.getSharedPreferences("config", MODE_PRIVATE); + //获取Editor对象 + SharedPreferences.Editor editor=sharedPre.edit(); + //设置参数 + editor.putString("bizid", bizid); + editor.putString("bizname",name); + //提交 + editor.commit(); + mBizid=sharedPre.getString("bizid", ""); + mBizName = sharedPre.getString("bizname",""); + Intent intent = new Intent(update_biz); + getActivity().sendBroadcast(intent); + } + + class NowTaskReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + try { + patrols = (List) intent.getSerializableExtra("tasks"); + all = intent.getStringExtra("all"); + unsub = intent.getStringExtra("unsub"); + sub = intent.getStringExtra("sub"); + updatePatrols(); + } catch (Exception e) { + + } + } + } + + private void updatePatrols() { + if (isAdded()){ + if (!getActivity().isFinishing()) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + tv_all.setText(all); + tv_unsub.setText(unsub); + tv_sub.setText(sub); + if (patrols.size() > 0) { + if (patrols.get(0).getStartTime().length()>15&&patrols.get(0).getEndTime().length()>15) { + tv_duration.setText("(" + patrols.get(0).getStartTime().substring(5, 16) + " -- " + patrols.get(0).getEndTime().substring(5, 16) + ")"); + } + if (patrols.get(0).getName()!=null&&!patrols.get(0).getName().isEmpty()) { + tv_task_name.setText(patrols.get(0).getName()); + } + } else { + tv_duration.setText(""); + tv_duration.setText("暂无任务"); + } + } + }); + } + } + } + + private void initView(View view) { + pDialog = new SweetAlertDialog(getActivity(), SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + tab = view.findViewById(R.id.moudle_fg_main_tab); + tab.setOnTabStripSelectedIndexListener(new NavigationTabStrip.OnTabStripSelectedIndexListener() { + @Override + public void onStartTabSelected(String title, int index) { + getTabPointList(mainTabs.get(index).getId()); + } + + @Override + public void onEndTabSelected(String title, int index) { + + } + }); + emptyLayout = view.findViewById(R.id.moudle_main_fg_ui_empty); + emptyLayout.setOnClickListener(this); + rl_sel_point = view.findViewById(R.id.moudle_main_fg_rl_sel_point); + rl_sel_point.setOnClickListener(this); + rl_solution = view.findViewById(R.id.moudle_main_fg_rl_solution); + rl_solution.setOnClickListener(this); + rl_alarm = view.findViewById(R.id.moudle_main_fg_rl_alarm); + rl_alarm.setOnClickListener(this); + rl_patrol = view.findViewById(R.id.moudle_fg_main_rl_patrol); + rl_patrol.setOnClickListener(this); + rl_equ_search = view.findViewById(R.id.moudle_main_fg_rl_equ_search); + rl_equ_search.setOnClickListener(this); + rl_statement = view.findViewById(R.id.moudle_main_fg_rl_statement); + rl_statement.setOnClickListener(this); + tv_duration = view.findViewById(R.id.moudle_fg_main_tv_duration); + tv_task_name = view.findViewById(R.id.moudle_fg_main_tv_task_name); + tv_all = view.findViewById(R.id.moudle_main_fg_task_all); + tv_unsub = view.findViewById(R.id.moudle_main_fg_task_unsub); + tv_sub = view.findViewById(R.id.moudle_main_fg_task_sub); + rc_msg = view.findViewById(R.id.moudle_main_fg_rc_msg); + manager = new LinearLayoutManager(getActivity()); + rc_msg.setLayoutManager(manager); + rl_monitor_screen = view.findViewById(R.id.moudle_main_fg_rl_monitor_screen); + rl_monitor_screen.setOnClickListener(this); +// rl_file = view.findViewById(R.id.moudle_main_fg_rl_file); +// rl_file.setOnClickListener(this); + rl_backlog = view.findViewById(R.id.moudle_main_fg_rl_backlog); + rl_backlog.setOnClickListener(this); + tv_biz = view.findViewById(R.id.moudle_fg_main_tv_bizname); + tv_biz.setText(mBizName); + tv_biz.setOnClickListener(this); + } + + private void getTabPointList(String id) { + HashMap map = new HashMap<>(); + map.put("page","1"); + map.put("rows","100"); + map.put("unitId",mBizid); + map.put("pid",id); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetMainTabPointList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); +// showError(a); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res!=null&&!res.isEmpty()&&!res.contains("html")){ + points = parsePoints(res); + if (points.size()>0) { + updatePoints(); + }else { + showDialog("请至平台配置关联测量点"); + noPoint(); + } + }else { + showDialog("测量点获取失败,请重试"); + noPoint(); + } + } + }); + } + + private void updatePoints() { + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + emptyLayout.setVisibility(View.GONE); + rc_msg.setVisibility(View.VISIBLE); + pointlistadapter = new MeasurePointsAdapter(getActivity(),points); + rc_msg.setAdapter(pointlistadapter); + } + }); + } + } + } + + private List parsePoints(String res) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(res); + for (int i=0;i parseBiz(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i=0;i0){ + getTabPointList(mainTabs.get(tab.getTabIndex()).getId()); + }else { + getTab(); + } + break; + case R.id.moudle_main_fg_rl_backlog: + NewFaultActivity.actionStart(getActivity(),"","",""); +// GuideMenuActivity.actionStart(getActivity(), GuideMenuUrl.url_backlog, GuideMenuUrl.name_backlog); +// GuideMenuActivity.actionStart(getActivity(), GuideMenuUrl.url_subfault+"unitId="+mBizid, GuideMenuUrl.name_subfault); + break; + case R.id.moudle_main_fg_rl_monitor_screen: + Intent intent_ms = new Intent(getActivity(), MonitorScreenListActivity.class); + startActivity(intent_ms); + break; +// case R.id.moudle_main_fg_rl_file: +// GuideMenuActivity.actionStart(getActivity(), GuideMenuUrl.url_technical_file, GuideMenuUrl.name_technical_file); +// break; + case R.id.moudle_fg_main_rl_patrol: + Intent intent_patrol = new Intent(getActivity(), ProPatrolTaskListActivity.class); + startActivity(intent_patrol); + break; + case R.id.moudle_main_fg_rl_equ_search: + EquSearchActivity.actionStart(getActivity()); + break; + case R.id.moudle_fg_main_tv_bizname: + mPopupWindow=new CustomListPopupWindow(mContext, bizList,mCheckedUId, mCallBack); + mPopupWindow.showAsDropDown(tv_biz); + break; + case R.id.moudle_main_fg_rl_statement: + Intent intent_statement = new Intent(getActivity(), StatementTypeActivity.class); + startActivity(intent_statement); + break; + } + } + + private void getPatrolTask() { + HashMap map = new HashMap<>(); + map.put("unitId",mBizid); + map.put("userIds",mUserid); + map.put("bizid",mBizid); + map.put("type","P"); + OKHttpUtils.OKCallGet(map, mServer, MethodURL.GetPatrolList_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (!res.contains("fail")&&res.contains("allNum")) { + daily_patrols = getDailyPatrols(res); + if (daily_patrols.size()>0){ + List nowPatrols = checkPatrols(daily_patrols); + patrols = nowPatrols; + if (nowPatrols.size()==0){ + Patrol patrol = new Patrol(); + patrol.setContent("暂无任务"); + patrol.setEndTime(""); + patrol.setName("暂无任务"); + patrol.setStartTime(""); + nowPatrols.add(patrol); + } + updatePatrols(); + } + } + } + }); + } + + private List getDailyPatrols(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + all = jsonObject.opt("allNum").toString(); + unsub = jsonObject.opt("inCompleteNum").toString(); + sub = jsonObject.opt("completeNum").toString(); + JSONArray arry = new JSONArray(jsonObject.optString("content1")); + for (int i=0;i checkPatrols(List daily_patrols) { + List list = new ArrayList<>(); + for (int i=0;i=0&&result1<=0){ + list.add(item); + } + } catch (ParseException e) { + e.printStackTrace(); + } + } + return list; + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentContract.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentContract.java new file mode 100644 index 0000000..e508709 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentContract.java @@ -0,0 +1,21 @@ +package com.sipai.jspatrol.Main.fragment.mainfragment; + +import com.sipai.jspatrol.Bean.BaseEntity; + +/** + * created by lvliming on 2019/9/16 + */ +public interface MainFragmentContract { + + interface Model{ + + } + + interface View{ + + } + + interface Presenter{ + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentModel.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentModel.java new file mode 100644 index 0000000..899eb4b --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentModel.java @@ -0,0 +1,25 @@ +package com.sipai.jspatrol.Main.fragment.mainfragment; + +import com.sipai.jspatrol.Base.BaseFragmentModel; + +/** + * created by lvliming on 2019/9/16 + */ +public class MainFragmentModel extends BaseFragmentModel { + private String result; + private int un; + public MainFragmentModel(MainFragmentPresenter mainFragmentPresenter) { + super(mainFragmentPresenter); + } + + /** + * 获取系统消息 + * @return + */ + @Override + public MainFragmentContract.Model getContract() { + return new MainFragmentContract.Model() { + }; + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentPresenter.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentPresenter.java new file mode 100644 index 0000000..fab20f6 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/mainfragment/MainFragmentPresenter.java @@ -0,0 +1,20 @@ +package com.sipai.jspatrol.Main.fragment.mainfragment; + +import com.sipai.jspatrol.Base.BaseFragmentPresenter; + +/** + * created by lvliming on 2019/9/16 + */ +public class MainFragmentPresenter extends BaseFragmentPresenter { + @Override + public MainFragmentContract.Presenter getContract() { + return new MainFragmentContract.Presenter() { + + }; + } + + @Override + public MainFragmentModel getModel() { + return new MainFragmentModel(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragment.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragment.java new file mode 100644 index 0000000..2be3d91 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragment.java @@ -0,0 +1,661 @@ +package com.sipai.jspatrol.Main.fragment.promFragment; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.gigamole.navigationtabstrip.NavigationTabStrip; +import com.sipai.jspatrol.Base.BaseFragmentView; +import com.sipai.jspatrol.Bean.Area; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.ProMonitoring.MeasurePointsAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.Service.IPatrolService; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.BroadCastManager; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.ui.EmptyLayout; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +/** + * created by lvliming on 2019/9/16 + */ +public class ProMFragment extends BaseFragmentView implements View.OnClickListener{ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private String mGroup; + private String mGroup_com; + private String type_name = "";//type名称 + private Spinner area_sp;//区域sp + private Spinner type_sp;//类别sp + private Button iv_refresh; + private BroadcastReceiver mReceiver; + private BroadcastReceiver iReceiver; + private BroadcastReceiver refreshReceiver; + private SwipeRefreshLayout refreshLayout; + private RecyclerView recyclerView; + private ArrayAdapter typeadapter; + private static String[] types = {"全部信号","AI","DI"}; + private ArrayAdapter areaadapter; + private List areas = new ArrayList<>(); + private List areaname = new ArrayList<>(); + private static final int AREAS = 1; + private static final int POINTS = 2; + private LinearLayoutManager manager; + //上一个界面传过来的标志,用于判断返回 + private String b_mark; + private String area_id = ""; + private List points = new ArrayList<>(); + private MeasurePointsAdapter pointlistadapter; + private SweetAlertDialog pDialog; + private int area_locate = 0;//标记所选工艺段的下标 + private EmptyLayout emptyLayout; + private NavigationTabStrip tab; + private String[] tab_title = {"所有点","已收藏"}; + private String name = ""; + private int sel = 0; + private EditText edt_search; + private TextView tv_search,tv_show_search; + private LinearLayout ll_search; + private BroadcastReceiver pointReceiver; + + private Handler handler = new Handler(){ + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what){ + case AREAS: + if (isAdded()) { + if (!getActivity().isFinishing()) { + refreshLayout.setRefreshing(false); + areaadapter = new ArrayAdapter(getActivity(), R.layout.item_down, R.id.tv_down_sp, areaname); + area_sp.setAdapter(areaadapter); + area_sp.setSelection(area_locate); + } + } + break; + case POINTS: + if (isAdded()) { + if (!getActivity().isFinishing()) { + refreshLayout.setRefreshing(false); + if (points.size()>0) { + recyclerView.setVisibility(View.VISIBLE); + emptyLayout.setVisibility(View.GONE); + pointlistadapter = new MeasurePointsAdapter(getActivity(),points); + pointlistadapter.setOnCollecteListener(new MeasurePointsAdapter.onSwipeListener() { + @Override + public void onCollecte(int pos) { + if (!points.get(pos).getUserid().isEmpty()&&!points.get(pos).getUserid().equals("null")){ + unCollectePoints(points.get(pos),pos); + }else { + collectePoints(points.get(pos),pos); + } + } + }); + recyclerView.setAdapter(pointlistadapter); + }else { + recyclerView.setVisibility(View.GONE); + emptyLayout.setVisibility(View.VISIBLE); + } + } + } + break; + } + } + }; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_pro_m,container,false); + init(); + initView(view); + initBroadcast(); +// getarea(); + return view; + } + + private void initBroadcast() { + IntentFilter filter_nv = new IntentFilter(); + filter_nv.addAction(IPatrolService.update_newvalue); + pointReceiver = new NewValueReceiver(); + BroadCastManager.getInstance().registerReceiver(getActivity(), pointReceiver, filter_nv); + } + + private void init() { + SharedPreferences sharedPre = getActivity().getSharedPreferences("config", 0); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + } + + private void initView(View view) { + pDialog = new SweetAlertDialog(getActivity(), SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setTitleText("搜索中..."); + pDialog.setCancelable(false); + pDialog.setCanceledOnTouchOutside(false); + emptyLayout = view.findViewById(R.id.production_monitor_ui_empty); + edt_search = view.findViewById(R.id.production_monitor_edt_search); + ll_search = view.findViewById(R.id.moudle_pro_ll_search); + tv_search = view.findViewById(R.id.production_tv_search); + tv_search.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { +// page=1; + getAllPoints(sel); + } + }); + tv_show_search = view.findViewById(R.id.production_tv_show_search); + tv_show_search.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (ll_search.getVisibility()==View.GONE){ + tv_show_search.setText("隐藏"); + ll_search.setVisibility(View.VISIBLE); + }else { + tv_show_search.setText("搜索"); + edt_search.setText(""); + ll_search.setVisibility(View.GONE); + } + } + }); + type_sp = view.findViewById(R.id.production_monitor_type_sp); + typeadapter = new ArrayAdapter(getActivity(),R.layout.item_down,R.id.tv_down_sp,types); + type_sp.setAdapter(typeadapter); + type_sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + type_name = types[position]; + if (type_name.equals("全部信号")){ + type_name="全部"; + } + if (area_id!=null&&!area_id.isEmpty()) { + getAllPoints(sel); + }else { + area_id = ""; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + tab = view.findViewById(R.id.moudle_fg_pro_management_tab); + tab.setTitles(tab_title); + tab.setTabIndex(0); + tab.setOnTabStripSelectedIndexListener(new NavigationTabStrip.OnTabStripSelectedIndexListener() { + @Override + public void onStartTabSelected(String title, int index) { + sel = index; + getAllPoints(sel); + } + + @Override + public void onEndTabSelected(String title, int index) { + + } + }); + + pointlistadapter = new MeasurePointsAdapter(getActivity(),points); + + manager = new LinearLayoutManager(getActivity()); + area_sp = view.findViewById(R.id.production_monitor_area_sp); + iv_refresh = view.findViewById(R.id.production_iv_refresh); + iv_refresh.setOnClickListener(this); + refreshLayout = view.findViewById(R.id.production_monitor_refresh); + recyclerView = view.findViewById(R.id.production_monitor_recycleview); + recyclerView.setLayoutManager(manager); + recyclerView.setAdapter(pointlistadapter); + refreshLayout.setColorSchemeResources(R.color.blue); + refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getarea(); + } + }); + areaadapter = new ArrayAdapter(getActivity(),R.layout.item_down,R.id.tv_down_sp,areaname); + area_sp.setAdapter(areaadapter); + area_sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { +// Toast.makeText(ProductionMonitorActivity.this, ""+areaname.get(position), Toast.LENGTH_SHORT).show(); + if (areaname.get(position).equals("无")||areas.size()<1) { + if (type_name != null && !type_name.isEmpty()) { +// getAllPoints(); + } + }else { + area_id = areas.get(position).getId(); + area_locate = position; + if (type_name != null && !type_name.isEmpty()) { + getAllPoints(sel); + } + } + } + + @Override + public void onNothingSelected(AdapterView parent) { +// Toast.makeText(ProductionMonitorActivity.this, ""+areaname.get(0), Toast.LENGTH_SHORT).show(); +// area_id = areas.get(0).getCode(); +// getAllPoints(); + } + }); + } + + @Override + public void onResume() { + super.onResume(); + getarea(); + } + + @Override + public ProMFragmentContract.View getContract() { + return null; + } + + @Override + public ProMFragmentPresenter getPresenter() { + return new ProMFragmentPresenter(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + BroadCastManager.getInstance().unregisterReceiver(getActivity(),pointReceiver); + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.production_iv_refresh: + getarea(); + break; + } + } + + /** + * 更新数据广播 + */ + class NewValueReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + try { + String nValue = intent.getStringExtra("newvalue"); + parsenValue(nValue); + } catch (Exception e) { + + } + } + } + + private void parsenValue(String nValue) { + int cou=0; + try { + JSONArray array = new JSONArray(nValue); + for (int i=0;i0) { + updatePoints(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void updatePoints() { + if (isAdded()&&!getActivity().isFinishing()){ + getActivity().runOnUiThread(()->{ + pointlistadapter.setData(points); + pointlistadapter.notifyDataSetChanged(); + }); + } + } + + private void getarea() { + showDialog(); + HashMap map = new HashMap<>(); + map.put("page","1"); + map.put("rows","500"); + map.put("search_code",mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETPSLISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + hideDialog(); + String a = e.toString(); + if (isAdded()) { + if (!getActivity().isFinishing()) { + refreshLayout.setRefreshing(false); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(getActivity(), SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("工艺段数据获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getarea(); + } + }).show(); + } + }); + } + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + Log.i("areaname", "onSuccess: "+response); + hideDialog(); + areaname.clear(); + areas = getAreaData(res); + Log.i("areaname", "onSuccess: "+areas.size()); + if (areas!=null&&!areas.isEmpty()){ + for (int i=0;i getAreaData(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + + JSONArray aNews = new JSONArray(jsonObject.getString("rows")); + if (aNews != null && aNews.length() > 0) { + for (int i = 0; i map = new HashMap<>(); + map.put("bizid",mBizid);//厂id + map.put("processSectionCode", area_id);//工艺段 + map.put("isCollected",String.valueOf(index==1)); + map.put("page","1"); + map.put("userId",mUserid); + map.put("search_name",name); + map.put("rows","300"); + map.put("type", type_name);//类型 + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetAllCollectePoint_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + Toast.makeText(getActivity(), "测量点刷新失败,请重试!", Toast.LENGTH_SHORT).show(); + } + }); + } + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + points = getAreaPoints(res,type_name); + Message message = new Message(); + message.what = POINTS; + handler.sendMessage(message); + isShowEmpty(); + } + }); + } + + private List getAreaPoints(String response,String type) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + + JSONArray aNews = new JSONArray(jsonObject.getString("content1")); + if (aNews != null && aNews.length() > 0) { + for (int i = 0; i 0){ + recyclerView.setVisibility(View.VISIBLE); + emptyLayout.setVisibility(View.GONE); + }else { + recyclerView.setVisibility(View.GONE); + emptyLayout.setVisibility(View.VISIBLE); + } + } + }); + } + } + } + + private void collectePoints(Measuringpoint point,int pos){ + HashMap map = new HashMap<>(); + map.put("bizid",mBizid);//厂id + map.put("userId",mUserid); + map.put("mpid",point.getSid()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.CollectePoint_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + showToast("co","fail",pos); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.equals("fail")){ + showToast("co","fail",pos); + }else if (res.equals("suc")){ + showToast("co","suc",pos); + } + } + }); + } + + private void unCollectePoints(Measuringpoint point,int pos){ + HashMap map = new HashMap<>(); + map.put("bizid",mBizid);//厂id + map.put("userId",mUserid); + map.put("mpid",point.getSid()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.UnCollectePoint_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + showToast("un","fail",pos); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.equals("fail")){ + showToast("un","fail",pos); + }else if (res.equals("suc")){ + showToast("un","suc",pos); + } + } + }); + } + + private void showToast(String mark,String st,int pos) { + if (isAdded()){ + if (!getActivity().isFinishing()){ + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (mark.equals("un")) { + if (st.equals("suc")) { + Toast.makeText(getActivity(), "取消收藏成功", Toast.LENGTH_SHORT).show(); + if (sel==1){ + points.remove(pos); + pointlistadapter.setData(points); + pointlistadapter.notifyDataSetChanged(); + isShowEmpty(); + }else { + points.get(pos).setUserid(""); + pointlistadapter.notifyItemChanged(pos); + } + } else { + Toast.makeText(getActivity(), "取消收藏失败", Toast.LENGTH_SHORT).show(); + } + }else if (mark.equals("co")){ + if (st.equals("suc")) { + Toast.makeText(getActivity(), "收藏成功", Toast.LENGTH_SHORT).show(); + points.get(pos).setUserid(mUserid); + pointlistadapter.notifyItemChanged(pos); + } else { + Toast.makeText(getActivity(), "收藏失败", Toast.LENGTH_SHORT).show(); + } + } + } + }); + } + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentContract.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentContract.java new file mode 100644 index 0000000..514d10a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentContract.java @@ -0,0 +1,22 @@ +package com.sipai.jspatrol.Main.fragment.promFragment; + + +import com.sipai.jspatrol.Bean.BaseEntity; + +/** + * created by lvliming on 2019/9/16 + */ +public interface ProMFragmentContract { + + interface Model{ + + } + + interface View{ + + } + + interface Presenter{ + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentModel.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentModel.java new file mode 100644 index 0000000..ce8ff82 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentModel.java @@ -0,0 +1,18 @@ +package com.sipai.jspatrol.Main.fragment.promFragment; + + +import com.sipai.jspatrol.Base.BaseFragmentModel; + +/** + * created by lvliming on 2019/9/16 + */ +public class ProMFragmentModel extends BaseFragmentModel { + public ProMFragmentModel(ProMFragmentPresenter mainFragmentPresenter) { + super(mainFragmentPresenter); + } + + @Override + public ProMFragmentContract.Model getContract() { + return null; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentPresenter.java b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentPresenter.java new file mode 100644 index 0000000..9e43e42 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Main/fragment/promFragment/ProMFragmentPresenter.java @@ -0,0 +1,19 @@ +package com.sipai.jspatrol.Main.fragment.promFragment; + + +import com.sipai.jspatrol.Base.BaseFragmentPresenter; + +/** + * created by lvliming on 2019/9/16 + */ +public class ProMFragmentPresenter extends BaseFragmentPresenter { + @Override + public ProMFragmentContract.Presenter getContract() { + return null; + } + + @Override + public ProMFragmentModel getModel() { + return new ProMFragmentModel(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Message/MessageActivity.java b/app/src/main/java/com/sipai/jspatrol/Message/MessageActivity.java new file mode 100644 index 0000000..cb45a9f --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Message/MessageActivity.java @@ -0,0 +1,25 @@ +package com.sipai.jspatrol.Message; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +import com.sipai.jspatrol.R; + +public class MessageActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_message); + init(); + initView(); + } + + private void initView() { + } + + private void init() { + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Message/MessageAdapter.java b/app/src/main/java/com/sipai/jspatrol/Message/MessageAdapter.java new file mode 100644 index 0000000..eec4677 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Message/MessageAdapter.java @@ -0,0 +1,59 @@ +package com.sipai.jspatrol.Message; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import androidx.recyclerview.widget.RecyclerView; +import com.sipai.jspatrol.Bean.Message; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * Created by lvliming on 2017/10/24. + */ + +public class MessageAdapter extends RecyclerView.Adapter { + private List list; + + public MessageAdapter(List list) { + this.list = list; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.msg.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + Message item = list.get(position); + holder.time.setText(item.getSdt()); + holder.content.setText(item.getContent()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + static class ViewHolder extends RecyclerView.ViewHolder{ + View msg; + TextView time,content; + public ViewHolder(View itemView) { + super(itemView); + msg = itemView; + time = itemView.findViewById(R.id.moudle_item_message_tv_time); + content = itemView.findViewById(R.id.moudle_item_message_tv_content); + + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MenuTypeAdapter.java b/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MenuTypeAdapter.java new file mode 100644 index 0000000..9518de4 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MenuTypeAdapter.java @@ -0,0 +1,80 @@ +package com.sipai.jspatrol.MonitorScreen; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.Nodes; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * created by lvliming on 2021/3/19 + */ +public class MenuTypeAdapter extends RecyclerView.Adapter { + private List list; + private Context context; + //接口实例 + private RecyclerViewOnItemClickListener onItemClickListener; + + public MenuTypeAdapter(List list, Context context, RecyclerViewOnItemClickListener onItemClickListener) { + this.list = list; + this.context = context; + this.onItemClickListener = onItemClickListener; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_monitor_screen,parent,false); + ViewHolder viewHolder = new ViewHolder(view); + return viewHolder; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + Nodes item = list.get(position); + holder.name.setText(item.getText()); + if (item.getSel().equals("sel")){ + holder.name.setTextColor(context.getResources().getColor(R.color.white)); + holder.name.setBackground(context.getResources().getDrawable(R.drawable.bg_layout_shape_type_blue)); + }else { + holder.name.setTextColor(context.getResources().getColor(R.color.gray)); + holder.name.setBackground(context.getResources().getDrawable(R.drawable.bg_layout_shape_type_white)); + } + holder.mth.setTag(position); + } + + @Override + public int getItemCount() { + return list.size(); + } + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + View mth; + TextView name; + public ViewHolder(View itemView) { + super(itemView); + mth = itemView; + name = (TextView) itemView.findViewById(R.id.moudle_item_monitor_screen_tv_title); + itemView.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + //注意这里使用getTag方法获取数据 + onItemClickListener.onItemClickListener(v, (Integer) v.getTag()); + } + } + } + //接口回调设置点击事件 + public interface RecyclerViewOnItemClickListener { + //点击事件 + void onItemClickListener(View view, int position); + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MonitorScreenAdapter.java b/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MonitorScreenAdapter.java new file mode 100644 index 0000000..9955826 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MonitorScreenAdapter.java @@ -0,0 +1,90 @@ +package com.sipai.jspatrol.MonitorScreen; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.Nodes; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.GuideMenuUrl; +import com.sipai.jspatrol.Webv.MonitorScreenActivity; + +import java.util.List; + +/** + * created by lvliming on 2021/1/19 + */ +public class MonitorScreenAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + + public MonitorScreenAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_monitor_screen_ps,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.node.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + Nodes item = list.get(position); + MonitorScreenActivity.actionStart(context, GuideMenuUrl.url_monitor_screen+"?frameId="+item.getId(),item.getText()); + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Nodes item = list.get(position); + holder.tv_title.setText(item.getText()); + if (item.getText().contains("间")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_room)); + }else if (item.getText().contains("池")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_pool)); + }else if (item.getText().contains("滤池")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_filter_pool)); + }else if (item.getText().contains("脱水机房")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_water_room)); + }else if (item.getText().contains("鼓风机房")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_wind_room)); + }else if (item.getText().contains("沉淀池")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_settling_)); + }else if (item.getText().contains("泵房")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_pump_room)); + }else if (item.getText().contains("进水")) { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_area)); + }else { + holder.iv.setImageDrawable(context.getResources().getDrawable(R.mipmap.moudle_iv_pump_room)); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + View node; + ImageView iv; + TextView tv_title; + public ViewHolder(@NonNull View itemView) { + super(itemView); + node = itemView; + iv = itemView.findViewById(R.id.item_monitor_screen_iv); + tv_title = itemView.findViewById(R.id.item_monitor_screen_tv); + } + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MonitorScreenListActivity.java b/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MonitorScreenListActivity.java new file mode 100644 index 0000000..8f1860d --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/MonitorScreen/MonitorScreenListActivity.java @@ -0,0 +1,210 @@ +package com.sipai.jspatrol.MonitorScreen; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; + +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.sipai.jspatrol.Bean.Nodes; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.GuideMenuUrl; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.Webv.MonitorScreenActivity; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.ui.EmptyLayout; + +import org.json.JSONArray; +import org.json.JSONException; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class MonitorScreenListActivity extends AppCompatActivity { + private String mServer; + private String mBizid; + private List nodes; + private RecyclerView rc_type; + private RecyclerView rc_ps; + private LinearLayoutManager orManager; + private StaggeredGridLayoutManager manager; + private MenuTypeAdapter typeAdapter; + private MonitorScreenAdapter msAdapter; + private int sel = 0; + private EmptyLayout emptyLayout; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_monitor_screen_list); + init(); + initView(); + getMonitorScreenList(); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("监视画面"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + emptyLayout = findViewById(R.id.moudle_monitor_screen_ui_empty); + rc_type = findViewById(R.id.moudle_monitor_screen_rc_type); + orManager = new LinearLayoutManager(this); + orManager.setOrientation(RecyclerView.HORIZONTAL); + rc_type.setLayoutManager(orManager); + rc_ps = findViewById(R.id.moudle_monitor_screen_rc_ps); + manager = new StaggeredGridLayoutManager(4,StaggeredGridLayoutManager.VERTICAL); + rc_ps.setLayoutManager(manager); + } + + private void init() { + SharedPreferences sharedPre=this.getSharedPreferences("config", 0); + mServer=sharedPre.getString("server", ""); + mBizid=sharedPre.getString("bizid", ""); + } + + private void getMonitorScreenList() { + HashMap map = new HashMap<>(); + map.put("menuType", "proVisual"); + map.put("unitId", mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetFrameTree_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorResponse(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + nodes = parseNodes(res); + if (nodes.size()>0) { + nodes.get(0).setSel("sel"); + setType(); + +// setPSAdapter(); + }else { + errorResponse(); + } + } + }); + } + + private void setType() { + if (!MonitorScreenListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + typeAdapter = new MenuTypeAdapter(nodes,MonitorScreenListActivity.this, new MenuTypeAdapter.RecyclerViewOnItemClickListener(){ + @Override + public void onItemClickListener(View view, int position) { + nodes.get(sel).setSel("unsel"); + nodes.get(position).setSel("sel"); + sel = position; + typeAdapter.notifyDataSetChanged(); + if (nodes.get(sel).getNodes().size()>0) { + setPSAdapter(); + }else { + MonitorScreenActivity.actionStart(MonitorScreenListActivity.this, GuideMenuUrl.url_monitor_screen+"?frameId="+nodes.get(sel).getId(),nodes.get(sel).getText()); + } + } + }); + rc_type.setAdapter(typeAdapter); + if (nodes.get(sel).getNodes().size()>0) { + setPSAdapter(); + }else { + new SweetAlertDialog(MonitorScreenListActivity.this,SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("是否进入"+nodes.get(sel).getText()+"?") + .setConfirmText("进入") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + MonitorScreenActivity.actionStart(MonitorScreenListActivity.this, GuideMenuUrl.url_monitor_screen+"?frameId="+nodes.get(sel).getId(),nodes.get(sel).getText()); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + } + }); + } + } + + private void setPSAdapter() { + if (!MonitorScreenListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (nodes.get(sel).getNodes()!=null&&nodes.get(sel).getNodes().size()>0){ + emptyLayout.setVisibility(View.GONE); + rc_ps.setVisibility(View.VISIBLE); + msAdapter = new MonitorScreenAdapter(MonitorScreenListActivity.this,nodes.get(sel).getNodes()); + rc_ps.setAdapter(msAdapter); + }else { + emptyLayout.setVisibility(View.VISIBLE); + rc_ps.setVisibility(View.GONE); + } + } + }); + } + } + + private List parseNodes(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i=0;i areas = new ArrayList<>(); + if (!array.getJSONObject(i).optString("nodes").isEmpty()&&!array.getJSONObject(i).optString("nodes").equals("null")) { + areas = parseNodes(array.getJSONObject(i).optString("nodes")); + } + item.setNodes(areas); + list.add(item); + } + } catch (JSONException e) { + e.printStackTrace(); + return list; + } + return list; + } + + private void errorResponse() { + if (!MonitorScreenListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(MonitorScreenListActivity.this, "列表获取失败!", Toast.LENGTH_SHORT).show(); + } + }); + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/sipai/jspatrol/NFC/EquList.java b/app/src/main/java/com/sipai/jspatrol/NFC/EquList.java new file mode 100644 index 0000000..a67e60c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/NFC/EquList.java @@ -0,0 +1,430 @@ +package com.sipai.jspatrol.NFC; + + +import java.io.Serializable; + +public class EquList implements Serializable { + private String areaid; + private String assetClass; + private String assetclassid; + private String assetnumber; + private String bizid; + private String company; + private String currentmanageflag; + private String equipmentClass; + private String equipmentLevel; + private String equipmentPid; + private String equipmentSpecification; + private String equipmentTypeNumber; + private String equipmentcardid; + private String equipmentclassid; + private String equipmentlevelid; + private String equipmentmanufacturer; + private String equipmentmodel; + private String equipmentname; + private String equipmentstatus; + private String equipmentvalue; + private String geographyarea; + private String id; + private String insdt; + private String insuser; + private String leavefactorynumber; + private String maintenancecondition; + private String majorparameter; + private String nowtotaldepreciation; + private String pid; + private String processSection; + private String processsectionid; + private String productiondate; + private String purchasedate; + private String ratedcurrent; + private String ratedpower; + private String ratedvoltage; + private String remark; + private String residualvalue; + private String responsibledepartment; + private String servicephone; + private String specification; + private String sql; + private String supplierid; + private String totaltime; + private String useage; + private String usedate; + private String where; + + public String getAreaid() { + return areaid; + } + + public void setAreaid(String areaid) { + this.areaid = areaid; + } + + public String getAssetClass() { + return assetClass; + } + + public void setAssetClass(String assetClass) { + this.assetClass = assetClass; + } + + public String getAssetclassid() { + return assetclassid; + } + + public void setAssetclassid(String assetclassid) { + this.assetclassid = assetclassid; + } + + public String getAssetnumber() { + return assetnumber; + } + + public void setAssetnumber(String assetnumber) { + this.assetnumber = assetnumber; + } + + public String getBizid() { + return bizid; + } + + public void setBizid(String bizid) { + this.bizid = bizid; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public String getCurrentmanageflag() { + return currentmanageflag; + } + + public void setCurrentmanageflag(String currentmanageflag) { + this.currentmanageflag = currentmanageflag; + } + + public String getEquipmentClass() { + return equipmentClass; + } + + public void setEquipmentClass(String equipmentClass) { + this.equipmentClass = equipmentClass; + } + + public String getEquipmentLevel() { + return equipmentLevel; + } + + public void setEquipmentLevel(String equipmentLevel) { + this.equipmentLevel = equipmentLevel; + } + + public String getEquipmentPid() { + return equipmentPid; + } + + public void setEquipmentPid(String equipmentPid) { + this.equipmentPid = equipmentPid; + } + + public String getEquipmentSpecification() { + return equipmentSpecification; + } + + public void setEquipmentSpecification(String equipmentSpecification) { + this.equipmentSpecification = equipmentSpecification; + } + + public String getEquipmentTypeNumber() { + return equipmentTypeNumber; + } + + public void setEquipmentTypeNumber(String equipmentTypeNumber) { + this.equipmentTypeNumber = equipmentTypeNumber; + } + + public String getEquipmentcardid() { + return equipmentcardid; + } + + public void setEquipmentcardid(String equipmentcardid) { + this.equipmentcardid = equipmentcardid; + } + + public String getEquipmentclassid() { + return equipmentclassid; + } + + public void setEquipmentclassid(String equipmentclassid) { + this.equipmentclassid = equipmentclassid; + } + + public String getEquipmentlevelid() { + return equipmentlevelid; + } + + public void setEquipmentlevelid(String equipmentlevelid) { + this.equipmentlevelid = equipmentlevelid; + } + + public String getEquipmentmanufacturer() { + return equipmentmanufacturer; + } + + public void setEquipmentmanufacturer(String equipmentmanufacturer) { + this.equipmentmanufacturer = equipmentmanufacturer; + } + + public String getEquipmentmodel() { + return equipmentmodel; + } + + public void setEquipmentmodel(String equipmentmodel) { + this.equipmentmodel = equipmentmodel; + } + + public String getEquipmentname() { + return equipmentname; + } + + public void setEquipmentname(String equipmentname) { + this.equipmentname = equipmentname; + } + + public String getEquipmentstatus() { + return equipmentstatus; + } + + public void setEquipmentstatus(String equipmentstatus) { + this.equipmentstatus = equipmentstatus; + } + + public String getEquipmentvalue() { + return equipmentvalue; + } + + public void setEquipmentvalue(String equipmentvalue) { + this.equipmentvalue = equipmentvalue; + } + + public String getGeographyarea() { + return geographyarea; + } + + public void setGeographyarea(String geographyarea) { + this.geographyarea = geographyarea; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInsdt() { + return insdt; + } + + public void setInsdt(String insdt) { + this.insdt = insdt; + } + + public String getInsuser() { + return insuser; + } + + public void setInsuser(String insuser) { + this.insuser = insuser; + } + + public String getLeavefactorynumber() { + return leavefactorynumber; + } + + public void setLeavefactorynumber(String leavefactorynumber) { + this.leavefactorynumber = leavefactorynumber; + } + + public String getMaintenancecondition() { + return maintenancecondition; + } + + public void setMaintenancecondition(String maintenancecondition) { + this.maintenancecondition = maintenancecondition; + } + + public String getMajorparameter() { + return majorparameter; + } + + public void setMajorparameter(String majorparameter) { + this.majorparameter = majorparameter; + } + + public String getNowtotaldepreciation() { + return nowtotaldepreciation; + } + + public void setNowtotaldepreciation(String nowtotaldepreciation) { + this.nowtotaldepreciation = nowtotaldepreciation; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public String getProcessSection() { + return processSection; + } + + public void setProcessSection(String processSection) { + this.processSection = processSection; + } + + public String getProcesssectionid() { + return processsectionid; + } + + public void setProcesssectionid(String processsectionid) { + this.processsectionid = processsectionid; + } + + public String getProductiondate() { + return productiondate; + } + + public void setProductiondate(String productiondate) { + this.productiondate = productiondate; + } + + public String getPurchasedate() { + return purchasedate; + } + + public void setPurchasedate(String purchasedate) { + this.purchasedate = purchasedate; + } + + public String getRatedcurrent() { + return ratedcurrent; + } + + public void setRatedcurrent(String ratedcurrent) { + this.ratedcurrent = ratedcurrent; + } + + public String getRatedpower() { + return ratedpower; + } + + public void setRatedpower(String ratedpower) { + this.ratedpower = ratedpower; + } + + public String getRatedvoltage() { + return ratedvoltage; + } + + public void setRatedvoltage(String ratedvoltage) { + this.ratedvoltage = ratedvoltage; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getResidualvalue() { + return residualvalue; + } + + public void setResidualvalue(String residualvalue) { + this.residualvalue = residualvalue; + } + + public String getResponsibledepartment() { + return responsibledepartment; + } + + public void setResponsibledepartment(String responsibledepartment) { + this.responsibledepartment = responsibledepartment; + } + + public String getServicephone() { + return servicephone; + } + + public void setServicephone(String servicephone) { + this.servicephone = servicephone; + } + + public String getSpecification() { + return specification; + } + + public void setSpecification(String specification) { + this.specification = specification; + } + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getSupplierid() { + return supplierid; + } + + public void setSupplierid(String supplierid) { + this.supplierid = supplierid; + } + + public String getTotaltime() { + return totaltime; + } + + public void setTotaltime(String totaltime) { + this.totaltime = totaltime; + } + + public String getUseage() { + return useage; + } + + public void setUseage(String useage) { + this.useage = useage; + } + + public String getUsedate() { + return usedate; + } + + public void setUsedate(String usedate) { + this.usedate = usedate; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/NFC/EquNFCAdapter.java b/app/src/main/java/com/sipai/jspatrol/NFC/EquNFCAdapter.java new file mode 100644 index 0000000..d01ea76 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/NFC/EquNFCAdapter.java @@ -0,0 +1,80 @@ +package com.sipai.jspatrol.NFC; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * Created by lvliming on 2019/5/7. + */ + +public class EquNFCAdapter extends RecyclerView.Adapter { + private List list; + private Context mContext; + private onRecyclerViewItemClick mOnRvItemClick; + + public EquNFCAdapter(Context mContext, List list, onRecyclerViewItemClick mOnRvItemClick) { + this.mContext = mContext; + this.list = list; + this.mOnRvItemClick = mOnRvItemClick; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_equ_nfc,parent,false); + final ViewHolder holder = new ViewHolder(view); +// holder.point.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// int position = holder.getAdapterPosition(); +// PatrolPoint patrolPoint = list.get(position); +// WriteTag.actionStart(view.getContext(),patrolPoint.getId()); +// } +// }); + return holder; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + EquList equ = list.get(position); + holder.tv_equ_name.setText(equ.getEquipmentname()); + holder.tv_equ_info.setText("设备编号:"+equ.getEquipmentcardid()+"\n"+"资产编号:"+equ.getAssetnumber()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + View equ; + TextView tv_equ_name,tv_equ_info; + public ViewHolder(View itemView) { + super(itemView); + equ = itemView; + tv_equ_name = (TextView) itemView.findViewById(R.id.moudle_equ_nfc_tv_name); + tv_equ_info = itemView.findViewById(R.id.moudle_equ_nfc_tv_info); + equ.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (mOnRvItemClick != null) + mOnRvItemClick.onItemClick(view, getAdapterPosition()); + } + } + /** + * item点击接口 + */ + public interface onRecyclerViewItemClick { + void onItemClick(View v, int position); + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/NFC/NFCEquListActivity.java b/app/src/main/java/com/sipai/jspatrol/NFC/NFCEquListActivity.java new file mode 100644 index 0000000..56f0491 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/NFC/NFCEquListActivity.java @@ -0,0 +1,275 @@ +package com.sipai.jspatrol.NFC; + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.util.Log; +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 androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class NFCEquListActivity extends Activity { + private EditText edt_equ; + private Button btn_search; + private RecyclerView rc_view; + private LinearLayoutManager manager; + private List equs = new ArrayList<>(); + private EquNFCAdapter adapter; + private SweetAlertDialog pDialog; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_nfcequ_list); + init(); + initView(); + } + + /** + * 初始化 + */ + private String mServer; + private String mUserid; + private String mCaption; + private String mBizid; + + public void init() { + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + mServer = sharedPre.getString("server", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("数据写入"); + TextView tv_right = (TextView) findViewById(R.id.moudle_back_title_tv_save); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setTitleText("数据加载中..."); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + edt_equ = findViewById(R.id.moudle_nfcequ_edt_equ); + btn_search = findViewById(R.id.moudle_nfcequ_btn_search); + btn_search.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + checkList(); + } + }); + rc_view = findViewById(R.id.moudle_nfcequ_rc); + manager = new LinearLayoutManager(NFCEquListActivity.this); + rc_view.setLayoutManager(manager); + adapter = new EquNFCAdapter(NFCEquListActivity.this, equs, new EquNFCAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + EquList aa=equs.get(position); + String mPPid=aa.getId(); + Intent intent=new Intent(); + intent.putExtra("ppid",mPPid); + intent.putExtra("class","equ"); + setResult(RESULT_OK, intent); + finish(); + } + }); + rc_view.setAdapter(adapter); + } + + private void showDialog() { + if (!NFCEquListActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.show(); + } + }); + } + } + + private void hideDialog() { + if (!NFCEquListActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (pDialog.isShowing()) { + pDialog.hide(); + } + } + }); + } + } + + @Override + protected void onResume() { + super.onResume(); + checkList(); + } + + private void checkList() { + String equ = ""; + if (edt_equ.getText()!=null&&!edt_equ.getText().toString().isEmpty()){ + equ = edt_equ.getText().toString(); + } + getEquList(equ); + } + + private void getEquList(String equ) { + showDialog(); + HashMap map = new HashMap<>(); + map.put("unitId",mBizid); + map.put("search_code",equ); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.GetALLEquList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!NFCEquListActivity.this.isFinishing()) { + hideDialog(); + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NFCEquListActivity.this,"获取设备信息失败!",Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (!NFCEquListActivity.this.isFinishing()) { + hideDialog(); + if(res.isEmpty()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(NFCEquListActivity.this,"未查询到设备信息!",Toast.LENGTH_SHORT).show(); + } + }); + + }else{ + equs=getData(res); + runOnUiThread(new Runnable() { + @Override + public void run() { + manager = new LinearLayoutManager(NFCEquListActivity.this); + rc_view.setLayoutManager(manager); + adapter = new EquNFCAdapter(NFCEquListActivity.this, equs, new EquNFCAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + EquList aa=equs.get(position); + String mPPid=aa.getId(); + Intent intent=new Intent(); + intent.putExtra("ppid",mPPid); + intent.putExtra("class","equ"); + setResult(RESULT_OK, intent); + finish(); + } + }); + rc_view.setAdapter(adapter); + } + }); + } + } + } + }); + } + + private List getData(String response) { + List list = new ArrayList(); + try{ + JSONObject jsonObject = new JSONObject(response); + JSONArray array = new JSONArray(jsonObject.optString("result")); + for (int i=0;i bizList = new ArrayList<>(); + private String mBizid; + private String mBizName; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_nfcguide); + mCallBack=this; + mContext=this; + init(); + initView(); + } + + private void init() { + SharedPreferences sharedPreferences = getSharedPreferences("config",MODE_PRIVATE); + bizs = sharedPreferences.getString("biz",""); + bizList = parseBiz(bizs); + mBizName = sharedPreferences.getString("bizname",""); + } + + private void initView() { + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("NFC读写"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + tv_right = (TextView) findViewById(R.id.moudle_back_title_tv_save); + tv_right.setText(mBizName); + tv_right.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mPopupWindow=new CustomListPopupWindow(mContext, bizList,mCheckedUId, mCallBack); + mPopupWindow.showAsDropDown(tv_right); + } + }); + btn_read = findViewById(R.id.moudle_nfcguide_btn_read); + btn_read.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(NFCGuideActivity.this,ReadTag.class); + startActivity(intent); + } + }); + btn_write = findViewById(R.id.moudle_nfcguide_btn_write); + btn_write.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(NFCGuideActivity.this,WriteTag.class); + startActivity(intent); + } + }); + } + + @Override + public void callBack(Biz biz) { + mCheckedUId=biz.getBizid(); + final String name = biz.getName(); + saveBizid(NFCGuideActivity.this,mCheckedUId,name); + runOnUiThread(new Runnable() { + @Override + public void run() { + tv_right.setText(name); + mPopupWindow.dismiss(); + } + }); + } + + private List parseBiz(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i=0;i list = new ArrayList<>(); + private String mServer; + private String mBizid; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_patrol_point); + inits(); + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("巡检点选择"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + rc_view = (RecyclerView) findViewById(R.id.moudle_patrolpoint_rc); + manager = new LinearLayoutManager(PatrolPointActivity.this); + rc_view.setLayoutManager(manager); + adapter = new PatrolPointAdapter(PatrolPointActivity.this, list, new PatrolPointAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + PatrolPoint item = list.get(position); + Intent intent=new Intent(); + intent.putExtra("ppid",item.getId()); + intent.putExtra("class","PatrolPointActivity"); + setResult(PatrolPointActivity.this.RESULT_OK, intent); + finish(); + } + }); + rc_view.setAdapter(adapter); + refreshLayout = (SwipeRefreshLayout) findViewById(R.id.moudle_patrolpoint_refresh); + refreshLayout.setColorSchemeResources(R.color.blue); + refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getPatrolPoints(); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + getPatrolPoints(); + } + + private void getPatrolPoints() { + HashMap map = new HashMap<>(); + map.put("type","P"); + map.put("unitId",mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.GetALLPatrolPointList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + if (!PatrolPointActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + Toast.makeText(PatrolPointActivity.this,"获取巡更点信息失败!",Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (!PatrolPointActivity.this.isFinishing()) { + if (res.isEmpty()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + Toast.makeText(PatrolPointActivity.this, "未查询到厂区巡检点信息!", Toast.LENGTH_SHORT).show(); + } + }); + + } else { + list = getData(res); + runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); + manager = new LinearLayoutManager(PatrolPointActivity.this); + rc_view.setLayoutManager(manager); + adapter = new PatrolPointAdapter(PatrolPointActivity.this, list, new PatrolPointAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + PatrolPoint item = list.get(position); + Intent intent = new Intent(); + intent.putExtra("ppid", item.getId()); + intent.putExtra("class", "point"); + setResult(PatrolPointActivity.this.RESULT_OK, intent); + finish(); + } + }); + rc_view.setAdapter(adapter); + } + }); + } + } + } + }); + +// PersistentCookieStore myCookieStore = new PersistentCookieStore(this); +// RequestParams params = new RequestParams(); +// params.add("search_code",mBizid); +// AsyncHttpClient client = new AsyncHttpClient(); +// client.setCookieStore(myCookieStore); +// client.post(mServer+"timeEfficiency/patrolPoint/getList4APP.do",params ,new AsyncHttpResponseHandler() { +// @Override +// public void onSuccess(String response) { +// if(response.isEmpty()){ +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// refreshLayout.setRefreshing(false); +// Toast.makeText(PatrolPointActivity.this,"未查询到厂区信息!",Toast.LENGTH_SHORT).show(); +// } +// }); +// +// }else{ +// list=getData(response); +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// refreshLayout.setRefreshing(false); +// manager = new LinearLayoutManager(PatrolPointActivity.this); +// rc_view.setLayoutManager(manager); +// adapter = new PatrolPointAdapter(PatrolPointActivity.this, list, new PatrolPointAdapter.onRecyclerViewItemClick() { +// @Override +// public void onItemClick(View v, int position) { +// PatrolPoint item = list.get(position); +// Intent intent=new Intent(); +// intent.putExtra("ppid",item.getId()); +// intent.putExtra("class","point"); +// setResult(PatrolPointActivity.this.RESULT_OK, intent); +// finish(); +// } +// }); +// rc_view.setAdapter(adapter); +// } +// }); +// } +// } +// +// @Override +// public void onFailure(Throwable e) { +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// refreshLayout.setRefreshing(false); +// Toast.makeText(PatrolPointActivity.this,"获取巡更点信息失败!",Toast.LENGTH_SHORT).show(); +// } +// }); +// +// } +// +// @Override +// public void onStart() { +// super.onStart(); +// } +// +// @Override +// public void onFinish() { +// super.onFinish(); +// } +// }); + + } + + private List getData(String response) { + List listres = new ArrayList<>(); + try{ + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.getString("result") ); + if(aNews!=null && aNews.length()>0){ + for(int i=0;i { + private List list; + private Context mContext; + private onRecyclerViewItemClick mOnRvItemClick; + + public PatrolPointAdapter(Context mContext,List list, onRecyclerViewItemClick mOnRvItemClick) { + this.mContext = mContext; + this.list = list; + this.mOnRvItemClick = mOnRvItemClick; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_patrolpoint,parent,false); + final ViewHolder holder = new ViewHolder(view); +// holder.point.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// int position = holder.getAdapterPosition(); +// PatrolPoint patrolPoint = list.get(position); +// WriteTag.actionStart(view.getContext(),patrolPoint.getId()); +// } +// }); + return holder; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + PatrolPoint patrolPoint = list.get(position); + holder.tv_point.setText(patrolPoint.getName()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + View point; + TextView tv_point; + public ViewHolder(View itemView) { + super(itemView); + point = itemView; + tv_point = (TextView) itemView.findViewById(R.id.item_patrolpoint_tv_name); + point.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (mOnRvItemClick != null) + mOnRvItemClick.onItemClick(view, getAdapterPosition()); + } + } + /** + * item点击接口 + */ + public interface onRecyclerViewItemClick { + void onItemClick(View v, int position); + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/NFC/ReadTag.java b/app/src/main/java/com/sipai/jspatrol/NFC/ReadTag.java new file mode 100644 index 0000000..a2140be --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/NFC/ReadTag.java @@ -0,0 +1,191 @@ +package com.sipai.jspatrol.NFC; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.PendingIntent; +import android.content.Intent; +import android.content.IntentFilter; +import android.nfc.NdefMessage; +import android.nfc.NdefRecord; +import android.nfc.NfcAdapter; +import android.nfc.tech.MifareClassic; +import android.nfc.tech.NfcA; +import android.os.Bundle; +import android.os.Parcelable; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.sipai.jspatrol.R; + +/** + * + * + * @see + * @des + * + * Nfc 标签的扫描 + * + * + */ +@SuppressLint("NewApi") +public class ReadTag extends Activity { + private NfcAdapter nfcAdapter; + private TextView resultText; + private PendingIntent pendingIntent; + private IntentFilter[] mFilters; + private String[][] mTechLists; + private Button mJumpTagBtn; + private boolean isFirst = true; + // 是否支持NFC功能的标签 + private boolean isNFC_support = false; + @SuppressLint("NewApi") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // 获取nfc适配器,判断设备是否支持NFC功能 + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + if (nfcAdapter == null) { + Toast.makeText(this, getResources().getString(R.string.no_nfc), + Toast.LENGTH_SHORT).show(); +// finish(); +// return; + } else if (!nfcAdapter.isEnabled()) { + Toast.makeText(this, getResources().getString(R.string.open_nfc), + Toast.LENGTH_SHORT).show(); +// finish(); +// return; + } + + setContentView(R.layout.read_tag); + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("NFC读取"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + TextView tv_right = (TextView) findViewById(R.id.moudle_back_title_tv_save); + tv_right.setText("写入"); + tv_right.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(ReadTag.this,WriteTag.class); + startActivity(intent); + } + }); + // 显示结果Text + resultText = (TextView) findViewById(R.id.resultText); + // 写入标签按钮 + mJumpTagBtn = (Button) findViewById(R.id.jump); + mJumpTagBtn.setOnClickListener(new WriteBtnOnClick()); + + pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, + getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); + ndef.addCategory("*/*"); + mFilters = new IntentFilter[] { ndef };// 过滤器 + mTechLists = new String[][] { + new String[] { MifareClassic.class.getName() }, + new String[] { NfcA.class.getName() } };// 允许扫描的标签类型 + + } + + @SuppressLint("NewApi") + @Override + protected void onResume() { + // TODO Auto-generated method stub + super.onResume(); + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + if (nfcAdapter==null||!nfcAdapter.isEnabled()) { + isNFC_support=false; + }else{ + isNFC_support=true; + } + if (isNFC_support) { + nfcAdapter.enableForegroundDispatch(this, pendingIntent, mFilters, + mTechLists); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) { + // 注意这个if中的代码几乎不会进来,因为刚刚在上一行代码开启了监听NFC连接,下一行代码马上就收到了NFC连接的intent,这种几率很小 + // 处理该intent + String result = processIntent(getIntent()); + resultText.setText(result); + } +// isFirst = false; + } + + } + @Override + protected void onPause() { + super.onPause(); + if (nfcAdapter !=null && nfcAdapter.isEnabled()) { + // 当前Activity如果不在手机的最前端,就停止NFC设备连接的监听 + stopNFC_Listener(); + } + } + private void stopNFC_Listener() { + // 停止监听NFC设备是否连接 + nfcAdapter.disableForegroundDispatch(this); + } + @Override + protected void onNewIntent(Intent intent) { + // TODO Auto-generated method stub + // 当前app正在前端界面运行,这个时候有intent发送过来,那么系统就会调用onNewIntent回调方法,将intent传送过来 + // 我们只需要在这里检验这个intent是否是NFC相关的intent,如果是,就调用处理方法 + super.onNewIntent(intent); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { + String result = processIntent(intent); + resultText.setText(result); + } + } + + /** + * 获取tab标签中的内容 + * + * @param intent + * @return + */ + @SuppressLint("NewApi") + private String processIntent(Intent intent) { + Parcelable[] rawmsgs = intent + .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); + if (rawmsgs!=null) { + NdefMessage msg = (NdefMessage) rawmsgs[0]; + NdefRecord[] records = msg.getRecords(); + String resultStr = new String(records[0].getPayload()); + return resultStr; + }else{ + return "error"; + } + + + } + + /** + * 按钮点击事件 + * + * + * + */ + class WriteBtnOnClick implements OnClickListener { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + switch (v.getId()) { + case R.id.jump: + Intent intent = new Intent(ReadTag.this, WriteTag.class); + startActivity(intent); + default: + break; + } + } + + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/NFC/WriteTag.java b/app/src/main/java/com/sipai/jspatrol/NFC/WriteTag.java new file mode 100644 index 0000000..bc88c97 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/NFC/WriteTag.java @@ -0,0 +1,349 @@ +package com.sipai.jspatrol.NFC; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.nfc.NdefMessage; +import android.nfc.NdefRecord; +import android.nfc.NfcAdapter; +import android.nfc.Tag; +import android.nfc.tech.MifareClassic; +import android.nfc.tech.Ndef; +import android.nfc.tech.NdefFormatable; +import android.nfc.tech.NfcA; +import android.os.Bundle; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.sipai.jspatrol.Fault.SingleChoiceActivity; +import com.sipai.jspatrol.R; + +import java.io.IOException; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +/** + * 写入标签 + * + * @warn:弹出dialog 允许写入 + + * + */ +@SuppressLint("NewApi") +public class WriteTag extends Activity { + + private IntentFilter[] mWriteTagFilters; + private NfcAdapter nfcAdapter; + PendingIntent pendingIntent; + String[][] mTechLists; + Button writeBtn; + boolean isWrite = false; + EditText mContentEditText; + public static final int REQUSET = 1; + private Button btn_patrolpoint,btn_equ,btn_box; + private String cname = ""; + public static void actionStart(Context context,String id){ + Intent intent = new Intent(context,WriteTag.class); + intent.putExtra("id",id); + context.startActivity(intent); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + setContentView(R.layout.write_tag); + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("数据写入"); + TextView tv_right = (TextView) findViewById(R.id.moudle_back_title_tv_save); + tv_right.setText("读取"); + tv_right.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(WriteTag.this,ReadTag.class); + startActivity(intent); + } + }); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + writeBtn = (Button) findViewById(R.id.writeBtn); + writeBtn.setOnClickListener(new WriteOnClick()); + mContentEditText = (EditText) findViewById(R.id.content_edit); + // 获取nfc适配器,判断设备是否支持NFC功能 + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + if (nfcAdapter == null) { + Toast.makeText(this, getResources().getString(R.string.no_nfc), + Toast.LENGTH_SHORT).show(); + finish(); + return; + } else if (!nfcAdapter.isEnabled()) { + Toast.makeText(this, getResources().getString(R.string.open_nfc), + Toast.LENGTH_SHORT).show(); + finish(); + return; + } + pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, + getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + // 写入标签权限 + IntentFilter writeFilter = new IntentFilter( + NfcAdapter.ACTION_TECH_DISCOVERED); + mWriteTagFilters = new IntentFilter[] { writeFilter }; + mTechLists = new String[][] { + new String[] { MifareClassic.class.getName() }, + new String[] { NfcA.class.getName() } };// 允许扫描的标签类型 + Intent intent = getIntent(); + String id = intent.getStringExtra("id"); + if (id!=null&&!id.isEmpty()){ + mContentEditText.setText(""); + mContentEditText.setText(id); + } + btn_patrolpoint = (Button) findViewById(R.id.moudle_write_btn_patrolpoint); + btn_patrolpoint.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + Intent intent=new Intent(); + intent.setClass(WriteTag.this, PatrolPointActivity.class); + startActivityForResult(intent,REQUSET); + } + }); + btn_equ = (Button) findViewById(R.id.moudle_write_btn_equ); + btn_equ.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + Intent intent_sel_equ = new Intent(WriteTag.this, SingleChoiceActivity.class); + intent_sel_equ.putExtra("mark","equ"); + startActivityForResult(intent_sel_equ, REQUSET); +// Intent intent=new Intent(); +// intent.setClass(WriteTag.this, NFCEquListActivity.class); +// startActivityForResult(intent,REQUSET); + } + }); + + } + + @Override + protected void onRestart() { + super.onRestart(); +// if (getIntent().getStringExtra("id")!=null){ +/// +// } + } + + /** + * 写入标签按钮点击事件监听 + * + * + * + */ + class WriteOnClick implements OnClickListener { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + runOnUiThread(new Runnable() { + @Override + public void run() { + + + isWrite = true; + new SweetAlertDialog(WriteTag.this, SweetAlertDialog.NORMAL_TYPE) + .setTitleText("提示") + .setContentText("请将标签靠近!并请在数据写入成功后再点击按钮。") + .setConfirmText("继续") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + mContentEditText.setText(""); + isWrite = false; + if (cname!=null&&cname.length()>0) { + if(cname.equals("equ")){ + Intent intent_sel_equ = new Intent(WriteTag.this, SingleChoiceActivity.class); + intent_sel_equ.putExtra("mark","equ"); + startActivityForResult(intent_sel_equ, REQUSET); + }else if (cname.equals("point")){ + Intent intent=new Intent(); + intent.setClass(WriteTag.this, PatrolPointActivity.class); + startActivityForResult(intent,REQUSET); + } + } + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + isWrite = false; + } + }).show(); + } + }); + } + } + + @Override + protected void onResume() { + // TODO Auto-generated method stub + super.onResume(); + nfcAdapter.enableForegroundDispatch(this, pendingIntent, + mWriteTagFilters, mTechLists); + } + @Override + protected void onPause() { + super.onPause(); + if (nfcAdapter !=null && nfcAdapter.isEnabled()) { + // 当前Activity如果不在手机的最前端,就停止NFC设备连接的监听 + stopNFC_Listener(); + } + } + private void stopNFC_Listener() { + // 停止监听NFC设备是否连接 + nfcAdapter.disableForegroundDispatch(this); + } + // 写入模式时,才执行写入操作 + @Override + protected void onNewIntent(Intent intent) { + // TODO Auto-generated method stub + super.onNewIntent(intent); + if (isWrite == true + && NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { + Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); + NdefMessage ndefMessage = getNoteAsNdef(); + if (ndefMessage != null) { + writeTag(getNoteAsNdef(), tag); + } else { + showToast("请输入您要写入标签的内容"); + } + } + } + + // 根据文本生成一个NdefRecord + private NdefMessage getNoteAsNdef() { + String text = mContentEditText.getText().toString(); + if (text.equals("")) { + return null; + } else { + byte[] textBytes = text.getBytes(); + // image/jpeg text/plain + NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, + "image/jpeg".getBytes(), new byte[] {}, textBytes); + return new NdefMessage(new NdefRecord[] { textRecord }); + } + + } + + // 写入tag + boolean writeTag(NdefMessage message, Tag tag) { + + int size = message.toByteArray().length; + + try { + Ndef ndef = Ndef.get(tag); + if (ndef != null) { + ndef.connect(); + + if (!ndef.isWritable()) { + showToast("tag不允许写入"); + return false; + } + if (ndef.getMaxSize() < size) { + showToast("文件大小超出容量"); + return false; + } + + ndef.writeNdefMessage(message); + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(WriteTag.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("成功") + .setContentText("数据写入成功") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).setCancelText("查看写入数据") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + Intent intent = new Intent(WriteTag.this,ReadTag.class); + startActivity(intent); + } + }).show(); + + } + }); + return true; + } else { + NdefFormatable format = NdefFormatable.get(tag); + if (format != null) { + try { + format.connect(); + format.format(message); + showToast("格式化tag并且写入message"); + return true; + } catch (IOException e) { + showToast("格式化tag失败."); + return false; + } + } else { + showToast("Tag不支持NDEF"); + return false; + } + } + } catch (Exception e) { + new SweetAlertDialog(WriteTag.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("数据写入失败") + .setConfirmText("重写") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + + return false; + } + + private void showToast(String text) { + Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + + } + return super.onOptionsItemSelected(item); + } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + // TODO Auto-generated method stub + super.onActivityResult(requestCode, resultCode, data); + //requestCode标示请求的标示 resultCode表示有数据 + if (requestCode == WriteTag.REQUSET && resultCode == RESULT_OK) { + String ppid=data.getStringExtra("ppid"); + cname = data.getStringExtra("class"); + mContentEditText.setText(""); + mContentEditText.setText(ppid); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/EditMPointAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/EditMPointAdapter.java new file mode 100644 index 0000000..2dd49b3 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/EditMPointAdapter.java @@ -0,0 +1,210 @@ +package com.sipai.jspatrol.Patrol; + +import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.InputPoint; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * Created by lvliming on 2019/12/3. + */ + +public class EditMPointAdapter extends RecyclerView.Adapter implements View.OnClickListener{ + //数据源 + private List list; + private Context context; + //接口实例 + private EditMPointAdapter.RecyclerViewOnItemClickListener onItemClickListener; + + public EditMPointAdapter(List list, Context context) { + this.list = list; + this.context = context; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View root = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_edit_m_point, parent, false); + ViewHolder vh = new ViewHolder(root); + //为Item设置点击事件 + root.setOnClickListener(this); + return vh; + } + + @Override + public void onBindViewHolder(final ViewHolder holder, final int position) { + InputPoint point = list.get(position); + holder.rl_sp.setVisibility(View.VISIBLE); + holder.ll_value.setVisibility(View.GONE); + holder.tv_name.setText(point.getParmname()); + holder.tv_unit.setText(point.getUnit()); + if (holder.edt_value.getTag()!=null&&holder.edt_value.getTag() instanceof TextWatcher){ + holder.edt_value.removeTextChangedListener((TextWatcher) holder.edt_value.getText()); + } + holder.edt_value.setText(list.get(position).getParmvalue()); + TextWatcher textWatcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable s) { + if (s!=null&&s.length()>0) { + list.get(position).setParmvalue(s.toString()); + }else { + list.get(position).setParmvalue(""); + } + } + }; + holder.edt_value.addTextChangedListener(textWatcher); + holder.edt_value.setTag(textWatcher); + String[] types = new String[]{}; + if (point.getValuemeaning().equals("NOTHING3")){ + types = context.getResources().getStringArray(R.array.VM_NOTHING3); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("HAVE2")){ + types = context.getResources().getStringArray(R.array.VM_HAVE2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("HIGH2")){ + types = context.getResources().getStringArray(R.array.VM_HIGH2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("START3")){ + types = context.getResources().getStringArray(R.array.VM_START3); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("YELLOW3")){ + types = context.getResources().getStringArray(R.array.VM_YELLOW3); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("HIGH3")){ + types = context.getResources().getStringArray(R.array.VM_HIGH3); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("NORMAL2")){ + types = context.getResources().getStringArray(R.array.VM_NORMAL2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("FULL2")){ + types = context.getResources().getStringArray(R.array.VM_FULL2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("FULL3")){ + types = context.getResources().getStringArray(R.array.VM_FULL3); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("MORE3")){ + types = context.getResources().getStringArray(R.array.VM_MORE3); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("OPEN2")){ + types = context.getResources().getStringArray(R.array.VM_OPEN2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("DAMAGE2")){ + types = context.getResources().getStringArray(R.array.VM_DAMAGE2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("GOOD2")){ + types = context.getResources().getStringArray(R.array.VM_GOOD2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("YES2")){ + types = context.getResources().getStringArray(R.array.VM_YES2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("VOL2")){ + types = context.getResources().getStringArray(R.array.VM_VOL2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("VOL3")){ + types = context.getResources().getStringArray(R.array.VM_VOL3); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("FLOW2")){ + types = context.getResources().getStringArray(R.array.VM_FLOW2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else if (point.getValuemeaning().equals("DRY2")){ + types = context.getResources().getStringArray(R.array.VM_DRY2); + list.get(position).setSel(Integer.parseInt(list.get(position).getParmvalue())); + }else { + holder.rl_sp.setVisibility(View.GONE); + holder.ll_value.setVisibility(View.VISIBLE); + } + ArrayAdapter typeAdapter = new ArrayAdapter(context, R.layout.item_normal_little_spin, R.id.moudle_normal_little_spin_tv_title, types); + holder.sp_value.setAdapter(typeAdapter); + if (holder.sp_value.getTag()!=null){ + holder.sp_value.setSelection(list.get(position).getSel()); + }else { + holder.sp_value.setTag(list.get(position).getSel()); + holder.sp_value.setSelection(list.get(position).getSel()); + } +// final String[] finalTypes = types; + holder.sp_value.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int i, long id) { + list.get(position).setParmvalue(String.valueOf(i)); + list.get(position).setSel(i); + holder.sp_value.setTag(i); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + //设置Tag + holder.root.setTag(position); + } + + @Override + public int getItemCount() { + return list.size(); + } + + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + //注意这里使用getTag方法获取数据 + onItemClickListener.onItemClickListener(v, (Integer) v.getTag()); + } + } + + //视图管理 + public class ViewHolder extends RecyclerView.ViewHolder{ + private TextView tv_name,tv_unit; + private Spinner sp_value; + private EditText edt_value; + private RelativeLayout rl_sp; + private LinearLayout ll_value; + private View root; + public ViewHolder(View itemView) { + super(itemView); + this.root = itemView; + tv_name = root.findViewById(R.id.moudle_item_edit_m_point_tv_name); + tv_unit = root.findViewById(R.id.moudle_item_edit_m_point_tv_unit); + sp_value = root.findViewById(R.id.moudle_item_edit_m_point_sp_value); + edt_value = root.findViewById(R.id.moudle_item_edit_m_point_et_value); + rl_sp = root.findViewById(R.id.moudle_item_edit_m_point_rl_sp); + ll_value = root.findViewById(R.id.moudle_item_edit_m_point_ll_value); + } + } + //设置点击事件 + public void setRecyclerViewOnItemClickListener(RecyclerViewOnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + //接口回调设置点击事件 + public interface RecyclerViewOnItemClickListener { + //点击事件 + void onItemClickListener(View view, int position); + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/FileForDLAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/FileForDLAdapter.java new file mode 100644 index 0000000..2f36c48 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/FileForDLAdapter.java @@ -0,0 +1,71 @@ +package com.sipai.jspatrol.Patrol; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.FileForDL; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * created by lvliming on 2019/12/28 + */ +public class FileForDLAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + private onRcViewItemClick mOnRvItemClick; + + public FileForDLAdapter(Context context, List list, onRcViewItemClick mOnRvItemClick) { + this.context = context; + this.list = list; + this.mOnRvItemClick = mOnRvItemClick; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_file_for_dl,parent,false); + ViewHolder holder = new ViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + FileForDL item = list.get(position); + holder.tv_name.setText(item.getName()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + View tview; + TextView tv_name; + public ViewHolder(@NonNull View itemView) { + super(itemView); + tview = itemView; + tv_name = itemView.findViewById(R.id.moudle_item_file_for_dl_tv_name); + itemView.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (mOnRvItemClick!=null){ + mOnRvItemClick.onItemClick(view,getAdapterPosition()); + } + } + } + + public interface onRcViewItemClick{ + void onItemClick(View v, int position); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolDetailActivity.java b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolDetailActivity.java new file mode 100644 index 0000000..71a8d07 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolDetailActivity.java @@ -0,0 +1,1090 @@ +package com.sipai.jspatrol.Patrol; + +import android.annotation.SuppressLint; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.nfc.NdefMessage; +import android.nfc.NdefRecord; +import android.nfc.NfcAdapter; +import android.nfc.tech.MifareClassic; +import android.nfc.tech.NfcA; +import android.os.Bundle; +import android.os.Parcelable; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.sipai.jspatrol.Bean.InputPoint; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.Bean.PatrolLocation; +import com.sipai.jspatrol.Bean.PatrolPointContent; +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolEqu; +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolInfoEquAdapter; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.Bean.Patrol; +import com.sipai.jspatrol.Bean.ProPatrolPoint; +import com.sipai.jspatrol.Bean.ProcessSection; +import com.sipai.jspatrol.Fault.NewFaultActivity; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.Utils; +import com.sipai.ui.CustomDialog; +import com.yzq.zxinglibrary.android.CaptureActivity; +import com.yzq.zxinglibrary.bean.ZxingConfig; +import com.yzq.zxinglibrary.common.Constant; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.litepal.LitePal; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +import static com.sipai.jspatrol.utils.Global.GlobalVal.Status_PartFinish; +import static com.sipai.jspatrol.utils.Global.GlobalVal.Status_Undo; + + +/** + * 日常巡检任务详情 + */ +public class PatrolDetailActivity extends AppCompatActivity implements View.OnClickListener { + private TextView tv_content, tv_endtime, tv_add_remark, tv_name; + private RecyclerView rc_list; + private String remark = ""; + private Button btn_sub, btn_unfinish; + private LinearLayout ll_add_remark; + // private String id;//巡检任务id + private Patrol patrolDetail; + private List locations = new ArrayList<>(); + private String loc_json; + //巡检类型 + private String patrolType;//Product("P","生产巡检"), Equipment( "E","设备巡检"), Administrator("A","管理组"),Maintenance("M","运维组"); + private List points = new ArrayList<>(); + private List equs = new ArrayList<>(); + private ProPatrolPoint sel_point; + private ProPatrolPointAdapter adapter; + private StaggeredGridLayoutManager manager; + private NfcAdapter nfcAdapter; + // 是否支持NFC功能的标签 + private boolean isNFC_support = false; + private PendingIntent pendingIntent; + private IntentFilter[] mFilters; + private String[][] mTechLists; + private SweetAlertDialog pDialog; + private String status = "1"; + private LinearLayout ll_sub; + private String content, name, endTime, result, startTime; + private TextView tv_result,tv_worker,tv_finish_time; + private ImageView iv_back; + private LinearLayout ll_sub_fault; + private String requesturl = ""; + private LinearLayoutManager equManager; + private PatrolInfoEquAdapter equAdapter; + private static final int REQUEST_CODE_SCAN = 23; + private Button btn_off_line; + private CardView cv; + private String subTask = ""; + + public static void actionStart(Context context, Patrol task) { + Intent intent = new Intent(context, PatrolDetailActivity.class); + intent.putExtra("task", task); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_patrol_detail); + init(); + initView(); + updatePatrolInfo(); + checkNFC(); + } + + private void updatePatrolInfo() { + if (status.equals(GlobalVal.Status_Finish) || status.equals(Status_PartFinish) || status.equals(Status_Undo)) { + ll_sub.setVisibility(View.GONE); + if (nfcAdapter != null && nfcAdapter.isEnabled()) { + // 当前Activity如果不在手机的最前端,就停止NFC设备连接的监听 + stopNFC_Listener(); + } + tv_result.setVisibility(View.VISIBLE); + cv.setVisibility(View.GONE); + if (result != null && !result.isEmpty()) { + if (status.equals(GlobalVal.Status_Finish)) { + tv_result.setBackgroundColor(getResources().getColor(R.color.green)); + tv_result.setText("巡检结果:" + result); + } else { + tv_result.setText("巡检结果:" + result); + } + } else { + if (status.equals(GlobalVal.Status_Finish)) { + tv_result.setBackgroundColor(getResources().getColor(R.color.green)); + tv_result.setText("巡检结果:未填写"); + } else { + tv_result.setText("巡检结果:未填写"); + } + } + } else { + tv_result.setVisibility(View.GONE); + } + if (patrolDetail.getWorker()!=null&&!patrolDetail.getWorker().isEmpty()){ + tv_worker.setText("提交人: "+patrolDetail.getWorker()); + }else { + tv_worker.setVisibility(View.GONE); + } + if (patrolDetail.getActFinishTime()!=null&&!patrolDetail.getActFinishTime().isEmpty()){ + tv_finish_time.setText("提交时间: "+patrolDetail.getActFinishTime().substring(0,16)); + }else { + tv_finish_time.setVisibility(View.GONE); + } + tv_content.setText("内容: " + content); + if (endTime.length() > 15) { + tv_endtime.setText("任务时间: " + startTime.substring(5, 16) + " -- " + endTime.substring(5, 16)); + } else { + tv_endtime.setText("任务时间: " + startTime + " -- " + endTime); + } + tv_name.setText(name); + } + + private void checkNFC() { + // 获取nfc适配器,判断设备是否支持NFC功能 + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + if (nfcAdapter == null) { + showToast(getResources().getString(R.string.no_nfc)); + } else if (!nfcAdapter.isEnabled()) { + showToast(getResources().getString(R.string.open_nfc)); + } + pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, + getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); + ndef.addCategory("*/*"); + mFilters = new IntentFilter[]{ndef};// 过滤器 + mTechLists = new String[][]{ + new String[]{MifareClassic.class.getName()}, + new String[]{NfcA.class.getName()}};// 允许扫描的标签类型 + } + + private void pDialogHide() { + if (!PatrolDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.hide(); + } + }); + } + } + + private void pDialogshow(final String s) { + if (!PatrolDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.setTitleText(s); + pDialog.show(); + } + }); + } + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private String token; + + public void init() { + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + token = sharedPre.getString("token", ""); + subTask=sharedPre.getString("subtask", ""); + patrolDetail = (Patrol) getIntent().getSerializableExtra("task"); + status = patrolDetail.getStatus(); + content = patrolDetail.getContent(); + name = patrolDetail.getName(); + endTime = patrolDetail.getEndTime(); + startTime = patrolDetail.getStartTime(); + result = patrolDetail.getWorkResult(); + requesturl = MethodURL.GetPatrolTaskDetail_Method; + } + + private void initView() { + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setTitleText("数据上传中..."); + pDialog.setCancelable(false); + pDialog.setCanceledOnTouchOutside(false); + iv_back = findViewById(R.id.moudle_patrol_detail_iv_back); + iv_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + tv_content = findViewById(R.id.moudle_patrol_detail_tv_task_content); + tv_endtime = findViewById(R.id.moudle_patrol_detail_tv_task_endtime); + rc_list = findViewById(R.id.moudle_patrol_detail_rcview_point); + manager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); + rc_list.setLayoutManager(manager); + btn_sub = findViewById(R.id.moudle_patrol_detail_btn_sub_task); + btn_sub.setOnClickListener(this); + if (subTask.equals("true")){ + btn_sub.setVisibility(View.VISIBLE); + } + tv_result = findViewById(R.id.moudle_patrol_detail_tv_task_result); + tv_worker = findViewById(R.id.moudle_patrol_detail_tv_worker); + tv_finish_time = findViewById(R.id.moudle_patrol_detail_tv_finish_time); + ll_add_remark = findViewById(R.id.moudle_patrol_detail_ll_add_remark); + ll_add_remark.setOnClickListener(this); + ll_sub = findViewById(R.id.moudle_patrol_detail_ll_sub); + tv_name = findViewById(R.id.moudle_patrol_detail_tv_task_name); + btn_unfinish = findViewById(R.id.moudle_patrol_detail_btn_unfinish); + btn_unfinish.setOnClickListener(this); + ll_sub_fault = findViewById(R.id.moudle_patrol_detail_ll_sub_fault); + ll_sub_fault.setOnClickListener(this); + btn_off_line = findViewById(R.id.moudle_patrol_detail_btn_off_line); + btn_off_line.setOnClickListener(this); + cv = findViewById(R.id.moudle_patrol_detail_cv); +// List lll = LitePal.where("sid = ?",patrolDetail.getSid()).find(Patrol.class); +// if (lll.size()>0){ +// btn_off_line.setVisibility(View.GONE); +// }else { +// btn_off_line.setVisibility(View.VISIBLE); +// } + } + + @Override + public void onClick(View view) { + switch (view.getId()) { + case R.id.moudle_patrol_detail_btn_off_line: + LitePal.deleteAll(Patrol.class); + LitePal.deleteAll(ProPatrolPoint.class); + LitePal.deleteAll(PatrolEqu.class); + LitePal.deleteAll(InputPoint.class); + LitePal.deleteAll(PatrolPointContent.class); + getOffLineData(); + break; + case R.id.moudle_patrol_detail_ll_add_remark: + CustomDialog dialog = new CustomDialog(PatrolDetailActivity.this, R.style.customDialog, R.layout.edt_dialog); + dialog.setCanceledOnTouchOutside(true); + dialog.show(); + TextView tv_title = dialog.findViewById(R.id.moudle_edt_dialog_title); + tv_title.setText("填写备注"); + EditText edt_content = dialog.findViewById(R.id.moudle_edt_dialog_edt); + Button btn_cancel = dialog.findViewById(R.id.moudle_edt_dialog_btn_cancel); + btn_cancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + Button btn_confirm = dialog.findViewById(R.id.moudle_edt_dialog_btn_confirm); + btn_confirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + if (edt_content.getText() != null && !edt_content.getText().toString().isEmpty()) { + remark = edt_content.getText().toString(); + } else { + remark = ""; + } + } + }); + break; + case R.id.moudle_patrol_detail_ll_sub_fault: + NewFaultActivity.actionStart(PatrolDetailActivity.this,"",patrolDetail.getSid(),""); + break; + case R.id.moudle_patrol_detail_btn_sub_task: +// List lll = LitePal.where("sid = ?",patrolDetail.getSid()).find(Patrol.class); +// if (lll.size()>0) { +// Patrol pp = lll.get(0); +// points = pp.getPatrolRecordPatrolRoutes(); +// int a = points.size(); +// } +// List lp = LitePal.findAll(ProPatrolPoint.class,true); +// List li = LitePal.findAll(InputPoint.class); +// List le = LitePal.findAll(PatrolEqu.class,true); +// List ls = LitePal.findAll(PatrolPointContent.class); + int notAll = 0; + for (int i = 0; i < points.size(); i++) { + if (!points.get(i).getStatus().equals(GlobalVal.Status_Finish)) { + notAll = notAll + 1; + } + } + if (notAll > 0) { + isConfNotAll(); + } else { + isConfSub(); + } + break; + case R.id.moudle_patrol_detail_btn_unfinish: +// UnfinishedPatrolTaskActivity.actionStart(PatrolDetailActivity.this, id, patrolType); + break; + } + } + + /** + * 获取离线数据 + */ + private void getOffLineData() { + pDialogshow("数据下载中..."); + HashMap map = new HashMap<>(); + map.put("patrolRecordId", patrolDetail.getSid()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetOffLineData_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + showToast("离线数据获取失败:"+e.toString()); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pDialogHide(); + if (res != null && !res.isEmpty()) { + parseOfflineTask(res); + } else { + showToast("任务详情获取失败"); + } + } + }); + } + + private void parseOfflineTask(String res) { + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.optString("code").equals("1")){ + JSONArray array = jsonObject.getJSONArray("result"); + JSONObject jspatrol = array.getJSONObject(0); + Patrol patrol = new Patrol(); + patrol.setSid(jspatrol.optString("id")); + patrol.setType(jspatrol.optString("type")); + patrol.setContent(jspatrol.optString("content")); + patrol.setStatus(jspatrol.optString("status")); + patrol.setStartTime(jspatrol.optString("startTime")); + patrol.setEndTime(jspatrol.optString("endTime")); + patrol.setName(jspatrol.optString("name")); + //巡检执行内容 + List patrolPoints = new ArrayList<>(); + JSONArray jspoint = jspatrol.getJSONArray("patrolRecordPatrolRoutes"); + for (int i=0;i patrolPointContents = new ArrayList<>(); + JSONArray jscontents = jspoint.getJSONObject(i).getJSONArray("patrolContentsRecords"); + if (jscontents.length()>0) { + for (int a = 0; a < jscontents.length(); a++) { + PatrolPointContent content = new PatrolPointContent(); + content.setSid(jscontents.getJSONObject(a).optString("id")); + content.setContents(jscontents.getJSONObject(a).optString("contents")); + content.setContentsDetail(jscontents.getJSONObject(a).optString("contentsDetail")); + content.setStatus(jscontents.getJSONObject(a).optString("status")); + content.setPatrolPointId(jscontents.getJSONObject(a).optString("patrolPointId")); + content.setPatrolRecordId(jscontents.getJSONObject(a).optString("patrolRecordId")); + content.setPid(jscontents.getJSONObject(a).optString("pid")); + content.setType(jscontents.getJSONObject(a).optString("type")); + content.setEquipmentId(jscontents.getJSONObject(a).optString("equipmentId")); + content.setProPatrolPoint(item); + patrolPointContents.add(content); + if (content.save()){ + Log.i("Offline", "parseOfflineTask: true"); + } + content.save(); + } + } + item.setPatrolContentsRecords(patrolPointContents); + //巡检填报内容 + List inputPoints = new ArrayList<>(); + JSONArray jsinputs = jspoint.getJSONObject(i).getJSONArray("patrolMeasurePointRecords"); + if (jsinputs.length()>0) { + for (int b = 0; b < jsinputs.length(); b++) { + InputPoint in = new InputPoint(); + in.setSid(jsinputs.getJSONObject(b).optString("id")); + in.setPid(jsinputs.getJSONObject(b).optString("pid")); + in.setPatrolPointId(jsinputs.getJSONObject(b).optString("patrolPointId")); + in.setPatrolRecordId(jsinputs.getJSONObject(b).optString("patrolRecordId")); + in.setEquipmentId(jsinputs.getJSONObject(b).optString("equipmentId")); + JSONObject js = new JSONObject(jsinputs.getJSONObject(b).opt("mPoint").toString()); + in.setAlarmmax(js.optString("alarmmax")); + in.setAlarmmin(js.optString("alarmmin")); + in.setBiztype(js.optString("biztype")); + in.setValuemeaning(js.optString("valuemeaning")); + in.setMeasuredt(js.optString("measuredt")); + in.setMpointcode(js.optString("mpointcode")); + in.setParmname(js.optString("parmname")); + in.setParmvalue(jsinputs.getJSONObject(b).optString("mpvalue")); + in.setSignalType(js.optString("signaltype")); + in.setSql(js.optString("sql")); + in.setUnit(js.optString("unit")); + in.setWhere(js.optString("where")); + in.setProPatrolPoint(item); + inputPoints.add(in); + in.save(); + if (in.save()){ + Log.i("Offline", "parseOfflineTask: true"); + } + } + } + item.setPatrolMeasurePointRecords(inputPoints); + //巡检点下的设备 + List patrolEqus = new ArrayList<>(); + JSONArray jsequs = jspoint.getJSONObject(i).getJSONArray("patrolRecordPatrolEquipments"); + if (jsequs.length()>0) { + for (int c = 0; c < jsequs.length(); c++) { + PatrolEqu equ = new PatrolEqu(); + if (jsequs.getJSONObject(c).optString("equipmentCard")!=null&&!jsequs.getJSONObject(c).optString("equipmentCard").equals("null")) { + JSONObject jscard = jsequs.getJSONObject(c).getJSONObject("equipmentCard"); + equ.setEquipmentId(jscard.optString("id")); + equ.setSid(jsequs.getJSONObject(c).optString("id")); + equ.setEquipmentName(jscard.optString("equipmentname")); + equ.setStatus(jsequs.getJSONObject(c).optString("status")); + equ.setPatrolPointId(jsequs.getJSONObject(c).optString("patrolPointId")); + equ.setPatrolRecordId(jsequs.getJSONObject(c).optString("patrolRecordId")); + equ.setEquipmentCardId(jscard.optString("equipmentcardid")); + equ.setManufacturers(jscard.optString("equipmentmanufacturer")); + equ.setType(jspatrol.optString("type")); + if (jscard.optString("measurePoints") != null && !jscard.optString("measurePoints").isEmpty()) { + List mps = new ArrayList<>(); + JSONArray aps = new JSONArray(jscard.optString("measurePoints")); + if (aps.length() > 0) { + for (int a = 0; a < aps.length(); a++) { + Measuringpoint point = new Measuringpoint(); + point.setSid(aps.getJSONObject(a).optString("id")); + point.setName(aps.getJSONObject(a).optString("parmName")); + point.setCvalue(aps.getJSONObject(a).optString("parmValue")); + point.setUnit(aps.getJSONObject(a).optString("unit")); + point.setType(aps.getJSONObject(a).optString("signaltype")); + point.setPatrolEqu(equ); + mps.add(point); + point.save(); + } + } + equ.setMeasuringpoints(mps); + } + //设备下巡检内容 + JSONArray jsequcontents = jsequs.getJSONObject(c).getJSONArray("patrolContentsRecords"); + List equContents = new ArrayList<>(); + if (jsequcontents.length() > 0) { + for (int d = 0; d < jsequcontents.length(); d++) { + PatrolPointContent content = new PatrolPointContent(); + content.setSid(jsequcontents.getJSONObject(d).optString("id")); + content.setContents(jsequcontents.getJSONObject(d).optString("contents")); + content.setContentsDetail(jsequcontents.getJSONObject(d).optString("contentsDetail")); + content.setStatus(jsequcontents.getJSONObject(d).optString("status")); + content.setPatrolPointId(jsequcontents.getJSONObject(d).optString("patrolPointId")); + content.setPatrolRecordId(jsequcontents.getJSONObject(d).optString("patrolRecordId")); + content.setPid(jsequcontents.getJSONObject(d).optString("pid")); + content.setType(jsequcontents.getJSONObject(d).optString("type")); + content.setEquipmentId(jsequcontents.getJSONObject(d).optString("equipmentId")); + content.setPatrolEqu(equ); + equContents.add(content); + content.save(); + } + } + equ.setPatrolContentsRecords(equContents); + //设备下填报内容 + JSONArray jsequinpoints = jsequs.getJSONObject(c).getJSONArray("patrolMeasurePointRecords"); + List equinpoints = new ArrayList<>(); + if (jsequinpoints.length() > 0) { + for (int e = 0; e < jsequinpoints.length(); e++) { + InputPoint in = new InputPoint(); + in.setSid(jsequinpoints.getJSONObject(e).optString("id")); + in.setPid(jsequinpoints.getJSONObject(e).optString("pid")); + in.setPatrolPointId(jsequinpoints.getJSONObject(e).optString("patrolPointId")); + in.setPatrolRecordId(jsequinpoints.getJSONObject(e).optString("patrolRecordId")); + in.setEquipmentId(jsequinpoints.getJSONObject(e).optString("equipmentId")); + JSONObject js = new JSONObject(jsequinpoints.getJSONObject(e).optString("mPoint")); + in.setAlarmmax(js.optString("alarmmax")); + in.setAlarmmin(js.optString("alarmmin")); + in.setBiztype(js.optString("biztype")); + in.setValuemeaning(js.optString("valuemeaning")); + in.setMeasuredt(js.optString("measuredt")); + in.setMpointcode(js.optString("mpointcode")); + in.setParmname(js.optString("parmname")); + in.setParmvalue(jsequinpoints.getJSONObject(e).optString("mpvalue")); + in.setSignalType(js.optString("signaltype")); + in.setSql(js.optString("sql")); + in.setUnit(js.optString("unit")); + in.setWhere(js.optString("where")); + in.setPatrolEqu(equ); + equinpoints.add(in); + in.save(); + } + } + equ.setPatrolMeasurePointRecords(equinpoints); + equ.setProPatrolPoint(item); + patrolEqus.add(equ); + equ.save(); + } + } + } + item.setPatrolRecordPatrolEquipments(patrolEqus); + item.setPatrol(patrol); + patrolPoints.add(item); + item.save(); + } + patrol.setPatrolRecordPatrolRoutes(patrolPoints); + patrol.save(); + showToast("离线任务缓存成功!"); + }else { + showToast("任务详情获取失败"); + } + } catch (JSONException e) { + showToast("任务详情获取失败"); + e.printStackTrace(); + } + } + + private void isConfNotAll() { + if (!PatrolDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到尚有巡检点未巡检,是否确认提交任务?") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + if(remark!=null&&!remark.isEmpty()&&!remark.replaceAll(" +","").isEmpty()) { + subTask(); + }else { + showToast("请在备注中填写未巡检完整原因后再提交!"); + } + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void isConfSub() { + if (!PatrolDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("是否确认提交任务?") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + subTask(); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void subTask() { + pDialogshow("数据上传中..."); + locations = LitePal.where("insdt > ? and insdt < ?",startTime,endTime).find(PatrolLocation.class); + Gson gson = new Gson(); + loc_json = "{\"re1\":" + gson.toJson(locations) + "}"; + List lll = LitePal.where("sid = ?",patrolDetail.getSid()).find(Patrol.class); + if (lll.size()>0){ + subOfflineData(); + } + HashMap map = new HashMap<>(); + map.put("id", patrolDetail.getSid()); + map.put("workResult", remark); + map.put("workerId", mUserid); + map.put("json", loc_json); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.SubPatrolTask_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + showToast("失败:"+e.toString()); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pDialogHide(); + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.opt("code").toString().equals("1")) { +// subContent(); + successDialog(); + } else { + if (jsonObject.optString("msg").contains("时间内")) { + showToast(jsonObject.optString("msg")); + }else { + showToast("提交失败!"); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + }); + } + + private void subOfflineData() { + List lll = LitePal.where("sid = ?",patrolDetail.getSid()).find(Patrol.class); + if (lll.size()>0) { + Patrol pp = lll.get(0); + pp.setWorkResult(remark); + points = pp.getPatrolRecordPatrolRoutes(); + for (int i=0;i equs = points.get(i).getPatrolRecordPatrolEquipments(); + for (int a=0;a map = new HashMap<>(); + map.put("json", json); + map.put("isLimited","true"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.SubOfflinePatrolTask_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + showToast("失败:"+e.toString()); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pDialogHide(); + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.opt("code").toString().equals("1")) { +// successDialog(); + } else { + showToast("失败"); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + }); + } + } + + private void showToast(String s) { + if (!PatrolDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(PatrolDetailActivity.this, s, Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void successDialog() { + if (!PatrolDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("提交成功!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + private void getTaskDetail() { + pDialogshow("数据加载中..."); + HashMap map = new HashMap<>(); + map.put("patrolRecordId", patrolDetail.getSid()); + map.put("type", patrolDetail.getType()); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, requesturl)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + pDialogHide(); + showToast("失败:"+e.toString()); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + pDialogHide(); + if (res != null && !res.isEmpty()) { + points = parsePoints(res); + updateList(); + } else { + showToast("任务详情获取失败"); + } + } + }); + } + + private List parsePatrolEqu(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray array = new JSONArray(jsonObject.optString("result")); + for (int i = 0; i < array.length(); i++) { + PatrolEqu item = new PatrolEqu(); + JSONObject js = array.getJSONObject(i).getJSONObject("equipmentCard"); + item.setEquipmentId(js.optString("id")); + item.setEquipmentName(js.optString("equipmentname")); + item.setStatus(array.getJSONObject(i).optString("status")); + item.setPatrolPointId(array.getJSONObject(i).optString("patrolPointId")); + item.setPatrolRecordId(array.getJSONObject(i).optString("patrolRecordId")); + item.setEquipmentCardId(js.optString("equipmentcardid")); + item.setManufacturers(js.optString("equipmentmanufacturer")); + if (array.getJSONObject(i).optString("measurePoints") != null && !array.getJSONObject(i).optString("measurePoints").isEmpty()) { + List mps = new ArrayList<>(); + JSONArray aps = new JSONArray(array.getJSONObject(i).optString("measurePoints")); + for (int a = 0; a < aps.length(); a++) { + Measuringpoint point = new Measuringpoint(); + point.setSid(aps.getJSONObject(a).optString("id")); + point.setName(aps.getJSONObject(a).optString("parmName")); + point.setCvalue(aps.getJSONObject(a).optString("parmValue")); + point.setUnit(aps.getJSONObject(a).optString("unit")); + point.setType(aps.getJSONObject(a).optString("signaltype")); + mps.add(point); + } + item.setMeasuringpoints(mps); + } + list.add(item); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } + + /** + * 更新生产巡检巡检点列表 + */ + private void updateList() { + if (!PatrolDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (points.size() > 0) { + rc_list.setVisibility(View.VISIBLE); + adapter = new ProPatrolPointAdapter(points, PatrolDetailActivity.this, new ProPatrolPointAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { +// sel_point = points.get(position); +// Intent intent = new Intent(PatrolDetailActivity.this, CaptureActivity.class); +// /*ZxingConfig是配置类 +// *可以设置是否显示底部布局,闪光灯,相册, +// * 是否播放提示音 震动 +// * 设置扫描框颜色等 +// * 也可以不传这个参数 +// * */ +// ZxingConfig config = new ZxingConfig(); +// config.setPlayBeep(true);//是否播放扫描声音 默认为true +// config.setShake(true);//是否震动 默认为true +// config.setDecodeBarCode(true);//是否扫描条形码 默认为true +//// config.setReactColor(R.color.white);//设置扫描框四个角的颜色 默认为白色 +//// config.setFrameLineColor(R.color.colorAccent);//设置扫描框边框颜色 默认无色 +//// config.setScanLineColor(R.color.colorAccent);//设置扫描线的颜色 默认白色 +// config.setFullScreenScan(false);//是否全屏扫描 默认为true 设为false则只会在扫描框中扫描 +// intent.putExtra(Constant.INTENT_ZXING_CONFIG, config); +// startActivityForResult(intent, REQUEST_CODE_SCAN); + } + }); + rc_list.setAdapter(adapter); + manager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); + rc_list.setLayoutManager(manager); + } else { + rc_list.setVisibility(View.GONE); + } + } + }); + } + } + + /** + * 更新设备巡检设备列表 + */ + private void updateEquList() { + if (!PatrolDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (equs.size() > 0) { + rc_list.setVisibility(View.VISIBLE); + equManager = new LinearLayoutManager(PatrolDetailActivity.this); + rc_list.setLayoutManager(equManager); + equAdapter = new PatrolInfoEquAdapter(equs, PatrolDetailActivity.this); + rc_list.setAdapter(equAdapter); + } else { + rc_list.setVisibility(View.GONE); + } + } + }); + } + } + + private List parsePoints(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray arry = new JSONArray(jsonObject.optString("result")); + for (int i = 0; i < arry.length(); i++) { + ProPatrolPoint item = new ProPatrolPoint(); + item.setResultId(arry.getJSONObject(i).optString("recordId")); + item.setStatus(arry.getJSONObject(i).optString("status")); + item.setSid(arry.getJSONObject(i).optString("id")); + item.setName(arry.getJSONObject(i).optString("name")); + item.setTaskId(patrolDetail.getSid()); + item.setType(patrolDetail.getType()); + item.setPointType(arry.getJSONObject(i).optString("type")); + item.setProcessSectionId(arry.getJSONObject(i).optString("processSectionId")); + item.setWorkerName(arry.getJSONObject(i).optString("workerName")); + item.setFinishDt(arry.getJSONObject(i).optString("finishDt")); + if (arry.getJSONObject(i).optString("processSectionName") != null && !arry.getJSONObject(i).optString("processSectionName").isEmpty()) { + ProcessSection psn = new ProcessSection(); + psn.setSid(arry.getJSONObject(i).optString("processSectionId")); + psn.setName(arry.getJSONObject(i).optString("processSectionName")); + psn.setSname(arry.getJSONObject(i).optString("processSectionName")); + item.setProcessSection(psn); + } + List pps = LitePal.where("sid = ? and resultId = ?",item.getSid(),item.getResultId()).find(ProPatrolPoint.class); + if (pps.size()>0){ + if (pps.get(0).getWorkerId()!=null&&!pps.get(0).getWorkerId().isEmpty()){ + item.setWorkerName(pps.get(0).getWorkerName()); + item.setWorkerId(pps.get(0).getWorkerId()); + item.setStatus(pps.get(0).getStatus()); + item.setFinishDt(pps.get(0).getFinishDt()); + } + } + list.add(item); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } + + @Override + protected void onResume() { + super.onResume(); + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + isNFC_support = !(nfcAdapter == null || !nfcAdapter.isEnabled()); + if (isNFC_support) { + nfcAdapter.enableForegroundDispatch(this, pendingIntent, mFilters, + mTechLists); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) { + // 注意这个if中的代码几乎不会进来,因为刚刚在上一行代码开启了监听NFC连接,下一行代码马上就收到了NFC连接的intent,这种几率很小 + // 处理该intent + String result = processIntent(getIntent()); + checkResult(result); + } + } + if(Utils.isNetworkConnected(PatrolDetailActivity.this)) { + getTaskDetail(); + }else { + List lll = LitePal.where("sid = ?",patrolDetail.getSid()).find(Patrol.class); + if (lll.size()>0) { + Patrol pp = lll.get(0); + points = pp.getPatrolRecordPatrolRoutes(); + updateList(); + } + } + } + + private void checkResult(String result) { + Boolean ishave = false; + for (int i = 0; i < points.size(); i++) { + if (result.equals(points.get(i).getSid())) { + ishave = true; + sel_point = points.get(i); +// points.get(i).setStatus("2"); + } + } + if (ishave) { + if (sel_point.getPointType().equals("point")||sel_point.getPointType().equals("P")) { + PatrolPointDetailActivity.actionStart(PatrolDetailActivity.this, sel_point, sel_point.getTaskId(), sel_point.getType()); + } else if (sel_point.getPointType().equals("equipment")||sel_point.getPointType().equals("E")) { + PatrolEquDetailActivity.actionStart(PatrolDetailActivity.this, sel_point.getSid(), "", sel_point.getTaskId(), sel_point.getType()); + } +// PatrolPointDetailActivity.actionStart(PatrolDetailActivity.this, sel_point, patrolDetail.getId(), sel_point.getTaskType()); + } else { + noThisPoint(); + } + } + + private void noThisPoint() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("该巡检点不在任务中,请确认后再扫描!") + .show(); + } + }); + } + + /** + * 获取tab标签中的内容 + * + * @param intent + * @return + */ + @SuppressLint("NewApi") + private String processIntent(Intent intent) { + Parcelable[] rawmsgs = intent + .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); + if (rawmsgs != null) { + NdefMessage msg = (NdefMessage) rawmsgs[0]; + NdefRecord[] records = msg.getRecords(); + String resultStr = new String(records[0].getPayload()); + return resultStr; + } else { + return "error"; + } + } + + @Override + protected void onPause() { + super.onPause(); + if (nfcAdapter != null && nfcAdapter.isEnabled()) { + // 当前Activity如果不在手机的最前端,就停止NFC设备连接的监听 + stopNFC_Listener(); + } + } + + private void stopNFC_Listener() { + // 停止监听NFC设备是否连接 + nfcAdapter.disableForegroundDispatch(this); + } + + @Override + protected void onNewIntent(Intent intent) { + // TODO Auto-generated method stub + // 当前app正在前端界面运行,这个时候有intent发送过来,那么系统就会调用onNewIntent回调方法,将intent传送过来 + // 我们只需要在这里检验这个intent是否是NFC相关的intent,如果是,就调用处理方法 + super.onNewIntent(intent); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { + String result = processIntent(intent); + checkResult(result); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + // 扫描二维码/条码回传 + if (requestCode == REQUEST_CODE_SCAN && resultCode == RESULT_OK) { + if (data != null) { + String content = data.getStringExtra(Constant.CODED_CONTENT); + if (content.equals(sel_point.getSid())){ + if (sel_point.getPointType().equals("point")) { + PatrolPointDetailActivity.actionStart(PatrolDetailActivity.this, sel_point, sel_point.getTaskId(), sel_point.getType()); + } else if (sel_point.getPointType().equals("equipment")) { + PatrolEquDetailActivity.actionStart(PatrolDetailActivity.this, sel_point.getSid(), "", sel_point.getTaskId(), sel_point.getType()); + } + }else { + showNotice("二维码不匹配"); + } + } + } + } + + private void showNotice(String st) { + if (!PatrolDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolDetailActivity.this,SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText(st) + .setConfirmText("确定") + .show(); + } + }); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolEquAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolEquAdapter.java new file mode 100644 index 0000000..b1948e2 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolEquAdapter.java @@ -0,0 +1,62 @@ +package com.sipai.jspatrol.Patrol; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * created by lvliming on 2019/8/5 + */ +public class PatrolEquAdapter extends RecyclerView.Adapter { + private List list; + private Context context; + + public PatrolEquAdapter(List list, Context context) { + this.list = list; + this.context = context; + } + + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_patrol_equ ,parent,false); + ViewHolder holder = new ViewHolder(view); + return holder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + EquList item = list.get(position); + holder.tv_name.setText(item.getEquipmentname()); + holder.tv_cardId.setText(item.getEquipmentcardid()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + LinearLayout ll_all; + TextView tv_name,tv_status,tv_cardId; + View root; + public ViewHolder(@NonNull View itemView) { + super(itemView); + root = itemView; + ll_all = itemView.findViewById(R.id.moudle_item_patrol_equ_ll_all); + tv_name = itemView.findViewById(R.id.moudle_item_patrol_equ_tv_title); + tv_status = itemView.findViewById(R.id.moudle_item_patrol_equ_tv_status); + tv_cardId = itemView.findViewById(R.id.moudle_item_patrol_equ_tv_content); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolEquDetailActivity.java b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolEquDetailActivity.java new file mode 100644 index 0000000..2c13429 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolEquDetailActivity.java @@ -0,0 +1,887 @@ +package com.sipai.jspatrol.Patrol; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.gson.Gson; +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolEqu; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.Bean.PatrolPointContent; +import com.sipai.jspatrol.Bean.EquList; +import com.sipai.jspatrol.Bean.InputPoint; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.ProMonitoring.MeasurePointsAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.Utils; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.litepal.LitePal; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +/** + * 工艺巡检中设备详情 + */ +public class PatrolEquDetailActivity extends AppCompatActivity implements View.OnClickListener { + private TextView tv_equipmentname,tv_equipmentcardid,tv_equipmentclass,tv_equipmentlevel,tv_company,tv_equipmentmanufacturer,tv_area; + private TextView tv_hand,tv_auto; + private String id; + private EquList equ; + private List points = new ArrayList<>(); + private List autoPoints = new ArrayList<>(); + private SweetAlertDialog pDialog; + private RecyclerView rc_edit_point; + private EditMPointAdapter mAdapter; + private LinearLayoutManager editManager; + private RecyclerView rc; + private MeasurePointsAdapter pointlistadapter; + private LinearLayoutManager manager; + private Button btn_sub; + private String st_status; + private String pointId = "";//巡检点id + private String taskId = "";//巡检任务id + private String type; + private static String[] ar_status = {"封存","启用","故障异常"}; + private List ppcs = new ArrayList<>();//巡检内容列表 + private RecyclerView rc_content; + private LinearLayoutManager contentManager; + private PatrolPointContentSelectorAdapter contentSelectorAdapter; + private int subResult = 0; + private LinearLayout ll_do_content; + + public static void actionStart(Context context,String id,String patrolpointid,String patroltaskid,String type){ + Intent intent = new Intent(context,PatrolEquDetailActivity.class); + intent.putExtra("id",id); + intent.putExtra("pointId",patrolpointid); + intent.putExtra("taskId",patroltaskid); + intent.putExtra("type",type); + context.startActivity(intent); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_patrol_equ_detail); + init(); + initView(); + if (Utils.isNetworkConnected(PatrolEquDetailActivity.this)) { + getEquDetail(); + getEquPatrolEdtPoint(); + getEquPatrolContent(); + }else { + List equs = LitePal.where("equipmentId = ?",id).find(PatrolEqu.class); + if (equs.size()>0){ + tv_equipmentname.setText(equs.get(0).getEquipmentName()); + tv_equipmentcardid.setText(equs.get(0).getEquipmentCardId()); + } + points = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointId,taskId,id).find(InputPoint.class); + ppcs = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointId,taskId,id).find(PatrolPointContent.class); + UpDateUI(); + UpDateList(); + } + } + + /** + * 设备下巡检内容 + */ + private void getEquPatrolContent() { + HashMap map = new HashMap<>(); + map.put("equipmentId",id); + map.put("patrolPointId",pointId); + map.put("patrolRecordId",taskId); + map.put("type",type); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.GetPatrolPointEquDetailPC_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorToast(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res!=null&&!res.isEmpty()){ + ppcs = parseContent(res); + }else { + ppcs = new ArrayList<>(); + } + UpDateUI(); + } + }); + } + + /** + * 解析执行内容 + * @param response + * @return + */ + private List parseContent(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray jsonArray = new JSONArray(jsonObject.optString("result")); + if (jsonArray.length()>0) { + for (int i = 0; i < jsonArray.length(); i++) { + PatrolPointContent item = new PatrolPointContent(); + item.setSid(jsonArray.getJSONObject(i).optString("id")); + item.setContents(jsonArray.getJSONObject(i).optString("contents")); + item.setContentsDetail(jsonArray.getJSONObject(i).optString("contentsDetail")); + item.setStatus(jsonArray.getJSONObject(i).optString("status")); + list.add(item); + } + }else { +// ErrorDialog("巡检点执行内容获取失败,请重试","content"); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } + + + /** + * 获取设备下填报内容(手动测量点) + */ + private void getEquPatrolEdtPoint() { + HashMap map = new HashMap<>(); + map.put("equipmentId",id); + map.put("patrolPointId",pointId); + map.put("patrolRecordId",taskId); + map.put("unitId",mBizid); + map.put("type",type); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.GetPatrolPointEquDetailEC_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorToast(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + Log.i("Equ", "onResponse: "+res); + if (res!=null&&!res.isEmpty()&&res.contains("result")){ + points = parsePoint(res); + }else { + points = new ArrayList<>(); + } + UpDateList(); + } + }); + } + + /** + * 解析手动测量点 + * @param response + * @return + */ + private List parsePoint(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray jsonArray = new JSONArray(jsonObject.optString("result")); + for (int i=0;i map = new HashMap<>(); + map.put("id",id); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.GetPatrolPointEquDetail_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + stopRefresh(); + errorToast(e); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (!PatrolEquDetailActivity.this.isFinishing()){ + if (res!=null&&!res.isEmpty()&&res.contains("code")){ + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.optString("code").equals("1")&&jsonObject.optString("result").length()>10){ + equ = parseEquInfo(res); + runOnUiThread(new Runnable() { + @Override + public void run() { + tv_equipmentname.setText(equ.getEquipmentname()); + tv_equipmentcardid.setText(equ.getEquipmentcardid()); + } + }); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + } + stopRefresh(); + } + }); + } + + private EquList parseEquInfo(String response) { + EquList item = new EquList(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray jsonArray = jsonObject.getJSONArray("result"); + JSONObject js = jsonArray.getJSONObject(0); + item.setEquipmentname(js.optString("equipmentname")); + item.setEquipmentcardid(js.optString("equipmentcardid")); + } catch (JSONException e) { + e.printStackTrace(); + } + return item; + } + + /** + * 解析自动测量点 + * @param response + * @return + */ + private List getAutoPoints(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.getString("content3")); + if (aNews != null && aNews.length() > 0) { + for (int i = 0; i 0) { + tv_auto.setVisibility(View.GONE); + manager = new LinearLayoutManager(PatrolEquDetailActivity.this); + rc.setLayoutManager(manager); + pointlistadapter = new MeasurePointsAdapter(PatrolEquDetailActivity.this,autoPoints); + rc.setAdapter(pointlistadapter); + }else { + tv_auto.setVisibility(View.VISIBLE); + } + } + }); + } + } + + private void errorToast(final Throwable error) { + if (!PatrolEquDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(PatrolEquDetailActivity.this, "失败:"+error.toString(), Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void stopRefresh() { + if (!PatrolEquDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { +// refreshLayout.setRefreshing(false); + } + }); + } + } + + + private void UpDateList() { + if (!PatrolEquDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { +// refreshLayout.setRefreshing(false); + if (points.size()>0) { + tv_hand.setVisibility(View.GONE); + mAdapter = new EditMPointAdapter(points,PatrolEquDetailActivity.this); + rc_edit_point.setAdapter(mAdapter); + }else { + tv_hand.setVisibility(View.VISIBLE); + } + } + }); + } + } + + private void UpDateUI() { + if (!PatrolEquDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + contentSelectorAdapter = new PatrolPointContentSelectorAdapter(ppcs,PatrolEquDetailActivity.this); + rc_content.setAdapter(contentSelectorAdapter); + if (ppcs.size()==0){ + ll_do_content.setVisibility(View.GONE); + }else { + ll_do_content.setVisibility(View.VISIBLE); + } + } + }); + } + } + + /** + * 解析设备详情 + * @param response + * @return + */ + private EquList getDetail(String response) { + EquList item = new EquList(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray content = new JSONArray(jsonObject.optString("content1")); + if (content.length()>0) { + item.setAreaid(content.getJSONObject(0).optString("areaid")); + item.setAssetclassid(content.getJSONObject(0).optString("")); + item.setBizid(content.getJSONObject(0).optString("")); + if (content.getJSONObject(0).get("company") != null && !content.getJSONObject(0).get("company").toString().equals("null")) { + JSONObject company = new JSONObject(content.getJSONObject(0).optString("company")); + item.setCompany(company.optString("name")); + } else { + item.setCompany(""); + } + if (content.getJSONObject(0).get("equipmentClass") != null && !content.getJSONObject(0).get("equipmentClass").toString().equals("null")) { + JSONObject equClass = new JSONObject(content.getJSONObject(0).optString("equipmentClass")); + item.setEquipmentClass(equClass.optString("name")); + } else { + item.setEquipmentClass(""); + } + if (content.getJSONObject(0).get("equipmentLevel") != null && !content.getJSONObject(0).get("equipmentLevel").toString().equals("null")) { + JSONObject equLevel = new JSONObject(content.getJSONObject(0).optString("equipmentLevel")); + item.setEquipmentLevel(equLevel.optString("levelname")); + } else { + item.setEquipmentLevel(""); + } + if (content.getJSONObject(0).get("equipmentSpecification") != null && !content.getJSONObject(0).get("equipmentSpecification").toString().equals("null")) { + JSONObject equipmentSpecification = new JSONObject(content.getJSONObject(0).optString("equipmentSpecification")); + item.setEquipmentSpecification(equipmentSpecification.optString("name")); + } else { + item.setEquipmentSpecification(""); + + } + if (content.getJSONObject(0).get("equipmentTypeNumber") != null && !content.getJSONObject(0).get("equipmentTypeNumber").toString().equals("null")) { + JSONObject equipmentTypeNumber = new JSONObject(content.getJSONObject(0).optString("equipmentTypeNumber")); + item.setEquipmentTypeNumber(equipmentTypeNumber.optString("name")); + } else { + item.setEquipmentTypeNumber(""); + } + item.setEquipmentcardid(content.getJSONObject(0).optString("equipmentcardid")); + item.setEquipmentclassid(content.getJSONObject(0).optString("equipmentclassid")); + item.setEquipmentlevelid(content.getJSONObject(0).optString("equipmentlevelid")); + item.setEquipmentmanufacturer(content.getJSONObject(0).optString("equipmentmanufacturer")); + item.setEquipmentname(content.getJSONObject(0).optString("equipmentname")); + item.setEquipmentstatus(content.getJSONObject(0).optString("equipmentstatus")); + item.setId(content.getJSONObject(0).optString("id")); + item.setLeavefactorynumber(content.getJSONObject(0).optString("leavefactorynumber")); + item.setMajorparameter(content.getJSONObject(0).optString("majorparameter")); + item.setProductiondate(content.getJSONObject(0).optString("productiondate")); + item.setTotaltime(content.getJSONObject(0).optString("totaltime").toString()); + if (content.getJSONObject(0).optString("equipmentstatus").equals("0")) { + item.setEquipmentstatus("禁用"); + } else if (content.getJSONObject(0).optString("equipmentstatus").equals("1")) { + item.setEquipmentstatus("启用"); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + return item; + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private String token; + public void init(){ + SharedPreferences sharedPre=getSharedPreferences("config", MODE_PRIVATE); + mServer=sharedPre.getString("server", ""); + mUsername=sharedPre.getString("username", ""); + mPassword=sharedPre.getString("password", ""); + mUserid=sharedPre.getString("userid", ""); + mCaption=sharedPre.getString("caption", ""); + mBizid=sharedPre.getString("bizid", ""); + id = getIntent().getStringExtra("id"); + token = sharedPre.getString("token",""); + type = getIntent().getStringExtra("type"); + if (getIntent().getStringExtra("pointId")!=null&&!getIntent().getStringExtra("pointId").isEmpty()){ + pointId = getIntent().getStringExtra("pointId"); + } + if (getIntent().getStringExtra("taskId")!=null&&!getIntent().getStringExtra("taskId").isEmpty()){ + taskId = getIntent().getStringExtra("taskId"); + } + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + case R.id.moudle_patrol_equ_detail_btn_sub: + if (subResult!=2) { + subResult = 0; + if (Utils.isNetworkConnected(PatrolEquDetailActivity.this)) { + subValue();//上传填报内容 + subContent();//上传巡检内容 + }else { + List equs = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointId,taskId,id).find(PatrolEqu.class); + if (equs.size()>0) { + saveOfflineInfo(); + }else { + noOfflineData(); + } + } + } + break; + } + } + + private void noOfflineData() { + if (!PatrolEquDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolEquDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("网络不可用,且本地未检测到本条任务离线数据,无法进行离线保存!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void saveOfflineInfo() { + //保存执行内容 + for (int i = 0; i < ppcs.size(); i++) { + ppcs.get(i).setStatus(GlobalVal.Status_Issue); + ppcs.get(i).updateAll("sid = ?",ppcs.get(i).getSid()); + } + Map map1 = contentSelectorAdapter.getMap(); + for (int i = map1.size()-1; 0<=i; i--) { + if (map1.get(i)) { + Log.d("TAG", "你选了第:" + i + "项"); +// sel_users.add(users.get(i)); + ppcs.get(i).setStatus(GlobalVal.Status_Finish); + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ppcs.get(i).setFinishDt(format.format(date)); + ppcs.get(i).updateAll("sid = ?",ppcs.get(i).getSid()); + } + } + List contents = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointId,taskId,id).find(PatrolPointContent.class); + //保存填报内容 + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for(int i=0;i pts = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointId,taskId,id).find(InputPoint.class); + //保存巡检点状态与提交时间 + List equs = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointId,taskId,id).find(PatrolEqu.class); + equs.get(0).setFinishDt(format.format(date)); + equs.get(0).setStatus(GlobalVal.Status_Finish); + equs.get(0).updateAll("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointId,taskId,id); + showSaveSuccessDialog(); + } + + private void showSaveSuccessDialog() { + if (!PatrolEquDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolEquDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("成功") + .setContentText("保存成功!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + /** + * 提交设备数据 + */ + private void subValue() { + Gson gson = new Gson(); + String json = "{\"re1\":"+gson.toJson(points)+"}"; + subAllPoints(json); + } + + /** + * 上传所有测量点 + * @param json + */ + private void subAllPoints(String json) { + HashMap map = new HashMap<>(); + map.put("isLimited","true"); + map.put("json",json); + map.put("patrolPointId",pointId); + map.put("patrolRecordId",taskId); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.SubPatrolPointEquDetailEC_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorDialog(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("code")&&res.contains("result")){ + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.get("code").toString().equals("1")){ +// successDialog(); + subResult = subResult + 1; + if (subResult==2){ + subEquStatus(); + } + }else { + errorDialog(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + } + }); + } + + + /** + * 上传执行内容 + */ + private void subContent() { + for (int i = 0; i < ppcs.size(); i++) { + ppcs.get(i).setStatus(GlobalVal.Status_Issue); + } + Map map1 = contentSelectorAdapter.getMap(); + for (int i = map1.size()-1; 0<=i; i--) { + if (map1.get(i)) { + Log.d("TAG", "你选了第:" + i + "项"); +// sel_users.add(users.get(i)); + ppcs.get(i).setStatus(GlobalVal.Status_Finish); + } + } + Gson gson = new Gson(); + String json = "{\"re1\":"+gson.toJson(ppcs)+"}"; + HashMap map = new HashMap<>(); + map.put("isLimited","true"); + map.put("json",json); + map.put("patrolPointId",pointId); + map.put("patrolRecordId",taskId); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.SubPatrolPointEquDetailPC_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorDialog(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("code")&&res.contains("result")){ + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.get("code").toString().equals("1")){ + subResult = subResult + 1; + if (subResult==2){ + subEquStatus(); + } + }else { + errorDialog(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + } + }); + +// AsyncHttpClient client = new AsyncHttpClient(); +// client.addHeader("token",token); +// RequestParams params = new RequestParams(); +// params.put("patrolPointId",pointId); +// params.put("patrolRecordId",taskId); +// params.put("json",json); +// client.post(mServer+"SIPAIIS_Patrol/timeEfficiency/patrolContentsRecord/updatePatrolContents.do?", params ,new AsyncHttpResponseHandler() { +// +// @Override +// public void onSuccess(String response) { +// String res = response; +// +// } +// @Override +// public void onFailure(Throwable e) { +// +// } +// @Override +// public void onStart() { +// super.onStart(); +// } +// +// @Override +// public void onFinish() { +// super.onFinish(); +// } +// +// }); + } + + private void subEquStatus() { + HashMap map = new HashMap<>(); + map.put("equipmentId",id); + map.put("patrolPointId",pointId); + map.put("patrolRecordId",taskId); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.SubPatrolPointEquDetailPS_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorDialog(); + subResult=0; + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("code")&&res.contains("result")){ + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.get("code").toString().equals("1")){ + successDialog(); + }else { + errorStatusDialog(); + subResult=0; + } + } catch (JSONException e) { + e.printStackTrace(); + } + }else { + subResult=0; + } + } + }); + } + + + private void successDialog() { + if (!PatrolEquDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolEquDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("成功") + .setContentText("提交成功!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + private void errorDialog() { + if (!PatrolEquDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolEquDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("测量点信息提交失败,请重试!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void errorStatusDialog() { + if (!PatrolEquDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolEquDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("提交失败,请重试!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void pDialogHide() { + if (!PatrolEquDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!PatrolEquDetailActivity.this.isFinishing()) { + pDialog.hide(); + } + } + }); + } + } + + private void pDialogshow() { + if (!PatrolEquDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!PatrolEquDetailActivity.this.isFinishing()) { + pDialog.show(); + } + } + }); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolPointContentSelectorAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolPointContentSelectorAdapter.java new file mode 100644 index 0000000..4bb61f5 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolPointContentSelectorAdapter.java @@ -0,0 +1,157 @@ +package com.sipai.jspatrol.Patrol; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.LinearLayout; +import android.widget.TextView; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.Bean.PatrolPointContent; +import com.sipai.jspatrol.R; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * created by lvliming on 2019/8/27 + */ +public class PatrolPointContentSelectorAdapter extends RecyclerView.Adapter implements View.OnClickListener { + + //数据源 + private List list; + private Context context; + //是否显示单选框 + private boolean isshowBox = true; + //存储勾选框状态的map集合 + private Map map = new HashMap<>(); + //接口实例 + private RecyclerViewOnItemClickListener onItemClickListener; + + public PatrolPointContentSelectorAdapter(List list, Context context) { + this.list = list; + this.context = context; + initMap(); + } + //初始化map集合,默认不选中 + private void initMap() { + for (int i=0;i getMap() { + return map; + } + + //接口回调设置点击事件 + public interface RecyclerViewOnItemClickListener { + //点击事件 + void onItemClickListener(View view, int position); + + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolPointDetailActivity.java b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolPointDetailActivity.java new file mode 100644 index 0000000..00a239b --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/PatrolPointDetailActivity.java @@ -0,0 +1,1188 @@ +package com.sipai.jspatrol.Patrol; + +import android.app.PendingIntent; +import android.content.ContentValues; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.net.Uri; +import android.nfc.NdefMessage; +import android.nfc.NdefRecord; +import android.nfc.NfcAdapter; +import android.nfc.tech.MifareClassic; +import android.nfc.tech.NfcA; +import android.os.Build; +import android.os.Bundle; +import android.os.Parcelable; +import android.speech.tts.TextToSpeech; +import android.text.Html; +import android.text.format.DateFormat; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.gson.Gson; +import com.sipai.jspatrol.Bean.Patrol; +import com.sipai.jspatrol.Fault.NewFaultActivity; +import com.sipai.jspatrol.utils.Global.GlobalVal; +import com.sipai.jspatrol.Bean.PatrolPointContent; +import com.sipai.jspatrol.Bean.FileForDL; +import com.sipai.jspatrol.Bean.InputPoint; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.Bean.ProPatrolPoint; +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolEqu; +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolInfoEquAdapter; +import com.sipai.jspatrol.Patrol.patrolInfoAdapter.PatrolInfoMeasurePointAdapter; +import com.sipai.jspatrol.ProMonitoring.MeasurePointsAdapter; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.Utils; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.litepal.LitePal; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class PatrolPointDetailActivity extends AppCompatActivity implements TextToSpeech.OnInitListener { + private String pointid; + private String taskId; + private String taskType; + private ProPatrolPoint sel_point; + private LinearLayoutManager manager,equManager; + private List measuringpoints = new ArrayList<>(); + private PatrolInfoMeasurePointAdapter pointAdapter; + private FileForDLAdapter fileForDLAdapter; + private PatrolInfoEquAdapter equAdapter; + private List points = new ArrayList<>(); + private EditMPointAdapter mAdapter; + private LinearLayoutManager editManager; + private List fileForDLs = new ArrayList<>(); + private List ppcs = new ArrayList<>(); + private final int POINTINFO=2; + private String sel_content = ""; + private TextView tv_content; + private TextToSpeech tts; + private String ttstext="";//存储tts播放内容 + private List equs = new ArrayList<>(); + private NfcAdapter nfcAdapter; + private PendingIntent pendingIntent; + private IntentFilter[] mFilters; + private String[][] mTechLists; + private boolean isNFC_support = false; + private TextView tv_point_detail_title; + private RecyclerView rc_file; + private RecyclerView rc_edit_point; + private RecyclerView rc_equs; + private TextView tv_point,tv_edit_point,tv_equ; + private Button btn_sub_point; + private SweetAlertDialog pDialog; + private TextView tv_file_count; + private RecyclerView rc_content; + private LinearLayoutManager contentManager; + private PatrolPointContentSelectorAdapter contentSelectorAdapter; + private String markOfSub = "0";//标记上传进行到的步骤,0为填报内容(测量点),1为巡检内容,2为巡检点状态 + private RecyclerView rc_point; + private LinearLayoutManager autoManager; + private MeasurePointsAdapter autoAdapter; + private LinearLayout ll_sub_fault; + private LinearLayout ll_auto_point,ll_do_content,ll_edit_point,ll_equ; + + public static void actionStart(Context context , ProPatrolPoint point, String taskid,String taskType){ + Intent intent = new Intent(context,PatrolPointDetailActivity.class); + intent.putExtra("point",point); + intent.putExtra("taskid",taskid); + intent.putExtra("tasktype",taskType); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_patrol_point_detail); + init(); + initView(); + if (Utils.isNetworkConnected(PatrolPointDetailActivity.this)) { + if (pointid != null && pointid.length() > 0) { + getAutoPoint(); + getPointDetail(); + getPointPatrolContent(); + } + }else { + measuringpoints = new ArrayList<>(); + updateAutoPoint(); + points = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointid,taskId,"").find(InputPoint.class); + updateEditPoints(); + ppcs = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointid,taskId,"").find(PatrolPointContent.class); + updatePC(); + } + } + + @Override + protected void onResume() { + super.onResume(); + nfcAdapter = NfcAdapter.getDefaultAdapter(this); + isNFC_support = !(nfcAdapter == null || !nfcAdapter.isEnabled()); + if (isNFC_support) { + nfcAdapter.enableForegroundDispatch(this, pendingIntent, mFilters, + mTechLists); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(getIntent().getAction())) { + // 注意这个if中的代码几乎不会进来,因为刚刚在上一行代码开启了监听NFC连接,下一行代码马上就收到了NFC连接的intent,这种几率很小 + // 处理该intent + String result = processIntent(getIntent()); + if(result!=null && !result.equals("error")){ + showinfobyNFC(result); + } + } + } + if (Utils.isNetworkConnected(PatrolPointDetailActivity.this)) { + if (pointid != null && pointid.length() > 0) { + getPointEquList(); + } + }else { + equs = LitePal.where("patrolPointId = ? and patrolRecordId = ?",pointid,taskId).find(PatrolEqu.class); + UpdateEquUI(); + } + } + + @Override + protected void onPause() { + super.onPause(); + if (nfcAdapter !=null && nfcAdapter.isEnabled()) { + // 当前Activity如果不在手机的最前端,就停止NFC设备连接的监听 + stopNFC_Listener(); + } + } + + private void stopNFC_Listener() { + // 停止监听NFC设备是否连接 + nfcAdapter.disableForegroundDispatch(this); + } + + @Override + protected void onNewIntent(Intent intent) { + // TODO Auto-generated method stub + // 当前app正在前端界面运行,这个时候有intent发送过来,那么系统就会调用onNewIntent回调方法,将intent传送过来 + // 我们只需要在这里检验这个intent是否是NFC相关的intent,如果是,就调用处理方法 + super.onNewIntent(intent); + if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) { + String result = processIntent(intent); + if(result!=null && !result.equals("error")){ + showinfobyNFC(result); + } + } + } + private void showinfobyNFC(String st){ + int ishave = 0; + if (ishave>0){ + Intent intent = new Intent(PatrolPointDetailActivity.this,PatrolEquDetailActivity.class); + intent.putExtra("id",st); + intent.putExtra("pointId",pointid); + intent.putExtra("taskId",taskId); + startActivity(intent); + }else { + NoThisEqu(); + } + } + + private void NoThisEqu() { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("该区域巡检列表中无此设备!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + + /** + * 获取tab标签中的内容 + * @param intent + * @return + */ + private String processIntent(Intent intent) { + Parcelable[] rawmsgs = intent + .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); + try { + if (rawmsgs != null) { + NdefMessage msg = (NdefMessage) rawmsgs[0]; + NdefRecord[] records = msg.getRecords(); + String resultStr = new String(records[0].getPayload()); + return resultStr; + } else { + return "error"; + } + }catch (Exception e){ + return "error"; + } + } + + /** + * 获取巡检点下自动点 + */ + private void getAutoPoint() { + HashMap map = new HashMap<>(); + map.put("type","auto"); + map.put("patrolPointId",sel_point.getSid()); + map.put("unitId",mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.GetPatrolPointAutoPoint_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + ErrorDialog("巡检点下测量点列表获取失败,请重试","auto"); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("code")&&res.contains("result")) { + measuringpoints = parseMeasuringPoints(res); + }else { + measuringpoints = new ArrayList<>(); + } + updateAutoPoint(); + } + }); + } + + /** + * 更新自动点列表 + */ + private void updateAutoPoint() { + if (!PatrolPointDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + autoAdapter = new MeasurePointsAdapter(PatrolPointDetailActivity.this,measuringpoints); + rc_point.setAdapter(autoAdapter); + if (measuringpoints.size()==0){ + ll_auto_point.setVisibility(View.GONE); + }else { + ll_auto_point.setVisibility(View.VISIBLE); + } + } + }); + } + } + + /** + * 解析自动点 + * @param response + * @return + */ + private List parseMeasuringPoints(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.getString("result")); + for (int i=0;i map = new HashMap<>(); + map.put("patrolRecordId",sel_point.getTaskId()); + map.put("patrolPointId",sel_point.getSid()); + map.put("unitId",mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.GetPatrolPointEquList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + ErrorDialog("巡检点下设备列表获取失败,请重试","equs"); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + Log.i("Equ", "onResponse: "+res); + if (res.contains("code")&&res.contains("result")){ + equs = parsePatrolEqu(res); + } + UpdateEquUI(); + } + }); + } + + private List parsePatrolEqu(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray array = new JSONArray(jsonObject.optString("result")); + for (int i=0;i mps = new ArrayList<>(); + JSONArray aps = new JSONArray(array.getJSONObject(i).optString("measurePoints")); + for (int a=0;a map = new HashMap<>(); + map.put("patrolRecordId",sel_point.getTaskId()); + map.put("patrolPointId",sel_point.getSid()); + map.put("type",sel_point.getType()); + map.put("equipmentId",""); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.GetPatrolPointContent_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + ErrorDialog("巡检点执行内容获取失败,请重试","content"); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res!=null&&!res.isEmpty()){ + ppcs = parseContent(res); + } + updatePC(); + } + }); + } + + private void updatePC() { + if (!PatrolPointDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + if (ppcs.size()==0){ + ll_do_content.setVisibility(View.GONE); + }else { + ll_do_content.setVisibility(View.VISIBLE); + } + contentSelectorAdapter = new PatrolPointContentSelectorAdapter(ppcs,PatrolPointDetailActivity.this); + rc_content.setAdapter(contentSelectorAdapter); + } + }); + } + } + + private List parseContent(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray jsonArray = new JSONArray(jsonObject.optString("result")); + if (jsonArray.length()>0) { + for (int i = 0; i < jsonArray.length(); i++) { + PatrolPointContent item = new PatrolPointContent(); + item.setSid(jsonArray.getJSONObject(i).optString("id")); + item.setContents(jsonArray.getJSONObject(i).optString("contents")); + item.setContentsDetail(jsonArray.getJSONObject(i).optString("contentsDetail")); + item.setStatus(jsonArray.getJSONObject(i).optString("status")); + list.add(item); + } + } + } catch (JSONException e) { + e.printStackTrace(); + } + return list; + } + + /** + * 巡检点下填报内容 + */ + private void getPointDetail() { + HashMap map = new HashMap<>(); + map.put("patrolRecordId",sel_point.getTaskId()); + map.put("patrolPointId",sel_point.getSid()); + map.put("unitId",mBizid); + map.put("type",sel_point.getType()); + map.put("equipmentId",""); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.GetPatrolPointEditPoint_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + ErrorDialog("手动测量点列表获取失败,请重试","point"); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray jsonArray = new JSONArray(jsonObject.optString("result")); + if (jsonArray.length()>0) { + points = parsePoint(res); + }else { +// ErrorDialog("手动测量点列表获取失败,请重试","point"); + points = new ArrayList<>(); + } + updateEditPoints(); + } catch (JSONException e) { + e.printStackTrace(); + } + } + }); + } + + private void updateEditPoints() { + if (!PatrolPointDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + editManager = new LinearLayoutManager(PatrolPointDetailActivity.this); + rc_edit_point.setLayoutManager(editManager); + mAdapter = new EditMPointAdapter(points,PatrolPointDetailActivity.this); + rc_edit_point.setAdapter(mAdapter); + if (points.size()==0){ + ll_edit_point.setVisibility(View.GONE); + }else { + ll_edit_point.setVisibility(View.VISIBLE); + } + } + }); + } + } + + private void ErrorDialog(String content,String type) { + if (!PatrolPointDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText(content) + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + if (type.equals("content")){ + getPointPatrolContent(); + }else if (type.equals("point")){ + getPointDetail(); + }else if (type.equals("equs")){ + getPointEquList(); + }else if(type.equals("auto")){ + getAutoPoint(); + } + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private String token; + public void init(){ + SharedPreferences sharedPre=getSharedPreferences("config", MODE_PRIVATE); + mServer=sharedPre.getString("server", ""); + mUsername=sharedPre.getString("username", ""); + mPassword=sharedPre.getString("password", ""); + mUserid=sharedPre.getString("userid", ""); + mCaption=sharedPre.getString("caption", ""); + mBizid=sharedPre.getString("bizid", ""); + token = sharedPre.getString("token",""); + sel_point = (ProPatrolPoint) getIntent().getSerializableExtra("point"); + if (sel_point.getSid()!=null&&sel_point.getSid().length()>0){ + pointid = sel_point.getSid(); + } + taskId = getIntent().getStringExtra("taskid"); + taskType = getIntent().getStringExtra("tasktype"); + } + + private void initView() { + TextView tv_title = findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("巡检点详情"); + ImageView btn_back = findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setTitleText("数据获取中..."); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + ll_auto_point = findViewById(R.id.moudle_patrolinfo_ll_auto_point); + ll_do_content = findViewById(R.id.moudle_patrolinfo_ll_do_content); + ll_edit_point = findViewById(R.id.moudle_patrolinfo_ll_edit_point); + ll_equ = findViewById(R.id.moudle_patrolinfo_ll_equ); + tv_point = findViewById(R.id.moudle_patrol_point_detail_tv_file); + tv_point.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (pointid!=null&&pointid.length()>0){ + getPointDetail(); + } + } + }); + tv_edit_point = findViewById(R.id.moudle_patrol_point_detail_tv_edit_point); + tv_edit_point.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (pointid!=null&&pointid.length()>0){ + getPointDetail(); + } + } + }); + ll_sub_fault = findViewById(R.id.moudle_patrol_point_detail_ll_sub_fault); + ll_sub_fault.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + NewFaultActivity.actionStart(PatrolPointDetailActivity.this,sel_point.getSid(),taskId,sel_point.getTaskId()); + } + }); + rc_point = findViewById(R.id.moudle_patrolinfo_rc_auto_point); + autoManager = new LinearLayoutManager(this); + rc_point.setLayoutManager(autoManager); + autoAdapter = new MeasurePointsAdapter(PatrolPointDetailActivity.this,measuringpoints); + rc_point.setAdapter(autoAdapter); + + rc_content = findViewById(R.id.moudle_patrolinfo_rc_content); + contentManager = new LinearLayoutManager(PatrolPointDetailActivity.this); + rc_content.setLayoutManager(contentManager); + contentSelectorAdapter = new PatrolPointContentSelectorAdapter(ppcs,PatrolPointDetailActivity.this); + rc_content.setAdapter(contentSelectorAdapter); + + tv_equ = findViewById(R.id.moudle_patrol_point_detail_tv_equ); + tv_equ.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (pointid!=null&&pointid.length()>0) { + getPointEquList(); + } + } + }); + btn_sub_point = findViewById(R.id.moudle_patrol_point_detail_btn_sub_point); + btn_sub_point.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (Utils.isNetworkConnected(PatrolPointDetailActivity.this)) { + if (markOfSub.equals("0")) { + subValue(); + } else if (markOfSub.equals("1")) { + subContent(); + } else if (markOfSub.equals("2")) { + subThisPatrolPoint(); + } + }else { + List lll = LitePal.where("sid = ?",taskId).find(Patrol.class); + if (lll.size()>0) { + saveOfflineInfo(); + }else { + noOfflineData(); + } + } + } + }); + tv_point_detail_title = findViewById(R.id.moudle_patrol_point_detail_tv_point_name); + tv_point_detail_title.setText(sel_point.getName()); + tv_content = findViewById(R.id.moudle_patrol_point_detail_tv_content); + if (sel_content.length()>0){ + if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.N) { + tv_content.setText(Html.fromHtml(sel_content,Html.FROM_HTML_MODE_COMPACT)); + }else { + tv_content.setText(Html.fromHtml(sel_content)); + } + }else { + tv_content.setText("查看巡检点区域测量点及设备!"); + } + rc_file = findViewById(R.id.moudle_patrol_point_detail_rc_file); + manager = new LinearLayoutManager(PatrolPointDetailActivity.this); + rc_file.setLayoutManager(manager); + fileForDLAdapter = new FileForDLAdapter(PatrolPointDetailActivity.this, fileForDLs, new FileForDLAdapter.onRcViewItemClick() { + @Override + public void onItemClick(View v, int position) { + checkFile(fileForDLs.get(position)); + } + }); + rc_file.setAdapter(fileForDLAdapter); + tv_file_count = findViewById(R.id.moudle_patrol_point_detail_tv_file_count); + tv_file_count.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (rc_file.getVisibility()==View.GONE){ + rc_file.setVisibility(View.VISIBLE); + }else { + rc_file.setVisibility(View.GONE); + } + } + }); + rc_edit_point = findViewById(R.id.moudle_patrol_point_detail_rc_edit_point); + editManager = new LinearLayoutManager(PatrolPointDetailActivity.this); + rc_edit_point.setLayoutManager(editManager); + mAdapter = new EditMPointAdapter(points,PatrolPointDetailActivity.this); + rc_edit_point.setAdapter(mAdapter); + + rc_equs = findViewById(R.id.moudle_patrol_point_detail_rc_equ); + equManager = new LinearLayoutManager(PatrolPointDetailActivity.this); + rc_equs.setLayoutManager(equManager); + equAdapter = new PatrolInfoEquAdapter(equs,PatrolPointDetailActivity.this); + rc_equs.setAdapter(equAdapter); + tts = new TextToSpeech(this, this); + //nfc初始化 + pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, + getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); + IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); + ndef.addCategory("*/*"); + mFilters = new IntentFilter[] { ndef };// 过滤器 + mTechLists = new String[][] { + new String[] { MifareClassic.class.getName() }, + new String[] { NfcA.class.getName() } };// 允许扫描的标签类型 + } + + private void noOfflineData() { + if (!PatrolPointDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("网络不可用,且本地未检测到本条任务离线数据,无法进行离线保存!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void saveOfflineInfo() { + //保存执行内容 + for (int i = 0; i < ppcs.size(); i++) { + ppcs.get(i).setStatus(GlobalVal.Status_Issue); + ppcs.get(i).updateAll("sid = ?",ppcs.get(i).getSid()); + } + Map map1 = contentSelectorAdapter.getMap(); + for (int i = map1.size()-1; 0<=i; i--) { + if (map1.get(i)) { + Log.d("TAG", "你选了第:" + i + "项"); +// sel_users.add(users.get(i)); + ppcs.get(i).setStatus(GlobalVal.Status_Finish); + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ppcs.get(i).setFinishDt(format.format(date)); + ppcs.get(i).updateAll("sid = ?",ppcs.get(i).getSid()); + } + } + List contents = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointid,taskId,"").find(PatrolPointContent.class); + //保存填报内容 + Date date = new Date(System.currentTimeMillis()); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for(int i=0;i pts = LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",pointid,taskId,"").find(InputPoint.class); + //保存巡检点状态与提交时间 + sel_point.setFinishDt(format.format(date)); + sel_point.setWorkerId(mUserid); + sel_point.setWorkerName(mCaption); + sel_point.setStatus(GlobalVal.Status_Finish); + sel_point.updateAll("sid = ? and resultId = ?",sel_point.getSid(),sel_point.getResultId()); + List list = LitePal.where("sid = ?",sel_point.getSid()).find(ProPatrolPoint.class); + showSaveSuccessDialog(); + } + + private void showSaveSuccessDialog() { + if (!PatrolPointDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("成功") + .setContentText("保存成功!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + /** + * 上传执行内容 + */ + private void subContent() { + for (int i = 0; i < ppcs.size(); i++) { + ppcs.get(i).setStatus(GlobalVal.Status_Issue); + } + Map map1 = contentSelectorAdapter.getMap(); + for (int i = map1.size()-1; 0<=i; i--) { + if (map1.get(i)) { + Log.d("TAG", "你选了第:" + i + "项"); + ppcs.get(i).setStatus(GlobalVal.Status_Finish); + } + } + Gson gson = new Gson(); + String json = "{\"re1\":"+gson.toJson(ppcs)+"}"; + HashMap map = new HashMap<>(); + map.put("isLimited","true"); + map.put("patrolRecordId",sel_point.getTaskId()); + map.put("patrolPointId",sel_point.getSid()); + map.put("json",json); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.SubPatrolPointContent_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { +// ErrorDialog("巡检点下测量点列表获取失败,请重试","auto"); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.opt("code").toString().equals("1")){ + markOfSub = "2"; + subThisPatrolPoint(); + }else { + markOfSub = "1"; + subError(); + } + } catch (JSONException e) { + e.printStackTrace(); + markOfSub = "1"; + subError(); + } + } + }); + } + + private void subError() { + if (!PatrolPointDetailActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this,SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("上传失败,请重试") + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + subContent(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + } + + + /** + * 上传巡检点内所有手动点 + */ + private void subValue() { + Gson gson = new Gson(); + String json = "{\"re1\":"+gson.toJson(points)+"}"; + subAllPoints(json); + } + + /** + * 上传所有测量点 + * @param json + */ + private void subAllPoints(String json) { + HashMap map = new HashMap<>(); + map.put("patrolRecordId",sel_point.getTaskId()); + map.put("patrolPointId",sel_point.getSid()); + map.put("json",json); + map.put("isLimited","true"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.SubPatrolPointEditPoint_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { +// ErrorDialog("巡检点下测量点列表获取失败,请重试","auto"); + failDailog(json); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.opt("code").toString().equals("1")){ + markOfSub = "1"; + subContent(); +// successDialog(); + }else { + markOfSub = "0"; + failDailog(json); + } + } catch (JSONException e) { + e.printStackTrace(); + markOfSub = "0"; + failDailog(json); + } + } + }); + } + + /** + * 上传巡检点巡检状态 + */ + private void subThisPatrolPoint() { + HashMap map = new HashMap<>(); + map.put("id",sel_point.getResultId()); + map.put("patrolRecordId",sel_point.getTaskId()); + map.put("isLimited","true"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer,MethodURL.SubPatrolPointStatus_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { +// ErrorDialog("巡检点下测量点列表获取失败,请重试","auto"); + confirmFailDailog("提交失败!"); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.opt("code").toString().equals("1")){ + successDialog(); + subPatrolPointStatus(); + }else { + markOfSub = "2"; + if (jsonObject.optString("msg").contains("时间内")) { + confirmFailDailog(jsonObject.optString("msg")); + }else { + confirmFailDailog("提交失败!"); + } + } + } catch (JSONException e) { + e.printStackTrace(); + markOfSub = "2"; + confirmFailDailog("提交失败!"); + } + } + }); + + } + + private void subPatrolPointStatus() { + HashMap map = new HashMap<>(); + map.put("patrolRecordId",sel_point.getTaskId()); + map.put("patrolPointId",sel_point.getSid()); + map.put("userId",mUserid); + map.put("isLimited","true"); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map,mServer, MethodURL.SubPatrolPointPS_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("code")&&res.contains("result")){ + try { + JSONObject jsonObject = new JSONObject(res); + if (jsonObject.get("code").toString().equals("1")){ + successDialog(); + }else { + markOfSub = "3"; + if (jsonObject.optString("msg").contains("时间内")) { + subStatusFail(jsonObject.optString("msg")); + }else { + subStatusFail("提交失败!"); + } + + } + } catch (JSONException e) { + e.printStackTrace(); + } + }else { + markOfSub = "3"; + } + } + }); + } + + private void subStatusFail(String s) { + if (!PatrolPointDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText(s) + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + subPatrolPointStatus(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + } + + private void failDailog(String json) { + if (!PatrolPointDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText("测量点信息提交失败,请重试!") + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + subAllPoints(json); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + } + + private void confirmFailDailog(String s) { + if (!PatrolPointDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.ERROR_TYPE) + .setTitleText("失败") + .setContentText(s) + .setConfirmText("重试") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + subThisPatrolPoint(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + } + + private void successDialog() { + if (!PatrolPointDetailActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolPointDetailActivity.this, SweetAlertDialog.SUCCESS_TYPE) + .setTitleText("成功") + .setContentText("提交成功!") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + }); + } + } + + + + /** + * 解析手动测量点 + * @param response + * @return + */ + private List parsePoint(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray jsonArray = new JSONArray(jsonObject.optString("result")); + for (int i=0;i { + private List list; + private Context context; + private onRecyclerViewItemClick mOnClick; + + public ProPatrolPointAdapter(List list, Context context,onRecyclerViewItemClick mOnClick) { + this.list = list; + this.context = context; + this.mOnClick = mOnClick; + } + + @Override + public ProPatrolPointAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pro_point,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); +// viewHolder.view.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// +// } +// }); + return viewHolder; + } + + @Override + public void onBindViewHolder(ProPatrolPointAdapter.ViewHolder holder, int position) { + ProPatrolPoint item = list.get(position); + holder.tv_name.setText(item.getName()); + if (item.getProcessSection()!=null) { + holder.tv_area.setText(item.getProcessSection().getName()); + }else if (item.getProcessSectionName()!=null&&!item.getProcessSectionName().isEmpty()){ + holder.tv_area.setText(item.getProcessSectionName()); + } + holder.tv_worker.setText(item.getWorkerName()); + if (item.getFinishDt()!=null&&item.getFinishDt().length()>16) { + holder.tv_finishDt.setText(item.getFinishDt().substring(0,16)); + } + if (item.getStatus().equals(GlobalVal.Status_Issue)) { + holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.bg_patrol_point_uncom)); + holder.tv_name.setTextColor(context.getResources().getColor(R.color.black)); + holder.tv_area.setTextColor(context.getResources().getColor(R.color.bg_patrol_point_area)); + }else if(item.getStatus().equals(GlobalVal.Status_Finish)) { + holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.bg_patrol_point_com)); + holder.tv_name.setTextColor(context.getResources().getColor(R.color.task_top_little_blue)); + holder.tv_area.setTextColor(context.getResources().getColor(R.color.task_top_little_blue)); + holder.tv_worker.setTextColor(context.getResources().getColor(R.color.task_top_little_blue)); + holder.tv_finishDt.setTextColor(context.getResources().getColor(R.color.task_top_little_blue)); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + @Override + public int getItemViewType(int position) { + return position; + } + + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + View view; + LinearLayout ll_all; + TextView tv_name,tv_area,tv_worker,tv_finishDt; + public ViewHolder(View itemView) { + super(itemView); + view = itemView; + ll_all = itemView.findViewById(R.id.moudle_item_pro_patrol_point_ll_all); + tv_name = itemView.findViewById(R.id.moudle_item_pro_patrol_point_tv_name); + tv_area = itemView.findViewById(R.id.moudle_item_pro_patrol_point_tv_area); + tv_worker = itemView.findViewById(R.id.moudle_item_pro_patrol_point_tv_worker); + tv_finishDt = itemView.findViewById(R.id.moudle_item_pro_patrol_point_tv_date); + view.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if (mOnClick!=null){ + mOnClick.onItemClick(v,getAdapterPosition()); + } + } + } + + public interface onRecyclerViewItemClick{ + void onItemClick(View v,int position); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/ProPatrolTaskAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/ProPatrolTaskAdapter.java new file mode 100644 index 0000000..fbbd2a0 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/ProPatrolTaskAdapter.java @@ -0,0 +1,225 @@ +package com.sipai.jspatrol.Patrol; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.Patrol; +import com.sipai.jspatrol.R; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * Created by lvliming on 2019/2/19. + */ + +public class ProPatrolTaskAdapter extends RecyclerView.Adapter { + private List list; + private Context context; + + public ProPatrolTaskAdapter(List list, Context context) { + this.list = list; + this.context = context; + } + + @Override + public ProPatrolTaskAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pro_patrol_task_list, parent, false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.task.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int position = viewHolder.getAdapterPosition(); + Patrol item = list.get(position); + actionStart(item); + } + }); + return viewHolder; + } + + private void actionStart(Patrol item) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date curDate = new Date(System.currentTimeMillis()); + Calendar cnow = Calendar.getInstance(); + Calendar cstart = Calendar.getInstance(); + Calendar cend = Calendar.getInstance(); + int result = 0; + int result1 = 0; + try { + cnow.setTime(curDate); + cstart.setTime(df.parse(item.getStartTime())); + cend.setTime(df.parse(item.getEndTime())); + result = cnow.compareTo(cstart); + result1 = cnow.compareTo(cend); + } catch (ParseException e) { + e.printStackTrace(); + } + PatrolDetailActivity.actionStart(context,item); +// if (result < 0) { +// Toast.makeText(context, "任务尚未开始", Toast.LENGTH_SHORT).show(); +// } else { +// if (result1 > 0) { +// try { +// Date d1 = df.parse(item.getEndTime()); +// Date d2 = new Date(System.currentTimeMillis()); +// long diff = d2.getTime() - d1.getTime(); +// long hours = diff / (1000 * 60 * 60); +// if (hours<1){ +// if (item.getType().equals("P")) { +// PatrolDetailActivity.actionStart(context, item); +// }else if (item.getType().equals("E")){ +//// PatrolEquRepairActivity.actionStart(context, item.getId()); +// } +// }else { +// if (item.getStatus().equals("4")||item.getStatus().equals("5")){ +// Toast.makeText(context, "未巡检原因:"+item.getWorkResult(), Toast.LENGTH_LONG).show(); +// }else { +//// UnfinishedPatrolTaskActivity.actionStart(context, item.getId(), item.getPatrolType()); +// } +// } +// } catch (ParseException e) { +// e.printStackTrace(); +// } +// } else { +// if (item.getStatus().equals("3")) { +// if (item.getType().equals("P")) { +// PatrolDetailActivity.actionStart(context, item); +// }else if (item.getType().equals("E")){ +//// PatrolEquRepairActivity.actionStart(context, item.getId()); +// } +// } else if (item.getStatus().equals("1")) { +// PatrolDetailActivity.actionStart(context,item); +// }else { +// PatrolDetailActivity.actionStart(context,item); +// } +// } +// } + } + + @Override + public void onBindViewHolder(ProPatrolTaskAdapter.ViewHolder holder, int position) { + Patrol item = list.get(position); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date curDate = new Date(System.currentTimeMillis()); + Calendar cnow = Calendar.getInstance(); + Calendar cstart = Calendar.getInstance(); + Calendar cend = Calendar.getInstance(); + int result = 0; + int result1 = 0; + try { + cnow.setTime(curDate); + cstart.setTime(df.parse(item.getStartTime())); + cend.setTime(df.parse(item.getEndTime())); + result = cnow.compareTo(cstart); + result1 = cnow.compareTo(cend); + } catch (ParseException e) { + e.printStackTrace(); + } + if (result < 0) { + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_notstarted)); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.task_top_gray)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.task_top_gray)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.task_top_gray)); + holder.tv_status.setText("任务未开始"); + } else { + if (result1 > 0) { +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.red)); + if (item.getStatus().equals("4")){ + holder.tv_status.setText("部分巡检"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.error_yellow)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_com_part)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.task_top_blue)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_red)); + +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); + }else if (item.getStatus().equals("5")){ + holder.tv_status.setText("无法巡检"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.error_yellow)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_can_not)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); + }else if (item.getStatus().equals("3")){ +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.green)); + holder.tv_status.setText("已完成"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.task_top_little_blue)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_com)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_blue)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_blue)); + }else { + holder.tv_status.setText("任务已过期"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.task_top_little_red)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_out_of_date)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_red)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_red)); + } + } else { + if (item.getStatus().equals("3")) { +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.green)); + holder.tv_status.setText("已完成"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.task_top_little_blue)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_com)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_blue)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_blue)); + } else if (item.getStatus().equals("1")||item.getStatus().equals("2")) { +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.title_blue)); + holder.tv_status.setText("执行中"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.task_top_blue)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_doing)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.task_top_blue)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.task_top_blue)); + }else if (item.getStatus().equals("4")){ +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); + holder.tv_status.setText("部分巡检"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.error_yellow)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_com_part)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.task_top_blue)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.task_top_little_red)); + }else if (item.getStatus().equals("5")){ + holder.tv_status.setText("无法巡检"); + holder.tv_status.setTextColor(context.getResources().getColor(R.color.error_yellow)); + holder.tv_status.setBackground(context.getResources().getDrawable(R.drawable.bg_task_can_not)); + holder.v_left.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); + holder.v_right.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); +// holder.ll_all.setBackgroundColor(context.getResources().getColor(R.color.error_yellow)); + } + } + } + holder.tv_title.setText(item.getName()); + holder.tv_time.setText("任务时限:" + item.getStartTime().substring(5, 16) + "——" + item.getEndTime().substring(5, 16)); + holder.tv_content.setText(item.getContent()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + static class ViewHolder extends RecyclerView.ViewHolder { + View task; + LinearLayout ll_all; + TextView tv_title, tv_status, tv_time, tv_content; + View v_left,v_right; + + public ViewHolder(View itemView) { + super(itemView); + task = itemView; + ll_all = itemView.findViewById(R.id.moudle_item_pro_patrol_task_ll_all); + tv_title = itemView.findViewById(R.id.moudle_item_pro_patrol_task_tv_title); + tv_status = itemView.findViewById(R.id.moudle_item_pro_patrol_task_tv_status); + tv_time = itemView.findViewById(R.id.moudle_item_pro_patrol_task_tv_time); + tv_content = itemView.findViewById(R.id.moudle_item_pro_patrol_task_tv_content); + v_left = itemView.findViewById(R.id.moudle_item_patrol_task_left); + v_right = itemView.findViewById(R.id.moudle_item_patrol_task_right); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/ProPatrolTaskListActivity.java b/app/src/main/java/com/sipai/jspatrol/Patrol/ProPatrolTaskListActivity.java new file mode 100644 index 0000000..e843423 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/ProPatrolTaskListActivity.java @@ -0,0 +1,532 @@ +package com.sipai.jspatrol.Patrol; + +import android.Manifest; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.graphics.Color; +import android.location.LocationManager; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.provider.Settings; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.gigamole.navigationtabstrip.NavigationTabStrip; +import com.sipai.jspatrol.Bean.Biz; +import com.sipai.jspatrol.Bean.Patrol; +import com.sipai.jspatrol.Bean.PatrolLocation; +import com.sipai.jspatrol.Bean.PatrolModel; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.GuideMenuUrl; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.Webv.GuideMenuLandscapeActivity; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.ui.EmptyLayout; +import com.sipai.ui.bizPopWindow.CustomListPopupWindow; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.litepal.LitePal; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; +import q.rorbin.badgeview.QBadgeView; + +public class ProPatrolTaskListActivity extends AppCompatActivity implements View.OnClickListener, CustomListPopupWindow.ItemClickCallBack { + private TextView tv_daily,tv_tem,tv_area; + private NavigationTabStrip tab_task; + private SwipeRefreshLayout refresh_layout; + private RecyclerView rc_view; + private List daily_patrols = new ArrayList<>(); + private List daily_temp = new ArrayList<>(); + private List daily_temp_undo = new ArrayList<>(); + private ProPatrolTaskAdapter adapter; + private LinearLayoutManager manager; + private String model="0";//0为日常,1为临时 + private QBadgeView bv_task; + private EmptyLayout emptyLayout; + private String mCheckedUId=""; + private Context mContext; + private List areas = new ArrayList<>(); + CustomListPopupWindow mPopupWindow; + private CustomListPopupWindow.ItemClickCallBack mCallBack; + //巡检类型 + private String patrolType;//Product("P","生产巡检"), Equipment( "E","设备巡检"), Administrator("A","管理组"),Maintenance("M","运维组"); + private static final int GPS_REQUEST_CODE = 101; + private String[] permissions = { Manifest.permission.ACCESS_COARSE_LOCATION}; + List mPermissionList = new ArrayList<>(); + private final int mRequestCode = 100;//权限请求码 + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_pro_patrol_task_list); + mCallBack=this; + mContext=this; + init(); + initView(); + checkLocPs(); + if (!isOpenGPS()){ + openGPS(); + } + } + + @Override + protected void onResume() { + super.onResume(); + getPatrolTask(); + } + + private void checkLocPs() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + for (int i = 0; i < permissions.length; i++) { + if (ContextCompat.checkSelfPermission(this, permissions[i]) != PackageManager.PERMISSION_GRANTED) { + mPermissionList.add(permissions[i]);//添加还未授予的权限 + } + } + // 权限是否已经 授权 GRANTED---授权 DINIED---拒绝 + if (mPermissionList.size() > 0) { + // 如果没有授予该权限,就去提示用户请求 + ActivityCompat.requestPermissions(this, permissions, mRequestCode); + } + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + boolean hasPermissionDismiss = false;//有权限没有通过 + if (mRequestCode == requestCode) { + for (int i = 0; i < grantResults.length; i++) { + if (grantResults[i] == -1) { + hasPermissionDismiss = true; + } + } + if (hasPermissionDismiss) { + // 用户还是想用我的 APP 的 + // 提示用户去应用设置界面手动开启权限 + showDialogTipUserGoToAppSettting(); + } + } + } + + // 提示用户去应用设置界面手动开启权限 + + private void showDialogTipUserGoToAppSettting() { + new SweetAlertDialog(ProPatrolTaskListActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("位置信息权限不可用") + .setContentText("请在-应用设置-权限中,点击允许") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + goToAppSetting(); + } + }).show(); + } + + // 跳转到当前应用的设置界面 + private void goToAppSetting() { + Intent intent = new Intent(); + + intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getPackageName(), null); + intent.setData(uri); + + startActivityForResult(intent, 123); + } + + private void openGPS() { + new SweetAlertDialog(ProPatrolTaskListActivity.this,SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到未开启GPS定位功能,请开启,否则将无法进行巡检操作!") + .setConfirmText("开启") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + startActivityForResult(intent,GPS_REQUEST_CODE); + } + }).setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + finish(); + } + }).show(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); +// if (requestCode == GPS_REQUEST_CODE){ + checkLocPs(); + if (!isOpenGPS()){ + openGPS(); + } +// } + } + + private Boolean isOpenGPS() { + LocationManager locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE); + boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + boolean net = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + if (gps||net){ + return true; + } + return false; + } + + + /** + * 初始化 + */ + private String mServer; + private String mUserid; + private String mBizid; + private String mUsername; + private String mPassword; + private String mCaption; + private String mGroup; + private String role; + private String mGroup_com; + private String mGroup_equ; + private String mGroup_sludge; + private String mAreaId = ""; + private String mAreaName = ""; + private String st_area; + private String token; + public void init(){ +// List locations = LitePal.findAll(PatrolLocation.class); + SharedPreferences sharedPre=getSharedPreferences("config", MODE_PRIVATE); + mServer=sharedPre.getString("server", ""); + mUsername=sharedPre.getString("username", ""); + mPassword=sharedPre.getString("password", ""); + mUserid=sharedPre.getString("userid", ""); + mCaption=sharedPre.getString("caption", ""); + mBizid=sharedPre.getString("bizid", ""); + mGroup=sharedPre.getString("group", ""); + mAreaId = sharedPre.getString("areaid",""); + mAreaName = sharedPre.getString("areaname",""); + st_area = sharedPre.getString("arealist",""); + patrolType = sharedPre.getString("patrolTypeId",""); + token = sharedPre.getString("token",""); + areas = parseAreas(st_area); + } + + private List parseAreas(String response) { + List listres = new ArrayList(); + try{ + JSONObject jsonObject = new JSONObject(response); + JSONArray aNews = new JSONArray(jsonObject.optString("rows")); + if(aNews!=null && aNews.length()>0){ + for(int i=0;i getDailyPatrols(String response) { + daily_temp = new ArrayList<>(); + daily_temp_undo = new ArrayList<>(); + List list = new ArrayList<>(); + List list_done = new ArrayList<>(); + List list_undo = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + JSONArray arry = new JSONArray(jsonObject.optString("content1")); + for (int i=0;i measuringpoints; + private String type; + private List patrolContentsRecords; + private List patrolMeasurePointRecords; + private ProPatrolPoint proPatrolPoint; + private String finishDt; + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getEquipmentId() { + return equipmentId; + } + + public void setEquipmentId(String equipmentId) { + this.equipmentId = equipmentId; + } + + public String getEquipmentName() { + return equipmentName; + } + + public void setEquipmentName(String equipmentName) { + this.equipmentName = equipmentName; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPatrolPointId() { + return patrolPointId; + } + + public void setPatrolPointId(String patrolPointId) { + this.patrolPointId = patrolPointId; + } + + public String getPatrolRecordId() { + return patrolRecordId; + } + + public void setPatrolRecordId(String patrolRecordId) { + this.patrolRecordId = patrolRecordId; + } + + public String getManufacturers() { + return manufacturers; + } + + public void setManufacturers(String manufacturers) { + this.manufacturers = manufacturers; + } + + public String getEquipmentCardId() { + return equipmentCardId; + } + + public void setEquipmentCardId(String equipmentCardId) { + this.equipmentCardId = equipmentCardId; + } + + public List getMeasuringpoints() { + return measuringpoints; + } + + public void setMeasuringpoints(List measuringpoints) { + this.measuringpoints = measuringpoints; + } + + public String getFinishDt() { + return finishDt; + } + + public void setFinishDt(String finishDt) { + this.finishDt = finishDt; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getPatrolContentsRecords() { + return LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",patrolPointId,patrolRecordId,equipmentId).find(PatrolPointContent.class); + } + + public void setPatrolContentsRecords(List patrolContentsRecords) { + this.patrolContentsRecords = patrolContentsRecords; + } + + public List getPatrolMeasurePointRecords() { + return LitePal.where("patrolPointId = ? and patrolRecordId = ? and equipmentId = ?",patrolPointId,patrolRecordId,equipmentId).find(InputPoint.class); + } + + public void setPatrolMeasurePointRecords(List patrolMeasurePointRecords) { + this.patrolMeasurePointRecords = patrolMeasurePointRecords; + } + + public ProPatrolPoint getProPatrolPoint() { + return proPatrolPoint; + } + + public void setProPatrolPoint(ProPatrolPoint proPatrolPoint) { + this.proPatrolPoint = proPatrolPoint; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoEquAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoEquAdapter.java new file mode 100644 index 0000000..f73de54 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoEquAdapter.java @@ -0,0 +1,125 @@ +package com.sipai.jspatrol.Patrol.patrolInfoAdapter; + +import android.content.Context; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.core.content.res.ResourcesCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Patrol.PatrolEquDetailActivity; +import com.sipai.jspatrol.R; + +import java.util.List; + +/** + * created by lvliming on 2019/6/17 + */ +public class PatrolInfoEquAdapter extends RecyclerView.Adapter { + private List list; + private Context context; +// private DoubleManager keyDoubleManager = null; + + public PatrolInfoEquAdapter(List list, Context context) { + this.list = list; + this.context = context; + } + + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_patrol_info_equ,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.ll_item.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + PatrolEqu infoBean = list.get(position); + if (infoBean.getMeasuringpoints()!=null&&infoBean.getMeasuringpoints().size()>0) { + if (viewHolder.rc_list.getVisibility() == View.VISIBLE) { + viewHolder.rc_list.setVisibility(View.GONE); + } else if (viewHolder.rc_list.getVisibility() == View.GONE) { + viewHolder.rc_list.setVisibility(View.VISIBLE); + } + }else { + Toast.makeText(context, "该设备下暂未配置测量点", Toast.LENGTH_SHORT).show(); + } + } + }); + viewHolder.ll_item.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + int position = viewHolder.getAdapterPosition(); + PatrolEqu infoBean = list.get(position); + PatrolEquDetailActivity.actionStart(context, infoBean.getEquipmentId(), infoBean.getPatrolPointId(), infoBean.getPatrolRecordId(),infoBean.getType()); + return false; + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + PatrolEqu item = list.get(position); + holder.tv_title.setText(item.getEquipmentName()); + if (item.getManufacturers()!=null&&!item.getManufacturers().isEmpty()) { + holder.tv_equipmentmanufacturer.setText(item.getManufacturers()); + } + holder.tv_cardId.setText("设备号:"+item.getEquipmentCardId()); + if (item.getMeasuringpoints()!=null&&item.getMeasuringpoints().size()>0){ + PatrolInfoEquMeasurePointAdapter measurePointsAdapter = new PatrolInfoEquMeasurePointAdapter(item.getMeasuringpoints()); + holder.rc_list.setLayoutManager(new LinearLayoutManager(context)); + holder.rc_list.setAdapter(measurePointsAdapter); + holder.tv_count.setText(String.valueOf(item.getMeasuringpoints().size())); + }else { + holder.tv_count.setText("0"); + } + if (item.getStatus().equals("3")){ + holder.tv_title.setTextColor(context.getResources().getColor(R.color.white)); + holder.tv_equipmentmanufacturer.setTextColor(context.getResources().getColor(R.color.white)); + holder.tv_cardId.setTextColor(context.getResources().getColor(R.color.white)); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + holder.ll_all.setBackground(context.getDrawable(R.drawable.bg_layout_shape_com)); + }else { + holder.ll_all.setBackground(ResourcesCompat.getDrawable(context.getResources(),R.drawable.bg_layout_shape_com,null)); + } + }else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + holder.ll_all.setBackground(context.getDrawable(R.drawable.bg_layout_shape_factory)); + }else { + holder.ll_all.setBackground(ResourcesCompat.getDrawable(context.getResources(),R.drawable.bg_layout_shape_factory,null)); + } + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + static class ViewHolder extends RecyclerView.ViewHolder{ + TextView tv_title,tv_count; + LinearLayout ll_item,ll_all; + RecyclerView rc_list; + TextView tv_equipmentmanufacturer,tv_cardId; + public ViewHolder(View itemView) { + super(itemView); + tv_count = itemView.findViewById(R.id.moudle_item_patrol_info_equ_pointcount); + tv_title = itemView.findViewById(R.id.moudle_item_patrol_info_equ_title); +// tv_majorparameter = itemView.findViewById(R.id.moudle_item_patrol_info_equ_majorparameter); +// tv_type = itemView.findViewById(R.id.moudle_item_patrol_info_equ_type); + tv_cardId = itemView.findViewById(R.id.moudle_item_patrol_info_equ_cardid); + tv_equipmentmanufacturer = itemView.findViewById(R.id.moudle_item_patrol_info_equ_equipmentmanufacturer); + ll_item = itemView.findViewById(R.id.moudle_item_patrol_info_equ_ll_title); + rc_list = itemView.findViewById(R.id.moudle_item_patrol_info_equ_rc_grid); + ll_all = itemView.findViewById(R.id.moudle_item_patrol_info_ll); + + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoEquMeasurePointAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoEquMeasurePointAdapter.java new file mode 100644 index 0000000..ac89661 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoEquMeasurePointAdapter.java @@ -0,0 +1,156 @@ +package com.sipai.jspatrol.Patrol.patrolInfoAdapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.Utils; + +import java.util.List; + +/** + * created by lvliming on 2019/6/17 + */ +public class PatrolInfoEquMeasurePointAdapter extends RecyclerView.Adapter { + private List list; + + public PatrolInfoEquMeasurePointAdapter(List list) { + this.list = list; + } + + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_patrol_point_equ_point,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.point.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int positon = viewHolder.getAdapterPosition(); +// Intent intent=new Intent(); +// intent.putExtra("planid", list.get(positon).getPlanid()); +// intent.putExtra("last_reason", list.get(positon).getName().toString()+"当前值为:"+list.get(positon).getCvalue().toString()); +// intent.putExtra("equid",list.get(positon).getEquId()); +// intent.setClass(v.getContext(), EquFault_TZActivity.class); +// v.getContext().startActivity(intent); + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Measuringpoint item = list.get(position); + holder.name.setText(item.getName()); + if (item.getName().contains("运行")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().contains("故障")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().contains("功率")||item.getName().toLowerCase().contains("p")&&!item.getName().toLowerCase().contains("ph")&&!item.getName().toLowerCase().contains("tp")&&!item.getName().toLowerCase().contains("输出")){ + holder.iv_logo.setImageResource(R.mipmap.iv_p); + } + else if (item.getName().toLowerCase().contains("ph")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ph); + } + else if (item.getName().contains("氨氮")){ + holder.iv_logo.setImageResource(R.mipmap.iv_nh3); + } + else if (item.getName().contains("温度")){ + holder.iv_logo.setImageResource(R.mipmap.iv_temp_r); + } + else if (item.getName().toLowerCase().contains("cod")){ + holder.iv_logo.setImageResource(R.mipmap.iv_cod); + } + else if (item.getName().contains("流量")){ + holder.iv_logo.setImageResource(R.mipmap.iv_waterflow); + } + else if (item.getName().contains("风量")){ + holder.iv_logo.setImageResource(R.mipmap.iv_airflow); + } + else if (item.getName().contains("电")||item.getName().toLowerCase().contains("ia")||item.getName().toLowerCase().contains("uan")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ele); + } + else if (item.getName().contains("液位")){ + holder.iv_logo.setImageResource(R.mipmap.iv_waterliqu); + } + else if (item.getName().toLowerCase().contains("ss")&&!item.getName().toLowerCase().contains("mlss")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ss); + } + else if (item.getName().toLowerCase().contains("mlss")){ + holder.iv_logo.setImageResource(R.mipmap.iv_mlss); + } + else if (item.getName().toLowerCase().contains("nh3n")){ + holder.iv_logo.setImageResource(R.mipmap.iv_nh3n); + } + else if (item.getName().toLowerCase().contains("pa")||item.getName().contains("压力")){ + holder.iv_logo.setImageResource(R.mipmap.iv_pa); + } + else if (item.getName().toLowerCase().contains("hz")||item.getName().contains("频率")){ + holder.iv_logo.setImageResource(R.mipmap.iv_hz); + } + else if (item.getName().toLowerCase().contains("do1")){ + holder.iv_logo.setImageResource(R.mipmap.iv_do); + } + else if (item.getName().toLowerCase().contains("do2")){ + holder.iv_logo.setImageResource(R.mipmap.iv_do); + } + else if (item.getName().toLowerCase().contains("输出")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().toLowerCase().contains("tn")||item.getName().contains("总氮")){ + holder.iv_logo.setImageResource(R.mipmap.iv_tn); + } + else if (item.getName().toLowerCase().contains("tp")||item.getName().contains("总磷")){ + holder.iv_logo.setImageResource(R.mipmap.iv_tp); + } + else{ + holder.iv_logo.setImageResource(R.mipmap.iv_water); + } + + if (item.getUnit()!=null&&!item.getUnit().isEmpty()&&!item.getUnit().equals("null")) { + holder.value.setText(item.getCvalue() + item.getUnit()); + }else { + holder.value.setText(item.getCvalue()); + } + if (item.getType().equals("DI")){ + holder.value.setVisibility(View.GONE); + }else if (item.getType().equals("AI")){ + holder.value.setVisibility(View.VISIBLE); + } + String info = item.getName(); + if(item.getType().equals("DI")){ + int id= Utils.getlight4mp(info,item.getCvalue()); + holder.iv_btn.setVisibility(View.VISIBLE); + holder.iv_btn.setImageResource(id); + }else { + holder.iv_btn.setVisibility(View.GONE); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + View point; + TextView name,value; + ImageView iv_btn,iv_logo; + public ViewHolder(View itemView) { + super(itemView); + point = itemView; + name = (TextView) itemView.findViewById(R.id.point_name); + value = (TextView) itemView.findViewById(R.id.point_value); + iv_btn = (ImageView) itemView.findViewById(R.id.point_btn); + iv_logo = (ImageView) itemView.findViewById(R.id.moudle_measurepoint_iv); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoMeasurePointAdapter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoMeasurePointAdapter.java new file mode 100644 index 0000000..54d519c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolInfoAdapter/PatrolInfoMeasurePointAdapter.java @@ -0,0 +1,171 @@ +package com.sipai.jspatrol.Patrol.patrolInfoAdapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.Utils; + +import java.util.List; + +/** + * created by lvliming on 2019/6/17 + */ +public class PatrolInfoMeasurePointAdapter extends RecyclerView.Adapter { + private List list; + private String planid; + + public PatrolInfoMeasurePointAdapter(List list, String planid) { + this.list = list; + this.planid = planid; + } + + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_measurepoint,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.point.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int positon = viewHolder.getAdapterPosition(); +// Intent intent=new Intent(); +// intent.putExtra("planid", planid); +// intent.putExtra("info", list.get(positon).getName()+"当前值为:"+list.get(positon).getCvalue()+list.get(positon).getUnit()); +// intent.setClass(v.getContext(), EquFault_NewActivity.class); +// v.getContext().startActivity(intent); + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Measuringpoint item = list.get(position); + holder.name.setText(item.getName()); + if (item.getName().contains("运行")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().contains("故障")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().contains("功率")||item.getName().toLowerCase().contains("p")&&!item.getName().toLowerCase().contains("ph")&&!item.getName().toLowerCase().contains("tp")&&!item.getName().toLowerCase().contains("输出")){ + holder.iv_logo.setImageResource(R.mipmap.iv_p); + } + else if (item.getName().toLowerCase().contains("ph")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ph); + } + else if (item.getName().contains("氨氮")){ + holder.iv_logo.setImageResource(R.mipmap.iv_nh3); + } + else if (item.getName().contains("温度")){ + holder.iv_logo.setImageResource(R.mipmap.iv_temp_r); + } + else if (item.getName().toLowerCase().contains("cod")){ + holder.iv_logo.setImageResource(R.mipmap.iv_cod); + } + else if (item.getName().contains("流量")){ + holder.iv_logo.setImageResource(R.mipmap.iv_waterflow); + } + else if (item.getName().contains("风量")){ + holder.iv_logo.setImageResource(R.mipmap.iv_airflow); + } + else if (item.getName().contains("电")||item.getName().toLowerCase().contains("ia")||item.getName().toLowerCase().contains("uan")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ele); + } + else if (item.getName().contains("液位")){ + holder.iv_logo.setImageResource(R.mipmap.iv_waterliqu); + } + else if (item.getName().toLowerCase().contains("ss")&&!item.getName().toLowerCase().contains("mlss")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ss); + } + else if (item.getName().toLowerCase().contains("mlss")){ + holder.iv_logo.setImageResource(R.mipmap.iv_mlss); + } + else if (item.getName().toLowerCase().contains("nh3n")){ + holder.iv_logo.setImageResource(R.mipmap.iv_nh3n); + } + else if (item.getName().toLowerCase().contains("pa")||item.getName().contains("压力")){ + holder.iv_logo.setImageResource(R.mipmap.iv_pa); + } + else if (item.getName().toLowerCase().contains("hz")||item.getName().contains("频率")){ + holder.iv_logo.setImageResource(R.mipmap.iv_hz); + } + else if (item.getName().toLowerCase().contains("do1")){ + holder.iv_logo.setImageResource(R.mipmap.iv_do); + } + else if (item.getName().toLowerCase().contains("do2")){ + holder.iv_logo.setImageResource(R.mipmap.iv_do); + } + else if (item.getName().toLowerCase().contains("输出")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().toLowerCase().contains("tn")||item.getName().contains("总氮")){ + holder.iv_logo.setImageResource(R.mipmap.iv_tn); + } + else if (item.getName().toLowerCase().contains("tp")||item.getName().contains("总磷")){ + holder.iv_logo.setImageResource(R.mipmap.iv_tp); + } + else{ + holder.iv_logo.setImageResource(R.mipmap.iv_water); + } + + if (item.getUnit()!=null&&!item.getUnit().isEmpty()&&!item.getUnit().equals("null")) { + holder.value.setText(item.getCvalue() + item.getUnit()); + }else { + holder.value.setText(item.getCvalue()); + } + if (item.getAlarmmax()!=null&&!item.getAlarmmax().isEmpty()&&item.getAlarmmin()!=null&&!item.getAlarmmin().isEmpty()) { + float max = Float.parseFloat(item.getAlarmmax()); + float min = Float.parseFloat(item.getAlarmmin()); + float value = Float.parseFloat(item.getCvalue()); + if (max==min){ + holder.value.setTextColor(holder.point.getContext().getResources().getColor(R.color.gray04)); + }else { + if (value < min || value > max) { + holder.value.setTextColor(holder.point.getContext().getResources().getColor(R.color.red)); + } else { + holder.value.setTextColor(holder.point.getContext().getResources().getColor(R.color.gray04)); + } + } + } + if (item.getType().equals("DI")){ + holder.value.setVisibility(View.GONE); + }else if (item.getType().equals("AI")){ + holder.value.setVisibility(View.VISIBLE); + } + String info = item.getName(); + if(item.getType().equals("DI")){ + int id= Utils.getlight4mp(info,item.getCvalue()); + holder.iv_btn.setVisibility(View.VISIBLE); + holder.iv_btn.setImageResource(id); + }else { + holder.iv_btn.setVisibility(View.GONE); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + View point; + TextView name,value; + ImageView iv_btn,iv_logo; + public ViewHolder(View itemView) { + super(itemView); + point = itemView; + name = (TextView) itemView.findViewById(R.id.point_name); + value = (TextView) itemView.findViewById(R.id.point_value); + iv_btn = (ImageView) itemView.findViewById(R.id.point_btn); + iv_logo = (ImageView) itemView.findViewById(R.id.moudle_measurepoint_iv); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListActivity.java b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListActivity.java new file mode 100644 index 0000000..d591927 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListActivity.java @@ -0,0 +1,176 @@ +package com.sipai.jspatrol.Patrol.patrolList; + +import android.content.Intent; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.Toast; + + +import androidx.annotation.Nullable; + +import com.sipai.jspatrol.Base.ActivityCollector; +import com.sipai.jspatrol.Base.BaseView; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.SharedPreferencesData; + +import java.util.HashMap; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class PatrolListActivity extends BaseView implements View.OnClickListener { + private String mServer = ""; + private String mServerIp = ""; + private static final int SET_IP = 121; + private SharedPreferencesData sharedpre; + private String mUserid; + private String mBizid; + private String patrolType; + + private HashMap map = new HashMap<>(); + private HashMap map_base = new HashMap<>(); + + private SweetAlertDialog pDialog; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_patrol_list); + ActivityCollector.addActivity(this); + init(); + initView(); +// MainActivity.actionStart(PatrolListActivity.this); + } + + private void initView() { + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + } + + private void showMsgFinish() { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.hide(); + } + }); + } + + private void showMsgDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + initDialog("登录中..."); + pDialog.show(); + } + }); + } + + private void initDialog(String st) { + pDialog.setTitleText(st); + } + + private void init() { + sharedpre = new SharedPreferencesData(this); + map_base = sharedpre.getAll(); + mServer = map_base.get("mServer"); + mServerIp = map_base.get("mServerIp"); + + } + + @Override + protected PatrolListPresenter getPresenter() { + return new PatrolListPresenter(); + } + + @Override + public PatrolListContract.View getContract() { + return null; + } + + private void failLogin(final String reason) { + if (!PatrolListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(PatrolListActivity.this,SweetAlertDialog.ERROR_TYPE) + .setTitleText("提示") + .setContentText(reason) + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + }); + } + } + + private void showError() { + if (!PatrolListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(PatrolListActivity.this, "登录请求失败!", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onClick(View v) { + switch (v.getId()){ + + } + } + + private void showCannotNull(final EditText edt) { + if (!PatrolListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + edt.setError("不能为空"); + } + }); + } + } + + private void getPatrols() { + showMsgDialog(); + map.put("userid",mUserid); + map.put("bizid",mBizid); + map.put("type",patrolType); + p.getContract().requestData(PatrolListActivity.this,map,mServer, MethodURL.GetPatrolList_Method); + } + + + private boolean judgeString(String st, final String notice) { + if (st!=null&&!st.isEmpty()){ + return true; + }else { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(PatrolListActivity.this, notice+"不能为空", Toast.LENGTH_SHORT).show(); + } + }); + return false; + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + ActivityCollector.removeActivity(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListContract.java b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListContract.java new file mode 100644 index 0000000..6147a88 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListContract.java @@ -0,0 +1,29 @@ +package com.sipai.jspatrol.Patrol.patrolList; + +import android.content.Context; + +import com.sipai.jspatrol.Bean.BaseEntity; + +import java.util.HashMap; + +/** + * created by lvliming on 2019/9/11 + */ +public interface PatrolListContract { + + interface Model{ + void executeData(Context context, HashMap map, String server, String url) throws Exception; + } + + interface View{ + void handlerResult(T t); + } + + interface Presenter{ + //请求数据 + void requestData(Context context, HashMap map, String server, String url); + + //结果响应 + void responseResult(T t); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListModel.java b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListModel.java new file mode 100644 index 0000000..933ac60 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListModel.java @@ -0,0 +1,92 @@ +package com.sipai.jspatrol.Patrol.patrolList; + +import android.content.Context; + +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; +import com.sipai.jspatrol.Base.BaseModel; +import com.sipai.jspatrol.Bean.LoginInfo; +import com.sipai.jspatrol.Bean.User; + +import org.json.JSONException; +import org.json.JSONObject; +import java.io.IOException; +import java.util.HashMap; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.FormBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +/** + * created by lvliming on 2019/9/11 + */ +public class PatrolListModel extends BaseModel { + public PatrolListModel(PatrolListPresenter patrolListPresenter){ + super(patrolListPresenter); + } + + @Override + public PatrolListContract.Model getContract() { + return new PatrolListContract.Model() { + @Override + public void executeData(Context context,HashMap map, String server, String url) throws Exception { + CookiesManager.clearCookie(context); + OkHttpClient.Builder clientBuilder = new OkHttpClient().newBuilder(); + clientBuilder.cookieJar(new CookiesManager()); + OkHttpClient client = clientBuilder.build(); + FormBody.Builder builder = new FormBody.Builder(); + if (map!=null){ + for (String key:map.keySet()){ + builder.add(key,map.get(key)); + } + } + FormBody body = builder.build(); + Request request = new Request.Builder() + .url(server+url) + .post(body) + .build(); + client.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + LoginInfo item = new LoginInfo(); + item.setStatus(false); + item.setReason("网络请求失败,请重试!"); + p.getContract().responseResult(item); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + LoginInfo item = new LoginInfo(); + item = parseData(res); + p.getContract().responseResult(item); + } + }); + } + }; + } + + private LoginInfo parseData(String res) { + LoginInfo item = new LoginInfo(); + try { + JSONObject jsonObject = new JSONObject(res); + item.setStatus(jsonObject.optBoolean("status")); + if (jsonObject.optBoolean("status")){ + JSONObject js = new JSONObject(jsonObject.optString("res")); + User rs = new User(); + rs.setId(js.opt("id").toString()); + rs.setCaption(js.opt("caption").toString()); + rs.setName(js.opt("name").toString()); + rs.setLastlogintime(js.opt("lastlogintime").toString()); + rs.setTotaltime(js.optDouble("totaltime")); + item.setUser(rs); + }else { + item.setReason(jsonObject.optString("res")); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return item; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListPresenter.java b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListPresenter.java new file mode 100644 index 0000000..2a11100 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Patrol/patrolList/PatrolListPresenter.java @@ -0,0 +1,38 @@ +package com.sipai.jspatrol.Patrol.patrolList; + +import android.content.Context; + +import com.sipai.jspatrol.Base.BasePresenter; +import com.sipai.jspatrol.Bean.LoginInfo; + +import java.util.HashMap; + +/** + * created by lvliming on 2019/9/11 + */ +public class PatrolListPresenter extends BasePresenter { + + @Override + public PatrolListContract.Presenter getContract() { + return new PatrolListContract.Presenter(){ + @Override + public void requestData(Context context,HashMap map, String server, String url) { + try { + m.getContract().executeData(context,map,server,url); + }catch (Exception e){ + e.printStackTrace(); + } + } + + @Override + public void responseResult(LoginInfo item) { + getView().getContract().handlerResult(item); + } + }; + } + + @Override + public PatrolListModel getModel() { + return new PatrolListModel(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/PointAnalysis/EchartView.java b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/EchartView.java new file mode 100644 index 0000000..4c7a78b --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/EchartView.java @@ -0,0 +1,57 @@ +package com.sipai.jspatrol.PointAnalysis; + +import android.content.Context; +import android.util.AttributeSet; + +import com.github.abel533.echarts.json.GsonOption; +import com.tencent.smtt.sdk.WebSettings; +import com.tencent.smtt.sdk.WebView; + +public class EchartView extends WebView { + private static final String TAG = EchartView.class.getSimpleName(); + + public EchartView(Context context) { + this(context, null); + } + + public EchartView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public EchartView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + private void init() { + WebSettings webSettings = getSettings(); + webSettings.setJavaScriptEnabled(true); + webSettings.setJavaScriptCanOpenWindowsAutomatically(true); + webSettings.setSupportZoom(false); + webSettings.setDisplayZoomControls(false); + //设置自适应屏幕,两者合用 +// webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小 +// webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小 + //缩放操作 +// webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 +// webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 +// webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件 +// webSettings.setDefaultTextEncodingName("utf-8"); + loadUrl("file:///android_asset/echart.html"); + } + + /**刷新图表 + * java调用js的loadEcharts方法刷新echart + * 不能在第一时间就用此方法来显示图表,因为第一时间html的标签还未加载完成,不能获取到标签值 + * @param option + */ + public void refreshEchartsWithOption(GsonOption option) { + if (option == null) { + return; + } + String optionString = option.toString(); + String call = "javascript:loadEcharts('" + optionString + "')"; + loadUrl(call); + } +} + diff --git a/app/src/main/java/com/sipai/jspatrol/PointAnalysis/EchartsOptionUtil.java b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/EchartsOptionUtil.java new file mode 100644 index 0000000..cc54644 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/EchartsOptionUtil.java @@ -0,0 +1,156 @@ +package com.sipai.jspatrol.PointAnalysis; + +import com.github.abel533.echarts.DataZoom; +import com.github.abel533.echarts.Grid; +import com.github.abel533.echarts.Legend; +import com.github.abel533.echarts.Tooltip; +import com.github.abel533.echarts.axis.AxisLabel; +import com.github.abel533.echarts.axis.CategoryAxis; +import com.github.abel533.echarts.axis.ValueAxis; +import com.github.abel533.echarts.code.DataZoomType; +import com.github.abel533.echarts.code.Orient; +import com.github.abel533.echarts.code.Trigger; +import com.github.abel533.echarts.json.GsonOption; +import com.github.abel533.echarts.series.Line; +import com.github.abel533.echarts.series.Series; +import com.github.abel533.echarts.style.TextStyle; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class EchartsOptionUtil { + + public static GsonOption getLineChartOptions(String name,Object[] xAxis, Object[] yAxis) { + GsonOption option = new GsonOption(); + //option.title().setText(""); + //图例 + option.legend(name); + //trigger为'item'时只会显示该点的数据,为'axis'时显示该列下所有坐标轴所对应的数据 + Tooltip tooltip = new Tooltip(); + TextStyle textStyle = new TextStyle(); + textStyle.setFontSize(12); + tooltip.setTextStyle(textStyle); + tooltip.setPadding(5); + tooltip.setWidth(220); + option.setTooltip(tooltip); + option.tooltip().trigger(Trigger.axis); + //设置y轴数据 + ValueAxis valueAxis = new ValueAxis(); + option.yAxis(valueAxis); + CategoryAxis categorxAxis = new CategoryAxis(); + categorxAxis.axisLine().onZero(false); + categorxAxis.boundaryGap(true); + //设置x轴数据 + categorxAxis.data(xAxis); + option.xAxis(categorxAxis); + Grid grid = new Grid(); + grid.left(50); + option.setGrid(grid); + Line line = new Line(); + //注意!!name要和上面的图例名称一样,不然图例会不显示!! + line.smooth(false).name(name).symbol("none").data(yAxis).itemStyle().normal().lineStyle().shadowColor("rgba(0,0,0,0.4)"); + option.series(line); + List zooms = new ArrayList<>(); + DataZoom zoom = new DataZoom(); + zoom.setType(DataZoomType.slider); + zooms.add(zoom); + option.setDataZoom(zooms); + return option; + } + + public static GsonOption getLinesChartOptions(String name,String name1,Object[] xAxis, Object[] yAxis,Object[] y2Axis) { + GsonOption option = new GsonOption(); + //option.title().setText(""); + //图例 + Object[] names = new Object[2]; + names[0] = name; + names[1] = name1; + option.legend(names); + //trigger为'item'时只会显示该点的数据,为'axis'时显示该列下所有坐标轴所对应的数据 + option.tooltip().trigger(Trigger.axis); + Legend legend = new Legend(); + legend.setOrient(Orient.horizontal); + option.setLegend(legend); + //设置y轴数据 + ValueAxis valueAxis = new ValueAxis(); + option.yAxis(valueAxis); + CategoryAxis categorxAxis = new CategoryAxis(); + categorxAxis.axisLine().onZero(false); + categorxAxis.boundaryGap(true); + //设置x轴数据 + categorxAxis.data(xAxis); + option.xAxis(categorxAxis); + List seriesList = new ArrayList<>(); + Line line = new Line(); + //注意!!name要和上面的图例名称一样,不然图例会不显示!! + line.smooth(false).name(names[0].toString()).symbol("none").data(yAxis).itemStyle().normal().lineStyle().shadowColor("rgba(0,0,0,0.4)"); + Line line1 = new Line(); + line1.smooth(false).name(names[1].toString()).symbol("none").data(y2Axis).itemStyle().normal().color("#BE55F5"); + seriesList.add(line); + seriesList.add(line1); + option.series(seriesList); + List zooms = new ArrayList<>(); + DataZoom zoom = new DataZoom(); + zoom.setType(DataZoomType.slider); + zooms.add(zoom); + option.setDataZoom(zooms); + return option; + } + + public static GsonOption getListLinesChartOptions(List nameList,Object[] xAxis, List yAxisList) { + GsonOption option = new GsonOption(); + //option.title().setText(""); + //图例 + Object[] names = new Object[nameList.size()]; + for (int a=0;a seriesList = new ArrayList<>(); + Random random = new Random(); + for (int i=0;i zooms = new ArrayList<>(); + DataZoom zoom = new DataZoom(); + zoom.setType(DataZoomType.slider); + zooms.add(zoom); + option.setDataZoom(zooms); + return option; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/PointAnalysis/PointAnalysisActivity.java b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/PointAnalysisActivity.java new file mode 100644 index 0000000..4415e8e --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/PointAnalysisActivity.java @@ -0,0 +1,240 @@ +package com.sipai.jspatrol.PointAnalysis; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +import com.bigkoo.pickerview.builder.TimePickerBuilder; +import com.bigkoo.pickerview.listener.OnTimeSelectListener; +import com.bigkoo.pickerview.view.TimePickerView; +import com.sipai.jspatrol.Bean.ChartData; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.Bean.PointLongValue; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.DateFormatUtils; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.ProgressForAll; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class PointAnalysisActivity extends AppCompatActivity { + private String token; + private String mServer; + private String mBizid; + private List points = new ArrayList<>(); + private List chartDataList = new ArrayList<>(); + private List chartNames = new ArrayList<>(); + private List yAxisList = new ArrayList<>(); + private EchartView echartView; + private int total,now; + private TextView tv_sdt,tv_edt; + private TimePickerView pvTime; + private String mark = "start"; + + public static void actionStart(Context context,List list){ + Intent intent = new Intent(context,PointAnalysisActivity.class); + intent.putExtra("points", (Serializable) list); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_point_analysis); + init(); + initView(); + initTimePicker(); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("曲线绘制"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(v -> finish()); + tv_sdt = findViewById(R.id.moudle_point_analysis_tv_startdate); + tv_sdt.setText(DateFormatUtils.DateFormatMinStringPL(System.currentTimeMillis()-24*60*60*1000)); + tv_sdt.setOnClickListener(v->{ + mark = "start"; + pvTime.show(); + }); + tv_edt = findViewById(R.id.moudle_point_analysis_tv_enddate); + tv_edt.setText(DateFormatUtils.DateFormatMinStringPL(System.currentTimeMillis())); + tv_edt.setOnClickListener(v->{ + mark = "end"; + pvTime.show(); + }); + echartView = findViewById(R.id.moudle_point_analysis_ev); + analysisData(); + } + + private void analysisData() { + if (points!=null&&points.size()>0){ + ProgressForAll.showProgress(PointAnalysisActivity.this,"","数据获取中..."); + total = points.size(); + for (int i=0;i map = new HashMap<>(); + map.put("unitId", mBizid); + map.put("mpids", point.getSid()); + map.put("func", "-"); + map.put("mpname",point.getName()); + map.put("sdt", tv_sdt.getText().toString()); + map.put("edt", tv_edt.getText().toString()); + map.put("slope", ""); + OKHttpUtils.OKCall(map, mServer, MethodURL.GETPointFormatHistory_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + showToast("数据获取失败:"+e.toString()); + now+=1; + if (total==now&&chartDataList.size()>0) { + ProgressForAll.cancelProgress(); + runOnUiThread(()->refreshLineChart()); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + now+=1; + if (total==now) { + ProgressForAll.cancelProgress(); + } + if(res.contains("data")){ + ChartData chartData = parseHistory(res,point); + chartDataList.add(chartData); + if (total==now&&chartDataList.size()>0) { + runOnUiThread(()->refreshLineChart()); + } + }else{ + showToast("暂无该日数据!"); + } + } + }); + } + + private void refreshLineChart(){ + chartNames = new ArrayList<>(); + yAxisList = new ArrayList<>(); + for (int i=0;i0){ + JSONObject jsonObject = ra.getJSONObject(0); + JSONArray arrayItem = jsonObject.optJSONArray("data"); + List longValueList = new ArrayList<>(); + for (int a=0;a) getIntent().getSerializableExtra("points"); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sipai/jspatrol/PointAnalysis/SelPointListActivity.java b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/SelPointListActivity.java new file mode 100644 index 0000000..aaf9d96 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/SelPointListActivity.java @@ -0,0 +1,559 @@ +package com.sipai.jspatrol.PointAnalysis; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.Message; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.scwang.smart.refresh.footer.ClassicsFooter; +import com.scwang.smart.refresh.header.ClassicsHeader; +import com.scwang.smart.refresh.layout.SmartRefreshLayout; +import com.scwang.smart.refresh.layout.api.RefreshLayout; +import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener; +import com.scwang.smart.refresh.layout.listener.OnRefreshListener; +import com.sipai.jspatrol.Bean.Area; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.ProgressForAll; +import com.sipai.jspatrol.utils.Utils; +import com.sipai.ui.EmptyLayout; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class SelPointListActivity extends AppCompatActivity { + private String mServer,token; + private String mBizid,mUserid; + private ImageView iv_back; + private EditText edt_search; + private TextView tv_search,tv_compare; + private String name = ""; + private String sourceType = ""; + private int page = 1; + private int rows = 20; + private int total = 0; + private String[] source = {"全部","外部导入点","KPI计算点","手动测量点","自动转发测量点"}; + private LinearLayout ll_source; + private Spinner sp_source; + private ArrayAdapter sourceadapter; + private List points = new ArrayList<>(); + private List seledPoints = new ArrayList<>(); + private SmartRefreshLayout refreshLayout; + private RecyclerView rc,rc_seled_point; + private LinearLayoutManager manager,seled_manager; + private MPointsAdapter pointsAdapter; + private SeledAdapter seledAdapter; + private EmptyLayout emptyLayout; + private ArrayAdapter areaadapter; + private List areas = new ArrayList<>(); + private List areaname = new ArrayList<>(); + private int area_locate = 0;//标记所选工艺段的下标 + private String area_id = ""; + private static final int AREAS = 1; + + @SuppressLint("MissingInflatedId") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sel_point_list); + init(); + initView(); + } + + private void initView() { + iv_back = findViewById(R.id.moudle_sel_point_iv_back); + iv_back.setOnClickListener(v -> { + finish(); + }); + edt_search = findViewById(R.id.moudle_sel_point_edt_pointname); + tv_search = findViewById(R.id.moudle_sel_point_tv_search); + tv_search.setOnClickListener(v -> { + page=1; + searchPoint(); + }); + tv_compare = findViewById(R.id.moudle_sel_point_tv_compare); + tv_compare.setOnClickListener(v -> { + PointAnalysisActivity.actionStart(SelPointListActivity.this,seledPoints); + }); + emptyLayout = findViewById(R.id.moudle_sel_point_ui_empty); + sp_source = findViewById(R.id.moudle_sel_point_sp_source); + sourceadapter = new ArrayAdapter(SelPointListActivity.this,R.layout.item_down,R.id.tv_down_sp,areaname); + sp_source.setAdapter(areaadapter); + sp_source.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { +// Toast.makeText(ProductionMonitorActivity.this, ""+areaname.get(position), Toast.LENGTH_SHORT).show(); + if (areaname.get(position).equals("无")||areas.size()<1) { + searchPoint(); + }else { + area_id = areas.get(position).getId(); + area_locate = position; + page=1; + searchPoint(); + } + } + + @Override + public void onNothingSelected(AdapterView parent) { +// Toast.makeText(ProductionMonitorActivity.this, ""+areaname.get(0), Toast.LENGTH_SHORT).show(); +// area_id = areas.get(0).getCode(); +// getAllPoints(); + } + }); + refreshLayout = findViewById(R.id.moudle_sel_point_refresh); + refreshLayout.setRefreshHeader(new ClassicsHeader(this)); + refreshLayout.setRefreshFooter(new ClassicsFooter(this)); + refreshLayout.setOnRefreshListener(new OnRefreshListener() { + @Override + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + page=1; + searchPoint(); + } + }); + refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() { + @Override + public void onLoadMore(@NonNull RefreshLayout refreshLayout) { + page = page+1; + searchPoint(); + } + }); + rc_seled_point = findViewById(R.id.moudle_sel_point_rc_seled_point); + rc = findViewById(R.id.moudle_sel_point_list_rc); + manager = new LinearLayoutManager(this); + rc.setLayoutManager(manager); + pointsAdapter = new MPointsAdapter(points); + rc.setAdapter(pointsAdapter); + } + + @Override + protected void onResume() { + super.onResume(); + getarea(); + } + + private void getarea() { + HashMap map = new HashMap<>(); + map.put("page","1"); + map.put("rows","500"); + map.put("search_code",mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GETPSLISt_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + String a = e.toString(); + if (!SelPointListActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(SelPointListActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("工艺段数据获取失败请重试!") + .setConfirmText("确认") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + getarea(); + } + }).show(); + } + }); + } + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + Log.i("areaname", "onSuccess: "+response); + areaname.clear(); + areas = getAreaData(res); + if (areas!=null&&!areas.isEmpty()){ + for (int i=0;i(SelPointListActivity.this, R.layout.item_down, R.id.tv_down_sp, areaname); + sp_source.setAdapter(areaadapter); + sp_source.setSelection(area_locate); + } + }); + } + }); + } + + private List getAreaData(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + + JSONArray aNews = new JSONArray(jsonObject.getString("rows")); + if (aNews != null && aNews.length() > 0) { + for (int i = 0; i map = new HashMap<>(); + map.put("bizid",mBizid);//厂id + map.put("processSectionCode", area_id);//工艺段 + map.put("isCollected","1"); + map.put("page",String.valueOf(page)); + map.put("userId",mUserid); + map.put("search_name",name); + map.put("rows","50"); + map.put("type", "");//类型 + OKHttpUtils.OKCall(map, mServer, MethodURL.GetAllCollectePoint_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + hidePg(); + noMore(false); + showToast("请求失败!"); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("content1")) { + hidePg(); + if (page==1) { + points = getAreaPoints(res); + updateList(); + }else { + List pList = getAreaPoints(res); + if (total>=(points.size()+pList.size())) { + points.addAll(pList); + updateList(); + }else { + noMore(true); + } + } + }else { + hidePg(); + } + } + }); + } + + private void updateList() { + if (!SelPointListActivity.this.isFinishing()){ + runOnUiThread(()->{ + if (page==1){ + if (points!=null&&points.size()>0){ + emptyLayout.setVisibility(View.GONE); + rc.setVisibility(View.VISIBLE); + refreshLayout.finishRefresh(true); + manager = new LinearLayoutManager(this); + rc.setLayoutManager(manager); + pointsAdapter = new MPointsAdapter(points); + rc.setAdapter(pointsAdapter); + }else { + refreshLayout.finishRefresh(false); + emptyLayout.setVisibility(View.VISIBLE); + rc.setVisibility(View.GONE); + } + }else { + refreshLayout.finishLoadMore(true); + pointsAdapter.notifyDataSetChanged(); + } + }); + } + } + + private List getAreaPoints(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + + JSONArray aNews = new JSONArray(jsonObject.getString("content1")); + if (aNews != null && aNews.length() > 0) { + for (int i = 0; i { + if (page==1) { + refreshLayout.finishRefresh(suc); + }else { + refreshLayout.finishLoadMore(suc); + } + }); + } + } + + private void showToast(String s) { + if (!SelPointListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(SelPointListActivity.this, s, Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void hidePg() { + if (!SelPointListActivity.this.isFinishing()){ + runOnUiThread(()->{ + ProgressForAll.cancelProgress(); + }); + } + } + + private void init(){ + SharedPreferences sharedPre = this.getSharedPreferences("config", 0); + mServer = sharedPre.getString("server", ""); + mBizid = sharedPre.getString("bizid", ""); + mUserid = sharedPre.getString("userid",""); + } + + class MPointsAdapter extends RecyclerView.Adapter { + private List list; + + public MPointsAdapter(List list) { + this.list = list; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_measurepoint,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + return viewHolder; + } + + public void setData(List list){ + this.list = list; + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + Measuringpoint item = list.get(position); + holder.name.setText(item.getName()); + holder.name.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (seledPoints!=null&&!seledPoints.contains(item)) { + seledPoints.add(item); + if (seledPoints.size()==1){ + rc_seled_point.setVisibility(View.VISIBLE); + seled_manager = new LinearLayoutManager(SelPointListActivity.this); + seled_manager.setOrientation(RecyclerView.HORIZONTAL); + rc_seled_point.setLayoutManager(seled_manager); + seledAdapter = new SeledAdapter(SelPointListActivity.this, seledPoints, new SeledAdapter.onRecyclerViewItemClick() { + @Override + public void onItemClick(View v, int position) { + seledPoints.remove(position); + if (seledPoints.size()>0) { + seledAdapter.notifyDataSetChanged(); + }else { + seledAdapter.notifyDataSetChanged(); + rc_seled_point.setVisibility(View.GONE); + } + } + }); + rc_seled_point.setAdapter(seledAdapter); + }else { + seledAdapter.notifyDataSetChanged(); + } + }else { + showToast("该点已在队列中!"); + } + } + }); + holder.iv_logo.setImageResource(Utils.getpointPic(item.getName())); + + if (item.getUnit()!=null&&!item.getUnit().isEmpty()&&!item.getUnit().equals("null")) { + holder.value.setText(item.getCvalue() + item.getUnit()); + }else if (item.getValuemeaning()==null||item.getValuemeaning().isEmpty()){ + holder.value.setText(item.getCvalue()); + }else { + String[] types = new String[]{}; + types = holder.itemView.getContext().getResources().getStringArray(Utils.getValueArray(item.getValuemeaning())); + if (types.length>0) { + holder.value.setText(types[Integer.parseInt(item.getCvalue())]); + }else { + holder.value.setText(item.getCvalue() + item.getUnit()); + } + } + if (item.getAlarmmax()!=null&&!item.getAlarmmax().equals("null")&&!item.getAlarmmax().isEmpty()&&item.getAlarmmin()!=null&&!item.getAlarmmin().equals("null")&&!item.getAlarmmin().isEmpty()) { + float max = Float.parseFloat(item.getAlarmmax()); + float min = Float.parseFloat(item.getAlarmmin()); + float value = Float.parseFloat(item.getCvalue()); + if (max==min){ + holder.value.setTextColor(holder.point.getContext().getResources().getColor(R.color.gray04)); + }else { + if (value <= min || value >= max) { + holder.value.setTextColor(holder.point.getContext().getResources().getColor(R.color.red)); + } else { + holder.value.setTextColor(holder.point.getContext().getResources().getColor(R.color.gray04)); + } + } + } + if (item.getType().equals("DI")){ + holder.value.setVisibility(View.GONE); + }else if (item.getType().equals("AI")){ + holder.value.setVisibility(View.VISIBLE); + } + String info = item.getName(); + if(item.getType().equals("DI")){ + int id= Utils.getlight4mp(info,item.getCvalue()); + holder.iv_btn.setVisibility(View.VISIBLE); + holder.iv_btn.setImageResource(id); + }else { + holder.iv_btn.setVisibility(View.GONE); + } + + + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + View point; + TextView name,value; + ImageView iv_btn,iv_logo; + public ViewHolder(View itemView) { + super(itemView); + point = itemView; + name = itemView.findViewById(R.id.point_name); + value = itemView.findViewById(R.id.point_value); + iv_btn = itemView.findViewById(R.id.point_btn); + iv_logo = itemView.findViewById(R.id.moudle_measurepoint_iv); + } + } + } + + static class SeledAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + private onRecyclerViewItemClick mOnRcClick; + + public SeledAdapter(Context context, List list, onRecyclerViewItemClick mOnRcClick) { + this.context = context; + this.list = list; + this.mOnRcClick = mOnRcClick; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_seled_nodes,parent,false); + ViewHolder viewHolder = new ViewHolder(view); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Measuringpoint item = list.get(position); + holder.tv_name.setText(item.getName()); + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + ImageView iv_cross; + TextView tv_name; + public ViewHolder(@NonNull View itemView) { + super(itemView); + iv_cross = itemView.findViewById(R.id.moudle_item_seled_nodes_iv_cross); + iv_cross.setOnClickListener(this); + tv_name = itemView.findViewById(R.id.moudle_item_seled_nodes_tv_name); + } + + @Override + public void onClick(View v) { + if (mOnRcClick!=null){ + mOnRcClick.onItemClick(v,getAdapterPosition()); + } + } + } + + public interface onRecyclerViewItemClick{ + void onItemClick(View v,int position); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sipai/jspatrol/PointAnalysis/SolutionListActivity.java b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/SolutionListActivity.java new file mode 100644 index 0000000..aa40cdf --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/PointAnalysis/SolutionListActivity.java @@ -0,0 +1,280 @@ +package com.sipai.jspatrol.PointAnalysis; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.Bean.Nodes; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.Statement.StatementListActivity; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.ui.EmptyLayout; + +import org.json.JSONArray; +import org.json.JSONException; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class SolutionListActivity extends AppCompatActivity { + private String mServer; + private String mBizid; + private List nodes = new ArrayList<>(); + private SwipeRefreshLayout refresh; + private RecyclerView rc_view; + private EmptyLayout emptyLayout; + private NodesAdapter nodesAdapter; + private LinearLayoutManager manager; + private List seledPoints = new ArrayList<>(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_statement_type); + init(); + initView(); + getSolutionList(); + } + + @Override + protected void onResume() { + super.onResume(); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("曲线方案"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + emptyLayout = findViewById(R.id.moudle_statement_type_ui_empty); + refresh = findViewById(R.id.moudle_statement_type_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getSolutionList(); + } + }); + rc_view = findViewById(R.id.moudle_statement_type_rc); + manager = new LinearLayoutManager(SolutionListActivity.this); + rc_view.setLayoutManager(manager); + } + + private void getSolutionList() { + HashMap map = new HashMap<>(); + map.put("unitId", mBizid); + map.put("search_name",""); + OKHttpUtils.OKCall(map, mServer, MethodURL.getSolutionList_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorResponse(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("nodes")&&res.contains("id")){ + nodes = parseNodes(res); + updateList(); + }else { + showEmpty(); + } + } + }); + } + + private void updateList() { + if (!SolutionListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + manager = new LinearLayoutManager(SolutionListActivity.this); + rc_view.setLayoutManager(manager); + nodesAdapter = new NodesAdapter(SolutionListActivity.this,nodes); + rc_view.setAdapter(nodesAdapter); + } + }); + } + } + + private List parseNodes(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i=0;i areas = new ArrayList<>(); + if (!array.getJSONObject(i).optString("nodes").isEmpty()&&!array.getJSONObject(i).optString("nodes").equals("null")) { + areas = parseNodes(array.getJSONObject(i).optString("nodes")); + } + item.setNodes(areas); + list.add(item); + } + } catch (JSONException e) { + e.printStackTrace(); + return list; + } + return list; + } + + private void showEmpty() { + if (!SolutionListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + rc_view.setVisibility(View.GONE); + emptyLayout.setVisibility(View.VISIBLE); + } + }); + } + } + + private void errorResponse() { + if (!SolutionListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + Toast.makeText(SolutionListActivity.this, "列表获取失败!", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void init() { + SharedPreferences sharedPre=this.getSharedPreferences("config", 0); + mServer=sharedPre.getString("server", ""); + mBizid=sharedPre.getString("bizid", ""); + } + + class NodesAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + + public NodesAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_nodes,parent,false); + ViewHolder viewHolder = new ViewHolder(view); + viewHolder.iv_arrow.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + Nodes item = list.get(position); + if (item.getNodes()!=null&&item.getNodes().size()>0){ + if (viewHolder.rc.getVisibility()==View.GONE) { + viewHolder.rc.setVisibility(View.VISIBLE); + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_down); + }else { + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_right); + viewHolder.rc.setVisibility(View.GONE); + } + } + } + }); + viewHolder.tv_title.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + seledPoints = new ArrayList<>(); + Nodes item = list.get(position); + if (item.getType().equals("4")||item.getType().equals("6")) { + if (item.getNodes() != null && item.getNodes().size() > 0) { + for (int i = 0; i < item.getNodes().size();i++){ + Measuringpoint measuringpoint = new Measuringpoint(); + measuringpoint.setSid(item.getNodes().get(i).getMpid()); + measuringpoint.setName(item.getNodes().get(i).getText()); + seledPoints.add(measuringpoint); + } + PointAnalysisActivity.actionStart(SolutionListActivity.this, seledPoints); + } else { + Measuringpoint point = new Measuringpoint(); + point.setSid(item.getMpid()); + point.setName(item.getText()); + seledPoints.add(point); + PointAnalysisActivity.actionStart(SolutionListActivity.this, seledPoints); + } + }else { + if (item.getNodes()!=null&&item.getNodes().size()>0){ + if (viewHolder.rc.getVisibility()==View.GONE) { + viewHolder.rc.setVisibility(View.VISIBLE); + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_down); + }else { + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_right); + viewHolder.rc.setVisibility(View.GONE); + } + } + } + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Nodes item = list.get(position); + holder.tv_title.setText(item.getText()); + if (item.getNodes()!=null&&item.getNodes().size()>0){ + holder.rc.setLayoutManager(new LinearLayoutManager(context)); + NodesAdapter nodesAdapter = new NodesAdapter(context,item.getNodes()); + holder.rc.setAdapter(nodesAdapter); + }else { + holder.rc.setVisibility(View.GONE); + holder.iv_arrow.setImageResource(R.mipmap.moudle_bizpop_biz); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + ImageView iv_arrow; + TextView tv_title; + RecyclerView rc; + public ViewHolder(@NonNull View itemView) { + super(itemView); + iv_arrow = itemView.findViewById(R.id.iv_arrow); + tv_title = itemView.findViewById(R.id.tv_title); + rc = itemView.findViewById(R.id.rc_children); + } + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sipai/jspatrol/ProMonitoring/MeasurePointsAdapter.java b/app/src/main/java/com/sipai/jspatrol/ProMonitoring/MeasurePointsAdapter.java new file mode 100644 index 0000000..d259d5c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/ProMonitoring/MeasurePointsAdapter.java @@ -0,0 +1,239 @@ +package com.sipai.jspatrol.ProMonitoring; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.Intent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.haozhang.lib.SlantedTextView; +import com.mcxtzhang.swipemenulib.SwipeMenuLayout; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.Utils; + +import java.util.List; + +/** + * Created by lvliming on 2017/10/24. + */ + +public class MeasurePointsAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + private onSwipeListener mOnSwipeListener; + + public MeasurePointsAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_measurepoint,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + return viewHolder; + } + + public void setData(List list){ + this.list = list; + } + + @SuppressLint({"RecyclerView", "ResourceAsColor"}) + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Measuringpoint item = list.get(position); + Measuringpoint finalItem = item; + holder.ll_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent=new Intent(view.getContext(), PointHistoryActivity.class); + intent.putExtra("point", finalItem); +// intent.putExtra("pointid", finalItem.getSid()); +// intent.putExtra("unitId", finalItem.getUnitId()); +// intent.putExtra("max", finalItem.getAlarmmax()); +// intent.putExtra("min", finalItem.getAlarmmin()); + view.getContext().startActivity(intent); + } + }); + holder.ll_all.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + String ss = "aaa"; + return false; + } + }); + item = list.get(position); + ((SwipeMenuLayout)holder.view).setIos(false).setLeftSwipe(true); + holder.tv_point_name.setText(item.getName()); + if (item.getName().contains("运行")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().contains("故障")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else if (item.getName().contains("功率")||item.getName().toLowerCase().contains("p")&&!item.getName().toLowerCase().contains("ph")&&!item.getName().toLowerCase().contains("tp")){ + holder.iv_logo.setImageResource(R.mipmap.iv_p); + } + else if (item.getName().toLowerCase().contains("ph")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ph); + } + else if (item.getName().contains("氨氮")){ + holder.iv_logo.setImageResource(R.mipmap.iv_nh3); + } + else if (item.getName().contains("温度")){ + holder.iv_logo.setImageResource(R.mipmap.iv_temp_r); + } + else if (item.getName().toLowerCase().contains("cod")){ + holder.iv_logo.setImageResource(R.mipmap.iv_cod); + } + else if (item.getName().contains("流量")){ + holder.iv_logo.setImageResource(R.mipmap.iv_waterflow); + } + else if (item.getName().contains("风量")){ + holder.iv_logo.setImageResource(R.mipmap.iv_airflow); + } + else if (item.getName().contains("电")||item.getName().toLowerCase().contains("ia")||item.getName().toLowerCase().contains("uan")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ele); + } + else if (item.getName().contains("液位")){ + holder.iv_logo.setImageResource(R.mipmap.iv_waterliqu); + } + else if (item.getName().toLowerCase().contains("ss")&&!item.getName().toLowerCase().contains("mlss")){ + holder.iv_logo.setImageResource(R.mipmap.iv_ss); + } + else if (item.getName().toLowerCase().contains("mlss")){ + holder.iv_logo.setImageResource(R.mipmap.iv_mlss); + } + else if (item.getName().toLowerCase().contains("nh3n")){ + holder.iv_logo.setImageResource(R.mipmap.iv_nh3n); + } + else if (item.getName().toLowerCase().contains("pa")||item.getName().contains("压力")){ + holder.iv_logo.setImageResource(R.mipmap.iv_pa); + } + else if (item.getName().toLowerCase().contains("hz")||item.getName().contains("频率")){ + holder.iv_logo.setImageResource(R.mipmap.iv_hz); + } + else if (item.getName().toLowerCase().contains("do1")){ + holder.iv_logo.setImageResource(R.mipmap.iv_do); + } + else if (item.getName().toLowerCase().contains("do2")){ + holder.iv_logo.setImageResource(R.mipmap.iv_do); + } + else if (item.getName().toLowerCase().contains("tn")||item.getName().contains("总氮")){ + holder.iv_logo.setImageResource(R.mipmap.iv_tn); + } + else if (item.getName().toLowerCase().contains("tp")||item.getName().contains("总磷")){ + holder.iv_logo.setImageResource(R.mipmap.iv_tp); + } + else if (item.getName().contains("维护")||item.getName().contains("维修")||item.getName().contains("过载")||item.getName().contains("超时")||item.getName().contains("信号")||item.getName().contains("到位")||item.getName().contains("力矩")||item.getName().contains("报警")||item.getName().contains("次数")){ + holder.iv_logo.setImageResource(R.mipmap.iv_eqp); + } + else{ + holder.iv_logo.setImageResource(R.mipmap.iv_water); + } + + + if (item.getValuemeaning()==null||item.getValuemeaning().isEmpty()){ + if (item.getUnit()!=null&&!item.getUnit().isEmpty()&&!item.getUnit().equals("null")) { + holder.tv_value.setText(item.getCvalue()+item.getUnit()); + }else { + holder.tv_value.setText(item.getCvalue()); + } + } + if (item.getAlarmmax()!=null&&!item.getAlarmmax().isEmpty()&&item.getAlarmmin()!=null&&!item.getAlarmmin().isEmpty()) { + float max = Float.parseFloat(item.getAlarmmax()); + float min = Float.parseFloat(item.getAlarmmin()); + float value = Float.parseFloat(item.getCvalue()); + if (max==min){ + holder.tv_value.setTextColor(R.color.gray04); + }else { + if (value <= min || value >= max) { + holder.tv_value.setTextColor(R.color.red); + } else { + holder.tv_value.setTextColor(R.color.gray04); + } + } + } + if (item.getType().equals("DI")){ + holder.tv_value.setVisibility(View.GONE); + }else if (item.getType().equals("AI")){ + holder.tv_value.setVisibility(View.VISIBLE); + } + String info = item.getName(); + if(item.getType().equals("DI")){ + int id= Utils.getlight4mp(info,item.getCvalue()); + holder.iv_value.setVisibility(View.VISIBLE); + holder.iv_value.setImageResource(id); + }else { + holder.iv_value.setVisibility(View.GONE); + } + if (item.getUserid()!=null) { + holder.btn_collecte.setVisibility(View.VISIBLE); + if (!item.getUserid().isEmpty() && !item.getUserid().equals("null")) { + holder.stv.setVisibility(View.VISIBLE); + holder.btn_collecte.setText("取消收藏"); + holder.btn_collecte.setBackgroundResource(R.drawable.btn_error_press); + } else { + holder.stv.setVisibility(View.GONE); + holder.btn_collecte.setText("收藏"); + holder.btn_collecte.setBackgroundResource(R.drawable.btn_press); + } + }else { + holder.stv.setVisibility(View.GONE); + holder.btn_collecte.setVisibility(View.GONE); + } + holder.btn_collecte.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (null!=mOnSwipeListener){ + mOnSwipeListener.onCollecte(position); + ((SwipeMenuLayout) holder.itemView).smoothClose(); + } + } + }); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public interface onSwipeListener{ + void onCollecte(int pos); + } + + public void setOnCollecteListener(onSwipeListener mOnCollecteListener) { + this.mOnSwipeListener = mOnCollecteListener; + } + + public class ViewHolder extends RecyclerView.ViewHolder{ + View view; + LinearLayout ll_all; + TextView tv_point_name,tv_value; + ImageView iv_logo,iv_value; + Button btn_collecte; + SlantedTextView stv; + public ViewHolder(@NonNull View itemView) { + super(itemView); + view = itemView; + ll_all = view.findViewById(R.id.moudle_point_ll_all); + tv_point_name = view.findViewById(R.id.point_name); + tv_value = view.findViewById(R.id.point_value); + iv_logo = view.findViewById(R.id.moudle_measurepoint_iv); + iv_value = view.findViewById(R.id.point_btn); + btn_collecte = view.findViewById(R.id.moudle_item_btn_collecte); + stv = view.findViewById(R.id.moudle_measurepoint_st); + } + } +} + diff --git a/app/src/main/java/com/sipai/jspatrol/ProMonitoring/PointHistoryActivity.java b/app/src/main/java/com/sipai/jspatrol/ProMonitoring/PointHistoryActivity.java new file mode 100644 index 0000000..172f9d9 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/ProMonitoring/PointHistoryActivity.java @@ -0,0 +1,672 @@ +package com.sipai.jspatrol.ProMonitoring; + +import android.app.DatePickerDialog; +import android.app.TimePickerDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnTouchListener; +import android.widget.Button; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.TimePicker; +import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; + +import com.bigkoo.pickerview.builder.TimePickerBuilder; +import com.bigkoo.pickerview.listener.OnTimeSelectListener; +import com.bigkoo.pickerview.view.TimePickerView; +import com.github.mikephil.charting.charts.LineChart; +import com.github.mikephil.charting.components.AxisBase; +import com.github.mikephil.charting.components.Description; +import com.github.mikephil.charting.components.XAxis; +import com.github.mikephil.charting.components.YAxis; +import com.github.mikephil.charting.data.Entry; +import com.github.mikephil.charting.data.LineData; +import com.github.mikephil.charting.data.LineDataSet; +import com.github.mikephil.charting.formatter.IAxisValueFormatter; +import com.github.mikephil.charting.highlight.Highlight; +import com.github.mikephil.charting.listener.OnChartValueSelectedListener; +import com.sipai.jspatrol.Bean.Measuringpoint; +import com.sipai.jspatrol.Bean.WaterQualityList; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.DateFormatUtils; +import com.sipai.jspatrol.utils.MyMarkerView; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.ProgressForAll; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +import static com.github.mikephil.charting.components.Legend.LegendPosition.RIGHT_OF_CHART_INSIDE; + + +public class PointHistoryActivity extends AppCompatActivity implements OnChartValueSelectedListener { + private View mMainView; + private List mData; + + private String mServer; + private String mBizid; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String pointid; + private Measuringpoint point; + private String unit = "值";//单位 + private TextView tvstartdate,tvenddate; + private TimePickerView pvTime; + private String mark = "start"; + private TextView tv_avg; + + /** + * Deep copy of data. + */ + private final int errorflag=0; + private final int passflag=1; + private LineChart lineChart; + private List mpList; + private String s_max,s_min,s_avg; + private ArrayList xValueList; + private ArrayList yValueList; + private ArrayList maxValueList; + private ArrayList minValueList; + //下拉刷新更新页面handler + private Handler mHandler = new Handler(){ + + public void handleMessage(Message msg) { + switch (msg.what){ + case passflag: + unit = ""; + if (s_max!=null){ + unit = "最大值:"+s_max; + } + if (s_min!=null){ + unit = unit+" "+"最小值:"+s_min; + } + if (s_avg!=null){ + unit = unit+" "+"平均值:"+s_avg; + } + tv_avg.setText(unit); + if (point.getAlarmmax()!=null&&!point.getAlarmmax().isEmpty()){ + setChartDataAndMaxMin(xValueList,yValueList,maxValueList,minValueList,0); + }else { + setChartData(xValueList, yValueList, 0); + } + lineChart.invalidate(); + break; + case errorflag: + cancelProgress(); + Toast.makeText(PointHistoryActivity.this,"查询失败",Toast.LENGTH_SHORT).show(); + break; + } + + } +}; + /** + * Called when the activity is first created. + */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_pointhistory); + init(); + initView(); + initTimePicker(); + if (tvstartdate.getText()!=null&&tvenddate.getText()!=null) { + showProgress(null, "数据加载中,请稍后..."); + new getResThread().start(); + } + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("历史曲线"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + lineChart = (LineChart) findViewById(R.id.moudle_point_history_linechart); + //对折线图初始化 + initChartView(); + tvstartdate=findViewById(R.id.et_startdate); + tvstartdate.setText(DateFormatUtils.DateFormatMinStringPL(System.currentTimeMillis()-24*60*60*1000)); + tvstartdate.setOnClickListener(v->{ + mark = "start"; + pvTime.show(); + }); + tv_avg = findViewById(R.id.moudle_avg); + tvenddate=findViewById(R.id.et_enddate); + tvenddate.setText(DateFormatUtils.DateFormatMinStringPL(System.currentTimeMillis())); + tvenddate.setOnClickListener(v->{ + mark = "end"; + pvTime.show(); + }); + Button butserch=(Button)findViewById(R.id.but_search); + butserch.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View arg0) { + // TODO Auto-generated method stub + showProgress(null, "数据加载中,请稍后..."); + new getResThread().start(); + } + }); + Button butlast=(Button)findViewById(R.id.but_last); + butlast.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View arg0) { + tvstartdate.setText(DateFormatUtils.DateFormatMinStringPL(DateFormatUtils.pareSec(tvstartdate.getText().toString()+":00")-24*60*60*1000)); + tvenddate.setText(DateFormatUtils.DateFormatMinStringPL(DateFormatUtils.pareSec(tvenddate.getText().toString()+":00")-24*60*60*1000)); + showProgress(null, "数据加载中,请稍后..."); + new getResThread().start(); + } + }); + Button butnext=(Button)findViewById(R.id.but_next); + butnext.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View arg0) { + tvstartdate.setText(DateFormatUtils.DateFormatMinStringPL(DateFormatUtils.pareSec(tvstartdate.getText().toString()+":00")+24*60*60*1000)); + tvenddate.setText(DateFormatUtils.DateFormatMinStringPL(DateFormatUtils.pareSec(tvenddate.getText().toString()+":00")+24*60*60*1000)); + + } + }); + } + + private void initTimePicker() { + //正确设置方式 原因:注意事项有说明 + pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() { + @Override + public void onTimeSelect(Date date,View v) {//选中事件回调 + if (mark.equals("start")) { + tvstartdate.setText(getTime(date)); + }else if (mark.equals("end")){ + tvenddate.setText(getTime(date)); + } + } + }) + .setType(new boolean[]{true, true, true, true, true, false})// 默认全部显示 + .setCancelText("取消")//取消按钮文字 + .setSubmitText("确认")//确认按钮文字 + .setTitleSize(20)//标题文字大小 + .setTitleText("选择时间")//标题文字 + .setOutSideCancelable(false)//点击屏幕,点在控件外部范围时,是否取消显示 + .isCyclic(true)//是否循环滚动 + .setTitleColor(Color.BLACK)//标题文字颜色 + .isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。 + .build(); + } + + private String getTime(Date date) {//可根据需要自行截取数据显示 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + return format.format(date); + } + + /** + * 初始化折线图 + */ + private void initChartView() { + + //在点击高亮值时回调 + lineChart.setOnChartValueSelectedListener(this); + + //设置整个图表的颜色 + lineChart.setBackgroundResource(R.drawable.bg_line_chart); + + Description description = lineChart.getDescription(); + description.setYOffset(10); + description.setEnabled(true); + description.setText("时间"); + + lineChart.getLegend().setPosition(RIGHT_OF_CHART_INSIDE); + + //是否可以缩放、移动、触摸 + lineChart.setTouchEnabled(true); + lineChart.setDragEnabled(true); + + //不能让缩放,不然有bug,所以接口也没实现 + lineChart.setScaleEnabled(true); + lineChart.setPinchZoom(true); + + //设置图表距离上下左右的距离 + lineChart.setExtraOffsets(10, 10, 10, 0); + + //获取左侧侧坐标轴 + YAxis leftAxis = lineChart.getAxisLeft(); + + //设置是否显示Y轴的值 + leftAxis.setDrawLabels(true); + leftAxis.setTextColor(this.getResources().getColor(R.color.blue)); + + //设置所有垂直Y轴的的网格线是否显示 + leftAxis.setDrawGridLines(true); + + //设置虚线 + leftAxis.enableGridDashedLine(10f, 10f, 0f); + leftAxis.setDrawZeroLine(false); + + //设置Y极值,我这里没设置最大值,因为项目需要没有设置最大值 + leftAxis.setAxisMinimum(0f); + + //将右边那条线隐藏 + lineChart.getAxisRight().setEnabled(false); + //获取X轴 + XAxis xAxis = lineChart.getXAxis(); + //设置X轴的位置,可上可下 + xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); + + //将垂直于X轴的网格线隐藏,将X轴显示 + xAxis.setDrawGridLines(false); + xAxis.setDrawAxisLine(true); + + //设置X轴上lable颜色和大小 + xAxis.setTextSize(8f); + xAxis.setTextColor(Color.GRAY); + + //设置X轴高度 + xAxis.setAxisLineWidth(1); + } + /** + * @param xData + * @param yData + * @param flag + */ + private void setChartData(final List xData , List yData, int flag) { + lineChart.getXAxis().setLabelCount(4); + lineChart.getXAxis().setValueFormatter(new IAxisValueFormatter() { + @Override + public String getFormattedValue(float value, AxisBase axis) { + + //对X轴上的值进行Format格式化,转成相应的值 + int intValue = (int)value; + + //筛选出自己需要的值,一般都是这样写没问题,并且一定要加上这个判断,不然会出错 + if(xData.size()>intValue && intValue>=0){ + //这样显示在X轴上值就是 05:30 05:35,不然会是1.0 2.0 + return xData.get(intValue); + }else{ + return ""; + } + } + }); + unit = ""; + if (s_max!=null){ + unit = "最大值:"+s_max; + } + if (s_min!=null){ + unit = unit+" "+"最小值:"+s_min; + } + if (s_avg!=null){ + unit = unit+" "+"平均值:"+s_avg; + } + lineChart.invalidate(); + + MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view,xData); + mv.setChartView(lineChart); + lineChart.setMarker(mv); + + final ArrayList values = new ArrayList<>(); + float min = Float.valueOf(yData.get(0)); + float max = Float.valueOf(yData.get(0)); + for (int i = 0; i < yData.size(); i++) { + //注意这里的Entry(不一定需要)采用这种方式构造,采用其他的结果是一样的 + values.add(new Entry(i, Float.valueOf(yData.get(i)), xData.get(i))); + if (min>Float.valueOf(yData.get(i))){ + min = Float.valueOf(yData.get(i)); + } + if (max0) { + lineChart.getAxisLeft().setAxisMaximum(max*2); + }else { + lineChart.getAxisLeft().setAxisMaximum(0); + } + + if (lineChart.getData() != null && lineChart.getData().getDataSetCount() > 0) { + + lineDataset = (LineDataSet) lineChart.getData().getDataSetByIndex(0); + lineDataset.setValues(values); + if(flag==0){ + lineDataset.setLabel(unit); + lineDataset.setDrawFilled(false); + }else{ + lineDataset.setLabel(""); + lineDataset.setDrawFilled(false); + } + lineChart.getData().notifyDataChanged(); + lineChart.notifyDataSetChanged(); + + }else{ + if(flag==0){ + lineDataset = new LineDataSet(values, unit); + lineDataset.setDrawFilled(false); + }else{ + lineDataset = new LineDataSet(values, unit); + lineDataset.setDrawFilled(false); + } + + lineDataset.setColor(this.getResources().getColor(R.color.green04)); + + //设置是否显示圆点 + lineDataset.setDrawCircles(false); + + //是否显示每个点的Y值 + lineDataset.setDrawValues(false); +// lineDataset.setFillColor(R.color.white); + LineData lineData = new LineData(lineDataset); + lineChart.setData(lineData); + lineChart.animateX(1000); + } + } + + private void setChartDataAndMaxMin(final List xData , List yData, List maxs,List mins, int flag) { + lineChart.getXAxis().setLabelCount(4); + lineChart.getXAxis().setValueFormatter(new IAxisValueFormatter() { + @Override + public String getFormattedValue(float value, AxisBase axis) { + + //对X轴上的值进行Format格式化,转成相应的值 + int intValue = (int)value; + + //筛选出自己需要的值,一般都是这样写没问题,并且一定要加上这个判断,不然会出错 + if(xData.size()>intValue && intValue>=0){ + //这样显示在X轴上值就是 05:30 05:35,不然会是1.0 2.0 + return xData.get(intValue); + }else{ + return ""; + } + } + }); + + + lineChart.invalidate(); + + MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view,xData); + mv.setChartView(lineChart); + lineChart.setMarker(mv); + + final ArrayList values1 = new ArrayList<>(); + final ArrayList values2 = new ArrayList<>(); + final ArrayList values3 = new ArrayList<>(); + float min = Float.valueOf(yData.get(0)); + float max = Float.valueOf(yData.get(0)); + for (int i = 0; i < yData.size(); i++) { + //注意这里的Entry(不一定需要)采用这种方式构造,采用其他的结果是一样的 + values1.add(new Entry(i, Float.valueOf(yData.get(i)), xData.get(i))); + values2.add(new Entry(i, Float.valueOf(maxs.get(i)), xData.get(i))); + values3.add(new Entry(i, Float.valueOf(mins.get(i)), xData.get(i))); + if (min>Float.valueOf(yData.get(i))){ + min = Float.valueOf(yData.get(i)); + } + if (maxFloat.valueOf(point.getAlarmmin())){ + min = Float.valueOf(point.getAlarmmin()); + } + } + + LineDataSet lineDataset ; + LineDataSet lineDataset2 ; + LineDataSet lineDataset3 ; + if (min<0) { + lineChart.getAxisLeft().setAxisMinimum(min * 2); + }else { + lineChart.getAxisLeft().setAxisMinimum(0); + } + if (max>0) { + lineChart.getAxisLeft().setAxisMaximum(max*2); + }else { + lineChart.getAxisLeft().setAxisMaximum(0); + } + + if (lineChart.getData() != null && lineChart.getData().getDataSetCount() > 0) { + + lineDataset = (LineDataSet) lineChart.getData().getDataSetByIndex(0); + lineDataset.setValues(values1); + lineDataset2 = (LineDataSet) lineChart.getData().getDataSetByIndex(1); + lineDataset2.setValues(values2); + lineDataset3 = (LineDataSet) lineChart.getData().getDataSetByIndex(2); + lineDataset3.setValues(values3); + + if(flag==0){ + lineDataset.setDrawFilled(false); + lineDataset2.setDrawFilled(false); + }else{ + lineDataset.setDrawFilled(false); + lineDataset2.setDrawFilled(false); + } + lineChart.getData().notifyDataChanged(); + lineChart.notifyDataSetChanged(); + + }else{ + if(flag==0){ + lineDataset = new LineDataSet(values1, "实际值"); + lineDataset.setDrawFilled(false); + lineDataset2 = new LineDataSet(values2,"报警上限:"+point.getAlarmmax()); + lineDataset2.setDrawFilled(false); + lineDataset3 = new LineDataSet(values3, "报警下限:"+point.getAlarmmin()); + lineDataset3.setDrawFilled(false); + }else{ + lineDataset = new LineDataSet(values1, "实际值"); + lineDataset.setDrawFilled(false); + lineDataset2 = new LineDataSet(values2, "报警上限:"+point.getAlarmmax()); + lineDataset2.setDrawFilled(false); + lineDataset3 = new LineDataSet(values3, "报警下限:"+point.getAlarmmin()); + lineDataset3.setDrawFilled(false); + } + + lineDataset.setColor(this.getResources().getColor(R.color.green04)); + lineDataset2.setColor(this.getResources().getColor(R.color.red)); + lineDataset3.setColor(this.getResources().getColor(R.color.red01)); + + //设置是否显示圆点 + lineDataset.setDrawCircles(false); + lineDataset2.setDrawCircles(false); + lineDataset3.setDrawCircles(false); + + //是否显示每个点的Y值 + lineDataset.setDrawValues(false); + lineDataset2.setDrawValues(false); + lineDataset3.setDrawValues(false); +// lineDataset.setFillColor(R.color.white); + LineData lineData = new LineData(lineDataset,lineDataset2,lineDataset3); + lineChart.setData(lineData); + lineChart.animateX(1000); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + //切换用户 + case android.R.id.home: + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override + public void onValueSelected(Entry entry, Highlight highlight) { + + } + + @Override + public void onNothingSelected() { + + } + + /** + * 初始化 + */ + public void init(){ + SharedPreferences sharedPre=this.getSharedPreferences("config", 0); + mServer=sharedPre.getString("server", ""); + mUsername=sharedPre.getString("username", ""); + mPassword=sharedPre.getString("password", ""); + mUserid=sharedPre.getString("userid", ""); + mCaption=sharedPre.getString("caption", ""); + + Intent intent=getIntent(); + point = (Measuringpoint) intent.getSerializableExtra("point"); + pointid=point.getSid(); + if (point.getUnitId()!=null&&!point.getUnitId().isEmpty()){ + mBizid = point.getUnitId(); + }else { + mBizid=sharedPre.getString("bizid", ""); + } + + TextView tvname =(TextView)findViewById(R.id.tv_name); + tvname.setText(intent.getStringExtra("name")); + + + } + + + private class getResThread extends Thread{ + public void run() { + + getRes(); + } + } + private void getRes(){ + HashMap map = new HashMap<>(); + map.put("bizId", mBizid); + map.put("ids", pointid); + map.put("sdt", tvstartdate.getText().toString()); + map.put("edt", tvenddate.getText().toString()); + OKHttpUtils.OKCallGet(map, mServer, MethodURL.GETPointHistory_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + Message message = Message.obtain(); + message.what=errorflag; + mHandler.sendMessage(message); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + cancelProgress(); + if(res.contains("measuredt")){ + getData(res); + Message message = Message.obtain(); + message.what=passflag; + mHandler.sendMessage(message); + }else{ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(PointHistoryActivity.this, "暂无该日数据!", Toast.LENGTH_SHORT).show(); + } + }); + } + } + }); + } + + private void getData(String response) { + xValueList = new ArrayList<>(); + yValueList = new ArrayList<>(); + maxValueList = new ArrayList<>(); + minValueList = new ArrayList<>(); + try{ + + JSONArray all = new JSONArray(response); + JSONObject jsonObject = all.getJSONObject(0); + s_max = jsonObject.optString("max"); + s_min = jsonObject.optString("min"); + DecimalFormat df = new DecimalFormat("#.##"); + s_avg = df.format(jsonObject.optDouble("avg")); + JSONArray aNews = jsonObject.optJSONArray("data"); + for(int i=0;i bizList = new ArrayList<>(); + //巡检类型 + private String patrolType;//Product("P","生产巡检"), Equipment( "E","设备巡检"), Administrator("A","管理组"),Maintenance("M","运维组"); + private String all; + private String unsub; + private String sub; + private List daily_patrols = new ArrayList<>(); + private List now_patrols = new ArrayList<>(); + public static final String update_task = "broadcast_update_task"; + //任务提醒 + private NotificationManager manager; + private Notification notification; + private String channelName = "com_patrol_task"; + private String channelID = "64368180"; + private static final int NOTIF = 12; + + MqttAndroidClient mqttAndroidClient; + private String title_msg = ""; + private String content_msg = ""; + private String serverUri = "ws://116.228.107.170:9291"; + String clientId = ""; + public static final String update_newvalue = "broadcast_update_newvalue"; + public static final String update_biz = "broadcast_update_biz"; + + private Handler handler = new Handler(){ + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what){ + case NOTIF: + Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALL); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_HIGH); + NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + manager.createNotificationChannel(channel); + Notification.Builder builder = new Notification.Builder(IPatrolService.this); + builder.setChannelId(channelID); + Notification notification = builder + .setSound(uri) + .setContentTitle("新任务") + .setContentText("您有新的巡检任务,请及时处理!") + .setWhen(System.currentTimeMillis()) + .setSmallIcon(R.mipmap.moudle_ipatrol_logo) + .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.moudle_ipatrol_logo)) + .setDefaults(NotificationCompat.DEFAULT_VIBRATE) + .setAutoCancel(true) + .build(); + manager.notify(1, notification); + } else { + NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + Notification notification = new Notification.Builder(IPatrolService.this) + .setSound(uri) + .setContentTitle("新任务") + .setContentText("您有新的巡检任务,请及时处理!") + .setWhen(System.currentTimeMillis()) + .setSmallIcon(R.mipmap.moudle_ipatrol_logo) + .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.moudle_ipatrol_logo)) + .setPriority(Notification.PRIORITY_DEFAULT) + .setAutoCancel(true) + .build(); + manager.notify(1, notification); + } + + AlertDialog.Builder alertDialog = new AlertDialog.Builder(IPatrolService.this); + alertDialog.setTitle("新的巡检任务开始啦!"); + alertDialog.setMessage(now_patrols.get(0).getName()); + final Dialog dialog = alertDialog.create(); + alertDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface arg0, int arg1) { + // TODO Auto-generated method stub + } + }); + AlertDialog ad = alertDialog.create(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + ad.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); + } else { + ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + } + ad.setCanceledOnTouchOutside(false); //点击外面区域不会让dialog消失 + ad.show(); + break; + } + } + }; + + + public IPatrolService() { + } + + @Override + public IBinder onBind(Intent intent) { + // TODO: Return the communication channel to the service. + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + public void onCreate() { + super.onCreate(); + initBroadcast(); + init(); + } + + private void initBroadcast() { + IntentFilter filte = new IntentFilter(); + filte.addAction(IPatrolService.update_biz); + registerReceiver(InfoReceiver, filte); + } + + BroadcastReceiver InfoReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + init(); + } + }; + + public void subscribeToTopic() { + try { + if (mBizid.equals(bizList.get(0).getBizid())){ + bizList.remove(0); + int[] Qos = new int[bizList.size()]; + String[] topic = new String[bizList.size()]; + for (int i=0;i 22) { + manager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi); + } else if (android.os.Build.VERSION.SDK_INT > 18) { + manager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi); + } else { + manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi); + } + return super.onStartCommand(intent, flags, startId); + } + + private List parseBiz(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i=0;i map = new HashMap<>(); + map.put("unitId",mBizid); + map.put("userIds",mUserid); + map.put("bizid",mBizid); + map.put("type","P"); + OKHttpUtils.OKCallGet(map, mServer, MethodURL.GetPatrolList_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (!res.contains("fail")&&res.contains("allNum")) { + daily_patrols = getDailyPatrols(res); + if (daily_patrols.size()>0){ + List nowPatrols = checkPatrols(daily_patrols); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String now = df.format(new Date()); + now_patrols.clear(); + for (int i=0;i0){ + PushNotification(now_patrols); + } + if (nowPatrols.size()==0){ + Patrol patrol = new Patrol(); + patrol.setContent("暂无任务"); + patrol.setEndTime(""); + patrol.setName("暂无任务"); + patrol.setStartTime(""); + nowPatrols.add(patrol); +// patrol.setStatus(arry.getJSONObject(i).opt("status").toString()); + } + Intent intent = new Intent(update_task); + intent.putExtra("all",all); + intent.putExtra("unsub",unsub); + intent.putExtra("sub",sub); + intent.putExtra("tasks", (Serializable) nowPatrols); + sendBroadcast(intent); + } + }else if (res.contains("html")){ + login("task"); + } + } + }); + } + + private void login(String mark) { + CookiesManager.clearCookie(getApplicationContext()); + HashMap map = new HashMap<>(); + String p_pwd = ""; + String vcode = ""; + String code = RandomStringUtils.getRandomStr(1,4); + try { + vcode = "64368180"; + vcode = "64368180"+code; + vcode = EncryptUtils.encrypt(vcode).replace("\n",""); + code = EncryptUtils.encrypt(code).replace("\n",""); + vcode = URLEncoder.encode(vcode,"UTF-8"); + code = URLEncoder.encode(code,"UTF-8"); + p_pwd = URLEncoder.encode(mPwd,"UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } + map.put("j_password",p_pwd); + map.put("j_username",mUsername); + map.put("androidId",androidId); + map.put("verCode",vcode); + map.put("code",code); + OKHttpUtils.OKCallGet(map,mServer,MethodURL.Login_Method).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + Log.i("IPatrol", "onFailure: "+e.toString()); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String result = response.body().string(); + if (mark.equals("task")){ + getPatrolTask(); + } + } + }); + } + + private void PushNotification(List nowPatrols) { + manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + notification = new Notification(R.mipmap.moudle_ipatrol_logo, nowPatrols.get(0).getContent(), + System.currentTimeMillis()); + + notification.defaults = Notification.DEFAULT_ALL; // + notification.flags = Notification.FLAG_AUTO_CANCEL; // + notification.flags |= Notification.FLAG_NO_CLEAR;// + + notification = new Notification.Builder(this) + .setTicker(nowPatrols.get(0).getContent()).setSmallIcon(R.mipmap.moudle_ipatrol_logo).setWhen(System.currentTimeMillis()) + .setContentTitle("新的巡检任务开始啦!").setContentText(nowPatrols.get(0).getName()).build(); + + + manager.notify(0, notification); + + //弹窗 + KeyguardManager km = (KeyguardManager) this.getSystemService(Context.KEYGUARD_SERVICE); + if (km.inKeyguardRestrictedInputMode()) { + LockScreenDialogActivity.actionStart(this,nowPatrols.get(0).getName(),nowPatrols.get(0).getContent()); +// Intent alarmIntent = new Intent(this, LockScreenDialogActivity.class); +// alarmIntent.putExtra("title", "巡检任务"); +// alarmIntent.putExtra("info", "您有新的巡检任务:\n" + nowPatrols.get(0).getName()); +// alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); +// startActivity(alarmIntent); + } else { + Message msg = new Message(); + msg.what = NOTIF; + handler.sendMessage(msg); + + } + } + + private List checkPatrols(List daily_patrols) { + List list = new ArrayList<>(); + for (int i=0;i=0&&result1<=0){ + list.add(item); + } + } catch (ParseException e) { + e.printStackTrace(); + } + } + return list; + } + + private List getDailyPatrols(String response) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(response); + all = jsonObject.opt("allNum").toString(); + unsub = jsonObject.opt("inCompleteNum").toString(); + sub = jsonObject.opt("completeNum").toString(); + JSONArray arry = new JSONArray(jsonObject.optString("content1")); + for (int i=0;i { + private Context context; + private List list; + + public NodesAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_nodes,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.node.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + Nodes item = list.get(position); + if (item.getNodes()!=null&&item.getNodes().size()>0){ + if (viewHolder.rc.getVisibility()==View.GONE) { + viewHolder.rc.setVisibility(View.VISIBLE); + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_down); + }else { + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_right); + viewHolder.rc.setVisibility(View.GONE); + } + }else { + StatementListActivity.actionStart(context,item.getId(),item.getText()); + } + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Nodes item = list.get(position); + holder.tv_title.setText(item.getText()); + if (item.getNodes()!=null&&item.getNodes().size()>0){ + holder.rc.setLayoutManager(new LinearLayoutManager(context)); + NodesAdapter nodesAdapter = new NodesAdapter(context,item.getNodes()); + holder.rc.setAdapter(nodesAdapter); + }else { + holder.rc.setVisibility(View.GONE); + holder.iv_arrow.setImageResource(R.mipmap.arrow_right); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + View node; + ImageView iv_arrow; + TextView tv_title; + RecyclerView rc; + public ViewHolder(@NonNull View itemView) { + super(itemView); + node = itemView; + iv_arrow = itemView.findViewById(R.id.iv_arrow); + tv_title = itemView.findViewById(R.id.tv_title); + rc = itemView.findViewById(R.id.rc_children); + } + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Statement/StatementAdapter.java b/app/src/main/java/com/sipai/jspatrol/Statement/StatementAdapter.java new file mode 100644 index 0000000..0b518c3 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Statement/StatementAdapter.java @@ -0,0 +1,78 @@ +package com.sipai.jspatrol.Statement; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.sipai.jspatrol.Bean.Statement; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.GuideMenuUrl; +import com.sipai.jspatrol.Webv.WebStatementActivity; + +import java.util.List; + +/** + * created by lvliming on 2021/1/19 + */ +public class StatementAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + + public StatementAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_statement,parent,false); + final ViewHolder viewHolder = new ViewHolder(view); + viewHolder.node.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + Statement item = list.get(position); + WebStatementActivity.actionStart(context, GuideMenuUrl.url_statement, item.getRptname(),item.getId()); + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Statement item = list.get(position); + holder.tv_rptdt.setText(item.getRptdt()); + holder.tv_inputusername.setText(item.getInputusername()); + holder.tv_rptname.setText(item.getRptname()); + if (item.getInsdt().length()>16){ + holder.tv_insdt.setText(item.getInsdt().substring(0,16)); + }else { + holder.tv_insdt.setText(item.getInsdt()); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + View node; + TextView tv_rptdt,tv_inputusername,tv_rptname,tv_insdt; + public ViewHolder(@NonNull View itemView) { + super(itemView); + node = itemView; + tv_rptdt = itemView.findViewById(R.id.moudle_item_statement_tv_rptdt); + tv_inputusername = itemView.findViewById(R.id.moudle_item_statement_tv_inputusername); + tv_rptname = itemView.findViewById(R.id.moudle_item_statement_tv_rptname); + tv_insdt = itemView.findViewById(R.id.moudle_item_statement_tv_insdt); + } + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Statement/StatementListActivity.java b/app/src/main/java/com/sipai/jspatrol/Statement/StatementListActivity.java new file mode 100644 index 0000000..8df9460 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Statement/StatementListActivity.java @@ -0,0 +1,213 @@ +package com.sipai.jspatrol.Statement; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.gigamole.navigationtabstrip.NavigationTabStrip; +import com.sipai.jspatrol.Bean.Statement; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.ui.EmptyLayout; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class StatementListActivity extends AppCompatActivity { + private String mServer; + private String mBizid; + private String classId; + private String title; + private NavigationTabStrip tab; + private String[] tab_title = new String[]{"报表生成","报表浏览"}; + private SwipeRefreshLayout refresh; + private RecyclerView rc_view; + private EmptyLayout emptyLayout; + private LinearLayoutManager manager; + private StatementAdapter adapter; + private List statements = new ArrayList<>(); + private String requestUrl; + + public static void actionStart(Context context,String id,String title){ + Intent intent = new Intent(context,StatementListActivity.class); + intent.putExtra("classId",id); + intent.putExtra("title",title); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_statement_list); + init(); + initView(); + getStatementList(); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText(title); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + tab = findViewById(R.id.moudle_statement_list_tab); + tab.setTitles(tab_title); + tab.setOnTabStripSelectedIndexListener(new NavigationTabStrip.OnTabStripSelectedIndexListener() { + @Override + public void onStartTabSelected(String title, int index) { + if (title.equals("报表生成")){ + requestUrl = MethodURL.GetStatementList_Method; + }else if (title.equals("报表浏览")){ + requestUrl = MethodURL.GetViewStatementList_Method; + }else if (title.equals("审核中")){ + requestUrl = MethodURL.GetAuditStatementList_Method; + } + getStatementList(); + } + + @Override + public void onEndTabSelected(String title, int index) { + + } + }); + tab.setTabIndex(0); + emptyLayout = findViewById(R.id.moudle_statement_list_ui_empty); + refresh = findViewById(R.id.moudle_statement_list_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getStatementList(); + } + }); + rc_view = findViewById(R.id.moudle_statement_list_rc); + manager = new LinearLayoutManager(StatementListActivity.this); + rc_view.setLayoutManager(manager); + } + + private void getStatementList() { + HashMap map = new HashMap<>(); + map.put("page","1"); + map.put("rows","50"); + map.put("sort","rptdt"); + map.put("order","desc"); + map.put("stdt",""); + map.put("eddt",""); + map.put("st",""); + map.put("unitId", mBizid); + map.put("classId", classId); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, requestUrl)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorResponse(); + showEmpty(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("total")&&res.contains("rows")){ + statements = parseStatement(res); + showStatement(); + }else { + showEmpty(); + } + } + }); + } + + private void showStatement() { + if (!StatementListActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + manager = new LinearLayoutManager(StatementListActivity.this); + rc_view.setLayoutManager(manager); + adapter = new StatementAdapter(StatementListActivity.this,statements); + rc_view.setAdapter(adapter); + } + }); + } + } + + private List parseStatement(String res) { + List list = new ArrayList<>(); + try { + JSONObject jsonObject = new JSONObject(res); + JSONArray array = jsonObject.getJSONArray("rows"); + for (int i=0;i nodes = new ArrayList<>(); + private SwipeRefreshLayout refresh; + private RecyclerView rc_view; + private EmptyLayout emptyLayout; + private NodesAdapter nodesAdapter; + private LinearLayoutManager manager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_statement_type); + init(); + initView(); + getStatementType(); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText("报表"); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + emptyLayout = findViewById(R.id.moudle_statement_type_ui_empty); + refresh = findViewById(R.id.moudle_statement_type_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + getStatementType(); + } + }); + rc_view = findViewById(R.id.moudle_statement_type_rc); + manager = new LinearLayoutManager(StatementTypeActivity.this); + rc_view.setLayoutManager(manager); + } + + private void getStatementType() { + HashMap map = new HashMap<>(); + map.put("unitId", mBizid); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetStatementTypeList_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorResponse(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("nodes")&&res.contains("id")){ + nodes = parseNodes(res); + updateList(); + }else { + showEmpty(); + } + } + }); + } + + private void updateList() { + if (!StatementTypeActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + manager = new LinearLayoutManager(StatementTypeActivity.this); + rc_view.setLayoutManager(manager); + nodesAdapter = new NodesAdapter(StatementTypeActivity.this,nodes); + rc_view.setAdapter(nodesAdapter); + } + }); + } + } + + private List parseNodes(String result) { + List list = new ArrayList<>(); + try { + JSONArray array = new JSONArray(result); + for (int i=0;i areas = new ArrayList<>(); + if (!array.getJSONObject(i).optString("nodes").isEmpty()&&!array.getJSONObject(i).optString("nodes").equals("null")) { + areas = parseNodes(array.getJSONObject(i).optString("nodes")); + } + item.setNodes(areas); + list.add(item); + } + } catch (JSONException e) { + e.printStackTrace(); + return list; + } + return list; + } + + private void showEmpty() { + if (!StatementTypeActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + rc_view.setVisibility(View.GONE); + emptyLayout.setVisibility(View.VISIBLE); + } + }); + } + } + + private void errorResponse() { + if (!StatementTypeActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + refresh.setRefreshing(false); + Toast.makeText(StatementTypeActivity.this, "列表获取失败!", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void init() { + SharedPreferences sharedPre=this.getSharedPreferences("config", 0); + mServer=sharedPre.getString("server", ""); + mBizid=sharedPre.getString("bizid", ""); + } + + class NodesAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + + public NodesAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_nodes,parent,false); + ViewHolder viewHolder = new NodesAdapter.ViewHolder(view); + viewHolder.iv_arrow.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + Nodes item = list.get(position); + if (item.getNodes()!=null&&item.getNodes().size()>0){ + if (viewHolder.rc.getVisibility()==View.GONE) { + viewHolder.rc.setVisibility(View.VISIBLE); + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_down); + }else { + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_right); + viewHolder.rc.setVisibility(View.GONE); + } + } + } + }); + viewHolder.tv_title.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + Nodes item = list.get(position); + if (item.getNodes()!=null&&item.getNodes().size()>0){ + if (viewHolder.rc.getVisibility()==View.GONE) { + viewHolder.rc.setVisibility(View.VISIBLE); + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_down); + }else { + viewHolder.iv_arrow.setImageResource(R.mipmap.arrow_right); + viewHolder.rc.setVisibility(View.GONE); + } + }else { + StatementListActivity.actionStart(context,item.getId(),item.getText()); + } + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + Nodes item = list.get(position); + holder.tv_title.setText(item.getText()); + if (item.getNodes()!=null&&item.getNodes().size()>0){ + holder.rc.setLayoutManager(new LinearLayoutManager(context)); + NodesAdapter nodesAdapter = new NodesAdapter(context,item.getNodes()); + holder.rc.setAdapter(nodesAdapter); + }else { + holder.rc.setVisibility(View.GONE); + holder.iv_arrow.setImageResource(R.mipmap.moudle_bizpop_biz); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + ImageView iv_arrow; + TextView tv_title; + RecyclerView rc; + public ViewHolder(@NonNull View itemView) { + super(itemView); + iv_arrow = itemView.findViewById(R.id.iv_arrow); + tv_title = itemView.findViewById(R.id.tv_title); + rc = itemView.findViewById(R.id.rc_children); + } + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sipai/jspatrol/URL/GuideMenuUrl.java b/app/src/main/java/com/sipai/jspatrol/URL/GuideMenuUrl.java new file mode 100644 index 0000000..e798e00 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/URL/GuideMenuUrl.java @@ -0,0 +1,74 @@ +package com.sipai.jspatrol.URL; + +/** + * created by lvliming on 2019/8/8 + */ +public class GuideMenuUrl { + //管理制度 + public static final String url_system_of_management = "/document/showManageDataTree.do"; + public static final String name_system_of_management = "管理制度"; + //维修 + public static final String url_equ_repair = "/maintenance/showMaintenanceDetailList.do"; + public static final String name_equ_repair = "维修"; + //保养 + public static final String url_equ_maintain = "/equipment/equipmentMaintain/showEquipmentMaintainList.do"; + public static final String name_equ_maintain = "保养"; + //盘点 + public static final String url_check = "/sparepart/stockCheck/showList.do"; + public static final String name_check = "盘点"; + + //巡检记录 + public static final String url_patrol_record = "/timeEfficiency/patrolRecord/showCalendar.do"; + public static final String name_patrol_record = "巡检记录"; + + //技术档案 + public static final String url_technical_file = "/document/showDataTree.do"; + public static final String name_technical_file = "技术档案"; + //消息中心 + public static final String url_messages = "/msg/showMsgrecv.do"; + public static final String name_messages = "消息中心"; + + //待办事项 + public static final String url_backlog = "/activiti/workflow/taskList.do"; + public static final String name_backlog = "待办事项"; + + //异常列表 + public static final String url_faultlist = "/maintenance/abnormity/showList_new.do?"; + public static final String name_faultlist = "异常列表"; + + //委外工单 + public static final String url_wwlist = "/workorder/workorderDetail/showMaintainListOut.do?"; + public static final String name_wwlist = "委外工单"; + + //待办事项 + public static final String url_subfault = "/maintenance/abnormity/showList_new.do?"; + public static final String name_subfault = "异常上报"; + + //物资申领 + public static final String url_outstockrecord = "/sparepart/outStockRecord/showList.do"; + public static final String out_stock_record = "物资申领"; + + //监视画面 + public static final String url_monitor_screen = "/process/dataVisualFrame/view.do"; + + //报表 + public static final String url_statement = "/report/rptCreate/viewFile.do"; + + /** + * 交接班 + */ + //接班 + public static final String url_catch = "/work/scheduling/showSucceed.do"; + public static final String name_catch = "接班"; + //交班 + public static final String url_sub = "/work/scheduling/showHandover.do"; + public static final String name_sub = "交班"; + + //巡检记录 + public static final String url_shift_record = "/work/scheduling/showHandoverRecord.do"; + public static final String name_shift_record = "交接班"; + + //测试 +// public static final String url_test = "http://113.98.238.130:9091/BKSW/cameraction.do?method=camview&view=02&id=7451appb3d03407087167f858b1de112"; +// public static final String out_stock_record = "物资申领"; +} diff --git a/app/src/main/java/com/sipai/jspatrol/URL/MethodURL.java b/app/src/main/java/com/sipai/jspatrol/URL/MethodURL.java new file mode 100644 index 0000000..7e1e816 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/URL/MethodURL.java @@ -0,0 +1,240 @@ +package com.sipai.jspatrol.URL; + +/** + * created by lvliming on 2019/9/12 + * 接口集 + */ +public class MethodURL { + /** + * 项目名 + */ +// public static final String PJ_Base = "SIPAIIS_WMS"; + + public static final String PJ_Base = "JSYW"; + + /** + * 方法名 + */ + //登录接口 + public static final String Login_Method = PJ_Base+"/j_spring_security_check"; + + //获取服务器最新版APK名 + public static final String Check_Apk_Method = PJ_Base+"/app/getApkName.do"; + + /** + * NFC模块 + */ + + //获取厂区内所有巡检点接口(NFC写入调用) + public static final String GetALLPatrolPointList_Method = PJ_Base+"/timeEfficiency/patrolPoint/getPatrolPointForUnitId.do"; + + //获取厂区内所有设备接口(NFC写入调用) + public static final String GetALLEquList_Method = PJ_Base+"/equipment/getEquipmentList.do"; + + /** + * 巡检模块 + */ + + //获取离线巡检任务数据接口 + public static final String GetOffLineData_Method = PJ_Base+"/timeEfficiency/patrolRecord/getPatrolRecord4All.do"; + + //获取巡检任务列表接口 + public static final String GetPatrolList_Method = PJ_Base+"/timeEfficiency/patrolRecord/getPatrolRecord4APP.do"; + + //获取运行巡检任务详情接口 + public static final String GetPatrolTaskDetail_Method = PJ_Base+"/timeEfficiency/patrolPoint/getPatrolPointForRecord4APP.do"; + + //获取厂区特定人员的接口(可搜索) + public static final String GETPartUserList_Method = PJ_Base+"/user/getUsers4Abnormity.do"; + + //获取设备任务详情接口 + public static final String GetEquPatrolTaskDetail_Method = PJ_Base+"/timeEfficiency/patrolRecord/getEquipmentCards.do"; + + //获取巡检点内自动点 + public static final String GetPatrolPointAutoPoint_Method = PJ_Base+"/timeEfficiency/patrolPoint/getMPoint4APP.do"; + + //获取巡检点内填报内容 + public static final String GetPatrolPointEditPoint_Method = PJ_Base+"/timeEfficiency/patrolMeasurePointRecord/getPatrolMeasurePoint4APP.do"; + + //上传巡检点内填报内容 + public static final String SubPatrolPointEditPoint_Method = PJ_Base+"/timeEfficiency/patrolMeasurePointRecord/updatePatrolMeasurePoint.do"; + + //获取巡检点内执行内容 + public static final String GetPatrolPointContent_Method = PJ_Base+"/timeEfficiency/patrolContentsRecord/getPatrolContents4APP.do"; + + //上传巡检点内执行内容 + public static final String SubPatrolPointContent_Method = PJ_Base+"/timeEfficiency/patrolContentsRecord/updatePatrolContents.do"; + + //上传巡检点状态 + public static final String SubPatrolPointStatus_Method = PJ_Base+"/timeEfficiency/patrolRecord/updatePatrolPointByAPP.do"; + + //获取巡检点内设备列表 + public static final String GetPatrolPointEquList_Method = PJ_Base+"/timeEfficiency/patrolRecord/getEquipmentByPatrolPoint4APP.do"; + + //获取巡检点下设备详情 + public static final String GetPatrolPointEquDetail_Method = PJ_Base+"/equipment/doview4Id.do"; + + //获取巡检点下设备执行内容 + public static final String GetPatrolPointEquDetailPC_Method = PJ_Base+"/timeEfficiency/patrolContentsRecord/getPatrolContents4APP.do"; + + //获取巡检点下设备填报内容 + public static final String GetPatrolPointEquDetailEC_Method = PJ_Base+"/timeEfficiency/patrolMeasurePointRecord/getPatrolMeasurePoint4APP.do"; + + //提交巡检点下设备填报内容 + public static final String SubPatrolPointEquDetailEC_Method = PJ_Base+"/timeEfficiency/patrolMeasurePointRecord/updatePatrolMeasurePoint.do"; + + //提交巡检点下设备执行内容 + public static final String SubPatrolPointEquDetailPC_Method = PJ_Base+"/timeEfficiency/patrolContentsRecord/updatePatrolContents.do"; + + //提交巡检点下设备巡检状态 + public static final String SubPatrolPointEquDetailPS_Method = PJ_Base+"/timeEfficiency/patrolRecord/subEquipment4APP.do"; + + //提交巡检点状态 + public static final String SubPatrolPointPS_Method = PJ_Base+"/timeEfficiency/patrolRecord/subPatrolPoint4APP.do"; + + //提交巡检任务接口 + public static final String SubPatrolTask_Method = PJ_Base+"/timeEfficiency/patrolRecord/updatePatrolRecordByAPP.do"; + + //提交离线巡检任务数据接口 + public static final String SubOfflinePatrolTask_Method = PJ_Base+"/timeEfficiency/patrolRecord/receivePatrolRecord4App.do"; + + /** + * 厂区列表接口 + */ + //获取厂区列表接口 + public static final String ComList_Method = PJ_Base+"/user/getSearchBizsByUserId4Select.do"; + + //获取厂区所有工艺段接口(可搜索) + public static final String GETPSLISt_Method = PJ_Base+"/user/processSection/getlist.do"; + + //获取厂区所有设备接口(可搜索) + public static final String GETEQULISt_Method = PJ_Base+"/equipment/getList.do"; + + //获取厂区单个设备接口 + public static final String GETSINGLEEQU_Method = PJ_Base+"/equipment/getEquipmentcardById.do"; + + //获取厂区所有人员的接口(可搜索) + public static final String GETUSERLISt_Method = PJ_Base+"/user/getUsers.do"; + + //获取设备下测量点列表 + public static final String GETEquPoints_Method = PJ_Base+"/equipment/getEquipmentMpoint4APP.do"; + + //获取设备故障列表 + public static final String GETEquFaults_Method = PJ_Base+"/maintenance/getMaintainceList4APP.do"; + + //获取设备保养列表 + public static final String GETEquMaintains_Method = PJ_Base+"/maintenance/getMaintenanceDetailList4APP.do"; + + //获取设备资料列表 + public static final String GETEquDocument_Method = PJ_Base+"/document/getInputFileList.do"; + + //获取工艺位置下测量点列表 + public static final String GETPointList_Method = PJ_Base+"/user/processSection/getMPointByProcessSection4APP.do"; + + //获取所有收藏测量点 + public static final String GetAllCollectePoint_Method = PJ_Base+"/user/processSection/getMPointByProcessSection4APPLeftCollection.do"; + + //收藏测量点 + public static final String CollectePoint_Method = PJ_Base+"/work/personalMpCollection/save.do"; + + //取消收藏测量点 + public static final String UnCollectePoint_Method = PJ_Base+"/work/personalMpCollection/delete.do"; + + //获取测量点历史数据 + public static final String GETPointHistory_Method = PJ_Base+"/work/mpoint/getHistoryAPP.do"; + + //获取测量点统一格式历史数据 + public static final String GETPointFormatHistory_Method = PJ_Base+"/work/mpoint/getMpointJsonFormpids.do"; + + //获取测量点方案 + public static final String getSolutionList_Method = PJ_Base+"/data/getCurveProgrammeJson.do"; + + + /** + * 异常模块 + */ + //获取异常列表 + public static final String GetFaultList_Method = PJ_Base+"/maintenance/abnormity/getMaintainceList4APP.do"; + + //上报异常接口 + public static final String SubFault_Method = PJ_Base+"/maintenance/abnormity/start.do"; + + //获取异常图片接口 + public static final String GetFaultPics_Method = PJ_Base+"/base/getInputFileList.do"; + + //获取异常生成缺陷后图片接口 + public static final String GetFaultTodoPics_Method = PJ_Base+"/maintenance/getMastId4APP.do"; + + //异常生成缺陷接口 + public static final String IssuedFault_Method = PJ_Base+"/maintenance/abnormity/doCreateDefectByAbnormal.do"; + + //获取提交缺陷执行时所需提交的部分参数 + public static final String GetPar_Method = PJ_Base+"/maintenance/showHandleDetail4APP.do"; + + //更新流程 + public static final String UpdateProcess_Method = PJ_Base+"/maintenance/doHandleAdjust.do"; + + //缺陷签收 + public static final String SignIn_Method = PJ_Base+"/activiti/workflow/task/claim.do"; + + //缺陷实施提交接口 + public static final String SubImp_Method = PJ_Base+"/maintenance/updateDetail.do"; + + //获取执行详情 + public static final String GetSubDetail_Method = PJ_Base+"/maintenance/getHandleContent4APP.do"; + + //获取执行详情 + public static final String GetSubDetailPics_Method = PJ_Base+"/base/getInputFileList.do"; + + //获取维修流程图 + public static final String GetMaintenanceFlowChart_Method = PJ_Base+"/maintenance/showMaintenanceDetailView4APP.do"; + + /** + * 消息列表 + */ + public static final String GetMsgList_Method = PJ_Base + "/msg/getMsgrecv4APP.do"; + + /** + * 上传图片接口 + */ + public static final String SubPic_Method = PJ_Base + "/base/inputFile.do"; + + /** + * 首页tab接口 + */ + public static final String GetMainTab_Method = PJ_Base + "/app/appProductMonitor/getlist4APP.do"; + + /** + * 首页tab下测量点列表接口 + */ + public static final String GetMainTabPointList_Method = PJ_Base + "/app/appProductMonitor/getlistMp.do"; + + /** + * 报警列表 + */ + public static final String GetAlarmList_Method = PJ_Base + "/alarm/proAlarm/getlist.do"; + + /** + * 生产报表 + */ + //报表类型列表 + public static final String GetStatementTypeList_Method = PJ_Base + "/report/rptInfoSet/getTree4Generate.do"; + + //报表生成列表 + public static final String GetStatementList_Method = PJ_Base + "/report/rptCreate/getList4Generate.do"; + + //报表审核中列表 + public static final String GetAuditStatementList_Method = PJ_Base + "/report/rptCreate/showList4Check.do"; + + //报表浏览列表 + public static final String GetViewStatementList_Method = PJ_Base + "/report/rptCreate/getList4View.do"; + + //表名 + public static final String GetSheetName_Method = PJ_Base + "/report/rptCreate/getSheet.do"; + + /** + * 监视画面 + */ + public static final String GetFrameTree_Method = PJ_Base + "/process/dataVisualFrame/getFrameTree.do"; + +} diff --git a/app/src/main/java/com/sipai/jspatrol/Webv/GuideMenuActivity.java b/app/src/main/java/com/sipai/jspatrol/Webv/GuideMenuActivity.java new file mode 100644 index 0000000..5bf63d8 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Webv/GuideMenuActivity.java @@ -0,0 +1,515 @@ +package com.sipai.jspatrol.Webv; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Environment; +import android.view.View; +import android.webkit.URLUtil; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.AndroidFileUtil; +import com.sipai.jspatrol.utils.FileProvider7; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; +import com.tencent.smtt.sdk.CookieManager; +import com.tencent.smtt.sdk.CookieSyncManager; +import com.tencent.smtt.sdk.DownloadListener; +import com.tencent.smtt.sdk.MimeTypeMap; +import com.tencent.smtt.sdk.ValueCallback; +import com.tencent.smtt.sdk.WebChromeClient; +import com.tencent.smtt.sdk.WebView; +import com.tencent.smtt.sdk.WebViewClient; + +import org.xutils.x; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLDecoder; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class GuideMenuActivity extends AppCompatActivity { + private String url; + private String name; + private WebView webView; + private SwipeRefreshLayout refresh; + private SweetAlertDialog pDialog; + private String cookies; + private String fileabspath = ""; + private ProgressDialog progressDialog; + private ValueCallback mUploadMessage; + private ValueCallback uploadMessage; // 用于5.0以上 + final static int FILE_SELECTED = 4; + public static final int REQUEST_SELECT_FILE = 100; + + public static void actionStart(Context context, String url, String name) { + Intent intent = new Intent(context, GuideMenuActivity.class); + intent.putExtra("url", url); + intent.putExtra("name", name); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_guide_menu); + init(); + initView(); + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText(name); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + progressDialog = new ProgressDialog(this); + webView = (WebView) findViewById(R.id.moudle_guide_menu_webview); + webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setAllowFileAccess(true); + webView.getSettings().setDomStorageEnabled(true); + //设置自适应屏幕,两者合用 + webView.getSettings().setUseWideViewPort(true); //将图片调整到适合webview的大小 + webView.getSettings().setLoadWithOverviewMode(true); // 缩放至屏幕的大小 + //缩放操作 + webView.getSettings().setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 + webView.getSettings().setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 + webView.getSettings().setDisplayZoomControls(false); //隐藏原生的缩放控件 + webView.getSettings().setDefaultTextEncodingName("utf-8"); + webView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView webView, String s) { + return super.shouldOverrideUrlLoading(webView, s); + } + + @Override + public void onPageStarted(WebView webView, String s, Bitmap bitmap) { + super.onPageStarted(webView, s, bitmap); + showMsgDialog(); + } + + @Override + public void onPageFinished(WebView webView, String s) { + super.onPageFinished(webView, s); + showMsgFinish(); + } + }); + webView.setWebChromeClient(new WebChromeClient() { + public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { + mUploadMessage = uploadMsg; + if (mUploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + GuideMenuActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + FILE_SELECTED); + } + } + + @Override + public boolean onShowFileChooser(WebView webView, ValueCallback valueCallback, FileChooserParams fileChooserParams) { + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } + + uploadMessage = valueCallback; + if (uploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + GuideMenuActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + REQUEST_SELECT_FILE); + } + return true; + } + }); + cookies = CookiesManager.getCookieText(this); + synCookies(mServer, cookies); + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + webView.setDownloadListener(new DownloadListener() { + @Override + public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimeType, final long contentLength) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(GuideMenuActivity.this, SweetAlertDialog.NORMAL_TYPE) + .setTitleText("下载附件?") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + long caca = contentLength; + Uri uri = Uri.parse(url); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + +// downloadBySystem(url, contentDisposition, mimeType); + sweetAlertDialog.dismissWithAnimation(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + }); + refresh = (SwipeRefreshLayout) findViewById(R.id.moudle_guide_menu_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setEnabled(false); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + refresh.setRefreshing(false); + } + }); + } + + + private void downloadBySystem(String url, String contentDisposition, String mimeType) { + + + // 设置下载文件保存的路径和文件名 + String fileName = URLUtil.guessFileName(url, contentDisposition, mimeType); + fileName = URLDecoder.decode(fileName); + downloadFile(url, fileName, fileabspath); +// new DownloadTask().execute(url, fileabspath+"/"+fileName); + } + + private class DownloadTask extends AsyncTask { + // 传递两个参数:URL 和 目标路径 + private String url; + private String destPath; + + + @Override + protected void onPreExecute() { +// log.info("开始下载"); + if (!GuideMenuActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(GuideMenuActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + protected Void doInBackground(String... params) { + + if (!GuideMenuActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + } + }); + } +// log.debug("doInBackground. url:{}, dest:{}", params[0], params[1]); + url = params[0]; + destPath = params[1]; + OutputStream out = null; + HttpURLConnection urlConnection = null; + try { + URL url = new URL(params[0]); + urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setConnectTimeout(15000); + urlConnection.setReadTimeout(15000); + InputStream in = urlConnection.getInputStream(); + out = new FileOutputStream(params[1]); + byte[] buffer = new byte[10 * 1024]; + int len; + while ((len = in.read(buffer)) != -1) { + out.write(buffer, 0, len); + } + in.close(); + } catch (IOException e) { +// log.warn(e); + } finally { + if (urlConnection != null) { + urlConnection.disconnect(); + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { +// log.warn(e); + } + } + } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { +// log.info("完成下载"); + if (!GuideMenuActivity.this.isFinishing()) { + Toast.makeText(GuideMenuActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + File file = new File(destPath); + openThisFile(file); +// Intent handlerIntent = new Intent(Intent.ACTION_VIEW); +// String mimeType = getMIMEType(url); +// Uri uri = Uri.fromFile(new File(destPath)); +// handlerIntent.setDataAndType(uri, mimeType); +// startActivity(handlerIntent); + } + } + + private String getMIMEType(String url) { + String type = null; + String extension = MimeTypeMap.getFileExtensionFromUrl(url); +// log.debug("extension:{}", extension); + if (extension != null) { + type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + return type; + } + + + + private void downloadFile(String nowurl, String filename, String path) { + File filep = new File(path); + if (!filep.exists()) + filep.mkdirs(); + filep = null; + progressDialog = new ProgressDialog(this); + org.xutils.http.RequestParams requestParams = new org.xutils.http.RequestParams(nowurl); + requestParams.setAutoRename(false); + requestParams.setSaveFilePath(path +"/"+ filename); + x.http().get(requestParams, new org.xutils.common.Callback.ProgressCallback() { + @Override + public void onWaiting() { + } + + @Override + public void onStarted() { + if (!GuideMenuActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(GuideMenuActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onLoading(final long total, final long current, boolean isDownloading) { + if (!GuideMenuActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + progressDialog.setProgressNumberFormat(""); + progressDialog.setMax((int) total); + progressDialog.setProgress((int) current); + } + }); + } + } + + + @Override + public void onSuccess(File result) { + if (!GuideMenuActivity.this.isFinishing()) { + Toast.makeText(GuideMenuActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + //下载成功,file为下载好的文件 + File file = result; +// openFile(file); + String name = file.getName(); + String filepath = file.getPath(); + String abso = file.getAbsolutePath(); + openThisFile(file); + } + + @Override + public void onError(Throwable ex, boolean isOnCallback) { + ex.printStackTrace(); + if (!GuideMenuActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(GuideMenuActivity.this, "下载失败,请检查网络和SD卡", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onCancelled(CancelledException cex) { + } + + @Override + public void onFinished() { + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + +// if (resultCode == RESULT_OK) { + switch (requestCode) { + case REQUEST_SELECT_FILE: +// if (null == mUploadMessage) { +// break; +// } +// Uri mResult = data == null || resultCode != RESULT_OK ? null +// : data.getData(); +// mUploadMessage.onReceiveValue(mResult); +// mUploadMessage = null; + if (uploadMessage == null) + return; + Uri result = (data == null || resultCode != RESULT_OK) ? null : data.getData(); + if (result != null) { + uploadMessage.onReceiveValue(new Uri[]{result}); + } else { + uploadMessage.onReceiveValue(new Uri[]{}); + } + uploadMessage = null; //每次置空是为了防止下次点击按钮选择图片无响应 + break; + case FILE_SELECTED: + if (null == mUploadMessage) { + break; + } + Uri mResult = data == null || resultCode != RESULT_OK ? null + : data.getData(); + mUploadMessage.onReceiveValue(mResult); + mUploadMessage = null; + break; + + } +// }else { +// +// } + } + + private static final int REQUEST_CHOOSEFILE = 1212; + + private void openThisFile(File file) { + + + if (!file.exists()) { + + Toast.makeText(GuideMenuActivity.this, "文件不存在", Toast.LENGTH_SHORT).show(); + + } else { + + try { + + + Uri fileUri = FileProvider7.getUriForFile(GuideMenuActivity.this, file); + + Intent in = AndroidFileUtil.openFile(file.getPath() + "", fileUri); + + startActivity(in); + + } catch (Exception e) { + + Toast.makeText(GuideMenuActivity.this, "文件打开失败", Toast.LENGTH_SHORT).show(); + + } + + } + } + + private void showMsgFinish() { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.hide(); + } + }); + } + + private void showMsgDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + initDialog("页面加载中"); + pDialog.show(); + } + }); + } + + private void initDialog(String st) { + pDialog.setTitleText(st); + } + + public void synCookies(String url, String cookies) { + CookieSyncManager.createInstance(getApplicationContext()); + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.setAcceptCookie(true); + cookieManager.setCookie(url, cookies); + CookieSyncManager.getInstance().sync(); + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + + public void init() { + fileabspath = Environment.getExternalStorageDirectory() + "/" + getResources().getString(R.string.appflag) + "/" + getResources().getString(R.string.appflag) + "_FILE"; + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + url = getIntent().getStringExtra("url"); + name = getIntent().getStringExtra("name"); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Webv/GuideMenuLandscapeActivity.java b/app/src/main/java/com/sipai/jspatrol/Webv/GuideMenuLandscapeActivity.java new file mode 100644 index 0000000..8b6a97c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Webv/GuideMenuLandscapeActivity.java @@ -0,0 +1,546 @@ +package com.sipai.jspatrol.Webv; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Environment; +import android.view.View; +import android.webkit.URLUtil; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.AndroidFileUtil; +import com.sipai.jspatrol.utils.FileProvider7; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; +import com.sipai.ui.TitleLayout; +import com.tencent.smtt.sdk.CookieManager; +import com.tencent.smtt.sdk.CookieSyncManager; +import com.tencent.smtt.sdk.DownloadListener; +import com.tencent.smtt.sdk.MimeTypeMap; +import com.tencent.smtt.sdk.ValueCallback; +import com.tencent.smtt.sdk.WebChromeClient; +import com.tencent.smtt.sdk.WebView; +import com.tencent.smtt.sdk.WebViewClient; + +import org.xutils.x; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLDecoder; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class GuideMenuLandscapeActivity extends AppCompatActivity { + private String url; + private String name; + private WebView webView; + private SwipeRefreshLayout refresh; + private SweetAlertDialog pDialog; + private TitleLayout titleLayout; + private String cookies; + private String fileabspath = ""; + private ProgressDialog progressDialog; + private ValueCallback mUploadMessage; + private ValueCallback uploadMessage; // 用于5.0以上 + final static int FILE_SELECTED = 4; + public static final int REQUEST_SELECT_FILE = 100; + + public static void actionStart(Context context, String url, String name) { + Intent intent = new Intent(context, GuideMenuLandscapeActivity.class); + intent.putExtra("url", url); + intent.putExtra("name", name); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_guide_menu); + init(); + initView(); + } + + private void initView() { + titleLayout = findViewById(R.id.moudle_guide_menu_ui_title); + titleLayout.setVisibility(View.GONE); + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText(name); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + progressDialog = new ProgressDialog(this); + webView = (WebView) findViewById(R.id.moudle_guide_menu_webview); + webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setAllowFileAccess(true); + webView.getSettings().setDomStorageEnabled(true); + //设置自适应屏幕,两者合用 + webView.getSettings().setUseWideViewPort(true); //将图片调整到适合webview的大小 + webView.getSettings().setLoadWithOverviewMode(true); // 缩放至屏幕的大小 + //缩放操作 + webView.getSettings().setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 + webView.getSettings().setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 + webView.getSettings().setDisplayZoomControls(false); //隐藏原生的缩放控件 + webView.getSettings().setDefaultTextEncodingName("utf-8"); + webView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView webView, String s) { + return super.shouldOverrideUrlLoading(webView, s); + } + + @Override + public void onPageStarted(WebView webView, String s, Bitmap bitmap) { + super.onPageStarted(webView, s, bitmap); + showMsgDialog(); + } + + @Override + public void onPageFinished(WebView webView, String s) { + super.onPageFinished(webView, s); + showMsgFinish(); + showToast("长按显示回退按钮"); + } + }); + webView.setWebChromeClient(new WebChromeClient() { + public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { + mUploadMessage = uploadMsg; + if (mUploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + GuideMenuLandscapeActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + FILE_SELECTED); + } + } + + @Override + public boolean onShowFileChooser(WebView webView, ValueCallback valueCallback, FileChooserParams fileChooserParams) { + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } + + uploadMessage = valueCallback; + if (uploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + GuideMenuLandscapeActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + REQUEST_SELECT_FILE); + } + return true; + } + }); + cookies = CookiesManager.getCookieText(this); + synCookies(mServer, cookies); + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + webView.setDownloadListener(new DownloadListener() { + @Override + public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimeType, final long contentLength) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(GuideMenuLandscapeActivity.this, SweetAlertDialog.NORMAL_TYPE) + .setTitleText("下载附件?") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + long caca = contentLength; + Uri uri = Uri.parse(url); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + +// downloadBySystem(url, contentDisposition, mimeType); + sweetAlertDialog.dismissWithAnimation(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + }); + webView.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + if (titleLayout.getVisibility()==View.GONE) { + titleLayout.setVisibility(View.VISIBLE); + }else { + titleLayout.setVisibility(View.GONE); + } + return true; + } + }); + refresh = (SwipeRefreshLayout) findViewById(R.id.moudle_guide_menu_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setEnabled(false); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + refresh.setRefreshing(false); + } + }); + } + + private void showToast(String s) { + if (!GuideMenuLandscapeActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(GuideMenuLandscapeActivity.this, s, Toast.LENGTH_LONG).show(); + } + }); + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + webView.destroy(); + } + + private void downloadBySystem(String url, String contentDisposition, String mimeType) { + + + // 设置下载文件保存的路径和文件名 + String fileName = URLUtil.guessFileName(url, contentDisposition, mimeType); + fileName = URLDecoder.decode(fileName); + downloadFile(url, fileName, fileabspath); +// new DownloadTask().execute(url, fileabspath+"/"+fileName); + } + + private class DownloadTask extends AsyncTask { + // 传递两个参数:URL 和 目标路径 + private String url; + private String destPath; + + + @Override + protected void onPreExecute() { +// log.info("开始下载"); + if (!GuideMenuLandscapeActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(GuideMenuLandscapeActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + protected Void doInBackground(String... params) { + + if (!GuideMenuLandscapeActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + } + }); + } +// log.debug("doInBackground. url:{}, dest:{}", params[0], params[1]); + url = params[0]; + destPath = params[1]; + OutputStream out = null; + HttpURLConnection urlConnection = null; + try { + URL url = new URL(params[0]); + urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setConnectTimeout(15000); + urlConnection.setReadTimeout(15000); + InputStream in = urlConnection.getInputStream(); + out = new FileOutputStream(params[1]); + byte[] buffer = new byte[10 * 1024]; + int len; + while ((len = in.read(buffer)) != -1) { + out.write(buffer, 0, len); + } + in.close(); + } catch (IOException e) { +// log.warn(e); + } finally { + if (urlConnection != null) { + urlConnection.disconnect(); + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { +// log.warn(e); + } + } + } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { +// log.info("完成下载"); + if (!GuideMenuLandscapeActivity.this.isFinishing()) { + Toast.makeText(GuideMenuLandscapeActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + File file = new File(destPath); + openThisFile(file); +// Intent handlerIntent = new Intent(Intent.ACTION_VIEW); +// String mimeType = getMIMEType(url); +// Uri uri = Uri.fromFile(new File(destPath)); +// handlerIntent.setDataAndType(uri, mimeType); +// startActivity(handlerIntent); + } + } + + private String getMIMEType(String url) { + String type = null; + String extension = MimeTypeMap.getFileExtensionFromUrl(url); +// log.debug("extension:{}", extension); + if (extension != null) { + type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + return type; + } + + private void downloadFile(String nowurl, String filename, String path) { + File filep = new File(path); + if (!filep.exists()) + filep.mkdirs(); + filep = null; + progressDialog = new ProgressDialog(this); + org.xutils.http.RequestParams requestParams = new org.xutils.http.RequestParams(nowurl); + requestParams.setAutoRename(false); + requestParams.setSaveFilePath(path +"/"+ filename); + x.http().get(requestParams, new org.xutils.common.Callback.ProgressCallback() { + @Override + public void onWaiting() { + } + + @Override + public void onStarted() { + if (!GuideMenuLandscapeActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(GuideMenuLandscapeActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onLoading(final long total, final long current, boolean isDownloading) { + if (!GuideMenuLandscapeActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + progressDialog.setProgressNumberFormat(""); + progressDialog.setMax((int) total); + progressDialog.setProgress((int) current); + } + }); + } + } + + + @Override + public void onSuccess(File result) { + if (!GuideMenuLandscapeActivity.this.isFinishing()) { + Toast.makeText(GuideMenuLandscapeActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + //下载成功,file为下载好的文件 + File file = result; +// openFile(file); + String name = file.getName(); + String filepath = file.getPath(); + String abso = file.getAbsolutePath(); + openThisFile(file); + } + + @Override + public void onError(Throwable ex, boolean isOnCallback) { + ex.printStackTrace(); + if (!GuideMenuLandscapeActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(GuideMenuLandscapeActivity.this, "下载失败,请检查网络和SD卡", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onCancelled(CancelledException cex) { + } + + @Override + public void onFinished() { + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + +// if (resultCode == RESULT_OK) { + switch (requestCode) { + case REQUEST_SELECT_FILE: +// if (null == mUploadMessage) { +// break; +// } +// Uri mResult = data == null || resultCode != RESULT_OK ? null +// : data.getData(); +// mUploadMessage.onReceiveValue(mResult); +// mUploadMessage = null; + if (uploadMessage == null) + return; + Uri result = (data == null || resultCode != RESULT_OK) ? null : data.getData(); + if (result != null) { + uploadMessage.onReceiveValue(new Uri[]{result}); + } else { + uploadMessage.onReceiveValue(new Uri[]{}); + } + uploadMessage = null; //每次置空是为了防止下次点击按钮选择图片无响应 + break; + case FILE_SELECTED: + if (null == mUploadMessage) { + break; + } + Uri mResult = data == null || resultCode != RESULT_OK ? null + : data.getData(); + mUploadMessage.onReceiveValue(mResult); + mUploadMessage = null; + break; + + } +// }else { +// +// } + } + + private static final int REQUEST_CHOOSEFILE = 1212; + + private void openThisFile(File file) { + + + if (!file.exists()) { + + Toast.makeText(GuideMenuLandscapeActivity.this, "文件不存在", Toast.LENGTH_SHORT).show(); + + } else { + + try { + + + Uri fileUri = FileProvider7.getUriForFile(GuideMenuLandscapeActivity.this, file); + + Intent in = AndroidFileUtil.openFile(file.getPath() + "", fileUri); + + startActivity(in); + + } catch (Exception e) { + + Toast.makeText(GuideMenuLandscapeActivity.this, "文件打开失败", Toast.LENGTH_SHORT).show(); + + } + + } + } + + private void showMsgFinish() { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.hide(); + } + }); + } + + private void showMsgDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + initDialog("页面加载中"); + pDialog.show(); + } + }); + } + + private void initDialog(String st) { + pDialog.setTitleText(st); + } + + public void synCookies(String url, String cookies) { + CookieSyncManager.createInstance(getApplicationContext()); + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.setAcceptCookie(true); + cookieManager.setCookie(url, cookies); + CookieSyncManager.getInstance().sync(); + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + + public void init() { + fileabspath = Environment.getExternalStorageDirectory() + "/" + MethodURL.PJ_Base + "/" + MethodURL.PJ_Base + "_FILE"; + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + url = getIntent().getStringExtra("url"); + name = getIntent().getStringExtra("name"); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Webv/MonitorScreenActivity.java b/app/src/main/java/com/sipai/jspatrol/Webv/MonitorScreenActivity.java new file mode 100644 index 0000000..de1f303 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Webv/MonitorScreenActivity.java @@ -0,0 +1,538 @@ +package com.sipai.jspatrol.Webv; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Environment; +import android.view.View; +import android.view.WindowManager; +import android.webkit.URLUtil; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.AndroidFileUtil; +import com.sipai.jspatrol.utils.FileProvider7; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; +import com.sipai.ui.TitleLayout; +import com.tencent.smtt.sdk.CookieManager; +import com.tencent.smtt.sdk.CookieSyncManager; +import com.tencent.smtt.sdk.DownloadListener; +import com.tencent.smtt.sdk.MimeTypeMap; +import com.tencent.smtt.sdk.ValueCallback; +import com.tencent.smtt.sdk.WebChromeClient; +import com.tencent.smtt.sdk.WebView; +import com.tencent.smtt.sdk.WebViewClient; + +import org.xutils.x; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLDecoder; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class MonitorScreenActivity extends AppCompatActivity { + private String url; + private String name; + private WebView webView; + private SwipeRefreshLayout refresh; + private SweetAlertDialog pDialog; + private String cookies; + private String fileabspath = ""; + private ProgressDialog progressDialog; + private ValueCallback mUploadMessage; + private ValueCallback uploadMessage; // 用于5.0以上 + final static int FILE_SELECTED = 4; + public static final int REQUEST_SELECT_FILE = 100; + private TitleLayout titleLayout; + + public static void actionStart(Context context, String url, String name) { + Intent intent = new Intent(context, MonitorScreenActivity.class); + intent.putExtra("url", url); + intent.putExtra("name", name); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // 隐藏状态栏 + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + setContentView(R.layout.activity_guide_menu); + init(); + initView(); + } + + private void initView() { + titleLayout = findViewById(R.id.moudle_guide_menu_ui_title); + titleLayout.setVisibility(View.GONE); + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText(name); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + progressDialog = new ProgressDialog(this); + webView = (WebView) findViewById(R.id.moudle_guide_menu_webview); + webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setAllowFileAccess(true); + webView.getSettings().setDomStorageEnabled(true); + //设置自适应屏幕,两者合用 + webView.getSettings().setUseWideViewPort(true); //将图片调整到适合webview的大小 + webView.getSettings().setLoadWithOverviewMode(true); // 缩放至屏幕的大小 + //缩放操作 + webView.getSettings().setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 + webView.getSettings().setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 + webView.getSettings().setDisplayZoomControls(false); //隐藏原生的缩放控件 + webView.getSettings().setDefaultTextEncodingName("utf-8"); + webView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView webView, String s) { + return super.shouldOverrideUrlLoading(webView, s); + } + + @Override + public void onPageStarted(WebView webView, String s, Bitmap bitmap) { + super.onPageStarted(webView, s, bitmap); + showMsgDialog(); + } + + @Override + public void onPageFinished(WebView webView, String s) { + super.onPageFinished(webView, s); + showMsgFinish(); + } + }); + webView.setWebChromeClient(new WebChromeClient() { + public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { + mUploadMessage = uploadMsg; + if (mUploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + MonitorScreenActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + FILE_SELECTED); + } + } + + @Override + public boolean onShowFileChooser(WebView webView, ValueCallback valueCallback, FileChooserParams fileChooserParams) { + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } + + uploadMessage = valueCallback; + if (uploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + MonitorScreenActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + REQUEST_SELECT_FILE); + } + return true; + } + }); + cookies = CookiesManager.getCookieText(this); + synCookies(mServer, cookies); + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + webView.setDownloadListener(new DownloadListener() { + @Override + public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimeType, final long contentLength) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(MonitorScreenActivity.this, SweetAlertDialog.NORMAL_TYPE) + .setTitleText("下载附件?") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + long caca = contentLength; + Uri uri = Uri.parse(url); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + +// downloadBySystem(url, contentDisposition, mimeType); + sweetAlertDialog.dismissWithAnimation(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + }); + webView.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + if (titleLayout.getVisibility()==View.VISIBLE){ + titleLayout.setVisibility(View.GONE); + Toast.makeText(MonitorScreenActivity.this, "长按显示标题", Toast.LENGTH_LONG).show(); + }else { + titleLayout.setVisibility(View.VISIBLE); + Toast.makeText(MonitorScreenActivity.this, "长按隐藏标题", Toast.LENGTH_LONG).show(); + } + return true; + } + }); + refresh = (SwipeRefreshLayout) findViewById(R.id.moudle_guide_menu_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setEnabled(false); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + refresh.setRefreshing(false); + } + }); + Toast.makeText(MonitorScreenActivity.this, "长按页面显示标题", Toast.LENGTH_LONG).show(); + } + + + private void downloadBySystem(String url, String contentDisposition, String mimeType) { + + + // 设置下载文件保存的路径和文件名 + String fileName = URLUtil.guessFileName(url, contentDisposition, mimeType); + fileName = URLDecoder.decode(fileName); + downloadFile(url, fileName, fileabspath); +// new DownloadTask().execute(url, fileabspath+"/"+fileName); + } + + private class DownloadTask extends AsyncTask { + // 传递两个参数:URL 和 目标路径 + private String url; + private String destPath; + + + @Override + protected void onPreExecute() { +// log.info("开始下载"); + if (!MonitorScreenActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(MonitorScreenActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + protected Void doInBackground(String... params) { + + if (!MonitorScreenActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + } + }); + } +// log.debug("doInBackground. url:{}, dest:{}", params[0], params[1]); + url = params[0]; + destPath = params[1]; + OutputStream out = null; + HttpURLConnection urlConnection = null; + try { + URL url = new URL(params[0]); + urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setConnectTimeout(15000); + urlConnection.setReadTimeout(15000); + InputStream in = urlConnection.getInputStream(); + out = new FileOutputStream(params[1]); + byte[] buffer = new byte[10 * 1024]; + int len; + while ((len = in.read(buffer)) != -1) { + out.write(buffer, 0, len); + } + in.close(); + } catch (IOException e) { +// log.warn(e); + } finally { + if (urlConnection != null) { + urlConnection.disconnect(); + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { +// log.warn(e); + } + } + } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { +// log.info("完成下载"); + if (!MonitorScreenActivity.this.isFinishing()) { + Toast.makeText(MonitorScreenActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + File file = new File(destPath); + openThisFile(file); +// Intent handlerIntent = new Intent(Intent.ACTION_VIEW); +// String mimeType = getMIMEType(url); +// Uri uri = Uri.fromFile(new File(destPath)); +// handlerIntent.setDataAndType(uri, mimeType); +// startActivity(handlerIntent); + } + } + + private String getMIMEType(String url) { + String type = null; + String extension = MimeTypeMap.getFileExtensionFromUrl(url); +// log.debug("extension:{}", extension); + if (extension != null) { + type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + return type; + } + + + + private void downloadFile(String nowurl, String filename, String path) { + File filep = new File(path); + if (!filep.exists()) + filep.mkdirs(); + filep = null; + progressDialog = new ProgressDialog(this); + org.xutils.http.RequestParams requestParams = new org.xutils.http.RequestParams(nowurl); + requestParams.setAutoRename(false); + requestParams.setSaveFilePath(path +"/"+ filename); + x.http().get(requestParams, new org.xutils.common.Callback.ProgressCallback() { + @Override + public void onWaiting() { + } + + @Override + public void onStarted() { + if (!MonitorScreenActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(MonitorScreenActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onLoading(final long total, final long current, boolean isDownloading) { + if (!MonitorScreenActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + progressDialog.setProgressNumberFormat(""); + progressDialog.setMax((int) total); + progressDialog.setProgress((int) current); + } + }); + } + } + + + @Override + public void onSuccess(File result) { + if (!MonitorScreenActivity.this.isFinishing()) { + Toast.makeText(MonitorScreenActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + //下载成功,file为下载好的文件 + File file = result; +// openFile(file); + String name = file.getName(); + String filepath = file.getPath(); + String abso = file.getAbsolutePath(); + openThisFile(file); + } + + @Override + public void onError(Throwable ex, boolean isOnCallback) { + ex.printStackTrace(); + if (!MonitorScreenActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(MonitorScreenActivity.this, "下载失败,请检查网络和SD卡", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onCancelled(CancelledException cex) { + } + + @Override + public void onFinished() { + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + +// if (resultCode == RESULT_OK) { + switch (requestCode) { + case REQUEST_SELECT_FILE: +// if (null == mUploadMessage) { +// break; +// } +// Uri mResult = data == null || resultCode != RESULT_OK ? null +// : data.getData(); +// mUploadMessage.onReceiveValue(mResult); +// mUploadMessage = null; + if (uploadMessage == null) + return; + Uri result = (data == null || resultCode != RESULT_OK) ? null : data.getData(); + if (result != null) { + uploadMessage.onReceiveValue(new Uri[]{result}); + } else { + uploadMessage.onReceiveValue(new Uri[]{}); + } + uploadMessage = null; //每次置空是为了防止下次点击按钮选择图片无响应 + break; + case FILE_SELECTED: + if (null == mUploadMessage) { + break; + } + Uri mResult = data == null || resultCode != RESULT_OK ? null + : data.getData(); + mUploadMessage.onReceiveValue(mResult); + mUploadMessage = null; + break; + + } +// }else { +// +// } + } + + private static final int REQUEST_CHOOSEFILE = 1212; + + private void openThisFile(File file) { + + + if (!file.exists()) { + + Toast.makeText(MonitorScreenActivity.this, "文件不存在", Toast.LENGTH_SHORT).show(); + + } else { + + try { + + + Uri fileUri = FileProvider7.getUriForFile(MonitorScreenActivity.this, file); + + Intent in = AndroidFileUtil.openFile(file.getPath() + "", fileUri); + + startActivity(in); + + } catch (Exception e) { + + Toast.makeText(MonitorScreenActivity.this, "文件打开失败", Toast.LENGTH_SHORT).show(); + + } + + } + } + + private void showMsgFinish() { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.hide(); + } + }); + } + + private void showMsgDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + initDialog("页面加载中"); + pDialog.show(); + } + }); + } + + private void initDialog(String st) { + pDialog.setTitleText(st); + } + + public void synCookies(String url, String cookies) { + CookieSyncManager.createInstance(getApplicationContext()); + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.setAcceptCookie(true); + cookieManager.setCookie(url, cookies); + CookieSyncManager.getInstance().sync(); + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + + public void init() { + fileabspath = Environment.getExternalStorageDirectory() + "/" + getResources().getString(R.string.appflag) + "/" + getResources().getString(R.string.appflag) + "_FILE"; + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + url = getIntent().getStringExtra("url"); + name = getIntent().getStringExtra("name"); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/Webv/WebStatementActivity.java b/app/src/main/java/com/sipai/jspatrol/Webv/WebStatementActivity.java new file mode 100644 index 0000000..50c035a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/Webv/WebStatementActivity.java @@ -0,0 +1,683 @@ +package com.sipai.jspatrol.Webv; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Environment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.webkit.URLUtil; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.sipai.jspatrol.Bean.Nodes; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.Statement.StatementListActivity; +import com.sipai.jspatrol.Statement.StatementTypeActivity; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.AndroidFileUtil; +import com.sipai.jspatrol.utils.FileProvider7; +import com.sipai.jspatrol.utils.OKHttpUtils; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; +import com.tencent.smtt.sdk.CookieManager; +import com.tencent.smtt.sdk.CookieSyncManager; +import com.tencent.smtt.sdk.DownloadListener; +import com.tencent.smtt.sdk.MimeTypeMap; +import com.tencent.smtt.sdk.ValueCallback; +import com.tencent.smtt.sdk.WebChromeClient; +import com.tencent.smtt.sdk.WebView; +import com.tencent.smtt.sdk.WebViewClient; + +import org.json.JSONException; +import org.json.JSONObject; +import org.xutils.x; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import cn.pedant.SweetAlert.SweetAlertDialog; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + +public class WebStatementActivity extends AppCompatActivity { + private String url; + private String name; + private WebView webView; + private SwipeRefreshLayout refresh; + private SweetAlertDialog pDialog; + private String cookies; + private String fileabspath = ""; + private ProgressDialog progressDialog; + private ValueCallback mUploadMessage; + private ValueCallback uploadMessage; // 用于5.0以上 + final static int FILE_SELECTED = 4; + public static final int REQUEST_SELECT_FILE = 100; + private String id = ""; + private RecyclerView rc_view; + private LinearLayoutManager orManager; + private WebAdapter adapter; + private List list; + private int orsel = 0; + + public static void actionStart(Context context, String url, String name,String id) { + Intent intent = new Intent(context, WebStatementActivity.class); + intent.putExtra("url", url); + intent.putExtra("name", name); + intent.putExtra("id", id); + context.startActivity(intent); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_guide_menu); + init(); + initView(); + getSheet(); + } + + private void getSheet() { + HashMap map = new HashMap<>(); + map.put("id", id); + OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.GetSheetName_Method)).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + errorResponse(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + String res = response.body().string(); + if (res.contains("code")&&res.contains("msg")){ + try { + JSONObject jsonObject = new JSONObject(res); + String msg = jsonObject.optString("msg"); + String[] split = msg.split(","); + list = new ArrayList<>(); + for (int i=0;i0) { + orsel = 0; + list.get(0).setSel("sel"); + requestStatement(list.get(0).getText()); + } + } catch (JSONException e) { + e.printStackTrace(); + } + }else { + errorResponse(); + } + } + }); + } + + private void updateList() { + if (!WebStatementActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + orManager = new LinearLayoutManager(WebStatementActivity.this); + orManager.setOrientation(RecyclerView.HORIZONTAL); + rc_view.setLayoutManager(orManager); + adapter = new WebAdapter(WebStatementActivity.this,list); + rc_view.setAdapter(adapter); + } + }); + } + } + + private void requestStatement(String stn) { + if (!WebStatementActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + webView.loadUrl(mServer + MethodURL.PJ_Base + url+"?id="+id+"&sheetName="+stn+"&layerType=view"); + } + }); + } + } + + private void errorResponse() { + if (!WebStatementActivity.this.isFinishing()){ + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(WebStatementActivity.this, "报表获取失败!", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + private void initView() { + TextView tv_title = (TextView) findViewById(R.id.moudle_back_title_tv_title); + tv_title.setText(name); + ImageView btn_back = (ImageView) findViewById(R.id.moudle_back_title_iv_back); + btn_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE); + pDialog.getProgressHelper().setBarColor(Color.parseColor("#419DE4")); + pDialog.setCancelable(true); + pDialog.setCanceledOnTouchOutside(true); + progressDialog = new ProgressDialog(this); + rc_view = findViewById(R.id.moudle_guide_menu_rc_type); + rc_view.setVisibility(View.VISIBLE); + orManager = new LinearLayoutManager(this); + orManager.setOrientation(RecyclerView.HORIZONTAL); + rc_view.setLayoutManager(orManager); + webView = (WebView) findViewById(R.id.moudle_guide_menu_webview); + webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setAllowFileAccess(true); + webView.getSettings().setDomStorageEnabled(true); + //设置自适应屏幕,两者合用 + webView.getSettings().setUseWideViewPort(true); //将图片调整到适合webview的大小 + webView.getSettings().setLoadWithOverviewMode(true); // 缩放至屏幕的大小 + //缩放操作 + webView.getSettings().setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 + webView.getSettings().setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 + webView.getSettings().setDisplayZoomControls(false); //隐藏原生的缩放控件 + webView.getSettings().setDefaultTextEncodingName("utf-8"); + webView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView webView, String s) { + return super.shouldOverrideUrlLoading(webView, s); + } + + @Override + public void onPageStarted(WebView webView, String s, Bitmap bitmap) { + super.onPageStarted(webView, s, bitmap); + showMsgDialog(); + } + + @Override + public void onPageFinished(WebView webView, String s) { + super.onPageFinished(webView, s); + showMsgFinish(); + } + }); + webView.setWebChromeClient(new WebChromeClient() { + public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) { + mUploadMessage = uploadMsg; + if (mUploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + WebStatementActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + FILE_SELECTED); + } + } + + @Override + public boolean onShowFileChooser(WebView webView, ValueCallback valueCallback, FileChooserParams fileChooserParams) { + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } + + uploadMessage = valueCallback; + if (uploadMessage!=null) { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + intent.setType("image/*"); + WebStatementActivity.this.startActivityForResult( + Intent.createChooser(intent, "完成操作需要使用"), + REQUEST_SELECT_FILE); + } + return true; + } + }); + cookies = CookiesManager.getCookieText(this); + synCookies(mServer, cookies); +// webView.loadUrl(mServer + MethodURL.PJ_Base + url); + webView.setDownloadListener(new DownloadListener() { + @Override + public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimeType, final long contentLength) { + runOnUiThread(new Runnable() { + @Override + public void run() { + new SweetAlertDialog(WebStatementActivity.this, SweetAlertDialog.NORMAL_TYPE) + .setTitleText("下载附件?") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + long caca = contentLength; + Uri uri = Uri.parse(url); + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + startActivity(intent); + +// downloadBySystem(url, contentDisposition, mimeType); + sweetAlertDialog.dismissWithAnimation(); + } + }) + .setCancelText("取消") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }) + .show(); + } + }); + } + }); + refresh = (SwipeRefreshLayout) findViewById(R.id.moudle_guide_menu_refresh); + refresh.setColorSchemeResources(R.color.blue); + refresh.setEnabled(false); + refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + webView.loadUrl(mServer + MethodURL.PJ_Base + url); + refresh.setRefreshing(false); + } + }); + } + + + private void downloadBySystem(String url, String contentDisposition, String mimeType) { + + + // 设置下载文件保存的路径和文件名 + String fileName = URLUtil.guessFileName(url, contentDisposition, mimeType); + fileName = URLDecoder.decode(fileName); + downloadFile(url, fileName, fileabspath); +// new DownloadTask().execute(url, fileabspath+"/"+fileName); + } + + private class DownloadTask extends AsyncTask { + // 传递两个参数:URL 和 目标路径 + private String url; + private String destPath; + + + @Override + protected void onPreExecute() { +// log.info("开始下载"); + if (!WebStatementActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(WebStatementActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + protected Void doInBackground(String... params) { + + if (!WebStatementActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + } + }); + } +// log.debug("doInBackground. url:{}, dest:{}", params[0], params[1]); + url = params[0]; + destPath = params[1]; + OutputStream out = null; + HttpURLConnection urlConnection = null; + try { + URL url = new URL(params[0]); + urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setConnectTimeout(15000); + urlConnection.setReadTimeout(15000); + InputStream in = urlConnection.getInputStream(); + out = new FileOutputStream(params[1]); + byte[] buffer = new byte[10 * 1024]; + int len; + while ((len = in.read(buffer)) != -1) { + out.write(buffer, 0, len); + } + in.close(); + } catch (IOException e) { +// log.warn(e); + } finally { + if (urlConnection != null) { + urlConnection.disconnect(); + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { +// log.warn(e); + } + } + } + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { +// log.info("完成下载"); + if (!WebStatementActivity.this.isFinishing()) { + Toast.makeText(WebStatementActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + File file = new File(destPath); + openThisFile(file); +// Intent handlerIntent = new Intent(Intent.ACTION_VIEW); +// String mimeType = getMIMEType(url); +// Uri uri = Uri.fromFile(new File(destPath)); +// handlerIntent.setDataAndType(uri, mimeType); +// startActivity(handlerIntent); + } + } + + private String getMIMEType(String url) { + String type = null; + String extension = MimeTypeMap.getFileExtensionFromUrl(url); +// log.debug("extension:{}", extension); + if (extension != null) { + type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + return type; + } + + + + private void downloadFile(String nowurl, String filename, String path) { + File filep = new File(path); + if (!filep.exists()) + filep.mkdirs(); + filep = null; + progressDialog = new ProgressDialog(this); + org.xutils.http.RequestParams requestParams = new org.xutils.http.RequestParams(nowurl); + requestParams.setAutoRename(false); + requestParams.setSaveFilePath(path +"/"+ filename); + x.http().get(requestParams, new org.xutils.common.Callback.ProgressCallback() { + @Override + public void onWaiting() { + } + + @Override + public void onStarted() { + if (!WebStatementActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(WebStatementActivity.this, "开始下载", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onLoading(final long total, final long current, boolean isDownloading) { + if (!WebStatementActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage("下载中..."); + progressDialog.show(); + progressDialog.setProgressNumberFormat(""); + progressDialog.setMax((int) total); + progressDialog.setProgress((int) current); + } + }); + } + } + + + @Override + public void onSuccess(File result) { + if (!WebStatementActivity.this.isFinishing()) { + Toast.makeText(WebStatementActivity.this, "下载成功", Toast.LENGTH_SHORT).show(); + progressDialog.dismiss(); + } + //下载成功,file为下载好的文件 + File file = result; +// openFile(file); + String name = file.getName(); + String filepath = file.getPath(); + String abso = file.getAbsolutePath(); + openThisFile(file); + } + + @Override + public void onError(Throwable ex, boolean isOnCallback) { + ex.printStackTrace(); + if (!WebStatementActivity.this.isFinishing()) { + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(WebStatementActivity.this, "下载失败,请检查网络和SD卡", Toast.LENGTH_SHORT).show(); + } + }); + } + } + + @Override + public void onCancelled(CancelledException cex) { + } + + @Override + public void onFinished() { + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + +// if (resultCode == RESULT_OK) { + switch (requestCode) { + case REQUEST_SELECT_FILE: +// if (null == mUploadMessage) { +// break; +// } +// Uri mResult = data == null || resultCode != RESULT_OK ? null +// : data.getData(); +// mUploadMessage.onReceiveValue(mResult); +// mUploadMessage = null; + if (uploadMessage == null) + return; + Uri result = (data == null || resultCode != RESULT_OK) ? null : data.getData(); + if (result != null) { + uploadMessage.onReceiveValue(new Uri[]{result}); + } else { + uploadMessage.onReceiveValue(new Uri[]{}); + } + uploadMessage = null; //每次置空是为了防止下次点击按钮选择图片无响应 + break; + case FILE_SELECTED: + if (null == mUploadMessage) { + break; + } + Uri mResult = data == null || resultCode != RESULT_OK ? null + : data.getData(); + mUploadMessage.onReceiveValue(mResult); + mUploadMessage = null; + break; + + } +// }else { +// +// } + } + + private static final int REQUEST_CHOOSEFILE = 1212; + + private void openThisFile(File file) { + + + if (!file.exists()) { + + Toast.makeText(WebStatementActivity.this, "文件不存在", Toast.LENGTH_SHORT).show(); + + } else { + + try { + + + Uri fileUri = FileProvider7.getUriForFile(WebStatementActivity.this, file); + + Intent in = AndroidFileUtil.openFile(file.getPath() + "", fileUri); + + startActivity(in); + + } catch (Exception e) { + + Toast.makeText(WebStatementActivity.this, "文件打开失败", Toast.LENGTH_SHORT).show(); + + } + + } + } + + private void showMsgFinish() { + runOnUiThread(new Runnable() { + @Override + public void run() { + pDialog.hide(); + } + }); + } + + private void showMsgDialog() { + runOnUiThread(new Runnable() { + @Override + public void run() { + initDialog("页面加载中"); + pDialog.show(); + } + }); + } + + private void initDialog(String st) { + pDialog.setTitleText(st); + } + + public void synCookies(String url, String cookies) { + CookieSyncManager.createInstance(getApplicationContext()); + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.setAcceptCookie(true); + cookieManager.setCookie(url, cookies); + CookieSyncManager.getInstance().sync(); + } + + /** + * 初始化 + */ + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + + public void init() { + fileabspath = Environment.getExternalStorageDirectory() + "/" + getResources().getString(R.string.appflag) + "/" + getResources().getString(R.string.appflag) + "_FILE"; + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + url = getIntent().getStringExtra("url"); + name = getIntent().getStringExtra("name"); + id = getIntent().getStringExtra("id"); + } + + class WebAdapter extends RecyclerView.Adapter { + private Context context; + private List list; + + public WebAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @NonNull + @Override + public WebAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_monitor_screen,parent,false); + WebAdapter.ViewHolder viewHolder = new WebAdapter.ViewHolder(view); + viewHolder.tv_title.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = viewHolder.getAdapterPosition(); + Nodes item = list.get(position); + list.get(orsel).setSel("unsel"); + list.get(position).setSel("sel"); + adapter.notifyItemChanged(orsel); + adapter.notifyItemChanged(position); + orsel = position; + requestStatement(item.getText()); + } + }); + return viewHolder; + } + + @Override + public void onBindViewHolder(@NonNull WebAdapter.ViewHolder holder, int position) { + Nodes item = list.get(position); + holder.tv_title.setText(item.getText()); + if (item.getSel().equals("sel")){ + holder.tv_title.setTextColor(context.getResources().getColor(R.color.white)); + holder.tv_title.setBackground(context.getResources().getDrawable(R.drawable.bg_layout_shape_type_blue)); + }else { + holder.tv_title.setTextColor(context.getResources().getColor(R.color.gray)); + holder.tv_title.setBackground(context.getResources().getDrawable(R.drawable.bg_layout_shape_type_white)); + } + } + + @Override + public int getItemCount() { + return list.size(); + } + + class ViewHolder extends RecyclerView.ViewHolder{ + TextView tv_title; + public ViewHolder(@NonNull View itemView) { + super(itemView); + tv_title = itemView.findViewById(R.id.moudle_item_monitor_screen_tv_title); + } + } + + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/background/locationservice/LocationService.java b/app/src/main/java/com/sipai/jspatrol/background/locationservice/LocationService.java new file mode 100644 index 0000000..df49f5f --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/background/locationservice/LocationService.java @@ -0,0 +1,255 @@ +package com.sipai.jspatrol.background.locationservice; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.util.Log; + +import com.baidu.location.BDAbstractLocationListener; +import com.baidu.location.BDLocation; +import com.baidu.location.LocationClient; +import com.baidu.location.LocationClientOption; +import com.google.gson.Gson; +import com.sipai.jspatrol.Application.App; +import com.sipai.jspatrol.Bean.PatrolLocation; +import com.sipai.jspatrol.URL.MethodURL; +import com.sipai.jspatrol.utils.OKHttpUtils; + +import org.litepal.LitePal; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Response; + + +public class LocationService extends NotificationService { + + private double la = 0; + private double lo = 0; + private String IMEI; + private String mServer; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mBizid; + private SimpleDateFormat simpleDF; + private Date dtnow; + private LocationClient mLocationClient; + private MyLocationListener myListener = new MyLocationListener(); +// private List locations = new ArrayList<>(); + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + super.onStartCommand(intent, flags, startId); + + return START_STICKY; + } + + public void init() { + SharedPreferences sharedPre = getSharedPreferences("config", MODE_PRIVATE); + IMEI = sharedPre.getString("imei",""); + mServer = sharedPre.getString("server", ""); + mUsername = sharedPre.getString("username", ""); + mPassword = sharedPre.getString("password", ""); + mUserid = sharedPre.getString("userid", ""); + mCaption = sharedPre.getString("caption", ""); + mBizid = sharedPre.getString("bizid", ""); + simpleDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + } + + @Override + public void onCreate() { + super.onCreate(); + init(); + applyNotiKeepMech(); //开启利用notification提高进程优先级的机制 + ontimelocation(); + mLocationClient.start(); + } + + @Override + public void onDestroy() { + unApplyNotiKeepMech(); + stopLocation(); + super.onDestroy(); + } + + public void ontimelocation() { + //百度 + mLocationClient = new LocationClient(getApplicationContext()); + //声明LocationClient类 + mLocationClient.registerLocationListener(myListener); + //注册监听函数 + + LocationClientOption option = new LocationClientOption(); + +// option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); + option.setLocationMode(LocationClientOption.LocationMode.Battery_Saving); + //可选,设置定位模式,默认高精度 + //LocationMode.Hight_Accuracy:高精度; + //LocationMode. Battery_Saving:低功耗; + //LocationMode. Device_Sensors:仅使用设备; + + option.setCoorType("bd09ll"); + //可选,设置返回经纬度坐标类型,默认GCJ02 + //GCJ02:国测局坐标; + //BD09ll:百度经纬度坐标; + //BD09:百度墨卡托坐标; + //海外地区定位,无需设置坐标类型,统一返回WGS84类型坐标 + + option.setScanSpan(2500); + //可选,设置发起定位请求的间隔,int类型,单位ms + //如果设置为0,则代表单次定位,即仅定位一次,默认为0 + //如果设置非0,需设置1000ms以上才有效 + + option.setOpenGps(true); + //可选,设置是否使用gps,默认false + //使用高精度和仅用设备两种定位模式的,参数必须设置为true + + option.setLocationNotify(false); + //可选,设置是否当GPS有效时按照1S/1次频率输出GPS结果,默认false + + option.setIgnoreKillProcess(false); + //可选,定位SDK内部是一个service,并放到了独立进程。 + //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true) + + option.SetIgnoreCacheException(false); + //可选,设置是否收集Crash信息,默认收集,即参数为false + + option.setWifiCacheTimeOut(5 * 60 * 1000); + //可选,V7.2版本新增能力 + //如果设置了该接口,首次启动定位时,会先判断当前Wi-Fi是否超出有效期,若超出有效期,会先重新扫描Wi-Fi,然后定位 + + option.setEnableSimulateGps(false); + //可选,设置是否需要过滤GPS仿真结果,默认需要,即参数为false + + mLocationClient.setLocOption(option); + //mLocationClient为第二步初始化过的LocationClient对象 + //需将配置好的LocationClientOption对象,通过setLocOption方法传递给LocationClient对象使用 + //更多LocationClientOption的配置,请参照类参考中LocationClientOption类的详细说明 + } + + void stopLocation() { + if (mLocationClient.isStarted()) { + // 关闭前台定位服务 + mLocationClient.disableLocInForeground(true); + mLocationClient.unRegisterLocationListener(myListener); + mLocationClient.stop(); + } + } + + /** + * 实现实时位置回调监听 + */ + public class MyLocationListener extends BDAbstractLocationListener { + + @Override + public void onReceiveLocation(BDLocation location) { + try { + //保存全局变量 + App app = (App) getApplication(); + app.setLatitude(location.getLatitude()); + app.setLongitude(location.getLongitude()); + double latitude = location.getLatitude(); //获取纬度信息 + double longitude = location.getLongitude(); + Log.i("LocationNow", "Sa" +":"+ "latitude:" + latitude + ",longitude" + longitude); + if ((Math.abs(latitude - la) > 0.000001&&Math.abs(latitude - la)<0.0003)|| (Math.abs(longitude - lo) > 0.000001&&Math.abs(longitude - lo)<0.0003)) { + double aaa = GetDistance(longitude, latitude, lo, la); + String longs = String.valueOf(aaa); + String caca = longs.substring(0, longs.indexOf(".")); + final int caz = Integer.parseInt(caca); + Log.i("LocationNow", "SaveSuccess" +":"+caz+ ",latitude:" + latitude + ",longitude" + longitude); + if (caz > 0 && caz < 15) { + PatrolLocation pos = new PatrolLocation(); + pos.setLatitude(String.valueOf(latitude)); + pos.setLongitude(String.valueOf(longitude)); + pos.setUserid(mUserid); + dtnow = new Date(System.currentTimeMillis()); + pos.setInsdt(simpleDF.format(dtnow)); + pos.save(); +// postlocation(String.valueOf(latitude), String.valueOf(longitude)); + } + } + la = latitude; + lo = longitude; + } catch (Exception e) { + Log.i("PatrolActivity", "exception:" + e.toString()); + } +// List locations = LitePal.findAll(PatrolLocation.class); +// Gson gson = new Gson(); +// String loc_json = "{\"re1\":" + gson.toJson(locations) + "}"; +// String res = loc_json; + } + } + + private static double rad(double d) { + return d * Math.PI / 180.0; + } + + /** + * 计算距离 + * + * @param longitude1 + * @param latitude1 + * @param longitude2 + * @param latitude2 + * @return + */ + public static double GetDistance(double longitude1, double latitude1, double longitude2, double latitude2) { + double Lat1 = rad(latitude1); // 纬度 + + double Lat2 = rad(latitude2); + + double a = Lat1 - Lat2;//两点纬度之差 + + double b = rad(longitude1) - rad(longitude2); //经度之差 + + double s = 2 * Math.asin(Math + + .sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(Lat1) * Math.cos(Lat2) * Math.pow(Math.sin(b / 2), 2)));//计算两点距离的公式 + + s = s * 6378137.0;//弧长乘地球半径(半径为米) + + s = Math.round(s * 10000d) / 10000d;//精确距离的数值 + + return s; + + } + + //完成当前位置信息 +// private void postlocation(final String latitude, final String longitude) throws Exception { +// PatrolLocation pl = new PatrolLocation(); +// pl.setUserid(mUserid); +// pl.setLatitude(latitude); +// pl.setLongitude(longitude); +// Gson gson = new Gson(); +// String loc_json = ""; +// loc_json = gson.toJson(pl); +// HashMap map = new HashMap<>(); +// map.put("jsonMap",loc_json); +// OKHttpUtils.getClient().newCall(OKHttpUtils.OKHttpRequest(map, mServer, MethodURL.SubPatrolLocation_Method)).enqueue(new Callback() { +// @Override +// public void onFailure(Call call, IOException e) { +// Log.i("LocationNow", "onFailure: " + e.toString()); +// } +// +// @Override +// public void onResponse(Call call, Response response) throws IOException { +// final String res = response.body().string(); +//// if (res.contains("pass")) { +//// Log.i("LocationNow", "onSuccess: " + res + ",latitude:" + latitude + ",longitude" + longitude); +//// } else{ +//// Log.i("LocationNow", "onFailure: " + res + ",latitude:" + latitude + ",longitude" + longitude); +//// } +// } +// }); +// +// } + + +} diff --git a/app/src/main/java/com/sipai/jspatrol/background/locationservice/NotificationService.java b/app/src/main/java/com/sipai/jspatrol/background/locationservice/NotificationService.java new file mode 100644 index 0000000..56a5d69 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/background/locationservice/NotificationService.java @@ -0,0 +1,54 @@ +package com.sipai.jspatrol.background.locationservice; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + + +public class NotificationService extends Service { + + /** + * startForeground的 noti_id + */ + private static int NOTI_ID = 643681801; + + private Utils.CloseServiceReceiver mCloseReceiver; + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + mCloseReceiver = new Utils.CloseServiceReceiver(this); + registerReceiver(mCloseReceiver, Utils.getCloseServiceFilter()); + return START_STICKY; + } + + + @Override + public void onDestroy() { + if (mCloseReceiver != null) { + unregisterReceiver(mCloseReceiver); + mCloseReceiver = null; + } + + super.onDestroy(); + } + + + private final String mHelperServiceName = "com.hdsx.background.locationservice.LocationHelperService"; + + /** + * 触发利用notification增加进程优先级 + */ + protected void applyNotiKeepMech() { + startForeground(NOTI_ID, Utils.buildNotification(getBaseContext())); + } + + public void unApplyNotiKeepMech() { + stopForeground(true); + } + + @Override + public IBinder onBind(Intent intent) { + return null; + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/background/locationservice/PowerManagerUtil.java b/app/src/main/java/com/sipai/jspatrol/background/locationservice/PowerManagerUtil.java new file mode 100644 index 0000000..c708a5a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/background/locationservice/PowerManagerUtil.java @@ -0,0 +1,124 @@ +package com.sipai.jspatrol.background.locationservice; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.os.PowerManager; + +import java.lang.reflect.Method; +import java.util.concurrent.ThreadFactory; + +/** + * 获得PARTIAL_WAKE_LOCK , 保证在息屏状体下,CPU可以正常运行 + */ +public class PowerManagerUtil { + + private static class Holder { + public static PowerManagerUtil instance = new PowerManagerUtil(); + } + + + private PowerManager pm = null; + private PowerManager.WakeLock pmLock = null; + + /** + * 上次唤醒屏幕的触发时间 + */ + private long mLastWakupTime = System.currentTimeMillis(); + + /** + * 最小的唤醒时间间隔,防止频繁唤醒。默认20秒钟 + */ + private long mMinWakupInterval = 20 * 1000; + + private InnerThreadFactory mInnerThreadFactory = null; + + public static PowerManagerUtil getInstance() { + return Holder.instance; + } + + /** + * 判断屏幕是否处于点亮状态 + * + * @param context + */ + public boolean isScreenOn(final Context context) { + try { + Method isScreenMethod = PowerManager.class.getMethod("isScreenOn", + new Class[]{}); + if (pm == null) { + pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + } + boolean screenState = (Boolean) isScreenMethod.invoke(pm); + return screenState; + } catch (Exception e) { + return true; + } + } + + + /** + * 唤醒屏幕 + */ + public void wakeUpScreen(final Context context) { + + try { + acquirePowerLock(context, PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK); + } catch (Exception e) { + throw e; + } + } + + /** + * 根据levelAndFlags,获得PowerManager的WaveLock + * 利用worker thread去获得锁,以免阻塞主线程 + * @param context + * @param levelAndFlags + */ + private void acquirePowerLock(final Context context, final int levelAndFlags) { + if (context == null) { + throw new NullPointerException("when invoke aquirePowerLock , context is null which is unacceptable"); + } + + long currentMills = System.currentTimeMillis(); + + if (currentMills - mLastWakupTime < mMinWakupInterval) { + return; + } + + + mLastWakupTime = currentMills; + + if (mInnerThreadFactory == null) { + mInnerThreadFactory = new InnerThreadFactory(); + } + + mInnerThreadFactory.newThread(new Runnable() { + + @SuppressLint("InvalidWakeLockTag") + @Override + public void run() { + if (pm == null) { + pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + } + + if (pmLock != null) { + // release + pmLock.release(); + pmLock = null; + } + + pmLock = pm.newWakeLock(levelAndFlags, "MyTag"); + pmLock.acquire(); + pmLock.release(); + } + }).start(); + } + + private class InnerThreadFactory implements ThreadFactory { + + @Override + public Thread newThread(Runnable runnable) { + return new Thread(runnable); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/background/locationservice/Utils.java b/app/src/main/java/com/sipai/jspatrol/background/locationservice/Utils.java new file mode 100644 index 0000000..f3bac65 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/background/locationservice/Utils.java @@ -0,0 +1,203 @@ +/** + * + */ +package com.sipai.jspatrol.background.locationservice; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.graphics.Color; +import android.net.wifi.WifiManager; +import android.os.Build; +import android.os.Environment; +import android.text.TextUtils; +import android.util.Log; + +import com.sipai.jspatrol.R; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Locale; + + +public class Utils { + private static String CLOSE_BRODECAST_INTENT_ACTION_NAME="com.hdsx.background.locationservice.CloseService"; + private static SimpleDateFormat sdf = null; + private static NotificationManager mNotificationManager; + private final static String PRIMARY_CHANNEL = "bkswlocationservice"; + + public synchronized static String formatUTC(long l, String strPattern) { + if (TextUtils.isEmpty(strPattern)) { + strPattern = "yyyy-MM-dd HH:mm:ss"; + } + if (sdf == null) { + try { + sdf = new SimpleDateFormat(strPattern, Locale.CHINA); + } catch (Throwable e) { + } + } else { + sdf.applyPattern(strPattern); + } + return sdf == null ? "NULL" : sdf.format(l); + } + + public static Intent getExplicitIntent(Context context, Intent implicitIntent) { + if (context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { + return implicitIntent; + } + + // Retrieve all services that can match the given intent + PackageManager pm = context.getPackageManager(); + List resolveInfo = pm.queryIntentServices(implicitIntent, 0); + // Make sure only one match was found + if (resolveInfo == null || resolveInfo.size() != 1) { + return null; + } + // Get component info and create ComponentName + ResolveInfo serviceInfo = resolveInfo.get(0); + String packageName = serviceInfo.serviceInfo.packageName; + String className = serviceInfo.serviceInfo.name; + ComponentName component = new ComponentName(packageName, className); + // Create a new intent. Use the old one for extras and such reuse + Intent explicitIntent = new Intent(implicitIntent); + // Set the component to be explicit + explicitIntent.setComponent(component); + + return explicitIntent; + } + + public static void saveFile(String toSaveString, String fileName, boolean append) { + try { + String sdCardRoot = Environment.getExternalStorageDirectory() + .getAbsolutePath(); + File saveFile = new File(sdCardRoot + "/" + fileName); + if (!saveFile.exists()) { + File dir = new File(saveFile.getParent()); + dir.mkdirs(); + saveFile.createNewFile(); + } + FileOutputStream outStream = new FileOutputStream(saveFile, append); + outStream.write(toSaveString.getBytes()); + outStream.write("\n".getBytes()); + outStream.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void saveFile2(Context context,String toSaveString, String fileName, boolean append) { + try { + String mDownloadUrl = context.getExternalCacheDir().getPath(); + + File dir = new File(mDownloadUrl); + File mFile = new File(dir.getPath(),fileName); + + Log.e("下载地址下载地址下载地址", dir.getPath()+dir.getName()+""); + + if(!dir.exists()){ + dir.mkdirs(); + } + + FileOutputStream outStream = new FileOutputStream(mFile, append); + outStream.write(toSaveString.getBytes()); + outStream.write("\n".getBytes()); + outStream.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + public static Notification buildNotification(Context context) { + Notification notification = null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationChannel channel = new NotificationChannel(PRIMARY_CHANNEL, + "轨迹记录中...", NotificationManager.IMPORTANCE_DEFAULT); + channel.setLightColor(Color.GREEN); + channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); + + getNotificationManager(context).createNotificationChannel(channel); + Notification.Builder builder = new Notification.Builder(context,PRIMARY_CHANNEL) +// .setChannelId(channel.getId()) + .setContentText("巡检运行中...") + .setSmallIcon(R.mipmap.moudle_ipatrol_logo) + .setVisibility(Notification.VISIBILITY_PRIVATE) + .setAutoCancel(true); + notification = builder.build(); + } else { + Notification.Builder builder = new Notification.Builder(context); + builder.setSmallIcon(R.mipmap.moudle_ipatrol_logo); + builder.setContentText("巡检运行中..." ) + .setWhen(System.currentTimeMillis()); + notification = builder.build(); + } + + return notification; + } + + private static NotificationManager getNotificationManager(Context context) { + if (mNotificationManager == null) { + mNotificationManager = (NotificationManager)context.getSystemService( + Context.NOTIFICATION_SERVICE); + } + return mNotificationManager; + } + + public static void startWifi(Context context) { + WifiManager wm = (WifiManager) context + .getSystemService(Context.WIFI_SERVICE); + wm.setWifiEnabled(true); + wm.reconnect(); + } + + public static boolean isWifiEnabled(Context context) { + WifiManager wm = (WifiManager) context + .getSystemService(Context.WIFI_SERVICE); + return wm.isWifiEnabled(); + } + + public static String getManufacture(Context context) { + return Build.MANUFACTURER; + } + + public static Intent getCloseBrodecastIntent() { + return new Intent(CLOSE_BRODECAST_INTENT_ACTION_NAME); + } + + public static IntentFilter getCloseServiceFilter() { + return new IntentFilter(CLOSE_BRODECAST_INTENT_ACTION_NAME); + } + + public static class CloseServiceReceiver extends BroadcastReceiver { + + Service mService; + + public CloseServiceReceiver(Service service) { + this.mService = service; + } + + @Override + public void onReceive(Context context, Intent intent) { + if (mService == null) { + return; + } + mService.onDestroy(); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/setting/SettingActivity.java b/app/src/main/java/com/sipai/jspatrol/setting/SettingActivity.java new file mode 100644 index 0000000..c5108eb --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/setting/SettingActivity.java @@ -0,0 +1,189 @@ +package com.sipai.jspatrol.setting; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +import com.sipai.jspatrol.Base.ActivityCollector; +import com.sipai.jspatrol.R; +import com.sipai.jspatrol.utils.SharedPreferencesData; + +import java.util.HashMap; +import java.util.Map; + +import cn.pedant.SweetAlert.SweetAlertDialog; + +public class SettingActivity extends AppCompatActivity implements View.OnClickListener { + + private EditText edt_in_plant,edt_off_site; + private Button btn_no,btn_ok; + private String ip_in_plant="",ip_off_site=""; + private String androidId; + private TextView tv_id; + + public static void actionStart(Context context){ + Intent intent = new Intent(context,SettingActivity.class); + context.startActivity(intent); + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_setting); + ActivityCollector.addActivity(this); + inits(); + initView(); + } + + private void inits() { + SharedPreferences sharedPre=getSharedPreferences("config", 0); + if (sharedPre.getString("ip_in_plant", "")!=null&&sharedPre.getString("ip_in_plant", "").length()>0) { + ip_in_plant = sharedPre.getString("ip_in_plant", ""); + } + if (sharedPre.getString("ip_off_site", "")!=null&&sharedPre.getString("ip_off_site", "").length()>0) { + ip_off_site=sharedPre.getString("ip_off_site", ""); + } + TelephonyManager tm = (TelephonyManager) SettingActivity.this.getSystemService(TELEPHONY_SERVICE); +// mtyb = android.os.Build.BRAND;// 手机品牌 +// mtype = android.os.Build.MODEL; // 手机型号 +// imei = tm.getDeviceId();//uuid + androidId = Settings.System.getString( + getContentResolver(), Settings.Secure.ANDROID_ID);//10.0以后获取不到UUID,用androidId来代表唯一性 + } + + private void initView() { + edt_in_plant = (EditText) findViewById(R.id.moudle_edit_ip_edt_in); + edt_off_site = (EditText) findViewById(R.id.moudle_edit_ip_edt_off); + if (ip_in_plant.length()>0){ + edt_in_plant.setText(ip_in_plant); + } + if (ip_off_site.length()>0){ + edt_off_site.setText(ip_off_site); + } + tv_id = findViewById(R.id.moudle_setting_tv_id); + tv_id.setText(androidId); + btn_no = (Button) findViewById(R.id.moudle_edit_ip_btn_no); + btn_no.setOnClickListener(this); + btn_ok = (Button) findViewById(R.id.moudle_edit_ip_btn_ok); + btn_ok.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + switch (view.getId()){ + case R.id.moudle_edit_ip_btn_no: + Intent intent = new Intent(); + setResult(RESULT_OK,intent); + finish(); + break; + case R.id.moudle_edit_ip_btn_ok: + if (edt_in_plant.getText()!=null&&edt_in_plant.getText().toString().length()>5){ + ip_in_plant = edt_in_plant.getText().toString().trim(); + }else { + ip_in_plant = "no"; + } + if (edt_off_site.getText()!=null&&edt_off_site.getText().toString().length()>5){ + ip_off_site = edt_off_site.getText().toString(); + }else { + ip_off_site = "no"; + } + if (ip_in_plant.equals("no")&&ip_off_site.equals("no")){ + noText("all"); + }else if (ip_in_plant.equals("no")&&!ip_off_site.equals("no")){ + noText("in"); + }else if (!ip_in_plant.equals("no")&&ip_off_site.equals("no")){ + noText("off"); + }else { + saveIP(ip_in_plant,ip_off_site); + } + break; + } + } + + private void saveIP(String st_in, String st_off) { + if (st_in.contains(":")||st_off.contains(":")){ + st_in = st_in.replaceAll(":",":"); + st_off = st_off.replaceAll(":",":"); + } + st_in = st_in.replaceAll(" ",""); + st_off = st_off.replace(" ",""); + SharedPreferencesData sharedPreferencesData = new SharedPreferencesData(this); + Map map = new HashMap<>(); + map.put("ip_in_plant",st_in); + map.put("ip_off_site",st_off); + sharedPreferencesData.saveInfo(map); + Intent intent = new Intent(); + setResult(RESULT_OK,intent); + finish(); + } + + private void noText(final String st) { + runOnUiThread(new Runnable() { + @Override + public void run() { + if (st.equals("all")){ + new SweetAlertDialog(SettingActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到厂内厂外IP均未设置,请至少设置一项后点击保存") + .setConfirmText("确定") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + }else if (st.equals("in")){ + new SweetAlertDialog(SettingActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到厂内IP未设置,是否设置?") + .setConfirmText("否") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + saveIP(ip_in_plant,ip_off_site); + } + }).setCancelText("设置") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + }else if (st.equals("off")){ + new SweetAlertDialog(SettingActivity.this, SweetAlertDialog.WARNING_TYPE) + .setTitleText("提示") + .setContentText("检测到厂外IP未设置,是否设置?") + .setConfirmText("否") + .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + saveIP(ip_in_plant,ip_off_site); + } + }).setCancelText("设置") + .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { + @Override + public void onClick(SweetAlertDialog sweetAlertDialog) { + sweetAlertDialog.dismissWithAnimation(); + } + }).show(); + } + } + }); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + ActivityCollector.removeActivity(this); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/AESUtils.java b/app/src/main/java/com/sipai/jspatrol/utils/AESUtils.java new file mode 100644 index 0000000..5f32513 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/AESUtils.java @@ -0,0 +1,90 @@ +package com.sipai.jspatrol.utils; + + +import java.security.SecureRandom; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +public class AESUtils { + public static String encrypt(String seed, String cleartext) + throws Exception { + byte[] rawKey = getRawKey(seed.getBytes()); + byte[] result = encrypt(rawKey, cleartext.getBytes()); + return toHex(result); + } + + public static String decrypt(String seed, String encrypted) + throws Exception { + byte[] rawKey = getRawKey(seed.getBytes()); + byte[] enc = toByte(encrypted); + byte[] result = decrypt(rawKey, enc); + return new String(result); + } + + private static byte[] getRawKey(byte[] seed) throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto"); + sr.setSeed(seed); + kgen.init(128, sr); + SecretKey skey = kgen.generateKey(); + byte[] raw = skey.getEncoded(); + return raw; + } + + private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception { + SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); + Cipher cipher = Cipher.getInstance("AES"); + cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec( + new byte[cipher.getBlockSize()])); + byte[] encrypted = cipher.doFinal(clear); + return encrypted; + } + + private static byte[] decrypt(byte[] raw, byte[] encrypted) + throws Exception { + SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); + Cipher cipher = Cipher.getInstance("AES"); + cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec( + new byte[cipher.getBlockSize()])); + byte[] decrypted = cipher.doFinal(encrypted); + return decrypted; + } + + private static String toHex(String txt) { + return toHex(txt.getBytes()); + } + + private static String fromHex(String hex) { + return new String(toByte(hex)); + } + + private static byte[] toByte(String hexString) { + int len = hexString.length() / 2; + byte[] result = new byte[len]; + for (int i = 0; i < len; i++) + result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), + 16).byteValue(); + return result; + } + + private static String toHex(byte[] buf) { + if (buf == null) + return ""; + StringBuffer result = new StringBuffer(2 * buf.length); + for (int i = 0; i < buf.length; i++) { + appendHex(result, buf[i]); + } + return result.toString(); + } + + private final static String HEX = "0123456789ABCDEF"; + + private static void appendHex(StringBuffer sb, byte b) { + sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f)); + } +} + diff --git a/app/src/main/java/com/sipai/jspatrol/utils/AndroidFileUtil.java b/app/src/main/java/com/sipai/jspatrol/utils/AndroidFileUtil.java new file mode 100644 index 0000000..01f3bef --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/AndroidFileUtil.java @@ -0,0 +1,174 @@ +package com.sipai.jspatrol.utils; + +import android.content.Intent; +import android.net.Uri; +import android.os.Build; + +import java.io.File; + +/** + * created by lvliming on 2019/10/23 + */ +public class AndroidFileUtil { + public static Intent openFile(String filePath, Uri fileUri) { + System.out.println("打开的文件路径 : " + filePath); + File file = new File(filePath); + if (!file.exists()) { + return null; + } + /* + 取得扩展名 + */ + String fileName = file.getName(); + String end = fileName.substring(file.getName().lastIndexOf(".") + 1, + file.getName().length()).toLowerCase(); + /* 依扩展名的类型决定MimeType */ + Intent intent = null; + if (end.equals("jpg") || end.equals("gif") || end.equals("png") + || end.equals("jpeg") || end.equals("bmp")) { + intent = getImageFileIntent(filePath, fileUri); + } else if (end.equals("ppt")) { + intent = getPptFileIntent(filePath, fileUri); + } else if (end.equals("xls") || end.equals("xlsx") || end.equals("xml")) { + intent = getExcelFileIntent(filePath, fileUri); + } else if (end.equals("doc")) { + intent = getWordFileIntent(filePath, fileUri); + } else if (end.equals("docx")) { + intent = getWordFileIntent(filePath, fileUri); + } else if (end.equals("pdf")) { + intent = getPdfFileIntent(filePath, fileUri); + } else if (end.equals("chm")) { + intent = getChmFileIntent(filePath, fileUri); + } else if (end.equals("txt")) { + intent = getTextFileIntent(filePath, false, fileUri); + } + if (end.equals("mp4")) { + intent = getMp4FileIntent(filePath, fileUri); + } + return intent; + } + + // 播放音乐 + public static Intent openMusic(String filePath, Uri fileUri) { + File file = new File(filePath); + System.out.println("打开的文件路径 : " + filePath); + if (!file.exists()) { + return null; + } + /* 取得扩展名 */ + String fileName = file.getName(); + String end = fileName.substring(file.getName().lastIndexOf(".") + 1, + file.getName().length()).toLowerCase(); + /* 依扩展名的类型决定MimeType */ + Intent intent = null; + intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Uri uri = uriString(filePath, fileUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "audio/*"); + return intent; + } + + private static Intent getMp4FileIntent(String param, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Uri uri = uriString(param, filUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "video/mp4"); + return intent; + } + + public static Intent getImageFileIntent(String param, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Uri uri = uriString(param, filUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "image/*"); + return intent; + } // Android获取一个用于打开PPT文件的intent + + public static Intent getPptFileIntent(String param, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Uri uri = uriString(param, filUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); + return intent; + } + + // Android获取一个用于打开Excel文件的intent + public static Intent getExcelFileIntent(String param, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Uri uri = uriString(param, filUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "application/vnd.ms-excel"); + return intent; + } + + // Android获取一个用于打开Word文件的intent + public static Intent getWordFileIntent(String param, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // Uri uri = Uri.fromFile(new File(param)); + Uri uri = uriString(param, filUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "application/msword"); + return intent; + } + + // Android获取一个用于打开CHM文件的intent + public static Intent getChmFileIntent(String param, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Uri uri = uriString(param, filUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "application/x-chm"); + return intent; + } + + // Android获取一个用于打开文本文件的intent + public static Intent getTextFileIntent(String param, boolean paramBoolean, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + if (paramBoolean) { + Uri uri1 = Uri.parse(param); + intent.setDataAndType(uri1, "text/plain"); + } else { + Uri uri2 = Uri.fromFile(new File(param)); + intent.setDataAndType(uri2, "text/plain"); + } + return intent; + } + + // Android获取一个用于打开PDF文件的intent + public static Intent getPdfFileIntent(String param, Uri filUri) { + Intent intent = new Intent("android.intent.action.VIEW"); + intent.addCategory("android.intent.category.DEFAULT"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // Uri uri = Uri.fromFile(new File(param)); + Uri uri = uriString(param, filUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intent.setDataAndType(uri, "application/pdf"); + return intent; + } + + public static Uri uriString(String param, Uri filUri) { + Uri uri; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + //data是file类型,忘了复制过来 + uri = filUri; + } else { + uri = Uri.fromFile(new File(param)); + } + return uri; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/AsyncImageLoader.java b/app/src/main/java/com/sipai/jspatrol/utils/AsyncImageLoader.java new file mode 100644 index 0000000..a6f662c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/AsyncImageLoader.java @@ -0,0 +1,147 @@ +package com.sipai.jspatrol.utils; + +import android.graphics.drawable.Drawable; +import android.os.Handler; +import android.util.Log; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.ref.SoftReference; +import java.net.URL; +import java.util.HashMap; + +public class AsyncImageLoader { + private Object lock = new Object(); + private boolean mAllowLoad = true; + private boolean firstLoad = true; + private int mStartLoadLimit = 0; + private int mStopLoadLimit = 0; + final Handler handler = new Handler(); + + private HashMap> imageCache; + + public AsyncImageLoader() { + imageCache = new HashMap>(); + } + + public void setLoadLimit(int startLoadLimit, int stopLoadLimit) { + if (startLoadLimit > stopLoadLimit) { + return; + } + mStartLoadLimit = startLoadLimit; + mStopLoadLimit = stopLoadLimit; + } + + public void restore() { + mAllowLoad = true; + firstLoad = true; + } + + public void lock() { + mAllowLoad = false; + firstLoad = false; + } + + public void unlock() { + mAllowLoad = true; + synchronized (lock) { + lock.notifyAll(); + } + } + +public Drawable loadDrawable(final Integer pos, final String imageUrl, + final ImageCallback imageCallback) { + new Thread() { + @Override + public void run() { + if (!mAllowLoad) {// 先阻塞线程 + synchronized (lock) {// 加锁 + try { + lock.wait(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + // 如果是第一次加载XML就加载图片,对于是不是在显示范围内的加载控制放在VIEW中 + if (mAllowLoad && firstLoad) { + LoadImg(pos, imageUrl, imageCallback); + } + // 对于在显示范围内的,对其加载IMG + if (mAllowLoad && pos <= mStopLoadLimit + && pos >= mStartLoadLimit) { + LoadImg(pos, imageUrl, imageCallback); + } + + } + }.start(); + return null; +}// loadDrawable---end + + public void LoadImg(final Integer pos, final String imageUrl, + final ImageCallback imageCallback) { + // 首先判断是否在缓存中 + // 但有个问题是:ImageCache可能会越来越大,以至用户内存用光,所以要用SoftReference(弱引用)来实现 + if (imageCache.containsKey(imageUrl)) { + SoftReference softReference = imageCache.get(imageUrl); + final Drawable drawable = softReference.get(); + if (drawable != null) { + handler.post(new Runnable() { + @Override + public void run() { + if (mAllowLoad) { + imageCallback.onImageLoad(pos, drawable); + Log.d("msg","缓存加载的"+imageUrl+";POS:"+pos); + }else { + imageCallback.onError(pos); + } + } + }); + return; + } + } + // 尝试从URL中加载 + try { + final Drawable drawable = loadImageFromUrl(imageUrl); + if (drawable != null) { + imageCache.put(imageUrl, new SoftReference(drawable)); + } + handler.post(new Runnable() { + @Override + public void run() { + if (mAllowLoad) { + Log.d("msg","网上加载的"+imageUrl+";POS:"+pos); + imageCallback.onImageLoad(pos, drawable); + } + } + }); + } catch (IOException e) { + handler.post(new Runnable() { + @Override + public void run() { + imageCallback.onError(pos); + } + }); + e.printStackTrace(); + } + + } + + // 根据URL加载图片,如果出现错误throws IOException式的错误,以便在LoadImg中捕获,执行OnError()函数 + public static Drawable loadImageFromUrl(String url) throws IOException { + URL m; + InputStream i = null; + m = new URL(url); + i = (InputStream) m.getContent(); + Drawable d = Drawable.createFromStream(i, "src"); + return d; + } + + // 回调函数 + public interface ImageCallback { + void onImageLoad(Integer t, Drawable drawable); + void onError(Integer t); + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/BroadCastManager.java b/app/src/main/java/com/sipai/jspatrol/utils/BroadCastManager.java new file mode 100644 index 0000000..ec2a65e --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/BroadCastManager.java @@ -0,0 +1,35 @@ +package com.sipai.jspatrol.utils; + +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Intent; +import android.content.IntentFilter; + +/** + * Created by lvliming on 2018/1/3. + */ + +public class BroadCastManager { + private static BroadCastManager broadCastManager = new BroadCastManager(); + + public static BroadCastManager getInstance() { + return broadCastManager; + } + + //注册广播接收者 + public void registerReceiver(Activity activity, + BroadcastReceiver receiver, IntentFilter filter) { + activity.registerReceiver(receiver, filter); + } + + //注销广播接收者 + public void unregisterReceiver(Activity activity, + BroadcastReceiver receiver) { + activity.unregisterReceiver(receiver); + } + + //发送广播 + public void sendBroadCast(Activity activity, Intent intent) { + activity.sendBroadcast(intent); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/CookieUtils.java b/app/src/main/java/com/sipai/jspatrol/utils/CookieUtils.java new file mode 100644 index 0000000..81ea93c --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/CookieUtils.java @@ -0,0 +1,80 @@ +package com.sipai.jspatrol.utils; + +import android.content.Context; +import android.text.TextUtils; +import android.util.Log; + +import com.loopj.android.http.AsyncHttpClient; +import com.loopj.android.http.PersistentCookieStore; + +import org.apache.http.cookie.Cookie; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by lvliming on 2017/11/15. + */ + +public class CookieUtils { + private static List cookies; + + /* 返回cookies列表 */ + public static List getCookies() { + return cookies != null ? cookies : new ArrayList(); + } + + /* 设置cookies列表 */ + public static void setCookies(List cookies) { + CookieUtils.cookies = cookies; + } + + /* 存储cookie */ + public static void saveCookie(AsyncHttpClient client, Context context) { + PersistentCookieStore cookieStore = new PersistentCookieStore(context); + client.setCookieStore(cookieStore); + } + + /* 得到cookie */ + public static List getCookie(Context context) { + PersistentCookieStore cookieStore = new PersistentCookieStore(context); + List cookies = cookieStore.getCookies(); + return cookies; + } + + /* 清除cookie */ + public static void clearCookie(Context context) { + PersistentCookieStore cookieStore = new PersistentCookieStore(context); + cookieStore.clear(); + } + /** + * 获取标准 Cookie + */ + public static String getCookieText(Context context) { + PersistentCookieStore myCookieStore = new PersistentCookieStore(context); + List cookies = myCookieStore.getCookies(); + for (Cookie cookie : cookies) { + Log.d("cookieUtils", cookie.getName() + " = " + cookie.getValue()); + } + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < cookies.size(); i++) { +// Cookie cookie = cookies.get((cookies.size()-1)); + Cookie cookie = cookies.get(i); + String cookieName = cookie.getName(); + String cookieValue = cookie.getValue(); + String cookiepath = cookie.getPath(); + String cookiedomain = cookie.getDomain(); + if (!TextUtils.isEmpty(cookieName) + && !TextUtils.isEmpty(cookieValue)) { + sb.append(cookieName + "="); + sb.append(cookieValue + ";"); + sb.append("domain" + "="); + sb.append(cookiedomain+";"); + sb.append("path" + "="); + sb.append(cookiepath + ";"); + } + } + Log.e("cookie", sb.toString()); + return sb.toString(); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/CrashHandler.java b/app/src/main/java/com/sipai/jspatrol/utils/CrashHandler.java new file mode 100644 index 0000000..290de79 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/CrashHandler.java @@ -0,0 +1,352 @@ +package com.sipai.jspatrol.utils; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.SharedPreferences; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Build; +import android.os.Environment; +import android.os.Looper; +import android.util.Base64; +import android.util.Log; +import android.view.WindowManager; + +import com.sipai.jspatrol.R; + +import org.apache.http.protocol.HTTP; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.lang.Thread.UncaughtExceptionHandler; +import java.lang.reflect.Field; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * UncaughtException处理类,当程序发生Uncaught异常的时候,有该类来接管程序,并记录发送错误报告. + * + * @author user + * + */ +public class CrashHandler implements UncaughtExceptionHandler { + + public static final String TAG = "CrashHandler"; + + //系统默认的UncaughtException处理类 + private UncaughtExceptionHandler mDefaultHandler; + //CrashHandler实例 + private static CrashHandler INSTANCE = new CrashHandler(); + //程序的Context对象 + private Context mContext; + //用来存储设备信息和异常信息 + private Map infos = new HashMap(); + + //用于格式化日期,作为日志文件名的一部分 + private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); + private HttpURLConnection conn; + private URL url; + /** 保证只有一个CrashHandler实例 */ + private CrashHandler() { + } + + /** 获取CrashHandler实例 ,单例模式 */ + public static CrashHandler getInstance() { + return INSTANCE; + } + + /** + * 初始化 + * + * @param context + */ + public void init(Context context) { + mContext = context; + //获取系统默认的UncaughtException处理器 + mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); + //设置该CrashHandler为程序的默认处理器 + Thread.setDefaultUncaughtExceptionHandler(this); + } + + /** + * 当UncaughtException发生时会转入该函数来处理 + */ + @Override + public void uncaughtException(Thread thread, Throwable ex) { + if (!handleException(ex) && mDefaultHandler != null) { + //如果用户没有处理则让系统默认的异常处理器来处理 + mDefaultHandler.uncaughtException(thread, ex); + } else { + try { + Thread.sleep(15000); + } catch (InterruptedException e) { + Log.e(TAG, "error : ", e); + } + //退出程序 + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(1); + } + } + + /** + * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成. + * + * @param ex + * @return true:如果处理了该异常信息;否则返回false. + */ + private boolean handleException(Throwable ex) { + if (ex == null) { + return false; + } + //使用Toast来显示异常信息 + new Thread() { + @Override + public void run() { + Looper.prepare(); + sendAppCrashReport(mContext,"",null); +// Toast.makeText(mContext, "很抱歉,程序出现异常,即将退出.", Toast.LENGTH_LONG).show(); + Looper.loop(); + } + }.start(); + //收集设备参数信息 + collectDeviceInfo(mContext); + //保存日志文件 + saveCrashInfo2File(ex); + return true; + } + private void sendAppCrashReport(final Context context, + final String crashReport, final File file) { + AlertDialog.Builder builder = new AlertDialog.Builder(context) + .setIcon(android.R.drawable.ic_dialog_info) + .setTitle(R.string.app_error) + .setMessage(R.string.app_error_msg) + .setPositiveButton("确定", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { +// try { +// //发送报告到服务器 +// +// } catch (Exception e) { +// } finally { + dialog.dismiss(); + // 退出 + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(1); +// } + } + }); +// .setNegativeButton(android.R.string.cancel, +// new DialogInterface.OnClickListener() { +// public void onClick(DialogInterface dialog, int which) { +// dialog.dismiss(); +// // 退出 +// android.os.Process.killProcess(android.os.Process.myPid()); +// System.exit(1); +// } +// }); + + AlertDialog dialog = builder.create(); + //需要的窗口句柄方式,没有这句会报错的 + if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){ + dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); + }else { + dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + } + dialog.show(); + } + /** + * 收集设备参数信息 + * @param ctx + */ + public void collectDeviceInfo(Context ctx) { + try { + PackageManager pm = ctx.getPackageManager(); + PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES); + if (pi != null) { + String versionName = pi.versionName == null ? "null" : pi.versionName; + String versionCode = pi.versionCode + ""; + infos.put("versionName", versionName); + infos.put("versionCode", versionCode); + } + } catch (NameNotFoundException e) { + Log.e(TAG, "an error occured when collect package info", e); + } + Field[] fields = Build.class.getDeclaredFields(); + for (Field field : fields) { + try { + field.setAccessible(true); + infos.put(field.getName(), field.get(null).toString()); + Log.d(TAG, field.getName() + " : " + field.get(null)); + } catch (Exception e) { + Log.e(TAG, "an error occured when collect crash info", e); + } + } + } + + /** + * 保存错误信息到文件中 + * + * @param ex + * @return 返回文件名称,便于将文件传送到服务器 + */ + private String saveCrashInfo2File(Throwable ex) { + + StringBuffer sb = new StringBuffer(); + for (Map.Entry entry : infos.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + sb.append(key + "=" + value + "\n"); + } + + Writer writer = new StringWriter(); + PrintWriter printWriter = new PrintWriter(writer); + ex.printStackTrace(printWriter); + Throwable cause = ex.getCause(); + while (cause != null) { + cause.printStackTrace(printWriter); + cause = cause.getCause(); + } + printWriter.close(); + String result = writer.toString(); + sb.append(result); + try { +// long timestamp = System.currentTimeMillis(); + String time = formatter.format(new Date()); + final String fileName = mContext.getResources().getString(R.string.appflag).toLowerCase()+"-crash-" + time + ".txt"; + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { + final String path = "/sdcard/crash/"; + File dir = new File(path); + if (!dir.exists()) { + dir.mkdirs(); + } + FileOutputStream fos = new FileOutputStream(path + fileName); + fos.write(sb.toString().replaceAll("\n","\r\n").getBytes()); + fos.close(); + new Thread(new Runnable() { + @Override + public void run() { +// upFile(path,fileName); + } + }).start(); + + } + return fileName; + } catch (Exception e) { + Log.e(TAG, "an error occured while writing file...", e); + } + return null; + } + private String upFile(String path,String filename) { + + + ByteArrayOutputStream baos = null; + String _path = null; + try { + //构建host的url地址 + SharedPreferences sharedPre=mContext.getSharedPreferences("config", Context.MODE_PRIVATE); + String mServer=sharedPre.getString("server", ""); + String mBizid=sharedPre.getString("bizid", ""); + _path = path + filename; + byte[] photoBytes=null; + String BOUNDARY = "Boundary"; + String PREFIX = "--" , LINEND = "\r\n" ; + String MULTIPART_FROM_DATA = "multipart/form-data" ; + String CHARSET = "UTF-8" ; + //要上传的参数 + String param = "&filename=" + URLEncoder.encode(filename, "UTF-8"); + param+="&bizid=" + URLEncoder.encode(mBizid, "UTF-8"); + //通过openConnection 连接 + url=new URL(mServer+"proapp.do?method=dosavelog"+param); + conn=(HttpURLConnection)url.openConnection(); + //设置输入和输出流 + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setRequestMethod("POST"); + conn.setUseCaches(false); + conn.setRequestProperty("Connection", "Keep-Alive"); + conn.setRequestProperty("Charset", HTTP.UTF_8); + conn.setRequestProperty ( "Content-Type" , MULTIPART_FROM_DATA+";boundary=" + BOUNDARY ) ; + //HttpClient client = new DefaultHttpClient(); + conn.connect(); + baos = new ByteArrayOutputStream(); + File f=new File(_path); + if(f.exists()){ + /* 取得文件的FileInputStream */ + FileInputStream fStream =new FileInputStream(_path); + /* 设置每次写入1024bytes */ + int bufferSize =1024; + byte[] buffer =new byte[bufferSize]; + String bufferall=""; + int length =-1; + /* 从文件读取数据至缓冲区 */ + DataOutputStream out = new DataOutputStream ( + conn.getOutputStream ( ) ) ; + out.write("upLog ".getBytes());//标记图片流, 为与接口对应,需要在后面加空格 + while((length = fStream.read(buffer)) !=-1) + { + /* 将资料写入DataOutputStream中 */ + + baos.write(buffer); + + } + photoBytes=baos.toByteArray(); + out.write(Base64.encode(photoBytes, Base64.DEFAULT)); + //System.out.println(bufferall.getBytes(),Base64.DEFAULT).toString()); + //out.writeBytes(LINEND); + out.writeBytes( PREFIX + BOUNDARY + PREFIX + LINEND); + // OutputStream out = conn.getOutputStream ( ) ; + // out.write(Base64Coder.encodeLines(photoBytes).getBytes()); + //刷新、关闭 + out.flush(); + out.close(); + + } + + + if (HttpURLConnection.HTTP_OK == conn.getResponseCode() ) { +// System.out.println(conn.getContent()); +// Message message=Message.obtain(); +// message.what=SUCCESS; +// myHandler.sendMessage(message); + // System.out.println("上传完成"); + + } else { +// cancelProgress(); + // System.out.println("上传失败"); +// Message message=Message.obtain(); +// message.what=ERROR; +// myHandler.sendMessage(message); + } + + + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (baos != null) + baos.close(); + if (conn != null) { + // conn.disconnect(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return _path; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sipai/jspatrol/utils/DateFormatUtils.java b/app/src/main/java/com/sipai/jspatrol/utils/DateFormatUtils.java new file mode 100644 index 0000000..b708f87 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/DateFormatUtils.java @@ -0,0 +1,63 @@ +package com.sipai.jspatrol.utils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * created by lvliming on 2019/8/1 + */ +public class DateFormatUtils { + public static String DateFormatDayString(String st){ + String dateString = ""; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + try { + Date date = simpleDateFormat.parse(st); + dateString = simpleDateFormat.format(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return dateString; + } + public static String DateFormatMinString(String st){ + String dateString = ""; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + try { + Date date = simpleDateFormat.parse(st); + dateString = simpleDateFormat.format(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return dateString; + } + + public static String DateFormatMinStringPL(long st){ + String dateString = ""; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + dateString = simpleDateFormat.format(st); + return dateString; + } + + public static long pareSec(String time){ + + SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + + long s=0; + + try { + + s=sim.parse(time).getTime(); + + } catch (ParseException e) { + +// TODO Auto-generated catch block + + e.printStackTrace(); + + } + + return s; + + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleHandler.java b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleHandler.java new file mode 100644 index 0000000..fcc0be3 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleHandler.java @@ -0,0 +1,49 @@ +package com.sipai.jspatrol.utils.DoubleClickUtils; + +/** + * Created by lvliming on 2018/6/12. + */ + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; + +/** + * 连续点击事件监听器 可以用作双击事件 + * + */ +public class DoubleHandler extends Handler { + private OnDoubleClickListener mListener;//对是否双击结果的回调监听器 + private DoubleRunnable mDoubleRunnable;//负责双击事件的线程执行体 + + /** + * 双击事件处理器的构造函数 + * @param listener + * 对是否双击结果的回调监听器 + */ + public DoubleHandler(OnDoubleClickListener listener){ + super(Looper.getMainLooper()); + this.mListener = listener; + } + + @Override + public void handleMessage(Message msg) { + if ((boolean)msg.obj){ + mListener.onDoublePress(); + } + else { + mListener.onSinglePress(); + } + //通知双击事件线程执行体,事件已处理完 + mDoubleRunnable.setIsStarted(false); + } + + /** + * 设置handler处理所在的线程执行体 + * @param doubleRunnable + * 传入的当前线程执行体 + */ + public void setDoubleRunnable(DoubleRunnable doubleRunnable){ + this.mDoubleRunnable = doubleRunnable; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleManager.java b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleManager.java new file mode 100644 index 0000000..120d157 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleManager.java @@ -0,0 +1,51 @@ +package com.sipai.jspatrol.utils.DoubleClickUtils; + +/** + * Created by lvliming on 2018/6/12. + */ + +public class DoubleManager { + private DoubleRunnable mDoubleRunnable = null;//负责双击事件的线程执行体 + private Thread mThread = null;//负责双击事件的线程 + private long mClickTime = 0;//记录点击时间 + + private static final int DOUBLE_SPAN = 300;//用于判断双击的间隔时间 + + /** + * 双击事件管理器的构造函数 + * @param doubleRunnable + * 传入负责双击事件的线程执行体 + */ + public DoubleManager(DoubleRunnable doubleRunnable){ + if (doubleRunnable == null){ + return; + } + if (mDoubleRunnable == null){ + doubleRunnable.setDoubleSpan(DOUBLE_SPAN); + this.mDoubleRunnable = doubleRunnable; + } + } + + /** + * 开启双击事件的线程执行 + */ + public void start(){ + if (mDoubleRunnable == null){ + return; + } + boolean isDoubleClicked = false; + if ((System.currentTimeMillis() - mClickTime) < DOUBLE_SPAN) { + isDoubleClicked = true; + } + else { + isDoubleClicked = false; + mClickTime = System.currentTimeMillis(); + } + mDoubleRunnable.setPreparedState(true, isDoubleClicked); + if (mThread == null){ + mThread = new Thread(mDoubleRunnable); + mThread.start(); + } + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleRunnable.java b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleRunnable.java new file mode 100644 index 0000000..d65cae1 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/DoubleRunnable.java @@ -0,0 +1,81 @@ +package com.sipai.jspatrol.utils.DoubleClickUtils; + +import android.os.Message; + +/** + * Created by lvliming on 2018/6/12. + */ + +public class DoubleRunnable implements Runnable { + private DoubleHandler mHandler;//处理点击事件的handler + private boolean isStarted = false;//表示线程是否正处于阻塞中 + private boolean isPrepared = false;//表示是否已准备好启动线程 + private boolean isDoubleClicked = false;//表示是否被双击 + private int doubleSpan;//用于判断双击的间隔时间 + + /** + * 双击事件线程执行体的构造函数 + * @param handler + * 用于处理是否双击事件的handler + */ + public DoubleRunnable(DoubleHandler handler) { + handler.setDoubleRunnable(this); + this.mHandler = handler; + } + + @Override + public void run() { + + while (true){ + //如果没有被点击,则继续下次循环 + if (!isPrepared) { + continue; + } + isPrepared = false; + //如果线程处于一次双击事件的阻塞中,则继续下次循环,直至事件结束 + if (isStarted){ + continue; + } + isStarted = true; + try { + Thread.sleep(doubleSpan); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Message msg = mHandler.obtainMessage(); + msg.obj = isDoubleClicked; + mHandler.sendMessage(msg); + } + + } + + /** + * 设置当前双击事件的执行状态 + * @param isPrepared + * 是否已被点击(可以执行线程中代码) + * @param isDoubleClicked + * 是否已被双击 + */ + public void setPreparedState(boolean isPrepared, boolean isDoubleClicked) { + this.isPrepared = isPrepared; + this.isDoubleClicked = isDoubleClicked; + } + + /** + * 设置线程是否处于一次双击事件判断的阻塞之中 + * @param isStarted + * 传入是否阻塞开启 + */ + public void setIsStarted(boolean isStarted){ + this.isStarted = isStarted; + } + + /** + * 设置用于判断双击的间隔时间 + * @param doubleSpan + * 传入的时间间隔 + */ + public void setDoubleSpan(int doubleSpan){ + this.doubleSpan = doubleSpan; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/OnDoubleClickListener.java b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/OnDoubleClickListener.java new file mode 100644 index 0000000..30c97c9 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/DoubleClickUtils/OnDoubleClickListener.java @@ -0,0 +1,17 @@ +package com.sipai.jspatrol.utils.DoubleClickUtils; + +/** + * Created by lvliming on 2018/6/12. + */ + +public interface OnDoubleClickListener { + /** + * 用于处理单击事件 + */ + void onSinglePress(); + + /** + * 用于处理双击事件 + */ + void onDoublePress(); +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/EncryptUtils.java b/app/src/main/java/com/sipai/jspatrol/utils/EncryptUtils.java new file mode 100644 index 0000000..0f2b1c7 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/EncryptUtils.java @@ -0,0 +1,126 @@ +package com.sipai.jspatrol.utils; + + +import android.util.Base64; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.spec.SecretKeySpec; + +/** + * @ClassName : EncryptUtils + * @Description : 加密解密工具类 + * @Author : HJQ + * @Date: 2020-10-09 11:11 + */ +public class EncryptUtils { + + + //参数分别代表 算法名称/加密模式/数据填充方式 + + private static final String ALGORITHMSTR = "AES/ECB/PKCS7Padding"; + +// static { +// if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { +// System.out.println("security provider BC not found"); +// Security.addProvider(new BouncyCastleProvider()); +// } +// +// } + + //可配置到Constant中,并读取配置文件注入,16位,自己定义 + private static final String KEY = "34bfeacAB39053deb006df63"; + + + /** + * 加密 + * + * @param content 加密的字符串 + * @param encryptKey key值 + * @return + * @throws Exception + */ + public static String encrypt(String content, String encryptKey) throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128); + Cipher cipher = Cipher.getInstance(ALGORITHMSTR); + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES")); + byte[] b = cipher.doFinal(content.getBytes("utf-8")); + // 采用base64算法进行转码,避免出现中文乱码 + return Base64.encodeToString(b,Base64.DEFAULT); + + } + + /** + * 解密 + * + * @param encryptStr 解密的字符串 + * @param decryptKey 解密的key值 + * @return + * @throws Exception + */ + public static String decrypt(String encryptStr, String decryptKey) throws Exception { + KeyGenerator kgen = KeyGenerator.getInstance("AES"); + kgen.init(128); + Cipher cipher = Cipher.getInstance(ALGORITHMSTR); + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), "AES")); + // 采用base64算法进行转码,避免出现中文乱码 + byte[] encryptBytes = Base64.decode(encryptStr,Base64.DEFAULT); + byte[] decryptBytes = cipher.doFinal(encryptBytes); + return new String(decryptBytes); + } + + public static String encrypt(String content) throws Exception { + return encrypt(content, KEY); + } + + public static String decrypt(String encryptStr) throws Exception { + return decrypt(encryptStr, KEY); + } + + +// public static void main(String[] args) throws Exception { +// String name = "sipai"; +// String pwd = "123456"; +// +// String nameContent = JSONObject.toJSONString(name); +// String pwdContent = JSONObject.toJSONString(pwd); +// System.out.println("加密前:" + nameContent); +// System.out.println("加密前:" + pwdContent); +// +// String encryptName = encrypt(name, KEY); +// String encryptPwd = encrypt(pwd, KEY); +// System.out.println("加密后:" + encryptName); +// System.out.println("加密后:" + encryptPwd); +// +// String decryptName = decrypt(encryptName, KEY); +// String decryptPwd = decrypt(encryptPwd, KEY); +// System.out.println("解密后:" + decryptName); +// System.out.println("解密后:" + decryptPwd); +// } + + /** + * @Description: 根据body 获取数据 + * @Author: HJQ + * @Param request + * @Return: java.util.Map + * @Date: 2020/10/9 14:56 + */ +// public static HashMap getMap(HttpServletRequest request) { +// HashMap params = new HashMap(); +// BufferedReader br; +// try { +// br = request.getReader(); +// String str, wholeStr = ""; +// while ((str = br.readLine()) != null) { +// wholeStr += str; +// } +// if (StringUtils.isNotEmpty(wholeStr)) { +// params = JSON.parseObject(wholeStr, HashMap.class); +// } +// } catch (Exception e1) { +// } +// return params; +// } + +} \ No newline at end of file diff --git a/app/src/main/java/com/sipai/jspatrol/utils/FileChooseUtil.java b/app/src/main/java/com/sipai/jspatrol/utils/FileChooseUtil.java new file mode 100644 index 0000000..be414ce --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/FileChooseUtil.java @@ -0,0 +1,174 @@ +package com.sipai.jspatrol.utils; + +import android.annotation.SuppressLint; +import android.content.ContentUris; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.os.Build; +import android.os.Environment; +import android.provider.DocumentsContract; +import android.provider.MediaStore; +import android.widget.Toast; + +/** + * created by lvliming on 2019/10/21 + */ +public class FileChooseUtil { + private Context context; + private static FileChooseUtil util = null; + + private FileChooseUtil(Context context) { + this.context = context; + } + + public static FileChooseUtil getInstance(Context context) { + if (util == null) { + util = new FileChooseUtil(context); + } + return util; + } + + /** + * 对外接口 获取uri对应的路径 + * + * @param uri + * @return + */ + public String getChooseFileResultPath(Uri uri) { + String chooseFilePath = null; + if ("file".equalsIgnoreCase(uri.getScheme())) {//使用第三方应用打开 + chooseFilePath = uri.getPath(); + Toast.makeText(context, chooseFilePath, Toast.LENGTH_SHORT).show(); + return chooseFilePath; + } + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {//4.4以后 + chooseFilePath = getPath(context, uri); + } else {//4.4以下下系统调用方法 + chooseFilePath = getRealPathFromURI(uri); + } + return chooseFilePath; + } + + private String getRealPathFromURI(Uri contentUri) { + String res = null; + String[] proj = {MediaStore.Images.Media.DATA}; + Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null); + if (null != cursor && cursor.moveToFirst()) { + int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); + res = cursor.getString(column_index); + cursor.close(); + } + return res; + } + + /** + * 专为Android4.4设计的从Uri获取文件绝对路径,以前的方法已不好使 + */ + @SuppressLint("NewApi") + private String getPath(final Context context, final Uri uri) { + + final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; + + // DocumentProvider + if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { + // ExternalStorageProvider + if (isExternalStorageDocument(uri)) { + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; + + if ("primary".equalsIgnoreCase(type)) { + return Environment.getExternalStorageDirectory() + "/" + split[1]; + + } + } + // DownloadsProvider + else if (isDownloadsDocument(uri)) { + final String id = DocumentsContract.getDocumentId(uri); + final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); + return getDataColumn(context, contentUri, null, null); + + } + // MediaProvider + else if (isMediaDocument(uri)) { + final String docId = DocumentsContract.getDocumentId(uri); + final String[] split = docId.split(":"); + final String type = split[0]; + + Uri contentUri = null; + if ("image".equals(type)) { + contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; + + } else if ("video".equals(type)) { + contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; + + } else if ("audio".equals(type)) { + contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; + + } + + final String selection = "_id=?"; + final String[] selectionArgs = new String[]{split[1]}; + + return getDataColumn(context, contentUri, selection, selectionArgs); + + } + + } + // MediaStore (and general) + else if ("content".equalsIgnoreCase(uri.getScheme())) { + return getDataColumn(context, uri, null, null); + + } + // File + else if ("file".equalsIgnoreCase(uri.getScheme())) { + uri.getPath(); + + } + return null; + } + + private String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { + Cursor cursor = null; + final String column = "_data"; + final String[] projection = {column}; + try { + cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, + null); + if (cursor != null && cursor.moveToFirst()) { + final int column_index = cursor.getColumnIndexOrThrow(column); + return cursor.getString(column_index); + } + } finally { + if (cursor != null) + cursor.close(); + } + return null; + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is ExternalStorageProvider. + */ + private boolean isExternalStorageDocument(Uri uri) { + return "com.android.externalstorage.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is DownloadsProvider. + */ + private boolean isDownloadsDocument(Uri uri) { + return "com.android.providers.downloads.documents".equals(uri.getAuthority()); + } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is MediaProvider. + */ + private boolean isMediaDocument(Uri uri) { + return "com.android.providers.media.documents".equals(uri.getAuthority()); + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/FileProvider7.java b/app/src/main/java/com/sipai/jspatrol/utils/FileProvider7.java new file mode 100644 index 0000000..df3e0ea --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/FileProvider7.java @@ -0,0 +1,44 @@ +package com.sipai.jspatrol.utils; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; + +import androidx.core.content.FileProvider; + +import com.sipai.jspatrol.BuildConfig; + +import java.io.File; + +/** + * created by lvliming on 2019/10/23 + */ +public class FileProvider7 { + public static Uri getUriForFile(Context context, File file) { + Uri fileUri = null; + if (Build.VERSION.SDK_INT >= 24) { + fileUri = getUriForFile24(context, file); + } else { + fileUri = Uri.fromFile(file); + } + return fileUri; + } + + public static Uri getUriForFile24(Context context, File file) { + Uri fileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", file); + return fileUri; + } + + public static void setIntentDataAndType(Context context, Intent intent, String type, File file, boolean writeAble) { + if (Build.VERSION.SDK_INT >= 24) { + intent.setDataAndType(getUriForFile(context, file), type); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + if (writeAble) { + intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + } + } else { + intent.setDataAndType(Uri.fromFile(file), type); + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/FontUtils.java b/app/src/main/java/com/sipai/jspatrol/utils/FontUtils.java new file mode 100644 index 0000000..5f923b8 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/FontUtils.java @@ -0,0 +1,31 @@ +package com.sipai.jspatrol.utils; + +import android.content.Context; +import android.graphics.Typeface; +import android.widget.TextView; + +import java.util.List; + +/** + * created by lvliming on 2019/10/17 + */ +public class FontUtils { + +// public static final String iphone_black_1 = "iphone_1_simplified"; +// public static final String iphone_black_2 = "iphone_2_simplified"; +// public static final String iphone_black_3 = "iphone_3_simplified"; +// public static final String iphone_black_4 = "iphone_standard_simplified"; +// public static final String iphone_black_5 = "iphone_middle_black"; +// public static final String iphone_black_6 = "iphone_middle_thick"; + + public static void setFont(TextView tv, String st, Context context){ + Typeface typeface = Typeface.createFromAsset(context.getAssets(),"fonts/"+st+".ttf"); + tv.setTypeface(typeface); + } + public static void setFont(List views, String st, Context context){ + for (int i=0;i mXList; + + public MyMarkerView(Context context, int layoutResource, List xData) { + + super(context, layoutResource); + tvContent = findViewById(R.id.tvContent); + tv_marker_time = findViewById(R.id.tv_marker_time); + mXList = xData; + } + + // callbacks everytime the MarkerView is redrawn, can be used to update the + // content (user-interface) + @Override + public void refreshContent(Entry e, Highlight highlight) { + + if (e instanceof CandleEntry) { + + CandleEntry ce = (CandleEntry) e; + + tvContent.setText(Utils.formatNumber(ce.getHigh(), 0, true)); + + } else { + //这里 + tvContent.setText(String.valueOf( e.getY())); + + String time = mXList.get((int)e.getX()); + tv_marker_time.setText(time); + + } + + super.refreshContent(e, highlight); + } + + @Override + public MPPointF getOffset() { + return new MPPointF(-(getWidth() / 2), -getHeight()); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/OKHttpUtils.java b/app/src/main/java/com/sipai/jspatrol/utils/OKHttpUtils.java new file mode 100644 index 0000000..ea43831 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/OKHttpUtils.java @@ -0,0 +1,157 @@ +package com.sipai.jspatrol.utils; +import com.sipai.jspatrol.utils.okHttpCookie.CookiesManager; + +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import okhttp3.Call; +import okhttp3.FormBody; +import okhttp3.MediaType; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; + +/** + * created by lvliming on 2020/5/8 + */ +public class OKHttpUtils { + + public static OkHttpClient getClient(){ + OkHttpClient.Builder clientBuilder = new OkHttpClient().newBuilder(); + clientBuilder.readTimeout(8, TimeUnit.SECONDS); + clientBuilder.connectTimeout(8, TimeUnit.SECONDS); + clientBuilder.writeTimeout(8, TimeUnit.SECONDS); + clientBuilder.cookieJar(new CookiesManager()); + OkHttpClient client = clientBuilder.build(); + return client; + } + + + /** + * 带token的网络请求 + * @param map + * @param server + * @param url + * @param token + * @return + */ + public static Request OKHttpHeaderRequest(HashMap map, String server, String url,String token){ + FormBody.Builder builder = new FormBody.Builder(); + if (map!=null){ + for (String key:map.keySet()){ + builder.add(key,map.get(key)); + } + } + FormBody body = builder.build(); + Request request = new Request.Builder() + .url(server+url) + .addHeader("token",token) + .post(body) + .build(); + return request; + } + + /** + * 不带请求头的网络请求 + * @param map + * @param server + * @param url + * @return + */ + public static Request OKHttpRequest(HashMap map, String server, String url){ + FormBody.Builder builder = new FormBody.Builder(); + if (map!=null){ + for (String key:map.keySet()){ + builder.add(key,map.get(key)); + } + } + FormBody body = builder.build(); + Request request = new Request.Builder() + .url(server+url) + .post(body) + .build(); + return request; + } + + /** + * 不带请求头的Call + * @param map + * @param server + * @param url + * @return + */ + public static Call OKCall(HashMap map, String server, String url){ + FormBody.Builder builder = new FormBody.Builder(); + if (map!=null){ + for (String key:map.keySet()){ + builder.add(key,map.get(key)); + } + } + FormBody body = builder.build(); + Request request = new Request.Builder() + .url(server+url) + .post(body) + .build(); + return OKHttpUtils.getClient().newCall(request); + } + + + /** + * 不带请求头的Call + * @param map + * @param server + * @param url + * @return + */ + public static Call OKCallGet(HashMap map, String server, String url){ + String s_body = ""; + for (String key:map.keySet()){ + s_body = s_body+key+"="+map.get(key)+"&"; + } + Request request = new Request.Builder() + .url(server+url+"?"+(s_body.length()>0?s_body.substring(0,s_body.length()-1):"")) + .get() + .build(); + return OKHttpUtils.getClient().newCall(request); + } + + + /** + * 上传多图 + * @param map + * @param server + * @param url + * @param picMark + * @param datas + * @return + */ + public static Request OKHttpSubPics(HashMap map, String server, String url,String picMark, List> datas){ + MultipartBody.Builder builder = new MultipartBody.Builder(); + builder.setType(MultipartBody.FORM); + for (int i=0;i 64 && array[i] < 91) + || (array[i] > 96 && array[i] < 123)) + break; + } + chars[i] = (char) array[i]; + str.append(chars[i]); + } + return str.toString(); + } + + //字母数字组合 + public static String getStrNumRandom(Integer length) { + StringBuilder str = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < length; i++) { + boolean b = random.nextBoolean(); + if (b) { // 字符串 + int choice = random.nextBoolean() ? 65 : 97; //取得65大写字母还是97小写字母 + str.append((char) (choice + random.nextInt(26)));// 取得大写字母 + } else { // 数字 + str.append(random.nextInt(10)); + } + } + return str.toString(); + } + + //字母数字符号组合 + private static String getMixRandom(int length) { + int[] array = new int[length]; + char[] chars = new char[length]; + StringBuilder str = new StringBuilder(); + + for (int i = 0; i < length; i++) { + while (true) { + array[i] = (int) (Math.random() * 1000); + if (array[i] > 47 && array[i] < 91 || (array[i] > 96 && array[i] < 123)) + break; + } + chars[i] = (char) array[i]; + str.append(chars[i]); + } + return str.toString(); + } + + public static void main(String[] args) { +// System.out.println(StringUtil.getRandomStr(4, 10)); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/RxCaptcha.java b/app/src/main/java/com/sipai/jspatrol/utils/RxCaptcha.java new file mode 100644 index 0000000..f05e351 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/RxCaptcha.java @@ -0,0 +1,267 @@ +package com.sipai.jspatrol.utils; + +import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.widget.ImageView; + +import java.util.Random; + +/** + * 随机生成验证码,使用方法: + *

+ * 拿到验证码图片ImageView + * mIvCode.setImageBitmap(RxCaptcha.getInstance().createBitmap()); + * int code=RxCaptcha.getInstance().getCode(); + *

+ * 只需生成验证码值 String + * + *

+ * RxCaptcha + * + * @version 1.0.0 + */ +public class RxCaptcha { + + public static RxCaptcha build() { + if (rxCaptcha == null) { + rxCaptcha = new RxCaptcha(); + } + return rxCaptcha; + } + + private static final char[] CHARS_NUMBER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + + private static final char[] CHARS_LETTER = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z'}; + + private static final char[] CHARS_ALL = {'0', '1', '2', '3', '4', '5', '6', + '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z'}; + + private static RxCaptcha rxCaptcha; + + private TYPE type = TYPE.CHARS; + + public enum TYPE{ + NUMBER,LETTER,CHARS + } + + private RxCaptcha() { + + } + + private RxCaptcha(TYPE types) { + this.type = types; + } + + public static RxCaptcha getInstance(TYPE types) { + if (rxCaptcha == null) { + rxCaptcha = new RxCaptcha(types); + } + return rxCaptcha; + } + + // default settings + private static final int DEFAULT_CODE_LENGTH = 4;// 验证码的长度 这里是4位 + private static final int DEFAULT_FONT_SIZE = 60;// 字体大小 + private static final int DEFAULT_LINE_NUMBER = 0;// 多少条干扰线 + private static final int BASE_PADDING_LEFT = 20; // 左边距 + private static final int RANGE_PADDING_LEFT = 20;// 左边距范围值 + private static final int BASE_PADDING_TOP = 42;// 上边距 + private static final int RANGE_PADDING_TOP = 15;// 上边距范围值 + private static int DEFAULT_WIDTH = 200;// 默认宽度.图片的总宽 + private static int DEFAULT_HEIGHT = 70;// 默认高度.图片的总高 + private int DEFAULT_COLOR = 0xdf;// 默认背景颜色值 + + // settings decided by the layout xml + // canvas width and height + private int width = DEFAULT_WIDTH; + private int height = DEFAULT_HEIGHT; + + // random word space and pading_top + private int base_padding_left = BASE_PADDING_LEFT; + private int range_padding_left = RANGE_PADDING_LEFT; + private int base_padding_top = BASE_PADDING_TOP; + private int range_padding_top = RANGE_PADDING_TOP; + + // number of chars, lines; font size + private int codeLength = DEFAULT_CODE_LENGTH; + private int line_number = DEFAULT_LINE_NUMBER; + private int font_size = DEFAULT_FONT_SIZE; + + // variables + private String code;// 保存生成的验证码 + private int padding_left, padding_top; + private Random random = new Random(); + + /** + * @param length 验证码的长度 + * @return + */ + public RxCaptcha codeLength(int length) { + codeLength = length; + return rxCaptcha; + } + + /** + * @param size 字体大小 + * @return + */ + public RxCaptcha fontSize(int size) { + font_size = size; + return rxCaptcha; + } + + /** + * @param number 干扰线 数量 + * @return + */ + public RxCaptcha lineNumber(int number) { + line_number = number; + return rxCaptcha; + } + + /** + * @return 背景颜色值 + */ + public RxCaptcha backColor(int colorInt) { + DEFAULT_COLOR = colorInt; + return rxCaptcha; + } + + public RxCaptcha type(TYPE type) { + this.type = type; + return rxCaptcha; + } + + public RxCaptcha size(int width, int height) { + this.width = width; + this.height = height; + return rxCaptcha; + } + + private Bitmap makeBitmap() { + padding_left = 0; + + Bitmap bp = Bitmap.createBitmap(width, height, Config.ARGB_8888); + Canvas c = new Canvas(bp); + + code = makeCode(); + + c.drawColor(Color.rgb(DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_COLOR)); + Paint paint = new Paint(); + paint.setTextSize(font_size); + + for (int i = 0; i < code.length(); i++) { + randomTextStyle(paint); + randomPadding(); + c.drawText(code.charAt(i) + "", padding_left, padding_top, paint); + } + + for (int i = 0; i < line_number; i++) { + drawLine(c, paint); + } + + c.save();// 保存 + c.restore();// + return bp; + } + + public String getCode() { + return code.toLowerCase(); + } + + public Bitmap into(ImageView imageView){ + Bitmap bitmap = createBitmap(); + if (imageView != null) { + imageView.setImageBitmap(bitmap); + } + return bitmap; + } + + public String createCode() { + return makeCode(); + } + + private Bitmap mBitmapCode; + + public Bitmap createBitmap() { + mBitmapCode = makeBitmap(); + return mBitmapCode; + } + + private String makeCode() { + StringBuilder buffer = new StringBuilder(); + switch (type) { + case NUMBER: + for (int i = 0; i < codeLength; i++) { + buffer.append(CHARS_NUMBER[random.nextInt(CHARS_NUMBER.length)]); + } + break; + case LETTER: + for (int i = 0; i < codeLength; i++) { + buffer.append(CHARS_LETTER[random.nextInt(CHARS_LETTER.length)]); + } + break; + case CHARS: + for (int i = 0; i < codeLength; i++) { + buffer.append(CHARS_ALL[random.nextInt(CHARS_ALL.length)]); + } + break; + default: + for (int i = 0; i < codeLength; i++) { + buffer.append(CHARS_ALL[random.nextInt(CHARS_ALL.length)]); + } + break; + } + + return buffer.toString(); + } + + private void drawLine(Canvas canvas, Paint paint) { + int color = randomColor(); + int startX = random.nextInt(width); + int startY = random.nextInt(height); + int stopX = random.nextInt(width); + int stopY = random.nextInt(height); + paint.setStrokeWidth(1); + paint.setColor(color); + canvas.drawLine(startX, startY, stopX, stopY, paint); + } + + private int randomColor() { + return randomColor(1); + } + + private int randomColor(int rate) { + int red = random.nextInt(256) / rate; + int green = random.nextInt(256) / rate; + int blue = random.nextInt(256) / rate; + return Color.rgb(red, green, blue); + } + + private void randomTextStyle(Paint paint) { + int color = randomColor(); + paint.setColor(color); + paint.setFakeBoldText(random.nextBoolean()); // true为粗体,false为非粗体 + float skewX = random.nextInt(11) / 10; + skewX = random.nextBoolean() ? skewX : -skewX; + // paint.setTextSkewX(skewX); // float类型参数,负数表示右斜,整数左斜 + // paint.setUnderlineText(true); //true为下划线,false为非下划线 + // paint.setStrikeThruText(true); //true为删除线,false为非删除线 + } + + private void randomPadding() { + padding_left += base_padding_left + random.nextInt(range_padding_left); + padding_top = base_padding_top + random.nextInt(range_padding_top); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/SharedPreferencesData.java b/app/src/main/java/com/sipai/jspatrol/utils/SharedPreferencesData.java new file mode 100644 index 0000000..d7b6c8a --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/SharedPreferencesData.java @@ -0,0 +1,83 @@ +package com.sipai.jspatrol.utils; + +import android.content.Context; +import android.content.SharedPreferences; + +import java.util.HashMap; +import java.util.Map; + +/** + * created by lvliming on 2019/9/17 + */ +public class SharedPreferencesData { + private SharedPreferences sharedPreferences; + private SharedPreferences.Editor editor; + private String ip_in_plant = "", ip_off_site = "";//厂内,厂外ip地址 + private String mServer = ""; + private String mServerIp = ""; + private String mUsername; + private String mPassword; + private String mUserid; + private String mCaption; + private String mTotaltime; + private String mLastlogintime; + + + public SharedPreferencesData(Context context){ + sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE); + editor = sharedPreferences.edit(); + } + + public void removePwd(){ + editor.putString("password",""); + editor.commit(); + } + + public void saveInfo(Map map){ + if (map!=null){ + for (String key:map.keySet()){ + editor.putString(key,map.get(key)); + } + editor.commit(); + } + } + + public HashMap getAll(){ + if (sharedPreferences.getString("ip_in_plant", "")!=null) { + ip_in_plant = sharedPreferences.getString("ip_in_plant", ""); + } + if (sharedPreferences.getString("ip_off_site", "")!=null) { + ip_off_site=sharedPreferences.getString("ip_off_site", ""); + } + if (!sharedPreferences.getString("server", "").equals("")) { + mServer = sharedPreferences.getString("server", ""); + } else { + mServer = ""; + } + if (!sharedPreferences.getString("serverip", "").equals("")) { + mServerIp = sharedPreferences.getString("serverip", ""); + } else { + mServerIp = ""; + } + mUsername=sharedPreferences.getString("username", ""); + mPassword=sharedPreferences.getString("password", ""); + mUserid=sharedPreferences.getString("userid", ""); + mCaption=sharedPreferences.getString("caption", ""); + mTotaltime=sharedPreferences.getString("totaltime", ""); + mLastlogintime=sharedPreferences.getString("lastlogintime", ""); + HashMap map = new HashMap<>(); + map.put("ip_in_plant",ip_in_plant); + map.put("ip_off_site",ip_off_site); + map.put("mServer",mServer); + map.put("mServerIp",mServerIp); + map.put("mUsername",mUsername); + map.put("mPassword",mPassword); + map.put("mUserid",mUserid); + map.put("mCaption",mCaption); + map.put("mTotaltime",mTotaltime); + map.put("mLastlogintime",mLastlogintime); + return map; + } + + +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/StretchAnimation.java b/app/src/main/java/com/sipai/jspatrol/utils/StretchAnimation.java new file mode 100644 index 0000000..dcbef99 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/StretchAnimation.java @@ -0,0 +1,169 @@ +package com.sipai.jspatrol.utils; + +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; + +/** + * + * @author manymore13 + * @Blog http://blog.csdn.net/manymore13 + */ +public class StretchAnimation { + + private final static String TAG = "SizeChange"; + private Interpolator mInterpolator; // 好多书上翻译为插值器 + private View mView; // 你要伸缩的view + private int mCurrSize; //当前大小 + private int mRawSize; + private int mMinSize; // 最小大小 固定值 + private int mMaxSize; // 最大大小 固定值 + private boolean isFinished = true;// 动画结束标识 + private TYPE mType = TYPE.vertical; + private final static int FRAMTIME = 20;// 一帧的时间 毫秒 + public enum TYPE { + horizontal, // 改变view水平方向的大小 + vertical // 改变view竖直方向的大小 + } + + private int mDuration; // 动画运行的时间 + private long mStartTime;// 动画开始时间 + private float mDurationReciprocal; + private int mDSize; // 需要改变view大小的增量 + + public StretchAnimation(int maxSize, int minSize, TYPE type, int duration) { + if (minSize >= maxSize) { + throw new RuntimeException("View的最大改变值不能小于最小改变值"); + } + mMinSize = minSize; + mMaxSize = maxSize; + mType = type; + mDuration = duration; + } + + public void setInterpolator(Interpolator interpolator) { + mInterpolator = interpolator; + } + + public TYPE getmType() { + return mType; + } + + public boolean isFinished() { + return isFinished; + } + + public void setDuration(int duration) { + mDuration = duration; + } + + private void changeViewSize() { + + if (mView != null && mView.getVisibility() != View.GONE) { + LayoutParams params = mView.getLayoutParams(); + if (mType == TYPE.vertical) { + params.height = mCurrSize; + } else if (mType == TYPE.horizontal) { + params.width = mCurrSize; + } + Log.i(TAG, "CurrSize = " + mCurrSize + " Max=" + mMaxSize + " min=" + + mMinSize); + mView.setLayoutParams(params); + } + } + + private Handler mHandler = new Handler() { + + @Override + public void handleMessage(Message msg) { + + if (msg.what == 1) { + if (!computeViewSize()) { + + mHandler.sendEmptyMessageDelayed(1, FRAMTIME); + } else { + if (animationlistener != null) { + animationlistener.animationEnd(mView); + } + } + } + super.handleMessage(msg); + } + + }; + + /** + * @return 返回true 表示动画完成 + */ + private boolean computeViewSize() { + + if (isFinished) { + return isFinished; + } + int timePassed = (int) (AnimationUtils.currentAnimationTimeMillis() - mStartTime); + + if (timePassed <= mDuration) { + float x = timePassed * mDurationReciprocal; + if (mInterpolator != null) { + x = mInterpolator.getInterpolation(x); + } + mCurrSize = mRawSize + Math.round(x * mDSize); + } else { + + isFinished = true; + mCurrSize = mRawSize + mDSize; + + } + changeViewSize(); + return isFinished; + } + + public void startAnimation(View view) { + + if (view != null) { + mView = view; + } else { + Log.e(TAG, "view 不能为空"); + return; + } + LayoutParams params = mView.getLayoutParams(); + + if (isFinished) { + mDurationReciprocal = 1.0f / (float) mDuration; + if (mType == TYPE.vertical) { + mRawSize = mCurrSize = mView.getHeight(); + } else if (mType == TYPE.horizontal) { + mRawSize = mCurrSize = mView.getWidth(); + } + Log.i(TAG, "mRawSize=" + mRawSize); + if (mCurrSize > mMaxSize || mCurrSize < mMinSize) { + throw new RuntimeException( + "View 的大小不达标 currentViewSize > mMaxSize || currentViewSize < mMinSize"); + } + isFinished = false; + mStartTime = AnimationUtils.currentAnimationTimeMillis(); // 动画开始时间 + if (mCurrSize < mMaxSize) { + mDSize = mMaxSize - mCurrSize; + } else { + mDSize = mMinSize - mMaxSize; + } + Log.i(TAG, "mDSize=" + mDSize); + mHandler.sendEmptyMessage(1); + } + } + + private AnimationListener animationlistener; + + interface AnimationListener { + void animationEnd(View v); + } + + public void setOnAnimationListener(AnimationListener listener) { + animationlistener = listener; + } + +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/Utils.java b/app/src/main/java/com/sipai/jspatrol/utils/Utils.java new file mode 100644 index 0000000..3038c12 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/Utils.java @@ -0,0 +1,160 @@ +package com.sipai.jspatrol.utils; + + +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; + +import com.sipai.jspatrol.R; + +public class Utils { + + private static final String FILENAME = "userinfo.json"; // 用户保存文件名 + private static final String TAG = "Utils"; + + public static int getlight4mp(String name,String value){ + if(name.contains("故障")||name.contains("警告")||name.contains("需维护")||name.contains("过载")||name.contains("超时")){ + if(value!=null && value.equals("1")){ + return R.mipmap.yellow_btn; + }else{ + return R.mipmap.gray_btn; + } + }else{ + if(value!=null && value.contains("1")){ + return R.mipmap.green_btn; + }else{ + return R.mipmap.red_btn; + } + } + + } + + /** + * 判断网络是否可用 + * @param context + * @return + */ + public static boolean isNetworkConnected(Context context) { + if (context != null) { + ConnectivityManager mConnectivityManager = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); + if (mNetworkInfo != null) { + return mNetworkInfo.isAvailable(); + } + } + return false; + } + + + public static int getpointPic(String name){ + if (name.contains("运行")){ + return R.mipmap.iv_eqp; + } + else if (name.contains("故障")){ + return R.mipmap.iv_eqp; + } + else if (name.contains("功率")||name.toLowerCase().contains("p")&&!name.toLowerCase().contains("ph")&&!name.toLowerCase().contains("tp")){ + return R.mipmap.iv_p; + } + else if (name.toLowerCase().contains("ph")){ + return R.mipmap.iv_ph; + } + else if (name.contains("氨氮")){ + return R.mipmap.iv_nh3; + } + else if (name.contains("温度")){ + return R.mipmap.iv_temp_r; + } + else if (name.toLowerCase().contains("cod")){ + return R.mipmap.iv_cod; + } + else if (name.contains("流量")){ + return R.mipmap.iv_waterflow; + } + else if (name.contains("风量")){ + return R.mipmap.iv_airflow; + } + else if (name.contains("电")||name.toLowerCase().contains("ia")||name.toLowerCase().contains("uan")){ + return R.mipmap.iv_ele; + } + else if (name.contains("液位")){ + return R.mipmap.iv_waterliqu; + } + else if (name.toLowerCase().contains("ss")&&!name.toLowerCase().contains("mlss")){ + return R.mipmap.iv_ss; + } + else if (name.toLowerCase().contains("mlss")){ + return R.mipmap.iv_mlss; + } + else if (name.toLowerCase().contains("nh3n")){ + return R.mipmap.iv_nh3n; + } + else if (name.toLowerCase().contains("pa")||name.contains("压力")){ + return R.mipmap.iv_pa; + } + else if (name.toLowerCase().contains("hz")||name.contains("频率")){ + return R.mipmap.iv_hz; + } + else if (name.toLowerCase().contains("do1")){ + return R.mipmap.iv_do; + } + else if (name.toLowerCase().contains("do2")){ + return R.mipmap.iv_do; + } + else if (name.toLowerCase().contains("tn")||name.contains("总氮")){ + return R.mipmap.iv_tn; + } + else if (name.toLowerCase().contains("tp")||name.contains("总磷")){ + return R.mipmap.iv_tp; + } + else if (name.contains("维护")||name.contains("维修")||name.contains("过载")||name.contains("超时")||name.contains("信号")||name.contains("到位")||name.contains("力矩")||name.contains("报警")||name.contains("次数")){ + return R.mipmap.iv_eqp; + } + else{ + return R.mipmap.iv_water; + } + } + + public static int getValueArray(String mark){ + if (mark.equals("NOTHING3")){ + return R.array.NOTHING3; + }else if (mark.equals("HAVE2")){ + return R.array.HAVE2; + }else if (mark.equals("HIGH2")){ + return R.array.HIGH2; + }else if (mark.equals("START3")){ + return R.array.START3; + }else if (mark.equals("YELLOW3")){ + return R.array.YELLOW3; + }else if (mark.equals("HIGH3")){ + return R.array.HIGH3; + }else if (mark.equals("NORMAL2")){ + return R.array.NORMAL2; + }else if (mark.equals("FULL2")){ + return R.array.FULL2; + }else if (mark.equals("FULL3")){ + return R.array.FULL3; + }else if (mark.equals("MORE3")){ + return R.array.MORE3; + }else if (mark.equals("OPEN2")){ + return R.array.OPEN2; + }else if (mark.equals("DAMAGE2")){ + return R.array.DAMAGE2; + }else if (mark.equals("GOOD2")){ + return R.array.GOOD2; + }else if (mark.equals("YES2")){ + return R.array.YES2; + }else if (mark.equals("VOL2")){ + return R.array.VOL2; + }else if (mark.equals("VOL3")){ + return R.array.VOL3; + }else if (mark.equals("FLOW2")){ + return R.array.FLOW2; + }else if (mark.equals("DRY2")){ + return R.array.DRY2; + }else { + return R.array.HIGH2; + } + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/CookiesManager.java b/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/CookiesManager.java new file mode 100644 index 0000000..b5b0796 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/CookiesManager.java @@ -0,0 +1,80 @@ +package com.sipai.jspatrol.utils.okHttpCookie; + +import android.content.Context; +import android.text.TextUtils; +import android.util.Log; + +import com.sipai.jspatrol.Application.App; + +import java.util.List; + +import okhttp3.Cookie; +import okhttp3.CookieJar; +import okhttp3.HttpUrl; + +/** + * created by lvliming on 2019/9/16 + */ +public class CookiesManager implements CookieJar { + + private final PersistentCookieStore cookieStore = new PersistentCookieStore(App.getInstance()); + + @Override + public void saveFromResponse(HttpUrl url, List cookies) { + if (cookies != null && cookies.size() > 0) { + for (Cookie item : cookies) { + cookieStore.add(url, item); + } + } + } + + @Override + public List loadForRequest(HttpUrl url) { + List cookies = cookieStore.get(url); + return cookies; + } + + /* 得到cookie */ + public static List getCookie(Context context) { + PersistentCookieStore cookieStore = new PersistentCookieStore(context); + List cookies = cookieStore.getCookies(); + return cookies; + } + + /* 清除cookie */ + public static void clearCookie(Context context) { + PersistentCookieStore cookieStore = new PersistentCookieStore(context); + cookieStore.removeAll(); + } + + /** + * 获取标准 Cookie + */ + public static String getCookieText(Context context) { + PersistentCookieStore myCookieStore = new PersistentCookieStore(context); + List cookies = myCookieStore.getCookies(); + for (Cookie cookie : cookies) { + Log.d("cookieUtils", cookie.name() + " = " + cookie.value()); + } + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < cookies.size(); i++) { +// Cookie cookie = cookies.get((cookies.size()-1)); + Cookie cookie = cookies.get(i); + String cookieName = cookie.name(); + String cookieValue = cookie.value(); + String cookiepath = cookie.path(); + String cookiedomain = cookie.domain(); + if (!TextUtils.isEmpty(cookieName) + && !TextUtils.isEmpty(cookieValue)) { + sb.append(cookieName + "="); + sb.append(cookieValue + ";"); + sb.append("domain" + "="); + sb.append(cookiedomain+";"); + sb.append("path" + "="); + sb.append(cookiepath + ";"); + } + } + Log.e("cookie", sb.toString()); + return sb.toString(); + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/PersistentCookieStore.java b/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/PersistentCookieStore.java new file mode 100644 index 0000000..a202380 --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/PersistentCookieStore.java @@ -0,0 +1,199 @@ +package com.sipai.jspatrol.utils.okHttpCookie; + +import android.content.Context; +import android.content.SharedPreferences; +import android.text.TextUtils; +import android.util.Log; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import okhttp3.Cookie; +import okhttp3.HttpUrl; + +/** + * created by lvliming on 2019/9/16 + */ +public class PersistentCookieStore { + private static final String LOG_TAG = "PersistentCookieStore"; + private static final String COOKIE_PREFS = "Cookies_Prefs"; + + private final Map> cookies; + private final SharedPreferences cookiePrefs; + + public PersistentCookieStore(Context context) { + cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0); + cookies = new HashMap<>(); + + //将持久化的cookies缓存到内存中 即map cookies + Map prefsMap = cookiePrefs.getAll(); + for (Map.Entry entry : prefsMap.entrySet()) { + String[] cookieNames = TextUtils.split((String) entry.getValue(), ","); + for (String name : cookieNames) { + String encodedCookie = cookiePrefs.getString(name, null); + if (encodedCookie != null) { + Cookie decodedCookie = decodeCookie(encodedCookie); + if (decodedCookie != null) { + if (!cookies.containsKey(entry.getKey())) { + cookies.put(entry.getKey(), new ConcurrentHashMap()); + } + cookies.get(entry.getKey()).put(name, decodedCookie); + } + } + } + } + } + + protected String getCookieToken(Cookie cookie) { + return cookie.name() + "@" + cookie.domain(); + } + + public void add(HttpUrl url, Cookie cookie) { + String name = getCookieToken(cookie); + + //将cookies缓存到内存中 如果缓存过期 就重置此cookie + if (!cookie.persistent()) { + if (!cookies.containsKey(url.host())) { + cookies.put(url.host(), new ConcurrentHashMap()); + } + cookies.get(url.host()).put(name, cookie); + } else { + if (cookies.containsKey(url.host())) { + cookies.get(url.host()).remove(name); + } + } + + //讲cookies持久化到本地 + SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); + prefsWriter.putString(url.host(), TextUtils.join(",", cookies.get(url.host()).keySet())); + prefsWriter.putString(name, encodeCookie(new SerializableOkHttpCookies(cookie))); + prefsWriter.apply(); + } + + public List get(HttpUrl url) { + ArrayList ret = new ArrayList<>(); + if (cookies.containsKey(url.host())) + ret.addAll(cookies.get(url.host()).values()); + return ret; + } + + public boolean removeAll() { + SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); + prefsWriter.clear(); + prefsWriter.apply(); + cookies.clear(); + return true; + } + + public boolean remove(HttpUrl url, Cookie cookie) { + String name = getCookieToken(cookie); + + if (cookies.containsKey(url.host()) && cookies.get(url.host()).containsKey(name)) { + cookies.get(url.host()).remove(name); + + SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); + if (cookiePrefs.contains(name)) { + prefsWriter.remove(name); + } + prefsWriter.putString(url.host(), TextUtils.join(",", cookies.get(url.host()).keySet())); + prefsWriter.apply(); + + return true; + } else { + return false; + } + } + + public List getCookies() { + ArrayList ret = new ArrayList<>(); + for (String key : cookies.keySet()) + ret.addAll(cookies.get(key).values()); + + return ret; + } + + /** + * cookies 序列化成 string + * + * @param cookie 要序列化的cookie + * @return 序列化之后的string + */ + protected String encodeCookie(SerializableOkHttpCookies cookie) { + if (cookie == null) + return null; + ByteArrayOutputStream os = new ByteArrayOutputStream(); + try { + ObjectOutputStream outputStream = new ObjectOutputStream(os); + outputStream.writeObject(cookie); + } catch (IOException e) { + Log.d(LOG_TAG, "IOException in encodeCookie", e); + return null; + } + + return byteArrayToHexString(os.toByteArray()); + } + + /** + * 将字符串反序列化成cookies + * + * @param cookieString cookies string + * @return cookie object + */ + protected Cookie decodeCookie(String cookieString) { + byte[] bytes = hexStringToByteArray(cookieString); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); + Cookie cookie = null; + try { + ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); + cookie = ((SerializableOkHttpCookies) objectInputStream.readObject()).getCookies(); + } catch (IOException e) { + Log.d(LOG_TAG, "IOException in decodeCookie", e); + } catch (ClassNotFoundException e) { + Log.d(LOG_TAG, "ClassNotFoundException in decodeCookie", e); + } + + return cookie; + } + + /** + * 二进制数组转十六进制字符串 + * + * @param bytes byte array to be converted + * @return string containing hex values + */ + protected String byteArrayToHexString(byte[] bytes) { + StringBuilder sb = new StringBuilder(bytes.length * 2); + for (byte element : bytes) { + int v = element & 0xff; + if (v < 16) { + sb.append('0'); + } + sb.append(Integer.toHexString(v)); + } + return sb.toString().toUpperCase(Locale.US); + } + + /** + * 十六进制字符串转二进制数组 + * + * @param hexString string of hex-encoded values + * @return decoded byte array + */ + protected byte[] hexStringToByteArray(String hexString) { + int len = hexString.length(); + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4) + Character.digit(hexString.charAt(i + 1), 16)); + } + return data; + } +} diff --git a/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/SerializableOkHttpCookies.java b/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/SerializableOkHttpCookies.java new file mode 100644 index 0000000..866a9ac --- /dev/null +++ b/app/src/main/java/com/sipai/jspatrol/utils/okHttpCookie/SerializableOkHttpCookies.java @@ -0,0 +1,62 @@ +package com.sipai.jspatrol.utils.okHttpCookie; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +import okhttp3.Cookie; + +/** + * created by lvliming on 2019/9/16 + */ +public class SerializableOkHttpCookies implements Serializable { + private transient final Cookie cookies; + private transient Cookie clientCookies; + + public SerializableOkHttpCookies(Cookie cookies) { + this.cookies = cookies; + } + + public Cookie getCookies() { + Cookie bestCookies = cookies; + if (clientCookies != null) { + bestCookies = clientCookies; + } + return bestCookies; + } + + private void writeObject(ObjectOutputStream out) throws IOException { + out.writeObject(cookies.name()); + out.writeObject(cookies.value()); + out.writeLong(cookies.expiresAt()); + out.writeObject(cookies.domain()); + out.writeObject(cookies.path()); + out.writeBoolean(cookies.secure()); + out.writeBoolean(cookies.httpOnly()); + out.writeBoolean(cookies.hostOnly()); + out.writeBoolean(cookies.persistent()); + } + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + String name = (String) in.readObject(); + String value = (String) in.readObject(); + long expiresAt = in.readLong(); + String domain = (String) in.readObject(); + String path = (String) in.readObject(); + boolean secure = in.readBoolean(); + boolean httpOnly = in.readBoolean(); + boolean hostOnly = in.readBoolean(); + boolean persistent = in.readBoolean(); + Cookie.Builder builder = new Cookie.Builder(); + builder = builder.name(name); + builder = builder.value(value); + builder = builder.expiresAt(expiresAt); + builder = hostOnly ? builder.hostOnlyDomain(domain) : builder.domain(domain); + builder = builder.path(path); + builder = secure ? builder.secure() : builder; + builder = httpOnly ? builder.httpOnly() : builder; + clientCookies =builder.build(); + } + +} diff --git a/app/src/main/java/com/sipai/ui/CustomDialog.java b/app/src/main/java/com/sipai/ui/CustomDialog.java new file mode 100644 index 0000000..214edb5 --- /dev/null +++ b/app/src/main/java/com/sipai/ui/CustomDialog.java @@ -0,0 +1,32 @@ +package com.sipai.ui; + +import android.app.Dialog; +import android.content.Context; +import android.os.Bundle; + +/** + * Created by lvliming on 2017/8/12. + */ + +public class CustomDialog extends Dialog{ + private Context context; + private int resId; + public CustomDialog(Context context, int resLayout) { + this(context,0,0); + } + public CustomDialog(Context context, int themeResId, int resLayout) { + super(context, themeResId); + this.context = context; + this.resId = resLayout; + } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.setContentView(resId); + } + + @Override + public void setCanceledOnTouchOutside(boolean cancel) { + super.setCanceledOnTouchOutside(cancel); + } +} diff --git a/app/src/main/java/com/sipai/ui/EmptyLayout.java b/app/src/main/java/com/sipai/ui/EmptyLayout.java new file mode 100644 index 0000000..d9f567c --- /dev/null +++ b/app/src/main/java/com/sipai/ui/EmptyLayout.java @@ -0,0 +1,30 @@ +package com.sipai.ui; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.RelativeLayout; + +import com.sipai.jspatrol.R; + + +/** + * Created by lvliming on 2019/3/1. + */ + +public class EmptyLayout extends RelativeLayout { + public EmptyLayout(Context context, AttributeSet attrs) { + super(context, attrs); + LayoutInflater.from(context).inflate(R.layout.view_empty,this); + } + + @Override + public void setVisibility(int visibility) { + super.setVisibility(visibility); + } + + @Override + public int getVisibility() { + return super.getVisibility(); + } +} diff --git a/app/src/main/java/com/sipai/ui/TitleLayout.java b/app/src/main/java/com/sipai/ui/TitleLayout.java new file mode 100644 index 0000000..adbf1da --- /dev/null +++ b/app/src/main/java/com/sipai/ui/TitleLayout.java @@ -0,0 +1,23 @@ +package com.sipai.ui; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.LinearLayout; + +import androidx.annotation.Nullable; + +import com.sipai.jspatrol.R; + + +/** + * Created by lvliming on 2018/8/28. + */ + +public class TitleLayout extends LinearLayout { + public TitleLayout(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + LayoutInflater.from(context).inflate(R.layout.moudle_back_title,this); + + } +} diff --git a/app/src/main/java/com/sipai/ui/bizPopWindow/CustomListPopupWindow.java b/app/src/main/java/com/sipai/ui/bizPopWindow/CustomListPopupWindow.java new file mode 100644 index 0000000..8a1dfb7 --- /dev/null +++ b/app/src/main/java/com/sipai/ui/bizPopWindow/CustomListPopupWindow.java @@ -0,0 +1,157 @@ +package com.sipai.ui.bizPopWindow; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.PopupWindow; +import android.widget.PopupWindow.OnDismissListener; +import android.widget.TextView; + +import com.sipai.jspatrol.Bean.Biz; +import com.sipai.jspatrol.R; + +import java.util.ArrayList; +import java.util.List; + +/** + * 自定义popuwindow + * @author Alan
+ */ +public class CustomListPopupWindow extends PopupWindow implements OnDismissListener{ + + private ListView mListView; + TextView background; + private List mUserModels=new ArrayList(); + private ItemClickCallBack mItemCallBack; + private Context mContext; + private String checkedUId = ""; + private View rootView; + private DataAdapter mAdapter=null; + + /** + * + * @param context + * @param mUserModels 数据集 + * @param checkedUId 被选中的item + * @param mItemCallBack item的点击事件 + */ + public CustomListPopupWindow(Context context, List mUserModels, String checkedUId, ItemClickCallBack mItemCallBack){ + super(); + this.mContext=context; + this.mUserModels=mUserModels; + this.checkedUId=checkedUId; + this.mItemCallBack=mItemCallBack; + initPop(); + } + + + + private void initPop() { + // TODO Auto-generated method stub + rootView = LayoutInflater.from(mContext).inflate(R.layout.bizlist_popupwindow, null); + mListView= rootView.findViewById(R.id.lv_pop_datas); + this.setContentView(rootView); + this.setWidth(LayoutParams.WRAP_CONTENT); + this.setHeight(LayoutParams.WRAP_CONTENT); + this.setFocusable(true); + this.setOnDismissListener(this); +// this.setBackgroundDrawable(new BitmapDrawable()); + //this.setAnimationStyle(animStyle); + this.setContentView(rootView); + this.mAdapter=new DataAdapter(); + this.mListView.setAdapter(mAdapter); + this.mListView.setOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(AdapterView parent, View view, + int position, long id) { + if (mItemCallBack != null) { + Biz biz=mUserModels.get(position); + mItemCallBack.callBack(biz); + } + } + }); +// background.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// dismiss(); +// } +// }); + } + + private class DataAdapter extends BaseAdapter { + + class ViewHolder { + TextView tv_name; + ImageView iv_head; + } + + + + @Override + public int getCount() { + if (mUserModels != null) { + return mUserModels.size(); + } + return 0; + } + + @Override + public Object getItem(int position) { + if (mUserModels != null) { + return mUserModels.get(position); + } + return null; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder viewHolder; + Biz uModel=mUserModels.get(position); + if (convertView == null) { + viewHolder = new ViewHolder(); + convertView = LayoutInflater.from(mContext).inflate(R.layout.biz_poplistview_item, null); + viewHolder.tv_name= convertView.findViewById(R.id.moudle_bizpop_tv_name); + viewHolder.iv_head= convertView.findViewById(R.id.moudle_bizpop_iv_head); + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + //绑定数据 + viewHolder.tv_name.setText(uModel.getName()); + return convertView; + } + } + + public interface ItemClickCallBack { + void callBack(Biz biz); + } + + + + + + private int dp2Px(Context context, float dp) { + final float scale = context.getResources().getDisplayMetrics().density; + return (int) (dp * scale + 0.5f); + } + + @Override + public void onDismiss() { + // TODO Auto-generated method stub + + } + +} diff --git a/app/src/main/res/anim/list_anim.xml b/app/src/main/res/anim/list_anim.xml new file mode 100644 index 0000000..77938dc --- /dev/null +++ b/app/src/main/res/anim/list_anim.xml @@ -0,0 +1,14 @@ + + + + + diff --git a/app/src/main/res/anim/my_translate.xml b/app/src/main/res/anim/my_translate.xml new file mode 100644 index 0000000..7174e09 --- /dev/null +++ b/app/src/main/res/anim/my_translate.xml @@ -0,0 +1,28 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..971add5 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/bg_black_border.xml b/app/src/main/res/drawable/bg_black_border.xml new file mode 100644 index 0000000..9fa1636 --- /dev/null +++ b/app/src/main/res/drawable/bg_black_border.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_blue_bottom.xml b/app/src/main/res/drawable/bg_blue_bottom.xml new file mode 100644 index 0000000..d4f3f4b --- /dev/null +++ b/app/src/main/res/drawable/bg_blue_bottom.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_blue_status_sel.xml b/app/src/main/res/drawable/bg_blue_status_sel.xml new file mode 100644 index 0000000..f137104 --- /dev/null +++ b/app/src/main/res/drawable/bg_blue_status_sel.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_blue_status_unsel.xml b/app/src/main/res/drawable/bg_blue_status_unsel.xml new file mode 100644 index 0000000..2bcaf95 --- /dev/null +++ b/app/src/main/res/drawable/bg_blue_status_unsel.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_cursor.xml b/app/src/main/res/drawable/bg_cursor.xml new file mode 100644 index 0000000..9092184 --- /dev/null +++ b/app/src/main/res/drawable/bg_cursor.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_date_select.xml b/app/src/main/res/drawable/bg_date_select.xml new file mode 100644 index 0000000..b4c5c4c --- /dev/null +++ b/app/src/main/res/drawable/bg_date_select.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_edt_dialog_title.xml b/app/src/main/res/drawable/bg_edt_dialog_title.xml new file mode 100644 index 0000000..bb3450c --- /dev/null +++ b/app/src/main/res/drawable/bg_edt_dialog_title.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_equ_one_orange.xml b/app/src/main/res/drawable/bg_equ_one_orange.xml new file mode 100644 index 0000000..69f39be --- /dev/null +++ b/app/src/main/res/drawable/bg_equ_one_orange.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_gray_bottom.xml b/app/src/main/res/drawable/bg_gray_bottom.xml new file mode 100644 index 0000000..16ce2e8 --- /dev/null +++ b/app/src/main/res/drawable/bg_gray_bottom.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_gray_top.xml b/app/src/main/res/drawable/bg_gray_top.xml new file mode 100644 index 0000000..4914e66 --- /dev/null +++ b/app/src/main/res/drawable/bg_gray_top.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_shape_btn_blue.xml b/app/src/main/res/drawable/bg_layout_shape_btn_blue.xml new file mode 100644 index 0000000..938431c --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_btn_blue.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_btn_login.xml b/app/src/main/res/drawable/bg_layout_shape_btn_login.xml new file mode 100644 index 0000000..6a266ed --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_btn_login.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_com.xml b/app/src/main/res/drawable/bg_layout_shape_com.xml new file mode 100644 index 0000000..39018e8 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_com.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_factory.xml b/app/src/main/res/drawable/bg_layout_shape_factory.xml new file mode 100644 index 0000000..9009444 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_factory.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_gray.xml b/app/src/main/res/drawable/bg_layout_shape_gray.xml new file mode 100644 index 0000000..53a1bf9 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_gray.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_gray_bottom.xml b/app/src/main/res/drawable/bg_layout_shape_gray_bottom.xml new file mode 100644 index 0000000..7a5e678 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_gray_bottom.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_gray_top.xml b/app/src/main/res/drawable/bg_layout_shape_gray_top.xml new file mode 100644 index 0000000..4819ffb --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_gray_top.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_green.xml b/app/src/main/res/drawable/bg_layout_shape_green.xml new file mode 100644 index 0000000..2f46468 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_green.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_important_equ_fault.xml b/app/src/main/res/drawable/bg_layout_shape_important_equ_fault.xml new file mode 100644 index 0000000..134d500 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_important_equ_fault.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_layout_shape_login.xml b/app/src/main/res/drawable/bg_layout_shape_login.xml new file mode 100644 index 0000000..5288686 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_login.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_luc_blue.xml b/app/src/main/res/drawable/bg_layout_shape_luc_blue.xml new file mode 100644 index 0000000..68c0d82 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_luc_blue.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_pink.xml b/app/src/main/res/drawable/bg_layout_shape_pink.xml new file mode 100644 index 0000000..0616ce4 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_pink.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_type_blue.xml b/app/src/main/res/drawable/bg_layout_shape_type_blue.xml new file mode 100644 index 0000000..3c8cf3c --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_type_blue.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_type_white.xml b/app/src/main/res/drawable/bg_layout_shape_type_white.xml new file mode 100644 index 0000000..2d31142 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_type_white.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_layout_shape_white.xml b/app/src/main/res/drawable/bg_layout_shape_white.xml new file mode 100644 index 0000000..3da2878 --- /dev/null +++ b/app/src/main/res/drawable/bg_layout_shape_white.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/src/main/res/drawable/bg_line_chart.xml b/app/src/main/res/drawable/bg_line_chart.xml new file mode 100644 index 0000000..33568a3 --- /dev/null +++ b/app/src/main/res/drawable/bg_line_chart.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_little_blue_all.xml b/app/src/main/res/drawable/bg_little_blue_all.xml new file mode 100644 index 0000000..61c75bc --- /dev/null +++ b/app/src/main/res/drawable/bg_little_blue_all.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_oval.xml b/app/src/main/res/drawable/bg_oval.xml new file mode 100644 index 0000000..1c36946 --- /dev/null +++ b/app/src/main/res/drawable/bg_oval.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_patrol_point_list.xml b/app/src/main/res/drawable/bg_patrol_point_list.xml new file mode 100644 index 0000000..45b9804 --- /dev/null +++ b/app/src/main/res/drawable/bg_patrol_point_list.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_patrol_tab.xml b/app/src/main/res/drawable/bg_patrol_tab.xml new file mode 100644 index 0000000..4a18ee3 --- /dev/null +++ b/app/src/main/res/drawable/bg_patrol_tab.xml @@ -0,0 +1,9 @@ + + + + 0 + 2 + 4 + #80DCE1E3 + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_patrol_task_card.xml b/app/src/main/res/drawable/bg_patrol_task_card.xml new file mode 100644 index 0000000..67070a3 --- /dev/null +++ b/app/src/main/res/drawable/bg_patrol_task_card.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_patrol_task_detail.xml b/app/src/main/res/drawable/bg_patrol_task_detail.xml new file mode 100644 index 0000000..339868d --- /dev/null +++ b/app/src/main/res/drawable/bg_patrol_task_detail.xml @@ -0,0 +1,9 @@ + + + + 0 + 1 + 0 + #40000000 + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_sel_green.xml b/app/src/main/res/drawable/bg_sel_green.xml new file mode 100644 index 0000000..69a1560 --- /dev/null +++ b/app/src/main/res/drawable/bg_sel_green.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_shadow.xml b/app/src/main/res/drawable/bg_shadow.xml new file mode 100644 index 0000000..a4b8473 --- /dev/null +++ b/app/src/main/res/drawable/bg_shadow.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_task_can_not.xml b/app/src/main/res/drawable/bg_task_can_not.xml new file mode 100644 index 0000000..62f1d33 --- /dev/null +++ b/app/src/main/res/drawable/bg_task_can_not.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_task_com.xml b/app/src/main/res/drawable/bg_task_com.xml new file mode 100644 index 0000000..cdbd822 --- /dev/null +++ b/app/src/main/res/drawable/bg_task_com.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_task_com_part.xml b/app/src/main/res/drawable/bg_task_com_part.xml new file mode 100644 index 0000000..e83514b --- /dev/null +++ b/app/src/main/res/drawable/bg_task_com_part.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_task_doing.xml b/app/src/main/res/drawable/bg_task_doing.xml new file mode 100644 index 0000000..ff7ffc5 --- /dev/null +++ b/app/src/main/res/drawable/bg_task_doing.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_task_notstarted.xml b/app/src/main/res/drawable/bg_task_notstarted.xml new file mode 100644 index 0000000..d60778f --- /dev/null +++ b/app/src/main/res/drawable/bg_task_notstarted.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_task_out_of_date.xml b/app/src/main/res/drawable/bg_task_out_of_date.xml new file mode 100644 index 0000000..ee604d0 --- /dev/null +++ b/app/src/main/res/drawable/bg_task_out_of_date.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_title.xml b/app/src/main/res/drawable/bg_title.xml new file mode 100644 index 0000000..6f73e43 --- /dev/null +++ b/app/src/main/res/drawable/bg_title.xml @@ -0,0 +1,8 @@ + + + + 0 + 1 + 0 + #40000000 + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_white_all.xml b/app/src/main/res/drawable/bg_white_all.xml new file mode 100644 index 0000000..da9ce89 --- /dev/null +++ b/app/src/main/res/drawable/bg_white_all.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_white_bottom.xml b/app/src/main/res/drawable/bg_white_bottom.xml new file mode 100644 index 0000000..7dcaac0 --- /dev/null +++ b/app/src/main/res/drawable/bg_white_bottom.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bgl_marker.xml b/app/src/main/res/drawable/bgl_marker.xml new file mode 100644 index 0000000..9e0e0ee --- /dev/null +++ b/app/src/main/res/drawable/bgl_marker.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/blue_selector.xml b/app/src/main/res/drawable/blue_selector.xml new file mode 100644 index 0000000..943ac80 --- /dev/null +++ b/app/src/main/res/drawable/blue_selector.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bt_dynamic_add.xml b/app/src/main/res/drawable/bt_dynamic_add.xml new file mode 100644 index 0000000..8c29619 --- /dev/null +++ b/app/src/main/res/drawable/bt_dynamic_add.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bt_dynamic_del.xml b/app/src/main/res/drawable/bt_dynamic_del.xml new file mode 100644 index 0000000..7c85055 --- /dev/null +++ b/app/src/main/res/drawable/bt_dynamic_del.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_blue_selector.xml b/app/src/main/res/drawable/btn_blue_selector.xml new file mode 100644 index 0000000..e02bbc4 --- /dev/null +++ b/app/src/main/res/drawable/btn_blue_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_error_press.xml b/app/src/main/res/drawable/btn_error_press.xml new file mode 100644 index 0000000..48eee81 --- /dev/null +++ b/app/src/main/res/drawable/btn_error_press.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_error_selector.xml b/app/src/main/res/drawable/btn_error_selector.xml new file mode 100644 index 0000000..9e96dde --- /dev/null +++ b/app/src/main/res/drawable/btn_error_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_error_yellow_selector.xml b/app/src/main/res/drawable/btn_error_yellow_selector.xml new file mode 100644 index 0000000..b3597da --- /dev/null +++ b/app/src/main/res/drawable/btn_error_yellow_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_press.xml b/app/src/main/res/drawable/btn_press.xml new file mode 100644 index 0000000..9528b5c --- /dev/null +++ b/app/src/main/res/drawable/btn_press.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_pressed.xml b/app/src/main/res/drawable/btn_pressed.xml new file mode 100644 index 0000000..ae8a526 --- /dev/null +++ b/app/src/main/res/drawable/btn_pressed.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_selector2.xml b/app/src/main/res/drawable/btn_selector2.xml new file mode 100644 index 0000000..caf48ef --- /dev/null +++ b/app/src/main/res/drawable/btn_selector2.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_unpressed.xml b/app/src/main/res/drawable/btn_unpressed.xml new file mode 100644 index 0000000..8de826c --- /dev/null +++ b/app/src/main/res/drawable/btn_unpressed.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/btn_yellow_press.xml b/app/src/main/res/drawable/btn_yellow_press.xml new file mode 100644 index 0000000..a8ea9f1 --- /dev/null +++ b/app/src/main/res/drawable/btn_yellow_press.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/common_loading2_0.png b/app/src/main/res/drawable/common_loading2_0.png new file mode 100644 index 0000000..70f5abf Binary files /dev/null and b/app/src/main/res/drawable/common_loading2_0.png differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..eed7a42 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/progressbar_anim.xml b/app/src/main/res/drawable/progressbar_anim.xml new file mode 100644 index 0000000..9a01750 --- /dev/null +++ b/app/src/main/res/drawable/progressbar_anim.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_bg_little_blue.xml b/app/src/main/res/drawable/shape_bg_little_blue.xml new file mode 100644 index 0000000..4bcfae4 --- /dev/null +++ b/app/src/main/res/drawable/shape_bg_little_blue.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_btn_cancel.xml b/app/src/main/res/drawable/shape_btn_cancel.xml new file mode 100644 index 0000000..7f57b23 --- /dev/null +++ b/app/src/main/res/drawable/shape_btn_cancel.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_btn_confirm.xml b/app/src/main/res/drawable/shape_btn_confirm.xml new file mode 100644 index 0000000..de58ea6 --- /dev/null +++ b/app/src/main/res/drawable/shape_btn_confirm.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_dialog_ios.xml b/app/src/main/res/drawable/shape_dialog_ios.xml new file mode 100644 index 0000000..eb49445 --- /dev/null +++ b/app/src/main/res/drawable/shape_dialog_ios.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/tips_popup_win_bg.9.png b/app/src/main/res/drawable/tips_popup_win_bg.9.png new file mode 100644 index 0000000..7fcb51b Binary files /dev/null and b/app/src/main/res/drawable/tips_popup_win_bg.9.png differ diff --git a/app/src/main/res/drawable/view_dotted_line.xml b/app/src/main/res/drawable/view_dotted_line.xml new file mode 100644 index 0000000..e1b23e7 --- /dev/null +++ b/app/src/main/res/drawable/view_dotted_line.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_fault_flow_chart.xml b/app/src/main/res/layout/activity_fault_flow_chart.xml new file mode 100644 index 0000000..ac3075a --- /dev/null +++ b/app/src/main/res/layout/activity_fault_flow_chart.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_flutter_test.xml b/app/src/main/res/layout/activity_flutter_test.xml new file mode 100644 index 0000000..4144a4a --- /dev/null +++ b/app/src/main/res/layout/activity_flutter_test.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_loading.xml b/app/src/main/res/layout/activity_loading.xml new file mode 100644 index 0000000..1bc7d39 --- /dev/null +++ b/app/src/main/res/layout/activity_loading.xml @@ -0,0 +1,37 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_lock_screen_dialog.xml b/app/src/main/res/layout/activity_lock_screen_dialog.xml new file mode 100644 index 0000000..e367c43 --- /dev/null +++ b/app/src/main/res/layout/activity_lock_screen_dialog.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_point_analysis.xml b/app/src/main/res/layout/activity_point_analysis.xml new file mode 100644 index 0000000..6ab489d --- /dev/null +++ b/app/src/main/res/layout/activity_point_analysis.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_sel_point_list.xml b/app/src/main/res/layout/activity_sel_point_list.xml new file mode 100644 index 0000000..716ef30 --- /dev/null +++ b/app/src/main/res/layout/activity_sel_point_list.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/alarm/layout/activity_alarm_list.xml b/app/src/main/res/layout/alarm/layout/activity_alarm_list.xml new file mode 100644 index 0000000..2113472 --- /dev/null +++ b/app/src/main/res/layout/alarm/layout/activity_alarm_list.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/alarm/layout/item_alarm.xml b/app/src/main/res/layout/alarm/layout/item_alarm.xml new file mode 100644 index 0000000..acac9b4 --- /dev/null +++ b/app/src/main/res/layout/alarm/layout/item_alarm.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/equ/layout/activity_equ_card.xml b/app/src/main/res/layout/equ/layout/activity_equ_card.xml new file mode 100644 index 0000000..3a33225 --- /dev/null +++ b/app/src/main/res/layout/equ/layout/activity_equ_card.xml @@ -0,0 +1,30 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/equ/layout/activity_equ_detail.xml b/app/src/main/res/layout/equ/layout/activity_equ_detail.xml new file mode 100644 index 0000000..9b40fd8 --- /dev/null +++ b/app/src/main/res/layout/equ/layout/activity_equ_detail.xml @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/equ/layout/activity_equ_insert.xml b/app/src/main/res/layout/equ/layout/activity_equ_insert.xml new file mode 100644 index 0000000..a8b55d6 --- /dev/null +++ b/app/src/main/res/layout/equ/layout/activity_equ_insert.xml @@ -0,0 +1,623 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +