diff --git a/lmp_v0.3.9_del/.classpath b/lmp_v0.3.9_del/.classpath deleted file mode 100644 index b81161f..0000000 --- a/lmp_v0.3.9_del/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/lmp_v0.3.9_del/.idea/.gitignore b/lmp_v0.3.9_del/.idea/.gitignore deleted file mode 100644 index d52b102..0000000 --- a/lmp_v0.3.9_del/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/../../../../../../../../../../../../:\Users\xia\Documents\WeChat Files\wxid_4932589325712\FileStorage\File\2022-09\lmp_v0.3.9\lmp_v0.3.9\.idea/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/lmp_v0.3.9_del/.idea/ant.xml b/lmp_v0.3.9_del/.idea/ant.xml deleted file mode 100644 index a2a4769..0000000 --- a/lmp_v0.3.9_del/.idea/ant.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/lmp_v0.3.9_del/.idea/artifacts/LMP_jar.xml b/lmp_v0.3.9_del/.idea/artifacts/LMP_jar.xml deleted file mode 100644 index 5be8a26..0000000 --- a/lmp_v0.3.9_del/.idea/artifacts/LMP_jar.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/LMP_jar - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lmp_v0.3.9_del/.idea/compiler.xml b/lmp_v0.3.9_del/.idea/compiler.xml deleted file mode 100644 index ee3fcf6..0000000 --- a/lmp_v0.3.9_del/.idea/compiler.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/lmp_v0.3.9_del/.idea/libraries/lib.xml b/lmp_v0.3.9_del/.idea/libraries/lib.xml deleted file mode 100644 index fa8838a..0000000 --- a/lmp_v0.3.9_del/.idea/libraries/lib.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/lmp_v0.3.9_del/.idea/misc.xml b/lmp_v0.3.9_del/.idea/misc.xml deleted file mode 100644 index a8cf858..0000000 --- a/lmp_v0.3.9_del/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/lmp_v0.3.9_del/.idea/modules.xml b/lmp_v0.3.9_del/.idea/modules.xml deleted file mode 100644 index c1cd80f..0000000 --- a/lmp_v0.3.9_del/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/lmp_v0.3.9_del/.project b/lmp_v0.3.9_del/.project deleted file mode 100644 index a2e36fd..0000000 --- a/lmp_v0.3.9_del/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - LMP - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - - - 1665044943597 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - - diff --git a/lmp_v0.3.9_del/.settings/org.eclipse.core.resources.prefs b/lmp_v0.3.9_del/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 8fdd13b..0000000 --- a/lmp_v0.3.9_del/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/log4j.properties=UTF-8 -encoding/=UTF-8 -encoding/config.properties=UTF-8 diff --git a/lmp_v0.3.9_del/.settings/org.eclipse.jdt.core.prefs b/lmp_v0.3.9_del/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 6709bd3..0000000 --- a/lmp_v0.3.9_del/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,576 +0,0 @@ -eclipse.preferences.version=1 -enableParallelJavaIndexSearch=true -org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter= -org.eclipse.jdt.core.circularClasspath=warning -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.camelCaseMatch=enabled -org.eclipse.jdt.core.codeComplete.deprecationCheck=disabled -org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck=disabled -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.forbiddenReferenceCheck=enabled -org.eclipse.jdt.core.codeComplete.forceImplicitQualification=disabled -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -org.eclipse.jdt.core.codeComplete.subwordMatch=disabled -org.eclipse.jdt.core.codeComplete.suggestStaticImports=enabled -org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullable.secondary= -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.lambda.genericSignature=do not generate -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.shareCommonFinallyBlocks=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.emulateJavacBug8031744=enabled -org.eclipse.jdt.core.compiler.generateClassFiles=enabled -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.problem.APILeak=warning -org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deadCodeInTrivialIfStatement=disabled -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation=ignore -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.tasks=warning -org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore -org.eclipse.jdt.core.compiler.problem.uninternedIdentityComparison=disabled -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled -org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeArgumentsForMethodInvocation=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.processAnnotations=disabled -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.jdt.core.compiler.storeAnnotations=disabled -org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled -org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL -org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX -org.eclipse.jdt.core.computeJavaBuildOrder=ignore -org.eclipse.jdt.core.encoding=utf8 -org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false -org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 -org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line=true -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false -org.eclipse.jdt.core.formatter.align_with_spaces=false -org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon=16 -org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_record_components=16 -org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 -org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow=20 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 -org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 -org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true -org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false -org.eclipse.jdt.core.formatter.comment.indent_root_tags=false -org.eclipse.jdt.core.formatter.comment.indent_tag_description=false -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert -org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=false -org.eclipse.jdt.core.formatter.join_wrapped_lines=false -org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false -org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.lineSplit=120 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.text_block_indentation=0 -org.eclipse.jdt.core.formatter.use_on_off_tags=true -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true -org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true -org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true -org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true -org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true -org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true -org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true -org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true -org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator=false -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter -org.eclipse.jdt.core.timeoutForParameterNameFromAttachedJavadoc=50 diff --git a/lmp_v0.3.9_del/LMP.iml b/lmp_v0.3.9_del/LMP.iml deleted file mode 100644 index d670854..0000000 --- a/lmp_v0.3.9_del/LMP.iml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lmp_v0.3.9_del/bin/META-INF/MANIFEST.MF b/lmp_v0.3.9_del/bin/META-INF/MANIFEST.MF deleted file mode 100644 index 43127fe..0000000 --- a/lmp_v0.3.9_del/bin/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: com.lpro.iot.server.MinaServer - diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/BaseBean.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/BaseBean.class deleted file mode 100644 index c8385c1..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/BaseBean.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotBaseBean.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotBaseBean.class deleted file mode 100644 index bb40cda..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotBaseBean.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotMqttSensorInfo.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotMqttSensorInfo.class deleted file mode 100644 index 94533b0..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotMqttSensorInfo.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotNodeInfo.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotNodeInfo.class deleted file mode 100644 index 12af5c6..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotNodeInfo.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotNodeInfoBO.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotNodeInfoBO.class deleted file mode 100644 index aa7a66f..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotNodeInfoBO.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotSensorInfo.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotSensorInfo.class deleted file mode 100644 index a11e5c2..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotSensorInfo.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotSensorInfoBO.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotSensorInfoBO.class deleted file mode 100644 index e77643a..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/IotSensorInfoBO.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/LockResult.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/LockResult.class deleted file mode 100644 index ad5e605..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/LockResult.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/ModbusConfig.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/ModbusConfig.class deleted file mode 100644 index c96b090..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/ModbusConfig.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/ReturnObj.class b/lmp_v0.3.9_del/bin/com/lpro/iot/bean/ReturnObj.class deleted file mode 100644 index 400f2d2..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/bean/ReturnObj.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Cache.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Cache.class deleted file mode 100644 index a7bbfb3..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Cache.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$DEVICE_STATUS.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$DEVICE_STATUS.class deleted file mode 100644 index d873565..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$DEVICE_STATUS.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$IOT_NODE_STATUS.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$IOT_NODE_STATUS.class deleted file mode 100644 index 7f2f1af..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$IOT_NODE_STATUS.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$ResponseCode.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$ResponseCode.class deleted file mode 100644 index d8aa444..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code$ResponseCode.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code.class deleted file mode 100644 index 81d9361..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Code.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Config.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Config.class deleted file mode 100644 index b8eb388..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Config.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants$CODE_TYPE.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants$CODE_TYPE.class deleted file mode 100644 index 7e26a49..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants$CODE_TYPE.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants$URL.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants$URL.class deleted file mode 100644 index d1ee637..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants$URL.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants.class b/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants.class deleted file mode 100644 index c4bd46b..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/common/Constants.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/dto/Brower2LpmDto.class b/lmp_v0.3.9_del/bin/com/lpro/iot/dto/Brower2LpmDto.class deleted file mode 100644 index 7b95a22..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/dto/Brower2LpmDto.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MessageCallback.class b/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MessageCallback.class deleted file mode 100644 index adf7bf1..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MessageCallback.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MessageHandler.class b/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MessageHandler.class deleted file mode 100644 index 3d52cf0..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MessageHandler.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MqttService.class b/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MqttService.class deleted file mode 100644 index add403e..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/mqtt/MqttService.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/Iprotocal.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/Iprotocal.class deleted file mode 100644 index cf7f662..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/Iprotocal.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/Protocal.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/Protocal.class deleted file mode 100644 index 98a5133..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/Protocal.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/ProtocalFactory.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/ProtocalFactory.class deleted file mode 100644 index 7a113c4..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/ProtocalFactory.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalHj212.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalHj212.class deleted file mode 100644 index 788bdfd..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalHj212.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalMing.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalMing.class deleted file mode 100644 index 2edc502..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalMing.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$1.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$1.class deleted file mode 100644 index a745327..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$1.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$2.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$2.class deleted file mode 100644 index 95c3bb2..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$2.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$3.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$3.class deleted file mode 100644 index 5c4c967..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$3.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$4.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$4.class deleted file mode 100644 index 469f622..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus$4.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus.class deleted file mode 100644 index 9e6d66d..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbus.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$1.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$1.class deleted file mode 100644 index c633a7e..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$1.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$2.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$2.class deleted file mode 100644 index 67f81f5..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$2.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$3.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$3.class deleted file mode 100644 index 3f8a78b..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp$3.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp.class deleted file mode 100644 index 6bac0f5..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalModbusTcp.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYinTlink.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYinTlink.class deleted file mode 100644 index f728806..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYinTlink.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw$1.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw$1.class deleted file mode 100644 index 4ab0381..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw$1.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw$TimerTaskThread.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw$TimerTaskThread.class deleted file mode 100644 index 2d38ac5..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw$TimerTaskThread.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw.class b/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw.class deleted file mode 100644 index dada2bb..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/protocal/impl/ProtocalYw.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/server/MinaServer.class b/lmp_v0.3.9_del/bin/com/lpro/iot/server/MinaServer.class deleted file mode 100644 index 16934dc..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/server/MinaServer.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/server/ServerIoHandler.class b/lmp_v0.3.9_del/bin/com/lpro/iot/server/ServerIoHandler.class deleted file mode 100644 index dffed0f..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/server/ServerIoHandler.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/server/UdpSeverHandler.class b/lmp_v0.3.9_del/bin/com/lpro/iot/server/UdpSeverHandler.class deleted file mode 100644 index 6c37c68..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/server/UdpSeverHandler.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/service/MsgHandlerService.class b/lmp_v0.3.9_del/bin/com/lpro/iot/service/MsgHandlerService.class deleted file mode 100644 index c6bda15..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/service/MsgHandlerService.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/service/impl/task/NodeHeartTask.class b/lmp_v0.3.9_del/bin/com/lpro/iot/service/impl/task/NodeHeartTask.class deleted file mode 100644 index 60717ea..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/service/impl/task/NodeHeartTask.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/service/impl/task/SysHealthExam.class b/lmp_v0.3.9_del/bin/com/lpro/iot/service/impl/task/SysHealthExam.class deleted file mode 100644 index bed5a1b..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/service/impl/task/SysHealthExam.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.class b/lmp_v0.3.9_del/bin/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.class deleted file mode 100644 index 0fe8ad7..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/serviceImpl/TaskServiceImpl.class b/lmp_v0.3.9_del/bin/com/lpro/iot/serviceImpl/TaskServiceImpl.class deleted file mode 100644 index 9384054..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/serviceImpl/TaskServiceImpl.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/ArithHelper.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/ArithHelper.class deleted file mode 100644 index 5f9f016..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/ArithHelper.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Calculator.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Calculator.class deleted file mode 100644 index e06292d..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Calculator.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/CoordinateTransformUtil.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/CoordinateTransformUtil.class deleted file mode 100644 index 87e68e1..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/CoordinateTransformUtil.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/DateUtils.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/DateUtils.class deleted file mode 100644 index 81cc6b5..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/DateUtils.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/HttpServiceSender.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/HttpServiceSender.class deleted file mode 100644 index 16dd0a2..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/HttpServiceSender.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/MD5Util.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/MD5Util.class deleted file mode 100644 index aa2226e..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/MD5Util.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/ObjectUtil.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/ObjectUtil.class deleted file mode 100644 index 030db0b..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/ObjectUtil.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/PropertiesUtil.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/PropertiesUtil.class deleted file mode 100644 index b184dc5..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/PropertiesUtil.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/SortList$1.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/SortList$1.class deleted file mode 100644 index 7d6c59b..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/SortList$1.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/SortList.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/SortList.class deleted file mode 100644 index d33d5ea..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/SortList.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$ByteArrayConveter.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$ByteArrayConveter.class deleted file mode 100644 index 74ae774..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$ByteArrayConveter.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$NodeDevice.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$NodeDevice.class deleted file mode 100644 index 0bc3d76..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$NodeDevice.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$Obj.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$Obj.class deleted file mode 100644 index e978729..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$Obj.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$binhexoct.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$binhexoct.class deleted file mode 100644 index 8afece4..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$binhexoct.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$crc.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$crc.class deleted file mode 100644 index d1c13e9..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$crc.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$date.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$date.class deleted file mode 100644 index 10ebc95..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$date.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$file.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$file.class deleted file mode 100644 index 4f34188..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$file.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$json.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$json.class deleted file mode 100644 index 4dc7970..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$json.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$map.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$map.class deleted file mode 100644 index c2971a1..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$map.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$mina.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$mina.class deleted file mode 100644 index ac4873d..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$mina.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$protocal.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$protocal.class deleted file mode 100644 index 7754fd3..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$protocal.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$reflect.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$reflect.class deleted file mode 100644 index 11c32fc..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util$reflect.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util.class b/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util.class deleted file mode 100644 index 3f17fc3..0000000 Binary files a/lmp_v0.3.9_del/bin/com/lpro/iot/utils/Util.class and /dev/null differ diff --git a/lmp_v0.3.9_del/bin/log4j.properties b/lmp_v0.3.9_del/bin/log4j.properties deleted file mode 100644 index 6d3a782..0000000 --- a/lmp_v0.3.9_del/bin/log4j.properties +++ /dev/null @@ -1,41 +0,0 @@ -############################################################################# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################# -log4j.rootLogger=INFO,CONSOLE,R -log4j.additivity.org.apache=true - -#全局的日志级别(打印sql必须要该属性) -log4j.appender.Threshold=INFO - -#ConsoleAppender -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=DEBUG -log4j.appender.CONSOLE.Target=System.out -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p [%t] -%l - %m%n - -log4j.appender.R=org.apache.log4j.RollingFileAppender -log4j.appender.R.Threshold=DEBUG -log4j.appender.R.File=/log/lpm/${lpmKey}/${lpmKey}.log -log4j.appender.R.MaxFileSize=2048KB -log4j.appender.R.Append=true -log4j.appender.R.MaxBackupIndex=20 -log4j.appender.R.layout=org.apache.log4j.PatternLayout - -log4j.appender.R.layout.ConversionPattern=%d %p [%c] - <%m>%n - - - diff --git a/lmp_v0.3.9_del/bin/test.class b/lmp_v0.3.9_del/bin/test.class deleted file mode 100644 index 62a0969..0000000 Binary files a/lmp_v0.3.9_del/bin/test.class and /dev/null differ diff --git a/lmp_v0.3.9_del/build.xml b/lmp_v0.3.9_del/build.xml deleted file mode 100644 index e7752dd..0000000 --- a/lmp_v0.3.9_del/build.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - LSM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - libs ${libs} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lmp_v0.3.9_del/build/LSM.jar b/lmp_v0.3.9_del/build/LSM.jar deleted file mode 100644 index 91a04cb..0000000 Binary files a/lmp_v0.3.9_del/build/LSM.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/config.properties b/lmp_v0.3.9_del/config.properties deleted file mode 100644 index 950e499..0000000 --- a/lmp_v0.3.9_del/config.properties +++ /dev/null @@ -1,16 +0,0 @@ -# USER_KEY -iot.userKey=426aad8a150a4d85a8fa7221085edca3 - -#TCP SERVER PORT -iot.port=50001 -iot.url=http://127.0.0.1:8080/lpro -iot.lpm.key=qw3erfds3c4qq0856bf9b63f99529f - -#MQTT -iot.mqtt.host=tcp://127.0.0.1:1883 -iot.mqtt.userName=iot2yun -iot.mqtt.password=iot2yun - -#UDP----------- -iot.udp.switch=false -iot.udp.port=8000 \ No newline at end of file diff --git a/lmp_v0.3.9_del/lib/commons-codec-1.4.jar b/lmp_v0.3.9_del/lib/commons-codec-1.4.jar deleted file mode 100644 index 458d432..0000000 Binary files a/lmp_v0.3.9_del/lib/commons-codec-1.4.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/commons-httpclient-3.0.jar b/lmp_v0.3.9_del/lib/commons-httpclient-3.0.jar deleted file mode 100644 index 54a9300..0000000 Binary files a/lmp_v0.3.9_del/lib/commons-httpclient-3.0.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/commons-lang-2.6.jar b/lmp_v0.3.9_del/lib/commons-lang-2.6.jar deleted file mode 100644 index 98467d3..0000000 Binary files a/lmp_v0.3.9_del/lib/commons-lang-2.6.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/commons-logging-1.1.1.jar b/lmp_v0.3.9_del/lib/commons-logging-1.1.1.jar deleted file mode 100644 index 1deef14..0000000 Binary files a/lmp_v0.3.9_del/lib/commons-logging-1.1.1.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/fastjson-1.2.56.jar b/lmp_v0.3.9_del/lib/fastjson-1.2.56.jar deleted file mode 100644 index f07ff6e..0000000 Binary files a/lmp_v0.3.9_del/lib/fastjson-1.2.56.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/jackson-annotations-2.3.0.jar b/lmp_v0.3.9_del/lib/jackson-annotations-2.3.0.jar deleted file mode 100644 index 3901f32..0000000 Binary files a/lmp_v0.3.9_del/lib/jackson-annotations-2.3.0.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/jackson-core-2.3.0.jar b/lmp_v0.3.9_del/lib/jackson-core-2.3.0.jar deleted file mode 100644 index 1512100..0000000 Binary files a/lmp_v0.3.9_del/lib/jackson-core-2.3.0.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/jackson-core-asl-1.9.13.jar b/lmp_v0.3.9_del/lib/jackson-core-asl-1.9.13.jar deleted file mode 100644 index bb4fe1d..0000000 Binary files a/lmp_v0.3.9_del/lib/jackson-core-asl-1.9.13.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/jackson-databind-2.3.0.jar b/lmp_v0.3.9_del/lib/jackson-databind-2.3.0.jar deleted file mode 100644 index 32f12f0..0000000 Binary files a/lmp_v0.3.9_del/lib/jackson-databind-2.3.0.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/jackson-mapper-asl-1.9.13.jar b/lmp_v0.3.9_del/lib/jackson-mapper-asl-1.9.13.jar deleted file mode 100644 index 0f2073f..0000000 Binary files a/lmp_v0.3.9_del/lib/jackson-mapper-asl-1.9.13.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/log4j-1.2.16.jar b/lmp_v0.3.9_del/lib/log4j-1.2.16.jar deleted file mode 100644 index 3f9d847..0000000 Binary files a/lmp_v0.3.9_del/lib/log4j-1.2.16.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/lombok.jar b/lmp_v0.3.9_del/lib/lombok.jar deleted file mode 100644 index 703441b..0000000 Binary files a/lmp_v0.3.9_del/lib/lombok.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/mina-core-2.0.4.jar b/lmp_v0.3.9_del/lib/mina-core-2.0.4.jar deleted file mode 100644 index 985fb79..0000000 Binary files a/lmp_v0.3.9_del/lib/mina-core-2.0.4.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/mqtt-client-1.12.jar b/lmp_v0.3.9_del/lib/mqtt-client-1.12.jar deleted file mode 100644 index 48d9edb..0000000 Binary files a/lmp_v0.3.9_del/lib/mqtt-client-1.12.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/org.eclipse.paho.client.mqttv3-1.2.0.jar b/lmp_v0.3.9_del/lib/org.eclipse.paho.client.mqttv3-1.2.0.jar deleted file mode 100644 index dc4b1ea..0000000 Binary files a/lmp_v0.3.9_del/lib/org.eclipse.paho.client.mqttv3-1.2.0.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/slf4j-api-1.5.11.jar b/lmp_v0.3.9_del/lib/slf4j-api-1.5.11.jar deleted file mode 100644 index ccb8c72..0000000 Binary files a/lmp_v0.3.9_del/lib/slf4j-api-1.5.11.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/lib/slf4j-log4j12-1.5.11.jar b/lmp_v0.3.9_del/lib/slf4j-log4j12-1.5.11.jar deleted file mode 100644 index c30ef0e..0000000 Binary files a/lmp_v0.3.9_del/lib/slf4j-log4j12-1.5.11.jar and /dev/null differ diff --git a/lmp_v0.3.9_del/src/META-INF/MANIFEST.MF b/lmp_v0.3.9_del/src/META-INF/MANIFEST.MF deleted file mode 100644 index 43127fe..0000000 --- a/lmp_v0.3.9_del/src/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: com.lpro.iot.server.MinaServer - diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/BaseBean.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/BaseBean.java deleted file mode 100644 index c9039b8..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/BaseBean.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.lpro.iot.bean; - -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class BaseBean extends IotBaseBean { - - private Integer id ; - - private List id_array ; - - /** - * 删除标志,0正常,1删除 - */ - private Integer delete_flag = 0 ; - - public Integer offset ; - - public Integer limit ; - - public Map data = null; - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotBaseBean.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotBaseBean.java deleted file mode 100644 index 2713b6a..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotBaseBean.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.lpro.iot.bean; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 放置一些公共业务字段 - * @author chenrj - * - */ - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class IotBaseBean { - - private String sensor_name ; - - private Integer scene_id ; - - private Integer user_id ; -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotMqttSensorInfo.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotMqttSensorInfo.java deleted file mode 100644 index 5a02962..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotMqttSensorInfo.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lpro.iot.bean; - -import java.util.Date; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -/** - *@类:IotSensorInfo - *@作者:chenrj - */ - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class IotMqttSensorInfo { - - /**sensor_device_id*/ - private String sensor_device_id; - - /**port_id*/ - private Integer port_id; - - /**sdata*/ - private Float sdata; - - /**mtime*/ - private Date mtime; - - private String device_code ; - -} \ No newline at end of file diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotNodeInfo.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotNodeInfo.java deleted file mode 100644 index 8996044..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotNodeInfo.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.lpro.iot.bean; - -import java.util.Date; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - - -import lombok.Data; - -import lombok.EqualsAndHashCode; - -import lombok.NoArgsConstructor; - -/** - *@类:IotNodeInfo - */ - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class IotNodeInfo extends BaseBean { - - - - /**name*/ - private String name; - - /**device_code*/ - private String device_code; - - /**节点类型:数据节点,视频、门禁*/ - private Integer iot_node_type; - - /**协议类型*/ - private String iot_protocal_category; - - /**seq*/ - private Integer seq; - - /**scene_id*/ - private Integer scene_id; - - /**节点状态*/ - private Integer iot_node_status; - - /**img_id*/ - private Integer img_id; - - /**aid*/ - private Integer aid; - - /**atime*/ - private Date atime; - - /**mid*/ - private Integer mid; - - /**mtime*/ - private Date mtime; - - private String lpmKey ; - - private Integer period ; - - private Integer req_id ; - - - private String infos ; - - private Integer frequency ; - - /** - * 维保时间 - */ - private Date maintenance_time; - -} \ No newline at end of file diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotNodeInfoBO.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotNodeInfoBO.java deleted file mode 100644 index a5152fa..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotNodeInfoBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.lpro.iot.bean; - -import java.util.List; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - - - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -/** - *@类:IotNodeInfo - *@作者:chenrj - */ - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class IotNodeInfoBO extends IotNodeInfo { - - public IotNodeInfoBO(Integer id) { - super(); - //this.setId(id); - } - - private String scene_name; - - private String lpmKey ; - - private Integer device_template_id ; - - private String template_name ; - - private List iotSensorList ; - - - } - diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotSensorInfo.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotSensorInfo.java deleted file mode 100644 index 97451d6..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotSensorInfo.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.lpro.iot.bean; - -import java.util.Date; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -/** - *@类:IotSensorInfo - *@作者:chenrj - */ - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class IotSensorInfo extends BaseBean { - - public IotSensorInfo(String sensor_device_id, Integer port_id, Float sdata, - String device_code) { - super(); - this.sensor_device_id = sensor_device_id; - this.port_id = port_id; - this.sdata = sdata; - this.request_sdata = sdata; - this.device_code = device_code; - } - - public IotSensorInfo(String sensor_device_id, Integer port_id, Integer sdata, - String device_code) { - super(); - this.sensor_device_id = sensor_device_id; - this.port_id = port_id; - this.sdata = sdata+0.0f; - this.request_sdata = sdata+0.0f; - this.device_code = device_code; - } - - public IotSensorInfo(String sensor_device_id, Integer port_id, String strdata, - String device_code) { - super(); - this.sensor_device_id = sensor_device_id; - this.port_id = port_id; - this.str_sdata = strdata; - this.device_code = device_code; - } - - /** - * name - */ - - - - private String name; - - /**传感器单位*/ - private Integer measure_unit_type; - - /**类型:连续型、开关性等*/ - private Integer iot_sensor_type; - - /**种类:温度、IO、开关*/ - private Integer iot_sensor_category; - - /**node_id*/ - private Integer node_id; - - /**sensor_device_id*/ - private String sensor_device_id; - - /**port_id*/ - private Integer port_id; - - /**sdata*/ - private Float sdata; - - /**seq*/ - private Integer seq; - - /**传感器状态*/ - private Integer iot_sensor_status; - - /**request_sdata*/ - private Float request_sdata; - - /**精度*/ - private Integer sdata_degree; - - /**直接公式处理,公式可在数据字典选择*/ - private String formula_up; - - private String formula_down; - - /**register_time*/ - private Date register_time; - - /**aid*/ - private Integer aid; - - /**atime*/ - private Date atime; - - /**mid*/ - private Integer mid; - - /**mtime*/ - private Date mtime; - - private String device_code ; - - private String str_sdata ; - - - private String infos ; - -} \ No newline at end of file diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotSensorInfoBO.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotSensorInfoBO.java deleted file mode 100644 index 341071b..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/IotSensorInfoBO.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.lpro.iot.bean; - -import java.util.Date; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -/** - *@类:IotSensorInfo - *@作者:chenrj - */ - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class IotSensorInfoBO extends IotSensorInfo { - - - public IotSensorInfoBO(Integer id){ - - setId(id); - } - - - public IotSensorInfoBO(String device_code,String sensor_device_id,Integer port_id,Date mtime,Double sdata) { - super(); - this.device_code = device_code; - this.setSensor_device_id(sensor_device_id); - this.setSdata( sdata.floatValue() ); - this.setPort_id(port_id); - this.setMtime(mtime); - } - - - - private String device_code ; - - private String node_name ; - - private String scene_name ; - - private Integer scene_id ; - - private String iot_sensor_type_array ; - - } - diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/LockResult.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/LockResult.java deleted file mode 100644 index d507106..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/LockResult.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.lpro.iot.bean; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class LockResult { - - private volatile Boolean flag ; - - private volatile Integer sensor_device_id ; - - private volatile Integer port_id ; - - private ModbusConfig modbusConfig ; - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/ModbusConfig.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/ModbusConfig.java deleted file mode 100644 index bae7e70..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/ModbusConfig.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.lpro.iot.bean; - -import java.util.List; - -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class ModbusConfig { - - // 变量类型,字、双字 int 有符号 , float , uint, uint32 - private String type ; - - // 排序 默认ABCD - // CD AB - // BA DC - // DC BA - private String order ; - - // 功能码 - // 01 03 04 - private String fcode ; - - // 数值 - private String value ; - - // 寄存器数 - private String length ; - - // 起始地址 - private String saddr ; - - // 设备地址 - private String address ; - - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/bean/ReturnObj.java b/lmp_v0.3.9_del/src/com/lpro/iot/bean/ReturnObj.java deleted file mode 100644 index dd594b0..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/bean/ReturnObj.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.lpro.iot.bean; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class ReturnObj { - - private Integer status ; - - private String statusMsg ; - - private IotNodeInfoBO data ; - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/common/Cache.java b/lmp_v0.3.9_del/src/com/lpro/iot/common/Cache.java deleted file mode 100644 index aeb04a7..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/common/Cache.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lpro.iot.common; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.mina.core.session.IoSession; - - -/** - * 缓存 - * - */ -public class Cache { - - - /** - * nodeId session 缓存 - */ - public static Map nodeIdsessionMap = new ConcurrentHashMap<>(); - - - /** - * 定时任务轮训,主要主动请求数据 - */ - public static Map timerTaskMap = new ConcurrentHashMap<>(); - - /** - * 设备数据透传 - */ - public static Map deviceMap = new ConcurrentHashMap<>(); - - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/common/Code.java b/lmp_v0.3.9_del/src/com/lpro/iot/common/Code.java deleted file mode 100644 index eb63668..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/common/Code.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lpro.iot.common; - -public class Code { - - public static class IOT_NODE_STATUS { - - public static final Integer online = 16 ; - - public static final Integer offline = 17; - - } - - public static class ResponseCode{ - - public static final Integer OK = 2 ; - - public static final Integer NO_DATA = 4 ; - } - - /** - * 设备状态 - * @author chenrj - * - */ - public static class DEVICE_STATUS{ - - public static final Integer ONLINE = 16 ; - - public static final Integer OFFLINE = 17 ; - - public static final Integer UNCONTECT = 18; - - public static final Integer FAILURE = 19 ; - } - -} \ No newline at end of file diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/common/Config.java b/lmp_v0.3.9_del/src/com/lpro/iot/common/Config.java deleted file mode 100644 index f60186b..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/common/Config.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.lpro.iot.common; - -import com.lpro.iot.utils.PropertiesUtil; - -/** - * 配置文件数据 - * - */ -public class Config { - - public static String IOT_USER_KEY = PropertiesUtil.getProperty("iot.userKey"); - - public static Integer IOT_PORT = Integer.parseInt(PropertiesUtil.getProperty("iot.port")) ; - - public static Integer IOT_UDP_PORT = Integer.parseInt(PropertiesUtil.getProperty("iot.udp.port")) ; - - public static boolean IOT_UDP_SWITCH = PropertiesUtil.getProperty("iot.udp.switch").equalsIgnoreCase("true") ; - - public static String IOT_URL = PropertiesUtil.getProperty("iot.url"); - - public static String IOT_LPM_KEY = PropertiesUtil.getProperty("iot.lpm.key"); - - // 设备协议列表 - public static String IOT_PROTOCAL = "ProtocalHj212" ; - - public static String IOT_MQTT_HOST = PropertiesUtil.getProperty("iot.mqtt.host"); - - public static String IOT_MQTT_CLIENTID = IOT_LPM_KEY; - - public static String IOT_MQTT_TOPIC = "/lpm/" + IOT_LPM_KEY +",/transmit/device" ; - - public static String IOT_MQTT_USERNAME = PropertiesUtil.getProperty("iot.mqtt.userName"); - - public static String IOT_MQTT_PASSWORD = PropertiesUtil.getProperty("iot.mqtt.password"); - - /** - * 设置LPM启动时,传入备要的启动参数,以便修改配置文件的默认参数 - * @param str - */ - public static void loadExtenalConfig(String[] str){ - // ... - - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/common/Constants.java b/lmp_v0.3.9_del/src/com/lpro/iot/common/Constants.java deleted file mode 100644 index 92c6794..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/common/Constants.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.lpro.iot.common; - -public class Constants { - - public final static String IOT_LPM_TYPE = "IOT_SERVER_LPM"; - - public final static String DEVICECODE = "deviceId"; - - public final static String PROTOCOL_CATEGORY = "ProtocolCategory"; - - public final static String DEVICE_PARAM = "DeviceParam" ; - - public final static String DEVICE_TRANSFER = "deviceTransfer" ; - - public final static String DEVICE_FLAG = "deviceFlag" ; - - public final static String DEVICE_SESSION = "deviceSession" ; - - public final static String NODE_INFO = "nodeInfo" ; - - public final static String THREAD_HASH_CODE = "threadHashCode" ; - - public final static String DATA_CACHE = "dataCache"; - - - public static class CODE_TYPE{ - public final static String HEX = "hex"; - public final static String STR = "STR"; - } - - public static class URL{ - /** - * 同步lpro和lpm数据 - */ - public static String SYNC_NODE = Config.IOT_URL + "/service/node/data/sync.json" ; - - /** - * 修改传感器的请求值,实时值 - */ - public static String SENSORS_DATA = Config.IOT_URL + "/service/sensors/realtime/update.json"; - /** - * 修改设备的状态 - */ - public static String NODE_INFO = Config.IOT_URL +"/service/node/status.json"; - /** - * 批量保存储存传感器数据 - */ - public static String SAVE_NODE_DATA = Config.IOT_URL + "/service/save/node/data.json" ; - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/dto/Brower2LpmDto.java b/lmp_v0.3.9_del/src/com/lpro/iot/dto/Brower2LpmDto.java deleted file mode 100644 index d09bf3e..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/dto/Brower2LpmDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.lpro.iot.dto; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -@EqualsAndHashCode(callSuper = false) -public class Brower2LpmDto { - - private Integer messageType ; // 1 连接 ,2 数据 - - private String deviceCode ; // 设备号 - - private Integer dataType ; // 数据类型 1 16进制,2 ascii - - private String data ; // 数据 - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MessageCallback.java b/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MessageCallback.java deleted file mode 100644 index 8fe7e41..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MessageCallback.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lpro.iot.mqtt; - -import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; -import org.eclipse.paho.client.mqttv3.MqttCallbackExtended; -import org.eclipse.paho.client.mqttv3.MqttMessage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lpro.iot.server.MinaServer; - -public class MessageCallback implements MqttCallbackExtended { - - private static Logger LOGGER = (Logger) LoggerFactory.getLogger(MqttService.class); - - @Override - public void connectionLost(Throwable arg0) { - // TODO 连接断开,可以做重连,目前重连失败,还没有设置 - } - - @Override - public void deliveryComplete(IMqttDeliveryToken token) { - // TODO delivery 传送OK - } - - @Override - public void messageArrived(String topic, MqttMessage message) throws Exception { - // 消息放入线程池中处理 - MinaServer.threadPool.execute(new MessageHandler(message.getPayload() , new String(message.getPayload()), topic)); - } - - @Override - public void connectComplete(boolean arg0, String arg1) { - // 连接成功后,重新订阅自己的主题 - MqttService.subscribe(); - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MessageHandler.java b/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MessageHandler.java deleted file mode 100644 index 2b43365..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MessageHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.lpro.iot.mqtt; - -import java.util.Date; - -import org.apache.mina.core.session.IoSession; - -import com.alibaba.fastjson.JSON; - -import com.lpro.iot.common.Cache; -import com.lpro.iot.dto.Brower2LpmDto; -import com.lpro.iot.protocal.Protocal; -import com.lpro.iot.utils.ObjectUtil; -import com.lpro.iot.utils.Util; - -public class MessageHandler implements Runnable { - - private String message ; - private String topic ; - private byte[] msg ; - - public MessageHandler(byte[] msg , String message,String topic){ - this.message = message ; - this.topic = topic; - this.msg= msg; - } - - @Override - public void run() { - try{ - if(topic.contains("/lpm") ){ - // 服务器发送命令 - Protocal.execServer(null,msg,message); - - }else if(topic.contains("/transmit")){ - // 透传命令 - 入库和更新时间 - Brower2LpmDto browerDto = JSON.parseObject(message, Brower2LpmDto.class) ; - Integer messageType = browerDto.getMessageType() ; - String deviceCode = browerDto.getDeviceCode() ; - if( messageType == 1 ){ - Cache.deviceMap.put( deviceCode , new Date().getTime()) ; - }else{ - // 数据发送 - IoSession session = Cache.nodeIdsessionMap.get(deviceCode); - if(ObjectUtil.isNotEmpty(session)){ - Integer dataType = browerDto.getDataType() ; - if( dataType == 1 ){ - // 16进制 - byte[] sdata = Util.protocal.hexString2ByteArray(browerDto.getData().replaceAll(" ", "")); - Util.mina.write(session, sdata ); - }else{ - // ascii - Util.mina.writeStr(session, browerDto.getData() ); - } - }else{ - MqttService.pubMessage( "error", "/sys/debug/" + deviceCode ); - } - } - } - }catch(Exception e){ - MqttService.LOGGER.error(message); - } - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MqttService.java b/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MqttService.java deleted file mode 100644 index ba9b868..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/mqtt/MqttService.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.lpro.iot.mqtt; - -import org.eclipse.paho.client.mqttv3.MqttClient; -import org.eclipse.paho.client.mqttv3.MqttConnectOptions; -import org.eclipse.paho.client.mqttv3.MqttException; -import org.eclipse.paho.client.mqttv3.MqttMessage; -import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lpro.iot.common.Config; - -public class MqttService { - // MQTT安装的服务器地址:MQTT定义的端口号 - public static final String HOST = Config.IOT_MQTT_HOST; - // 定阅的主题 - public static final String TOPIC = Config.IOT_MQTT_TOPIC ; - // 定义MQTT的ID - private static final String clientid = Config.IOT_MQTT_CLIENTID ; - - private static final String userName = Config.IOT_MQTT_USERNAME ; - private static final String passWord = Config.IOT_MQTT_PASSWORD ; - - public static Logger LOGGER = (Logger) LoggerFactory.getLogger(MqttService.class); - - public static MqttClient client; - - /** - * 构造函数 - * @throws MqttException - */ - public MqttService() throws MqttException { - // MemoryPersistence设置 - client = new MqttClient(HOST, clientid, new MemoryPersistence()); - connect(); - } - - /** - * 用来连接服务器 - */ - public static void connect() { - MqttConnectOptions options = new MqttConnectOptions(); - options.setCleanSession(false); - options.setUserName(userName); - options.setPassword(passWord.toCharArray()); - // 设置超时时间 - options.setConnectionTimeout(10); - // 设置会话心跳时间 - options.setKeepAliveInterval(20); - // 重连 - options.setAutomaticReconnect(true); - options.setCleanSession(true); - try { - client.setCallback(new MessageCallback()); - client.connect(options); - LOGGER.info("mqtt server connect success ;"); - } catch (Exception e) { - LOGGER.error("Error:" + e.getLocalizedMessage() +",请检查EMQX是否正常启动!"); - } - } - - public static void subscribe(){ - try{ - // 订阅消息 - String[] topic1 = TOPIC.split(",") ; - int[] Qos = new int[topic1.length]; - for(int i = 0; i< Qos.length ;i++ ){ - Qos[i] =1 ; - } - client.subscribe(topic1, Qos); - }catch (Exception e) { - LOGGER.error(e.getLocalizedMessage()); - } - } - /** - * 消息发送 - * @param message byte - * @param topic - */ - public static void pubMessage(byte[] message,String topic){ - MqttMessage mess = new MqttMessage(); - mess.setQos(1); - mess.setRetained(false); - mess.setPayload(message); - try { - client.publish(topic, mess); - } catch (Exception e) { - LOGGER.error(e.getLocalizedMessage()); - } - } - - /** - * 消息发送 - * @param message - * @param topic - */ - public static void pubMessage(String message,String topic){ - MqttMessage mess = new MqttMessage(); - mess.setQos(1); - mess.setRetained(false); - mess.setPayload(message.getBytes()); - try { - client.publish(topic, mess); - } catch (Exception e) { - LOGGER.error(e.getLocalizedMessage()); - } - } - -} - - - diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/Iprotocal.java b/lmp_v0.3.9_del/src/com/lpro/iot/protocal/Iprotocal.java deleted file mode 100644 index c19c8b2..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/Iprotocal.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.lpro.iot.protocal; - -import org.apache.mina.core.session.IoSession; - -import com.lpro.iot.bean.ReturnObj; - -public interface Iprotocal { - - /** - * 协议匹配 - */ - boolean match(IoSession session,byte[] data,String msg) ; - - /** - * 登录判断 - * @param session - * @param data - * @param msg - */ - void loginProtocal(IoSession session,byte[] data,String msg , ReturnObj obj); - - /** - * 数据解析 - * @param session - * @param data - * @param msg - */ - void analysisData(IoSession session, byte[] data, String msg); - - /** - * 心跳包 - * @param session - */ - void handbert(IoSession session); - - /** - * 执行server - * @param session - * @param data - * @param msg - */ - void execServer(IoSession session, byte[] data, String msg) ; - - void logout(IoSession session); - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/Protocal.java b/lmp_v0.3.9_del/src/com/lpro/iot/protocal/Protocal.java deleted file mode 100644 index 52cc59e..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/Protocal.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.lpro.iot.protocal; - -import org.apache.mina.core.session.IoSession; - -import com.lpro.iot.bean.IotNodeInfoBO; -import com.lpro.iot.bean.ReturnObj; -import com.lpro.iot.common.Cache; -import com.lpro.iot.common.Code; -import com.lpro.iot.common.Config; -import com.lpro.iot.common.Constants; -import com.lpro.iot.server.ServerIoHandler; -import com.lpro.iot.utils.MD5Util; -import com.lpro.iot.utils.ObjectUtil; -import com.lpro.iot.utils.Util; - -/** - * 协议解析,入口 - * @author chenrj - * - */ -public class Protocal { - - - public static void main(String[] args) { - System.out.println( MD5Util.MD5Encode( "user" , "").subSequence(0, 6) ); - } - /** - * 登录判断并匹配协议 - * @param session - * @param data - * @param msg - */ - public static void loginProtocal(IoSession session,byte[] data,String msg){ - // 首先判断该命令是否为登录命令 >>< 匹配多种协议 - String protocals = Config.IOT_PROTOCAL ; - String[] protocal = protocals.split(","); - - if(ObjectUtil.isEmpty(protocal)) - return ; - - for(String subProtocal :protocal ){ - boolean flag = ProtocalFactory.getInstance(subProtocal).match(session, data, msg); - if(flag){ - ProtocalFactory.getInstance(subProtocal).loginProtocal(session, data, msg, null); - return ; - } - } - // 如果没有匹配带合适的协议,则取平台获取 - if(data.length >300 ){ - return ; - } - - // 设备协议中含有逗号,则认为是转发 - if( msg.contains(",") ) { - // 则认为是转发任务 - String[] deviceInfos = msg.split(",") ; - if( deviceInfos[1].equals( MD5Util.MD5Encode( deviceInfos[0] + "iot2yun" , "").substring(0, 6) ) ) { - IoSession transferSession = Cache.nodeIdsessionMap.get(deviceInfos[0]) ; - if(ObjectUtil.isEmpty(transferSession) || ObjectUtil.isNotEmpty(transferSession.getAttribute(Constants.DEVICE_FLAG)) ) { - Util.mina.writeStr(session, "failure") ; - return ; - } - session.setAttribute( Constants.DEVICE_TRANSFER , 1) ; - session.setAttribute( Constants.DEVICE_SESSION, transferSession) ; - transferSession.setAttribute(Constants.DEVICE_FLAG, 1) ; - transferSession.setAttribute(Constants.DEVICE_SESSION, session) ; - Util.mina.writeStr(session, "success") ; - return ; - } - } - - // 解析登录命令 - String deviceCode = msg ; - if( ObjectUtil.isNotEmpty(deviceCode) ){ - - ServerIoHandler.LOGGER.info("Login Code: " + deviceCode); - - // 设备登录获取信息 - ReturnObj obj = Util.NodeDevice.loginReturn( deviceCode ); - if(obj!=null && obj.getStatus() == Code.ResponseCode.OK+0 && ObjectUtil.isNotEmpty(obj.getData()) ){ - IotNodeInfoBO nodeInfo = obj.getData() ; - if(ObjectUtil.isNotEmpty( nodeInfo.getIot_protocal_category() ) ){ - // 协议类型 - try{ - ProtocalFactory.getInstance(nodeInfo.getIot_protocal_category()).loginProtocal(session, data, msg , obj); - }catch(Exception e){ - e.printStackTrace(); - } - } - }else { - session.close(true); - } - } - - } - - /** - * 数据解析 - * @param session - * @param data - * @param msg - */ - public static void analysisData(IoSession session, byte[] data, String msg) { - // 协议种类 - String deviceCategory = session.getAttribute(Constants.PROTOCOL_CATEGORY).toString() ; - ProtocalFactory.getInstance(deviceCategory).analysisData(session, data, msg); - } - - /** - * 动作执行 - * @param session - * @param data - * @param msg - * IOT_SERVER_LPM:TYPE,nodeId,SENSOR_DEVICE_ID,PORT_ID,DATA,FORMULATE - */ - public static void execServer(IoSession session, byte[] data, String msg) { - String subStr = msg.split(":")[1]; - String[] commands = subStr.split(","); - String nodeDeviceCode = commands[1]; - if("mqtt_control".equals(commands[0])){ - - }else if("param_mqtt_write".equalsIgnoreCase(commands[0])){ - - }else if("param_mqtt_read".equalsIgnoreCase(commands[0])){ - - }else if("reset".equals(commands[0])){ - // 设备重新同步 - IoSession sessionDeviceCode = Cache.nodeIdsessionMap.get(nodeDeviceCode); - // 这里http请求 - if( sessionDeviceCode != null ){ - ReturnObj obj = Util.NodeDevice.syncDeviceReturn(nodeDeviceCode); - if( obj.getStatus() == Code.ResponseCode.OK+0 ){ - sessionDeviceCode.setAttribute( "NODE_SENSORS_DATA" , obj.getData() ) ; - } - } - }else if("param_write".equalsIgnoreCase(commands[0])){ - // tcp 写配置 - IoSession sessionDeviceCode = Cache.nodeIdsessionMap.get(nodeDeviceCode); - if(sessionDeviceCode != null){ - String deviceCategory = sessionDeviceCode.getAttribute(Constants.PROTOCOL_CATEGORY).toString() ; - ProtocalFactory.getInstance(deviceCategory).execServer(sessionDeviceCode, data, msg); - } - }else if("param_read".equalsIgnoreCase(commands[0])){ - // tcp 读配置 - IoSession sessionDeviceCode = Cache.nodeIdsessionMap.get(nodeDeviceCode); - if(sessionDeviceCode != null){ - String deviceCategory = sessionDeviceCode.getAttribute(Constants.PROTOCOL_CATEGORY).toString() ; - ProtocalFactory.getInstance(deviceCategory).execServer(sessionDeviceCode, data, msg); - } - }else{ - IoSession sessionDeviceCode = Cache.nodeIdsessionMap.get(nodeDeviceCode); - if(sessionDeviceCode != null){ - String deviceCategory = sessionDeviceCode.getAttribute(Constants.PROTOCOL_CATEGORY).toString() ; - ProtocalFactory.getInstance(deviceCategory).execServer(sessionDeviceCode, data, msg); - } - } - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/ProtocalFactory.java b/lmp_v0.3.9_del/src/com/lpro/iot/protocal/ProtocalFactory.java deleted file mode 100644 index f2031f1..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/ProtocalFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.lpro.iot.protocal; - -import java.util.HashMap; -import java.util.Map; - -public class ProtocalFactory { - - // 对象列表 - private static Map objectList = new HashMap<>(); - - /** - * 根据路径新建对象 - * @param path - * @return - */ - public static Iprotocal getInstance(String path) { - if( objectList.containsKey(path) ){ - return objectList.get(path); - }else{ - try { - Class classObject = (Class) Class.forName("com.lpro.iot.protocal.impl." + path); - Iprotocal iprotocal = classObject.newInstance() ; - objectList.put(path,iprotocal ) ; - return iprotocal ; - } catch (Exception e) { - - } - } - return null; - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalHj212.java b/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalHj212.java deleted file mode 100644 index 1d4e042..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalHj212.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.lpro.iot.protocal.impl; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.StringUtils; -import org.apache.mina.core.session.IoSession; - -import com.alibaba.fastjson.JSON; -import com.lpro.iot.bean.IotNodeInfo; -import com.lpro.iot.bean.IotNodeInfoBO; -import com.lpro.iot.bean.IotSensorInfoBO; -import com.lpro.iot.bean.ReturnObj; -import com.lpro.iot.common.Cache; -import com.lpro.iot.common.Code; -import com.lpro.iot.common.Code.IOT_NODE_STATUS; -import com.lpro.iot.common.Config; -import com.lpro.iot.common.Constants; -import com.lpro.iot.mqtt.MqttService; -import com.lpro.iot.protocal.Iprotocal; -import com.lpro.iot.utils.HttpServiceSender; -import com.lpro.iot.utils.ObjectUtil; -import com.lpro.iot.utils.Util; - -/** - * - * @author M - * HJ212 - * - */ -public class ProtocalHj212 implements Iprotocal { - - private final static String nodeSensorsData = "NODE_SENSORS_DATA" ; - - @Override - public boolean match(IoSession session, byte[] data, String msg) { - if (msg.length() > 10 && "##".equals( msg.subSequence(0, 2) ) ) { - return true; - } - return false; - } - - @Override - public void loginProtocal(IoSession session, byte[] data, String msg , ReturnObj obj) { - // 解析登录命令 - String deviceCode = ""; - - if(obj == null){ - String[] cmds = msg.split("MN=") ; - if(cmds.length >1){ - deviceCode = cmds[1].split(";")[0]; - } - if(StringUtils.isBlank(deviceCode)){ - return ; - } - obj = Util.NodeDevice.login(deviceCode); - }else{ - deviceCode = msg ; - } - - if(obj.getStatus() == Code.ResponseCode.OK+0){ - // 将devicecode放入session - session.setAttribute(Constants.DEVICECODE,deviceCode); - - session.setAttribute( nodeSensorsData, obj.getData()) ; - // session 数据缓存 - session.setAttribute("dataCache",""); - // 添加协议类型 - session.setAttribute(Constants.PROTOCOL_CATEGORY, this.getClass().getSimpleName()); - Cache.nodeIdsessionMap.put( deviceCode , session); - - // 登录成功,可以直接转换数据 - analysisData(session, data, msg); - } - - } - - @Override - public void analysisData(IoSession session, byte[] data, String msg) { - // node id - Object deviceCode = session.getAttribute(Constants.DEVICECODE); - List senorList = new ArrayList(); - String dataCache = (String) session.getAttribute("dataCache"); - - if(Cache.deviceMap.containsKey(deviceCode)){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", msg) ; - map.put("byte", Util.binhexoct.bytesToHex(data)) ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - if(ObjectUtil.isNotEmpty(dataCache)){ - msg = dataCache + msg ; - session.setAttribute("dataCache",""); - } - - try { - String[] cmds = msg.split("&&") ; - if( cmds.length <3 ){ - session.setAttribute("dataCache",msg); - }else if( cmds.length >3){ - return ; - }else{ - Date date = new Date() ; - String[] datas = cmds[1].split(";"); - for(String tmp : datas){ - IotSensorInfoBO sensorInfo = new IotSensorInfoBO(); - sensorInfo.setDevice_code(deviceCode.toString() ); - if(tmp.contains("DataTime")){ - String dateStr = tmp.split("=")[1]; - if(dateStr.length() == 17){ - date = Util.date.parse( Util.date.dtVeryLong, dateStr) ; - }else{ - date = Util.date.parse( Util.date.dtLong, dateStr) ; - } - if( date.getTime() < new Date().getTime() - 24*60*60*1000 ){ - date = new Date() ; - }else if(date.getTime() > new Date().getTime() + 10 *60*100 ){ - date = new Date() ; - } - - }else{ - String[] val ; - if(tmp.contains(",")){ - val = tmp.split(",")[0].split("=") ; - }else{ - val = tmp.split("=") ; - } - sensorInfo.setSensor_device_id(val[0]); - sensorInfo.setPort_id(0); - try{ - sensorInfo.setSdata( Float.parseFloat(val[1]) ); - }catch (Exception e) { - continue ; - } - sensorInfo.setMtime(date); - senorList.add(sensorInfo); - } - } - String body = Util.json.object2Json(senorList); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void handbert(IoSession session) { - // 判断session 读写空闲时间 ( 在每种协议中,确认服务端空闲时间,每个的空闲时间不同则行 ) - if( session.containsAttribute(nodeSensorsData) ){ - IotNodeInfoBO nodeBO = (IotNodeInfoBO) session.getAttribute(nodeSensorsData); - // 如果上传周期配置为0以及以下,则不设置设备离线 ; - if( nodeBO.getFrequency() < 1 ){ - return ; - } - if(session.getLastReadTime() + (nodeBO.getFrequency()+30)*1000 < new Date().getTime() ){ - // session 已判断为假死,关闭session - session.close(true); - return ; - } - - }else{ - session.close(true); - } - } - - @Override - public void execServer(IoSession session, byte[] data, String msg) { - - } - - @Override - public void logout(IoSession session) { - IotNodeInfo iotNodeInfo = new IotNodeInfo(); - iotNodeInfo.setDevice_code( session.getAttribute(Constants.DEVICECODE) +""); ; - iotNodeInfo.setIot_node_status(IOT_NODE_STATUS.offline); - iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY); - String body = Util.json.object2Json(iotNodeInfo); - HttpServiceSender.doPut(Constants.URL.NODE_INFO, Config.IOT_USER_KEY, body); - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalMing.java b/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalMing.java deleted file mode 100644 index 546dd4b..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalMing.java +++ /dev/null @@ -1,251 +0,0 @@ -package com.lpro.iot.protocal.impl; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.mina.core.session.IoSession; - -import com.alibaba.fastjson.JSON; -import com.lpro.iot.bean.IotNodeInfo; -import com.lpro.iot.bean.IotNodeInfoBO; -import com.lpro.iot.bean.IotSensorInfo; -import com.lpro.iot.bean.ReturnObj; -import com.lpro.iot.common.Cache; -import com.lpro.iot.common.Code; -import com.lpro.iot.common.Config; -import com.lpro.iot.common.Constants; -import com.lpro.iot.common.Code.IOT_NODE_STATUS; -import com.lpro.iot.mqtt.MqttService; -import com.lpro.iot.protocal.Iprotocal; -import com.lpro.iot.server.ServerIoHandler; -import com.lpro.iot.utils.CoordinateTransformUtil; -import com.lpro.iot.utils.DateUtils; -import com.lpro.iot.utils.HttpServiceSender; -import com.lpro.iot.utils.ObjectUtil; -import com.lpro.iot.utils.Util; - -/** - * - * @author chenrj - * 尹 设备协议 - * - */ -public class ProtocalMing implements Iprotocal { - - /** - * 登录命令解析并处理 - * @param session - * @param data - * @param msg - */ - @Override - public void loginProtocal(IoSession session,byte[] data,String msg, ReturnObj obj){ - // 解析登录命令 - String deviceCode = null ; - if(obj == null){ - // 这边对IMing协议的登录串数据不能超过个字节 - if(msg.length() >60){ - return ; - } - if("S".equalsIgnoreCase(msg.substring(0,1)) && "E".equalsIgnoreCase(msg.substring(msg.length()-1, msg.length())) ){ - deviceCode = msg.substring(1,msg.length()-2); - }else{ - return ; - } - obj = Util.NodeDevice.login(deviceCode); - }else{ - deviceCode = msg ; - } - - if(obj.getStatus() == Code.ResponseCode.OK+0 ){ - // 将devicecode放入session - session.setAttribute(Constants.DEVICECODE,deviceCode); - session.setAttribute("nodeINfo", obj.getData()) ; - // session 数据缓存 - session.setAttribute("dataCache",""); - // 添加协议类型 - session.setAttribute(Constants.PROTOCOL_CATEGORY, this.getClass().getSimpleName() ); - // 这边判断设备是否有session连接存在着 - if( Cache.nodeIdsessionMap.containsKey(deviceCode) ){ - // 如果之前存在,则删除sesion的属性,并关闭会话 - Cache.nodeIdsessionMap.get(deviceCode).removeAttribute(Constants.DEVICECODE); - Cache.nodeIdsessionMap.get(deviceCode).close(true) ; - } - Cache.nodeIdsessionMap.put(deviceCode , session); - // 判断设备是否离保 -// if( ObjectUtil.isNotEmpty(obj.getData().getMaintenance_time()) && -// obj.getData().getMaintenance_time().getTime() < new Date().getTime() ){ -// // 这里就要剔除改设备的连接 -// session.close(true); -// Util.mina.writeStr(session, "login error , out of date"); -// return ; -// } - // 发送登录成功 - Util.mina.writeStr(session, "loginok"); - } - } - - /** - * 数据解析 - * @param session - * @param data - * @param msg - */ - @Override - public void analysisData(IoSession session, byte[] data, String msg) { - // node id - Object deviceCode = session.getAttribute(Constants.DEVICECODE); - String dataCache = (String) session.getAttribute("dataCache"); - if(ObjectUtil.isNotEmpty(dataCache)){ - msg = dataCache + msg ; - session.setAttribute("dataCache",""); - } - - if(Cache.deviceMap.containsKey(deviceCode)){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", msg) ; - map.put("byte", Util.binhexoct.bytesToHex(data)) ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - if("S".equalsIgnoreCase(msg.substring(0,1)) && "E".equalsIgnoreCase(msg.substring(msg.length()-1, msg.length())) ){ - String[] subValue = msg.substring(1,msg.length()-1).split(","); - - List listSensor = new ArrayList<>(); - - for(int i=0;i100 ){ - return ; - } - // 解析登录命令 - String deviceCode = msg ; - - if(obj == null) - obj = Util.NodeDevice.loginReturn( deviceCode ); - - if(obj.getStatus() == Code.ResponseCode.OK+0 && ObjectUtil.isNotEmpty(obj.getData()) ){ - // 将devicecode放入session - session.setAttribute(Constants.DEVICECODE, deviceCode ); - // 添加协议类型 - session.setAttribute(Constants.PROTOCOL_CATEGORY, this.getClass().getSimpleName() ); - - // 设置同步参数 - LockResult lockResult = new LockResult() ; - lockResult.setFlag(false); - session.setAttribute( cmdLock , lockResult ) ; - - session.setAttribute( nodeSensorsData , obj.getData()) ; - - // 这边判断设备是否有session连接存在着 - if( Cache.nodeIdsessionMap.containsKey(deviceCode) ){ - try{ - // 之前的那个session,需要关闭了 - Cache.nodeIdsessionMap.get(deviceCode).close(true) ; - // 删除之前的定时器任务 - if(Cache.timerTaskMap.containsKey(deviceCode)){ - Timer timeTask = Cache.timerTaskMap.get(deviceCode) ; - if(ObjectUtil.isNotEmpty(timeTask)){ - timeTask.cancel(); - timeTask = null ; - } - Cache.timerTaskMap.remove(deviceCode); - } - // 当前这个session 也要关闭掉,要不然不好区分上线和下线了 - session.close(true); - return ; - }catch(Exception e){ - e.printStackTrace(); - session.close(true); - return ; - } - } - - Cache.nodeIdsessionMap.put( deviceCode , session); - - Timer timeTask = new Timer() ; - - session.setAttribute("timer", timeTask.hashCode()) ; - - Integer frequency = obj.getData().getFrequency() ; - if(frequency != null && frequency+0 > 0 ){ - timeTask.schedule(new ProtocalModbus(obj.getData()), new Date(), frequency * 1000); - }else{ - timeTask.schedule(new ProtocalModbus(obj.getData()), new Date(), 3 * 1000); - } - Cache.timerTaskMap.put(deviceCode, timeTask) ; - } - } - - /** - * 数据解析 - * @param session - * @param data - * @param msg - */ - @Override - public void analysisData(IoSession session, byte[] data, String msg) { - String deviceCode = session.getAttribute(Constants.DEVICECODE)+""; - // log - - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", msg ) ; - map.put("byte", Util.binhexoct.bytesToHex(data)) ; - map.put("direction", "2") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - if( msg.contains("GPS:") ) { - // 解析gps信息 - List sensorList = ((IotNodeInfoBO) session.getAttribute(nodeSensorsData)).getIotSensorList() ; - List list = new ArrayList(); - for(int i=0; i< sensorList.size() ; i++ ){ - if( sensorList.get(i).getIot_sensor_type()+0 == 90 ) { - // gps传感器 - sensorList.get(i).setStr_sdata( msg.substring(4, msg.length() - 2 ) ); - sensorList.get(i).setSdata(0f); - list.add(sensorList.get(i)) ; - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - return ; - } - } - } - - // modbus 返回的数据判断,脏数据,乱数据丢弃 - if( ! ( ObjectUtil.isNotEmpty(data) && data.length > 5 && data[1] > 0 && data[1] <= 6 && - ( data[2]+5 == data.length || data.length == 8 ) ) ){ // 这里写数据只能写int类型的,后面再改 - return ; - } - LockResult lockResult = (LockResult) session.getAttribute(cmdLock) ; - synchronized ( lockResult ) { - lockResult = (LockResult) session.getAttribute(cmdLock) ; - session.setAttribute( realData , data ); - lockResult.setFlag(false); - lockResult.notify(); - } - } - - /** - * 动作执行 - * @param session - * @param data - * @param msg IOT_SERVER_LPM:control,gy_001_UwyhjkOeP,10,10,1.0, - * IOT_SERVER_LPM:TYPE,nodeId,SENSOR_DEVICE_ID,PORT_ID,DATA,FORMULATE - */ - @Override - public void execServer(IoSession session, byte[] data, String msg) { - String subStr = msg.split(":")[1]; - String[] commands = subStr.split(","); - String type = commands[0]; - String deviceCode = (String) session.getAttribute(Constants.DEVICECODE); - if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_FLAG))) { - return ; - } - if("control".equalsIgnoreCase(type) || "param_write".equalsIgnoreCase(type) ){ - Integer sensorDeviceId = Integer.parseInt(commands[2]); - Integer portId = Integer.parseInt(commands[3]); - Float datas = Float.parseFloat(commands[4]) ; - int aa = msg.trim().indexOf('{') ; - ModbusConfig modbus = null ; - if( aa > -1 ){ - modbus = JSON.parseObject( msg.trim().substring(aa) , ModbusConfig.class); - } - byte[] command = { 0x00 , 0x06 } ; - if( ObjectUtil.isNotEmpty(modbus.getFcode()) ){ - if( "06".equals(modbus.getFcode()) || "03".equals(modbus.getFcode()) ){ - command[1] = 0x06 ; - }else if( "05".equals(modbus.getFcode()) || "01".equals(modbus.getFcode()) ){ - command[1] = 0x05 ; - }else{ - return ; - } - } - // 从机地址 - command[0] = (byte) Integer.parseInt(sensorDeviceId +"") ; //Byte.parseByte( sensorDeviceId +"") ; - // 寄存器地址 - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( Integer.parseInt(portId+"") , 2) ); - if(datas == 1 && command[1]==0x05 ){ - // 开启 - datas = 65280f ; - } - // 这边如果数据比较多的话 - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( (int)(datas+0) , 2) ); - // CRC16 - command = Util.protocal.append(command, Util.protocal.octInt2ByteArray( Util.crc.getCRC162Int(command,true), 2) ); - try{ - LockResult lockResult = (LockResult) session.getAttribute(cmdLock) ; - int sleepCount = 0 ; - while( lockResult.getFlag() ){ - Thread.sleep(48); - if( sleepCount++ > 46 ){ - return ; - } - } - - // log - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", Util.binhexoct.bytesToHex(command) ) ; - map.put("byte", Util.binhexoct.bytesToHex(command)) ; - map.put("direction", "1") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - synchronized ( lockResult ) { - // 获取属性 - lockResult = (LockResult) session.getAttribute( cmdLock ) ; - lockResult.setFlag(true); - // 尝试次数 - int i = repeatTimes ; - while(i-- >0){ - Util.mina.write(session, command ); - lockResult.wait(timeOut); - if( ! lockResult.getFlag() ){ - break ; - } - } - } - if( !lockResult.getFlag() ){ - byte[] datab = (byte[]) session.getAttribute(realData) ; - if( datab[0] == command[0] && datab[1] == command[1] ){ - List list = new ArrayList<>(); - int rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(datab,4,5)) ; - if( datab[1] == 0x05 && rh == 65280 ){ - rh = 1 ; - } - list.add(new IotSensorInfo( sensorDeviceId+"" , portId, rh+0.0f , deviceCode )); - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - } - }else{ - // 做到这边的时候,其实是失败的 - lockResult.setFlag(false); - } - }catch(Exception e){ - if( ObjectUtil.isNotEmpty(session) ){ - session.close(true); - } - } - - } - } - - @Override - public void handbert(IoSession session) { - try{ - if( session.containsAttribute(nodeSensorsData) ){ - IotNodeInfoBO nodeBO = (IotNodeInfoBO) session.getAttribute(nodeSensorsData); - // 判断session 读写空闲时间 ( 在每种协议中,确认服务端空闲时间,每个的空闲时间不同则行 ) - long t = 120*1000 ; - if(session.getLastReadTime()+ t < new Date().getTime() ){ - // session 已判断为假死,关闭session - if( session.containsAttribute(Constants.DEVICE_FLAG) ) { - Util.mina.writeStr(session, "connect time out,") ; - Util.mina.writeStr(session, "please reconnect platform!") ; - } - session.close(true); - return ; - } - }else{ - session.close(true); - } - }catch(Exception e){ - - } - } - - public ProtocalModbus(){ - } - - private IotNodeInfoBO nodeInfo; - - public ProtocalModbus(IotNodeInfoBO nodeInfo) { - this.nodeInfo = nodeInfo; - } - - // 定时任务执行 - @Override - public void run() { - // 获取定时任务的session - IoSession session = Cache.nodeIdsessionMap.get(this.nodeInfo.getDevice_code()) ; - try{ - if( ObjectUtil.isNotEmpty(session) ){ - // 设备号 - String deviceCode = this.nodeInfo.getDevice_code() ; - // 同步session中的信息,跟任务开始信息 - this.nodeInfo = (IotNodeInfoBO) session.getAttribute(nodeSensorsData) ; - - if( ObjectUtil.isNotEmpty(this.nodeInfo.getInfos()) && this.nodeInfo.getInfos().contains("fcode") ){ - // 设备命令批量采集 - List sensorConfigs = JSON.parseArray(this.nodeInfo.getInfos(), ModbusConfig.class) ; - for(ModbusConfig sensorConfig : sensorConfigs){ - // 字节流数组 - byte[] command = { 0x01 , 0x03 } ; - // 从机地址 - command[0] = (byte) Integer.parseInt(sensorConfig.getAddress() +"") ;// Byte.parseByte( sensorConfig.getAddress() +"") ; - // 功能码 - if( "01".equals(sensorConfig.getFcode()) ){ - command[1] = 0x01 ; - }else if( "04".equals(sensorConfig.getFcode()) ){ - command[1] = 0x04 ; - }else if( "02".equals(sensorConfig.getFcode()) ){ - command[1] = 0x02 ; - }else { - command[1] = 0x03 ; - } - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( Integer.parseInt(sensorConfig.getSaddr()) , 2) ); - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( Integer.parseInt(sensorConfig.getLength()) , 2) ); - // CRC16 - command = Util.protocal.append(command, Util.protocal.octInt2ByteArray( Util.crc.getCRC162Int(command,true), 2) ); - LockResult lockResult = (LockResult) session.getAttribute(cmdLock) ; - int sleepCount = 0 ; - while( lockResult.getFlag() ){ - Thread.sleep(100); - if( sleepCount++ > 20 ){ - return ; - } - } - if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_FLAG))) { - continue ; - } - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("ascii", Util.binhexoct.bytesToHex(command) ) ; - map.put("byte", Util.binhexoct.bytesToHex(command)) ; - map.put("time", new Date().getTime()+""); - map.put("direction", "1") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - synchronized ( lockResult ) { - // 获取属性 - lockResult = (LockResult) session.getAttribute(cmdLock) ; - lockResult.setFlag(true); - // 尝试次数 - int i = repeatTimes ; - while( i-- > 0){ - Util.mina.write(session, command); - lockResult.wait( timeOut ); - if( ! lockResult.getFlag() ){ - break ; - } - } - } - // 等待设备返回数据,正确返回,处理数据,非正确返回,重新开始 - if( !lockResult.getFlag() ){ - byte[] data = (byte[]) session.getAttribute(realData) ; - int saddr = Integer.parseInt(sensorConfig.getSaddr()) ; - if( command[0] == data[0] && command[1] == data[1] && - ( data[2] == (Integer.parseInt(sensorConfig.getLength())-1)/8+1 || - data[2] == Integer.parseInt(sensorConfig.getLength())*2) ){ - // 传感器列表数据 - List list = new ArrayList<>(); - List sensorList = ((IotNodeInfoBO) session.getAttribute(nodeSensorsData)).getIotSensorList() ; - if( data[1] == 1 || data[1] == 2 ){ - // 读线圈数据(位类型) - // 返回的数据的数量 - int returnDataLength = data[2] ; - for(int k =0 ;k < returnDataLength ;k++ ){ - for(int m =0 ; m< 8 ;m++ ){ - // 遍历传感器 - for(int i=0; i< sensorList.size() ; i++ ){ - String sensorDeviceId = sensorList.get(i).getSensor_device_id() ; - Integer sensorPortId = sensorList.get(i).getPort_id() ; - if( sensorDeviceId.equals(data[0]+0 +"") && saddr+k*8+m == sensorPortId ){ - // 判断是否包含 - list.add(new IotSensorInfo( data[0]+0 +"", saddr+k*8+m, - (data[3+k] >> m ) &0x01 , deviceCode )); - break ; - } - - } - } - } - }else{ - // 字类型 - if(data[3] == '$'){ - // 经纬度 - StringBuffer stringBuffer = new StringBuffer(); - for (int i = 0; i < data.length; i++) { - stringBuffer.append((char) data[i]); - } - String msg = stringBuffer.toString(); - String gpsdata = msg.substring(3,73); - String[] subval = gpsdata.split(","); - if(subval.length >0){ - String lon = subval[3] ; - String lat = subval[5] ; - Float latf = Integer.parseInt(lat.substring(0,3))+ Float.parseFloat(lat.substring(3))/60.0f ; - Float lonf = Integer.parseInt(lon.substring(0,2))+ Float.parseFloat(lon.substring(2))/60.0f ; - String lonlat = latf+","+lonf ; - list.add(new IotSensorInfo(data[0]+"" , saddr , - CoordinateTransformUtil.strwgs2bd(lonlat) , deviceCode )); - } - }else{ - // 字节类型数据 - for(int i=0; i< sensorList.size() ; i++ ){ - if( ObjectUtil.isEmpty(sensorList.get(i).getInfos()) ){ - sensorList.get(i).setInfos("{}"); - } - ModbusConfig modbus = JSON.parseObject( sensorList.get(i).getInfos(), ModbusConfig.class); - - if(ObjectUtil.isEmpty(modbus)){ - modbus = new ModbusConfig(); - } - // 传感器portid 寄存器id - String sensorDeviceId = sensorList.get(i).getSensor_device_id() ; - Integer sensorPortId = sensorList.get(i).getPort_id() ; - if( Integer.parseInt(sensorDeviceId) != data[0] ){ - continue ; - } - // saddr 采集其实地址 - if( "float".equals(modbus.getType() ) ){ - if( sensorPortId >= saddr && 3 + (sensorPortId - saddr)*2 + 6 <= data.length ){ - float rh = -1 ; - if( "CDAB".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getFloat3412( data , 3 + (sensorPortId - saddr ) * 2 ); - }else if("DCBA".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getFloat4321( data , 3 + (sensorPortId - saddr ) * 2 ); - }else if("BADC".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getFloat2143( data , 3 + (sensorPortId - saddr ) * 2 ); - }else{ - rh = ByteArrayConveter.getFloat( data , 3+( sensorPortId - saddr ) * 2 ); - } - list.add(new IotSensorInfo( sensorDeviceId , sensorPortId, rh+0.0f , deviceCode )); - } - }else if( "int".equals(modbus.getType() ) ){ - if( sensorPortId >= saddr && 3 + (sensorPortId - saddr)*2 + 4 <= data.length ){ - Integer start = 3 + (sensorPortId - saddr ) * 2 ; - int rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+1)) ; - if(rh > 0x7fff){ - rh -= 0x10000 ; - } - list.add(new IotSensorInfo(sensorDeviceId, sensorPortId , rh+0.0f , deviceCode )); - } - }else if("uint32".equals(modbus.getType() ) ){ - if( sensorPortId >= saddr && 3+(sensorPortId - saddr)*2 + 6 <= data.length ){ - Integer start = 3 + (sensorPortId - saddr ) * 2 ; - int rh = 0 ; - //Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+3)) ; - if( "CDAB".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data, start) ; - }else if("DCBA".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data, start) ; - }else if("BADC".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data, start) ; - }else{ - rh = ByteArrayConveter.getInt(data, start) ; - } - - list.add(new IotSensorInfo(sensorDeviceId, sensorPortId, rh+0.0f , deviceCode )); - } - }else if("int32".equals(modbus.getType() ) ){ - if( sensorPortId >= saddr && 3+(sensorPortId - saddr)*2 + 6 <= data.length ){ - Integer start = 3 + (sensorPortId - saddr ) * 2 ; - int rh = 0 ; - // Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+3)) ; - if( "CDAB".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data, start) ; - }else if("DCBA".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data, start) ; - }else if("BADC".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data, start) ; - }else{ - rh = ByteArrayConveter.getInt(data, start) ; - } - if( rh > 0x7fffffff ){ - long srh = rh - 0x100000000L ; - rh = (int) srh ; - } - list.add(new IotSensorInfo(sensorDeviceId, sensorPortId, rh+0.0f , deviceCode )); - } - }else{ - if( sensorPortId >= saddr && ( 3+ (sensorPortId - saddr)*2 ) + 4 <= data.length ){ - Integer start = 3 + ( sensorPortId - saddr )*2 ; - int rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+1)) ; - list.add(new IotSensorInfo(sensorDeviceId, sensorPortId, rh+0.0f , deviceCode )); - } - } - } - } - } - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - } - }else{ - // 失败设置 - lockResult.setFlag(false); - } - // 睡眠100ms - Thread.sleep(120); - } - // 这边提交按设备储存 -// if( ObjectUtil.isNotEmpty(sensorConfigs) ){ -// HttpServiceSender.doGet( Constants.URL.SAVE_NODE_DATA +"?id=" + this.nodeInfo.getId() , -// Config.IOT_USER_KEY); -// } - }else{ - // 单个轮训modbus信息 - List iotSensorInfos = this.nodeInfo.getIotSensorList() ; - if(!ObjectUtil.isEmpty(iotSensorInfos)){ - for (IotSensorInfoBO obj : iotSensorInfos){ - ModbusConfig sensorConfig = JSON.parseObject(obj.getInfos(), ModbusConfig.class); - if(ObjectUtil.isEmpty(sensorConfig)){ - sensorConfig = new ModbusConfig(); - } - // 字节流数组 - byte[] command = {0x01,0x03 } ; - // 设备下无传感器,这里sensor_device_id为空,则这次循环就结束了 - if( ObjectUtil.isEmpty(obj.getSensor_device_id()) ){ - return ; - } - // - command[0] = (byte) Integer.parseInt(obj.getSensor_device_id() +"") ; - if( "01".equals(sensorConfig.getFcode()) ){ - command[1] = 0x01 ; - }else if( "02".equals(sensorConfig.getFcode()) ){ - command[1] = 0x02 ; - }else if( "04".equals(sensorConfig.getFcode()) ){ - command[1] = 0x04 ; - }else if( "05".equals(sensorConfig.getFcode()) ){ - // 05 线圈用01读 - command[1] = 0x01 ; - }else if( "06".equals(sensorConfig.getFcode()) ){ - command[1] = 0x03 ; - }else { - command[1] = 0x03 ; - } - // 寄存器地址 - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray(obj.getPort_id() , 2) ); - // 长度 - if( "float".equals(sensorConfig.getType()) || "uint32".equals(sensorConfig.getType()) || "int32".equals(sensorConfig.getType()) ){ - command = Util.protocal.append(command,new Byte[]{0x00,0x02}); - }else{ - command = Util.protocal.append(command,new Byte[]{0x00,0x01}); - } - // CRC16 - command = Util.protocal.append(command, Util.protocal.octInt2ByteArray( Util.crc.getCRC162Int(command,true), 2) ); - - LockResult lockResult = (LockResult) session.getAttribute(cmdLock) ; - - int sleepCount = 0 ; - while( lockResult.getFlag() ){ - Thread.sleep(100); - if( sleepCount++ > 20 ){ - return ; - } - } - - if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_FLAG))) { - continue ; - } - - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", Util.binhexoct.bytesToHex(command) ) ; - map.put("byte", Util.binhexoct.bytesToHex(command)) ; - map.put("direction", "1") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - synchronized ( lockResult ) { - // 获取属性 - lockResult = (LockResult) session.getAttribute(cmdLock) ; - lockResult.setFlag(true); - int i = repeatTimes ; - while(i-- >0){ - Util.mina.write(session, command); - lockResult.wait(timeOut); - if( ! lockResult.getFlag() ){ - break ; - } - } - } - if( !lockResult.getFlag() ){ - byte[] data = (byte[]) session.getAttribute(realData) ; - if( data[0] == command[0] && data[1] == command[1] ){ - - List list = new ArrayList<>(); - float rh = - 999 ; - if( "float".equals( sensorConfig.getType() ) && data[2] == 4 ){ - if( "CDAB".equals( sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getFloat3412( data , 3 ); - }else if("DCBA".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getFloat4321( data , 3 ); - }else if("BADC".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getFloat2143( data , 3 ); - }else{ - rh = ByteArrayConveter.getFloat( data , 3 ); - } - }else if( "int".equals(sensorConfig.getType() ) && data[2] == 2 ){ - rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,3,4)) ; - if( rh >0x7fff){ - rh -= 0x10000 ; - } - }else if("uint32".equals( sensorConfig.getType() ) && data[2] == 4 ){ - if( "CDAB".equals( sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data,3) ; - }else if("DCBA".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data,3) ; - }else if("BADC".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data,3) ; - }else{ - rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,3,6)) ; - } - }else if("int32".equals( sensorConfig.getType() ) && data[2] == 4 ){ - if( "CDAB".equals( sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data,3) ; - }else if("DCBA".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data,3) ; - }else if("BADC".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data,3) ; - }else{ - rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,3,6)) ; - } - if( rh > 0x7fffffff){ - double srh = rh - 0x100000000L ; - rh = (float) srh ; - } - }else{ - if(data[2] == 1){ - // 这边针对的单个字节的处理 - rh = (data[3] & 0x01) ; - }else{ - rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,3,4)) ; - } - } - if(rh != - 999){ - list.add( new IotSensorInfo( obj.getSensor_device_id() , - obj.getPort_id(), rh+0.0f , deviceCode ) ); - } - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - } - }else{ - lockResult.setFlag(false); - } - // 睡眠100ms - Thread.sleep(120); - } - // 这边提交按设备储存 -// if( ObjectUtil.isNotEmpty(iotSensorInfos) ){ -// HttpServiceSender.doGet( Constants.URL.SAVE_NODE_DATA +"?id=" + this.nodeInfo.getId() , -// Config.IOT_USER_KEY); -// } - } - } - }else{ - // 停止定时器 - Timer timeTask = Cache.timerTaskMap.get(this.nodeInfo.getDevice_code()) ; - timeTask.cancel(); - timeTask = null ; - Cache.timerTaskMap.remove(this.nodeInfo.getDevice_code()); - } - }catch(Exception e){ - cancel(); - if( ObjectUtil.isNotEmpty(session) ){ - session.close(true); - } - } - } - - @Override - public boolean match(IoSession session, byte[] data, String msg) { - if( msg.contains("modbus_") ){ - // modbus 协议 - return true ; - }else if( data!= null && data.length > 3 && data[0] == -1 && data[1]==0x00 &&data[2]==-1 ){ - // 如果无法配置string 心跳包,就发送FF00FF即可 - return true ; - } - return false; - } - - @Override - public void logout(IoSession session) { - // 这个协议下,需要关闭掉session - Timer timeTask = Cache.timerTaskMap.get(session.getAttribute(Constants.DEVICECODE)) ; - if(ObjectUtil.isNotEmpty(timeTask)){ - timeTask.cancel(); - timeTask = null ; - Cache.timerTaskMap.remove(session.getAttribute(Constants.DEVICECODE)); - } - - IotNodeInfo iotNodeInfo = new IotNodeInfo(); - iotNodeInfo.setDevice_code( session.getAttribute(Constants.DEVICECODE) +""); ; - iotNodeInfo.setIot_node_status(IOT_NODE_STATUS.offline); - iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY); - String body = Util.json.object2Json(iotNodeInfo); - HttpServiceSender.doPut(Constants.URL.NODE_INFO, Config.IOT_USER_KEY, body); - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalModbusTcp.java b/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalModbusTcp.java deleted file mode 100644 index 685637e..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalModbusTcp.java +++ /dev/null @@ -1,760 +0,0 @@ -package com.lpro.iot.protocal.impl; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.mina.core.session.IoSession; - -import com.alibaba.fastjson.JSON; -import com.lpro.iot.bean.IotNodeInfo; -import com.lpro.iot.bean.IotNodeInfoBO; -import com.lpro.iot.bean.IotSensorInfo; -import com.lpro.iot.bean.IotSensorInfoBO; -import com.lpro.iot.bean.LockResult; -import com.lpro.iot.bean.ModbusConfig; -import com.lpro.iot.bean.ReturnObj; -import com.lpro.iot.common.Cache; -import com.lpro.iot.common.Code; -import com.lpro.iot.common.Code.IOT_NODE_STATUS; -import com.lpro.iot.common.Config; -import com.lpro.iot.common.Constants; -import com.lpro.iot.mqtt.MqttService; -import com.lpro.iot.protocal.Iprotocal; -import com.lpro.iot.server.MinaServer; -import com.lpro.iot.utils.CoordinateTransformUtil; -import com.lpro.iot.utils.HttpServiceSender; -import com.lpro.iot.utils.ObjectUtil; -import com.lpro.iot.utils.Util; -import com.lpro.iot.utils.Util.ByteArrayConveter; - -/** - * - * @author - * Modbus 通用协议 - * - */ -public class ProtocalModbusTcp extends TimerTask implements Iprotocal { - - public static void main(String[] args) { - - } - - // 超时重发次数 - public final static Integer repeatTimes = 1 ; - - // 超时时间 - public final static Integer timeOut = 5000 ; - - private final static String realDataLock="REAL_DATA" ; - - private final static String realData ="DATA"; - - private final static String nodeSensorsInfo = "NODE_SENSORS_INFO" ; - - /** - * 登录命令解析并处理 - * @param session - * @param data - * @param msg - */ - @Override - public void loginProtocal(IoSession session,byte[] data,String msg, ReturnObj obj){ - if(data.length >100 ){ - return ; - } - // 解析登录命令 - String deviceCode = msg ; - - if(obj == null) - obj = Util.NodeDevice.loginReturn( deviceCode ); - - if(obj.getStatus() == Code.ResponseCode.OK+0 && ObjectUtil.isNotEmpty(obj.getData()) ){ - // 将devicecode放入session - session.setAttribute(Constants.DEVICECODE, deviceCode ); - // 添加协议类型 - session.setAttribute(Constants.PROTOCOL_CATEGORY, this.getClass().getSimpleName() ); - - // 设置同步数据 - LockResult lockResult = new LockResult() ; - lockResult.setFlag(false); - session.setAttribute( realDataLock , lockResult ) ; - - session.setAttribute( nodeSensorsInfo , obj.getData()) ; - - // 这边判断设备是否有session连接存在着 - if( Cache.nodeIdsessionMap.containsKey(deviceCode) ){ - try{ - // 之前的那个session,需要关闭了 - Cache.nodeIdsessionMap.get(deviceCode).close(true) ; - // 删除之前的定时器任务 - if(Cache.timerTaskMap.containsKey(deviceCode)){ - Timer timeTask = Cache.timerTaskMap.get(deviceCode) ; - if(ObjectUtil.isNotEmpty(timeTask)){ - timeTask.cancel(); - timeTask = null ; - } - Cache.timerTaskMap.remove(deviceCode); - } - // 当前这个session 也要关闭掉,要不然不好区分上线和下线了 - session.close(true); - return ; - }catch(Exception e){ - e.printStackTrace(); - session.close(true); - return ; - } - } - Cache.nodeIdsessionMap.put( deviceCode , session); - Timer timeTask = new Timer() ; - Integer frequency = obj.getData().getFrequency() ; - if(frequency != null && frequency+0 > 0 ){ - timeTask.schedule(new ProtocalModbusTcp(obj.getData()), new Date(), frequency * 1000); - }else{ - timeTask.schedule(new ProtocalModbusTcp(obj.getData()), new Date(), 3 * 1000); - } - Cache.timerTaskMap.put(deviceCode, timeTask) ; - } - } - - /** - * 数据解析 - * @param session - * @param data - * @param msg - */ - @Override - public void analysisData(IoSession session, byte[] data, String msg) { - - Object deviceCode = session.getAttribute(Constants.DEVICECODE); - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", msg) ; - map.put("byte", Util.binhexoct.bytesToHex(data)) ; - map.put("direction", "2") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - //ServerIoHandler.LOGGER.info("receive data: " + Util.binhexoct.bytesToHex(data)); - - // modbus 返回的数据判断,脏数据,乱数据丢弃 - if( ! (ObjectUtil.isNotEmpty(data) && data.length > 9 && data[2]==0 && data[3]==0 && data[5]+6 == data.length ) ){ - return ; - } - LockResult lockResult = (LockResult) session.getAttribute(realDataLock) ; - synchronized ( lockResult ) { - lockResult = (LockResult) session.getAttribute(realDataLock) ; - session.setAttribute( realData , data ); - lockResult.setFlag(false); - lockResult.notify(); - } - } - - @Override - public void execServer(IoSession session, byte[] data, String msg) { - String subStr = msg.split(":")[1]; - String[] commands = subStr.split(","); - String type = commands[0]; - String deviceCode = (String) session.getAttribute(Constants.DEVICECODE); - if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_FLAG))) { - return ; - } - if("control".equalsIgnoreCase(type) || "param_write".equalsIgnoreCase(type) ){ - Integer sensorDeviceId = Integer.parseInt(commands[2]); - Integer portId = Integer.parseInt(commands[3]); - Float datas = Float.parseFloat(commands[4]) ; - int aa = msg.trim().indexOf('{'); - ModbusConfig modbus = null ; - if( aa > -1 ){ - modbus = JSON.parseObject( msg.trim().substring(aa) , ModbusConfig.class); - } - int vseq = (int) Math.random()*1000 ; - byte[] seqs = Util.protocal.octInt2ByteArray(vseq , 2); - byte[] command = {0x00,0x00, 0x00,0x00 ,0x00,0x06, 0x01 , 0x06 } ; - command[0] = seqs[0]; - command[1] = seqs[1]; - if( ObjectUtil.isNotEmpty(modbus.getFcode()) ){ - if( "06".equals(modbus.getFcode()) || "03".equals(modbus.getFcode()) ){ - command[7] = 0x06 ; - }else if( "05".equals(modbus.getFcode()) || "01".equals(modbus.getFcode()) ){ - command[7] = 0x05 ; - } - } - command[6] = (byte) Integer.parseInt(sensorDeviceId +"") ; ;Byte.parseByte( sensorDeviceId +"") ; - command = Util.protocal.append(command, Util.protocal.octInt2ByteArray(whole2simple(portId) , 2) ); - // 开启 - if(datas == 1 && command[7]==0x05 ){ - datas = 65280f ; - } - command = Util.protocal.append(command, Util.protocal.octInt2ByteArray( (int)(datas+0) , 2) ); - - try{ - LockResult lockResult = (LockResult) session.getAttribute(realDataLock) ; - int sleepCount = 0 ; - while( lockResult.getFlag() ){ - Thread.sleep(48); - if( sleepCount++ > 46 ){ - return ; - } - } - - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", msg) ; - map.put("byte", Util.binhexoct.bytesToHex(data)) ; - map.put("direction", "1") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - synchronized (lockResult ) { - // 获取属性 - lockResult = (LockResult) session.getAttribute(realDataLock) ; - lockResult.setFlag(true); - // 尝试次数 - int i = repeatTimes ; - while(i-- >0){ - Util.mina.write(session, command); - lockResult.wait(timeOut); - if( ! lockResult.getFlag() ){ - break ; - } - } - } - if( !lockResult.getFlag() ){ - // 数据解析,获取到传输过来的数据 - byte[] datab = (byte[]) session.getAttribute(realData) ; - int respVisitorSeq = Integer.parseInt(Util.protocal.getOctFromHexBytes(datab,0,1)); - if( respVisitorSeq == vseq ){ - // - List list = new ArrayList<>(); - int rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(datab,6+4,6+5)) ; - if( datab[1+6] == 0x05 && rh == 65280 ){ - rh = 1 ; - } - list.add(new IotSensorInfo( datab[6] +"", portId, rh+0.0f , deviceCode )); - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - } - }else{ - lockResult.setFlag(false); - } - }catch(Exception e){ - if( ObjectUtil.isNotEmpty(session) ){ - session.close(true); - } - } - } - } - - @Override - public void handbert(IoSession session) { - try{ - if( session.containsAttribute(nodeSensorsInfo) ){ - IotNodeInfoBO nodeBO = (IotNodeInfoBO) session.getAttribute(nodeSensorsInfo); - // 判断session 读写空闲时间 ( 在每种协议中,确认服务端空闲时间,每个的空闲时间不同则行 ) - if( nodeBO.getFrequency() < 4 ){ - return ; - } - // 这边做5次下发不成功,则认为已离线;(nodeBO.getFrequency()) - if(session.getLastReadTime()+ 1200*1000 < new Date().getTime() ){ - // session 已判断为假死,关闭session - session.close(true); - return ; - } - }else{ - session.close(true); - } - }catch(Exception e){ - - } - } - - public ProtocalModbusTcp(){ - } - - private IotNodeInfoBO nodeInfo; - - public ProtocalModbusTcp(IotNodeInfoBO nodeInfo) { - this.nodeInfo = nodeInfo; - } - - // 定时任务执行 - @Override - public void run() { - // 获取定时任务的session - IoSession session = Cache.nodeIdsessionMap.get(this.nodeInfo.getDevice_code()) ; - try{ - if( ObjectUtil.isNotEmpty(session) ){ - String deviceCode = this.nodeInfo.getDevice_code() ; - // 同步session中的信息,跟任务开始信息 - this.nodeInfo = (IotNodeInfoBO) session.getAttribute(nodeSensorsInfo) ; - - if( ObjectUtil.isNotEmpty(this.nodeInfo.getInfos()) && this.nodeInfo.getInfos().contains("fcode") ){ - // 设备命令批量采集 - List sensorConfigs = JSON.parseArray(this.nodeInfo.getInfos(), ModbusConfig.class) ; - // 访问序列 - int vseq = (int) Math.random()*1000 ; - for(ModbusConfig sensorConfig : sensorConfigs){ - vseq ++ ; - byte[] seqs = Util.protocal.octInt2ByteArray( vseq , 2); - // 字节流数组 - byte[] command = {0x00,0x00, 0x00,0x00 ,0x00,0x06, 0x01 , 0x03 } ; - command[0] = seqs[0]; - command[1] = seqs[1]; - command[6] = (byte) Integer.parseInt( sensorConfig.getAddress() +"") ; ;Byte.parseByte( sensorConfig.getAddress() +"") ; - if( "01".equals(sensorConfig.getFcode()) ){ - command[7] = 0x01 ; - }else if( "04".equals(sensorConfig.getFcode()) ){ - command[7] = 0x04 ; - }else if( "02".equals(sensorConfig.getFcode()) ){ - command[7] = 0x02 ; - }else { - command[7] = 0x03 ; - } - int saddrparam = Integer.parseInt(sensorConfig.getSaddr()) ; - int lengthparam = Integer.parseInt(sensorConfig.getLength()) ; - int fcode = Integer.parseInt(sensorConfig.getFcode()) ; - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( saddrparam , 2) ); - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( lengthparam , 2) ); - - if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_FLAG))) { - continue ; - } - - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", Util.binhexoct.bytesToHex(command) ) ; - map.put("byte", Util.binhexoct.bytesToHex(command)) ; - map.put("direction", "1") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - LockResult lockResult = (LockResult) session.getAttribute(realDataLock) ; - - int sleepCount = 0 ; - while( lockResult.getFlag() ){ - Thread.sleep(100); - if( sleepCount++ > 20 ){ - return ; - } - } - - synchronized (lockResult) { - // 获取属性 - lockResult = (LockResult) session.getAttribute(realDataLock) ; - lockResult.setFlag(true); - // 尝试次数 - int i = repeatTimes ; - while(i-- >0){ - Util.mina.write(session, command); - lockResult.wait(timeOut); - if( ! lockResult.getFlag() ){ - break ; - } - } - } - if( !lockResult.getFlag() ){ - // 数据解析,获取到传输过来的数据 - byte[] data = (byte[]) session.getAttribute(realData) ; - int respVisitorSeq = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,0,1)); - if( respVisitorSeq == vseq ){ - // 传感器数值 - List list = new ArrayList<>(); - // 传感器缓存值 - List sensorList = ((IotNodeInfoBO) session.getAttribute(nodeSensorsInfo)).getIotSensorList() ; - if( fcode ==1 || fcode == 2 || fcode == 5 ){ - // 读线圈数据 - int returnDataLength = data[6+2] ; - for(int k =0 ;k < returnDataLength ;k++ ){ - - for(int m =0 ; m< 8 ;m++ ){ - - // 遍历传感器 - for(int i=0; i< sensorList.size() ; i++ ){ - String sensorDeviceId = sensorList.get(i).getSensor_device_id() ; - Integer sensorPortId = sensorList.get(i).getPort_id() ; - if( sensorDeviceId.equals(data[6+0]+0 +"") && simple2whole(saddrparam+k*8+m , fcode ) +0 == sensorPortId ){ - // 判断是否包含 - list.add(new IotSensorInfo( data[6+0]+0 +"", simple2whole(saddrparam+k*8+m , fcode ) , - (data[6+3+k] >> m ) &0x01 , deviceCode)); - break ; - } - } - - } - - } - }else{ - // 这里特殊处理modbus rtu处理GPS数据 - if(data[6+3] == '$'){ - StringBuffer stringBuffer = new StringBuffer(); - for (int i = 0; i < data.length; i++) { - stringBuffer.append((char) data[i]); - } - String msg = stringBuffer.toString(); - String gpsdata = msg.substring(6+3,6+73); - String[] subval = gpsdata.split(","); - if(subval.length >0){ - String lon = subval[3] ; - String lat = subval[5] ; - Float latf = Integer.parseInt(lat.substring(0,3))+ Float.parseFloat(lat.substring(3))/60.0f ; - Float lonf = Integer.parseInt(lon.substring(0,2))+ Float.parseFloat(lon.substring(2))/60.0f ; - String lonlat = latf+","+lonf ; - list.add(new IotSensorInfo(data[6+0]+"" , simple2whole( saddrparam,fcode) , - CoordinateTransformUtil.strwgs2bd(lonlat) , deviceCode)); - } - }else{ - // 读普通数据 - for(int i=0; i< sensorList.size() ; i++ ){ - int sensorDeviceId = Integer.parseInt( sensorList.get(i).getSensor_device_id() ) ; - - if( sensorDeviceId != data[6] ){ - continue ; - } - - if( ObjectUtil.isEmpty(sensorList.get(i).getInfos()) ){ - sensorList.get(i).setInfos("{}"); - } - ModbusConfig modbus = JSON.parseObject( sensorList.get(i).getInfos(), ModbusConfig.class); - if(ObjectUtil.isEmpty(modbus)){ - modbus = new ModbusConfig(); - } - int simpleaddress = whole2simple(sensorList.get(i).getPort_id()) ; - if( "float".equals(modbus.getType() ) ){ - if(simpleaddress >= saddrparam && (6+3+(simpleaddress - saddrparam )*2+ 4 ) <= data.length){ - float rh = -1 ; - if( "CDAB".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getFloat3412( data , 6+3+(simpleaddress - saddrparam )*2 ); - }else if("DCBA".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getFloat4321( data , 6+3+(simpleaddress - saddrparam )*2 ); - }else if("BADC".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getFloat2143( data , 6+3+(simpleaddress - saddrparam )*2 ); - }else{ - rh = ByteArrayConveter.getFloat( data , 6+3+(simpleaddress - saddrparam )*2 ); - } - list.add(new IotSensorInfo( sensorList.get(i).getSensor_device_id(), sensorList.get(i).getPort_id(), - rh+0.0f , deviceCode )); - } - }else if( "int".equals(modbus.getType() ) ){ - if( simpleaddress >= saddrparam && (6+ 3+(simpleaddress - saddrparam )*2 ) <= data.length -2 ){ - Integer start = 6+3+(simpleaddress - saddrparam)*2 ; - int rh = 0 ; - //Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+1)) ; - if( "CDAB".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data, start) ; - }else if("DCBA".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data, start) ; - }else if("BADC".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data, start) ; - }else{ - rh = ByteArrayConveter.getInt(data, start) ; - } - - if(rh > 0x7ff){ - rh -= 0x10000 ; - } - list.add(new IotSensorInfo(sensorList.get(i).getSensor_device_id(), sensorList.get(i).getPort_id(), - rh+0.0f , deviceCode )); - } - }else if("uint32".equals(modbus.getType() ) ){ - if( simpleaddress >= saddrparam && ( 6+ 3+(simpleaddress - saddrparam )*2 ) <= data.length -4 ){ - Integer start = 6+3+(simpleaddress - saddrparam)*2 ; - int rh = 0; //Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+3)) ; - - if( "CDAB".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data, start) ; - }else if("DCBA".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data, start) ; - }else if("BADC".equals(modbus.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data, start) ; - }else{ - rh = ByteArrayConveter.getInt(data, start) ; - } - - list.add(new IotSensorInfo(sensorList.get(i).getSensor_device_id(), sensorList.get(i).getPort_id(), - rh+0.0f , deviceCode )); - } - }else if("int32".equals(modbus.getType() ) ){ - if( simpleaddress >= saddrparam && ( 6+ 3+(simpleaddress - saddrparam )*2 ) <= data.length -4 ){ - Integer start = 6+3+(simpleaddress - saddrparam)*2 ; - int rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+3)) ; - if( rh > 0x7fffffff ){ - long srh = rh - 0x100000000L ; - rh = (int) srh ; - } - list.add(new IotSensorInfo(sensorList.get(i).getSensor_device_id(), sensorList.get(i).getPort_id(), - rh+0.0f , deviceCode )); - } - }else{ - if( simpleaddress >= saddrparam && ( 6+ 3+(simpleaddress - saddrparam )*2 ) <= data.length -2 ){ - Integer start = 6+3+(simpleaddress - saddrparam)*2 ; - int rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,start,start+1)) ; - list.add(new IotSensorInfo(sensorList.get(i).getSensor_device_id(), sensorList.get(i).getPort_id(), - rh+0.0f , deviceCode )); - } - } - } - } - } - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - } - }else{ - lockResult.setFlag(false); - //session.close(true); - } - // 睡眠100ms - Thread.sleep(120); - } - }else{ - // 单个轮训modbus信息 - List iotSensorInfos = this.nodeInfo.getIotSensorList() ; - if(!ObjectUtil.isEmpty(iotSensorInfos)){ - int vseq = (int) Math.random()*1000 ; - for (IotSensorInfoBO obj : iotSensorInfos){ - ModbusConfig sensorConfig = JSON.parseObject(obj.getInfos(), ModbusConfig.class); - if(ObjectUtil.isEmpty(sensorConfig)){ - sensorConfig = new ModbusConfig(); - } - if( ObjectUtil.isEmpty(obj.getSensor_device_id()) ){ - return ; - } - vseq ++ ; - byte[] seqs = Util.protocal.octInt2ByteArray( vseq , 2); - byte[] command = {0x00,0x00, 0x00,0x00 ,0x00,0x06, 0x01 , 0x03 } ; - command[0] = seqs[0]; - command[1] = seqs[1]; - command[6] = (byte) Integer.parseInt(obj.getSensor_device_id() +"") ; ;Byte.parseByte(obj.getSensor_device_id() +"") ; - if( "01".equals(sensorConfig.getFcode()) ){ - command[7] = 0x01 ; - }else if( "02".equals(sensorConfig.getFcode()) ){ - command[7] = 0x02 ; - }else if( "03".equals(sensorConfig.getFcode()) ){ - command[7] = 0x03 ; - }else if( "04".equals(sensorConfig.getFcode()) ){ - command[7] = 0x04 ; - }else if( "05".equals(sensorConfig.getFcode()) ){ - command[7] = 0x01 ; - }else if( "06".equals(sensorConfig.getFcode()) ){ - command[7] = 0x03 ; - }else { - command[7] = 0x03 ; - } - command = Util.protocal.append(command, Util.protocal.octInt2ByteArray( whole2simple(obj.getPort_id()) , 2) ); - // 长度 - if( "float".equals(sensorConfig.getType()) || "uint32".equals(sensorConfig.getType()) || "int32".equals(sensorConfig.getType()) ){ - command = Util.protocal.append(command,new Byte[]{0x00,0x02}); - }else{ - command = Util.protocal.append(command,new Byte[]{0x00,0x01}); - } - - if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_FLAG))) { - continue ; - } - - if( Cache.deviceMap.containsKey(deviceCode) ){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", Util.binhexoct.bytesToHex(command) ) ; - map.put("byte", Util.binhexoct.bytesToHex(command)) ; - map.put("direction", "1") ; - map.put("time", new Date().getTime()+"") ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - LockResult lockResult = (LockResult) session.getAttribute(realDataLock) ; - - int sleepCount = 0 ; - while( lockResult.getFlag() ){ - Thread.sleep(100); - if( sleepCount++ > 20 ){ - return ; - } - } - - synchronized (lockResult) { - // 获取属性 - lockResult = (LockResult) session.getAttribute(realDataLock) ; - lockResult.setFlag(true); - // 尝试次数 - int i = repeatTimes ; - while(i-- >0){ - Util.mina.write(session, command); - lockResult.wait(timeOut); - if( ! lockResult.getFlag() ){ - break ; - } - } - } - if( !lockResult.getFlag() ){ - // 数据解析,获取到传输过来的数据 - byte[] data = (byte[]) session.getAttribute(realData) ; - int respVisitorSeq = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,0,1)); - if( respVisitorSeq == vseq ){ - List list = new ArrayList<>(); - float rh = 0 ; - if( "float".equals(sensorConfig.getType()) ){ - if( "CDAB".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getFloat3412( data , 6+3 ); - }else if("DCBA".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getFloat4321( data , 6+3 ); - }else if("BADC".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getFloat2143( data ,6+3 ); - }else{ - rh = ByteArrayConveter.getFloat( data , 6+3 ); - } - }else if( "int".equals(sensorConfig.getType() ) ){ - rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,6+3,6+4)) ; - if( rh >0x7fff){ - rh -= 0x10000 ; - } - }else if("uint32".equals(sensorConfig.getType() ) ){ - //rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,6+3,6+6)) ; - if( "CDAB".equals( sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data,9) ; - }else if("DCBA".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data,9) ; - }else if("BADC".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data,9) ; - }else{ - rh = ByteArrayConveter.getInt(data,9) ; - } - }else if("int32".equals(sensorConfig.getType() ) ){ - //rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,6+3,6+6)) ; - if( "CDAB".equals( sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt3412(data,9) ; - }else if("DCBA".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt4321(data,9) ; - }else if("BADC".equals(sensorConfig.getOrder() ) ){ - rh = ByteArrayConveter.getInt2143(data,9) ; - }else{ - rh = ByteArrayConveter.getInt(data,9) ; - } - if( rh > 0x7fffffff ){ - double srh = rh - 0x100000000L ; - rh = (float) srh ; - } - }else{ - if(data[6+2] == 1){ // 这边针对的单个字节的处理 - rh = data[3+6] & 0x01 ; - }else{ - rh = Integer.parseInt(Util.protocal.getOctFromHexBytes(data,6+3,6+4)) ; - } - } - list.add(new IotSensorInfo(obj.getSensor_device_id()+"", obj.getPort_id(),rh+0.0f , deviceCode.toString())); - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - - } - }else{ - lockResult.setFlag(false); - } - // 睡眠100ms - Thread.sleep(120); - } - } - } - }else{ - // 停止定时器 - Timer timeTask = Cache.timerTaskMap.get(this.nodeInfo.getDevice_code()) ; - timeTask.cancel(); - timeTask = null ; - Cache.timerTaskMap.remove(this.nodeInfo.getDevice_code()); - } - }catch(Exception e){ - cancel(); - if( ObjectUtil.isNotEmpty(session) ){ - session.close(true); - } - } - } - - private Integer whole2simple(Integer val){ - if(val<=9999){ - val-=1; - }else if( val>=10001 && val <= 19999){ - val-= 10001 ; - }else if(val >= 30001 && val<= 39999 ){ - val -= 30001 ; - }else if( val >= 40001 && val<= 49999 ){ - val -= 40001 ; - }else{ - val = 0 ; - } - return val ; - } - - private Integer simple2whole(Integer val, Integer fcode ){ - if(fcode == 2){ - val += 10001 ; - }else if(fcode == 3 || fcode == 6 ){ - val += 40001 ; - }else if(fcode == 4){ - val += 30001 ; - }else if(fcode == 1 || fcode == 5){ - val += 1 ; - } - return val ; - } - - @Override - public boolean match(IoSession session, byte[] data, String msg) { - return false; - } - - @Override - public void logout(IoSession session) { - // 这个协议下,需要关闭掉session - Timer timeTask = Cache.timerTaskMap.get(session.getAttribute(Constants.DEVICECODE)) ; - if(ObjectUtil.isNotEmpty(timeTask)){ - timeTask.cancel(); - timeTask = null ; - Cache.timerTaskMap.remove(session.getAttribute(Constants.DEVICECODE)); - } - - IotNodeInfo iotNodeInfo = new IotNodeInfo(); - iotNodeInfo.setDevice_code( session.getAttribute(Constants.DEVICECODE) +""); ; - iotNodeInfo.setIot_node_status(IOT_NODE_STATUS.offline); - iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY); - String body = Util.json.object2Json(iotNodeInfo); - HttpServiceSender.doPut(Constants.URL.NODE_INFO, Config.IOT_USER_KEY, body); - } - - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalYinTlink.java b/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalYinTlink.java deleted file mode 100644 index eaeb5f5..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/protocal/impl/ProtocalYinTlink.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.lpro.iot.protocal.impl; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.mina.core.session.IoSession; - -import com.alibaba.fastjson.JSON; -import com.lpro.iot.bean.IotNodeInfo; -import com.lpro.iot.bean.IotNodeInfoBO; -import com.lpro.iot.bean.IotSensorInfo; -import com.lpro.iot.bean.ReturnObj; -import com.lpro.iot.common.Cache; -import com.lpro.iot.common.Code; -import com.lpro.iot.common.Code.IOT_NODE_STATUS; -import com.lpro.iot.common.Config; -import com.lpro.iot.common.Constants; -import com.lpro.iot.mqtt.MqttService; -import com.lpro.iot.protocal.Iprotocal; -import com.lpro.iot.utils.HttpServiceSender; -import com.lpro.iot.utils.ObjectUtil; -import com.lpro.iot.utils.Util; - -/** - * - * @author chenrj - * 尹 设备协议 - * - */ -public class ProtocalYinTlink implements Iprotocal { - - /** - * 登录命令解析并处理 - * @param session - * @param data - * @param msg - */ - @Override - public void loginProtocal(IoSession session,byte[] data,String msg, ReturnObj obj){ - // 解析登录命令 - String deviceCode = msg; - // 这边对TLink协议的登录串数据不能超过个字节 - if(deviceCode.length() >70){ - return ; - } - if(obj == null ) - obj = Util.NodeDevice.login(deviceCode); - - if(obj.getStatus() == Code.ResponseCode.OK+0){ - // 将devicecode放入session - session.setAttribute(Constants.DEVICECODE,deviceCode); - session.setAttribute("nodeINfo", obj.getData()) ; - // session - session.setAttribute("dataCache",""); - - // 添加协议类型 - session.setAttribute(Constants.PROTOCOL_CATEGORY, this.getClass().getSimpleName() ); - // 这边判断设备是否有session连接存在着 - if( Cache.nodeIdsessionMap.containsKey(deviceCode) ){ - Cache.nodeIdsessionMap.get(deviceCode).close(true) ; - Cache.nodeIdsessionMap.get(deviceCode).removeAttribute(Constants.DEVICECODE) ; - session.close(true); - return ; - } - - Cache.nodeIdsessionMap.put(deviceCode , session); - - } - } - - /** - * 数据解析 - * @param session - * @param data - * @param msg - */ - @Override - public void analysisData(IoSession session, byte[] data, String msg) { - if("Q".equals(msg)){ - Util.mina.writeStr(session, "A"); - System.out.println(msg); - return ; - } - // node id - Object deviceCode = session.getAttribute(Constants.DEVICECODE); - String dataCache = (String) session.getAttribute("dataCache"); - if(ObjectUtil.isNotEmpty(dataCache)){ - msg = dataCache+msg ; - session.setAttribute("dataCache",""); - } - - if(Cache.deviceMap.containsKey(deviceCode)){ - // 如果有,则返回数据 - Map map =new HashMap<>(); - map.put("askii", msg) ; - map.put("byte", Util.binhexoct.bytesToHex(data)) ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - - // S30.0,0,0,0,0,0,0,E - if("S".equalsIgnoreCase(msg.substring(0,1)) && "E".equalsIgnoreCase(msg.substring(msg.length()-1, msg.length())) ){ - String[] subValue = msg.substring(1,msg.length()-2).split(","); - List sensors = new ArrayList<>() ; - for(int i=0;i60){ - return ; - } - obj = Util.NodeDevice.login(deviceCode); - } - - if(obj.getStatus() == Code.ResponseCode.OK+0 ){ - // 将devicecode放入session - session.setAttribute(Constants.DEVICECODE , deviceCode); - session.setAttribute(Constants.NODE_INFO , obj.getData()) ; - // session 数据缓存 - session.setAttribute(Constants.DATA_CACHE , "" ); - // 添加协议类型 - session.setAttribute(Constants.PROTOCOL_CATEGORY, this.getClass().getSimpleName() ); - // 这边判断设备是否有session连接存在着 - if( Cache.nodeIdsessionMap.containsKey(deviceCode) ){ - // 如果之前存在,则删除sesion的属性,并关闭会话 - Cache.nodeIdsessionMap.get(deviceCode).removeAttribute(Constants.DEVICECODE); - Cache.nodeIdsessionMap.get(deviceCode).close(true) ; - } - Cache.nodeIdsessionMap.put(deviceCode , session) ; - Thread t = new Thread(new TimerTaskThread(obj.getData())) ; - t.start(); - session.setAttribute(Constants.THREAD_HASH_CODE, t.hashCode()) ; - } - } - - public class TimerTaskThread implements Runnable{ - - private IotNodeInfoBO nodeInfo; - - public TimerTaskThread(IotNodeInfoBO nodeInfo) { - super(); - this.nodeInfo = nodeInfo; - } - - @Override - public void run() { - while(true){ - try{ - if(ObjectUtil.isNotEmpty(nodeInfo)){ - Integer period = nodeInfo.getFrequency() ; - if(period !=null && period < 2){ - period = 2 ; - } - Thread.sleep(period * 1000); - // - IoSession session = Cache.nodeIdsessionMap.get(this.nodeInfo.getDevice_code()) ; - if(ObjectUtil.isEmpty(session)){ - return ; - } - // 判断线程是否一致 - Integer hashCode = (Integer) session.getAttribute(Constants.THREAD_HASH_CODE) ; - if(hashCode+0 != this.hashCode()){ - return ; - } - List sensorList = ((IotNodeInfoBO) session.getAttribute(Constants.NODE_INFO)).getIotSensorList() ; - Set addressSet = new HashSet<>(); - for(IotSensorInfoBO tmp : sensorList ){ - // 轮训 - if(addressSet.contains(tmp.getSensor_device_id())){ - continue ; - }else{ - addressSet.add(tmp.getSensor_device_id()) ; - } - String address = tmp.getSensor_device_id() ; - byte[] command = {0x77,0x07} ; - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( Integer.parseInt(address) , 4) ); - command = Util.protocal.append(command, - new byte[]{0x04} ); - byte a = 0 ; - for(int i=1;i< command.length ;i++){ - a += command[i] ; - } - command = Util.protocal.append(command, new byte[]{ a } ); - Util.mina.write(session, command); - } - }else{ - return ; - } - }catch(Exception e){ - - } - } - } - } - - /** - * 数据解析 - * @param session - * @param data - * @param msg - */ - @Override - public void analysisData(IoSession session, byte[] data, String msg) { - // node id - Object deviceCode = session.getAttribute(Constants.DEVICECODE); - // 窗口调试,返回 - if(Cache.deviceMap.containsKey(deviceCode)){ - Map map =new HashMap<>(); - map.put("askii", msg) ; - map.put("byte", Util.binhexoct.bytesToHex(data)) ; - MqttService.pubMessage(JSON.toJSONString(map), "/sys/debug/" + deviceCode ); - } - LOGGER.info("Lora YW 数据=" + msg ); - // - try { - if( 0x77 == Util.protocal.getOtcFromByte(data[0]) ) { - int lenght = Util.protocal.getOtcFromByte(data[1] ) ; - if( lenght + 1 == data.length || data.length % (lenght+1)==0 ){ - String address = Util.protocal.getOctFromHexBytes(data, 2, 5) ; - // x轴值 - int i = 7 ; - float x = ( data[i]==0x0?1:-1) * Integer.parseInt( Util.protocal.getHexFromByte(data[i+1]) +""+ - Util.protocal.getHexFromByte(data[i+2]) + Util.protocal.getHexFromByte(data[i+3]) ) /10000.0f ; - // y轴 - i = 11 ; - float y = ( data[i]==0x0?1:-1) * Integer.parseInt( Util.protocal.getHexFromByte(data[i+1])+""+ - Util.protocal.getHexFromByte(data[i+2])+Util.protocal.getHexFromByte(data[i+3]) )/10000.0f ; - // 温度 - i = 15 ; - float tempure = ( data[i]==0x0?1:-1) * Integer.parseInt( Util.protocal.getHexFromByte(data[i+1])+""+ - Util.protocal.getHexFromByte(data[i+2]) )/100.0f ; - - float battery = Integer.parseInt(Util.protocal.getHexFromByte(data[18]) ) + 0f; - - List list = new ArrayList<>(); - list.add(new IotSensorInfo(address, 0, x, deviceCode.toString())) ; - list.add(new IotSensorInfo(address, 1, y, deviceCode.toString())) ; - list.add(new IotSensorInfo(address, 2, tempure, deviceCode.toString())) ; - list.add(new IotSensorInfo(address, 3, battery, deviceCode.toString())) ; - // 上传 - // 放入到线程中走 - MinaServer.threadPool.execute(new Runnable() { - @Override - public void run() { - String body = Util.json.object2Json(list); - String url = Constants.URL.SENSORS_DATA; - // 控制状态修改 - HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - } - }); - }else{ - LOGGER.info("Lora YW 数据不完整,length=" + lenght+ ", datalength=" + data.length ); - } - } - - }catch(Exception e) { - - } - } - - /** - * 心跳包 - */ - @Override - public void handbert(IoSession session){ - try{ - // 判断session 读写空闲时间 ( 在每种协议中,确认服务端空闲时间,每个的空闲时间不同则行 ) - if( session.containsAttribute(Constants.NODE_INFO) ){ - IotNodeInfoBO nodeBO = (IotNodeInfoBO) session.getAttribute(Constants.NODE_INFO); - // 如果上传周期配置为0以及以下,则不设置设备离线 ; - if( nodeBO.getFrequency() <1 ){ - return ; - } - if(session.getLastReadTime() + (nodeBO.getFrequency()+60)*1000 < new Date().getTime() ){ - // session 已判断为假死,关闭session - session.close(true); - return ; - } - - }else{ - session.close(true); - } - }catch(Exception e){ - session.close(true); - } - } - - /** - * 动作执行 - * @param session - * @param data - * @param msg - * IOT_SERVER_LPM:TYPE,nodeId,SENSOR_DEVICE_ID,PORT_ID,DATA,FORMULATE - */ - @Override - public void execServer(IoSession session, byte[] data, String msg) { - // IOT_SERVER_LPM:control,device_code,sensor_device_id, subtype - String subStr = msg.split(":")[1]; - String[] commands = subStr.split(","); - String type = commands[0]; - String nodeDeviceCode = commands[1]; - String address = commands[2]; - String subType = commands[3] ; // 子类型 - - byte btype = Byte.parseByte(subType) ; - - // 设置绝对零点 - byte[] command = { 0x77 , 0x08 } ; - command = Util.protocal.append(command, - Util.protocal.octInt2ByteArray( Integer.parseInt(address) , 4) ); - command = Util.protocal.append(command, - new byte[]{0x05, btype } ); - byte a = 0 ; - for(int i=1;i< command.length ;i++){ - a += command[i] ; - } - command = Util.protocal.append(command, new byte[]{ a } ); - - Util.mina.write(Cache.nodeIdsessionMap.get(nodeDeviceCode), command); - } - - @Override - public boolean match(IoSession session, byte[] data, String msg) { - return false ; - } - - @Override - public void logout(IoSession session) { - IotNodeInfo iotNodeInfo = new IotNodeInfo(); - iotNodeInfo.setDevice_code( session.getAttribute(Constants.DEVICECODE) +""); ; - iotNodeInfo.setIot_node_status(IOT_NODE_STATUS.offline); - iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY); - String body = Util.json.object2Json(iotNodeInfo); - HttpServiceSender.doPut(Constants.URL.NODE_INFO, Config.IOT_USER_KEY, body); - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/server/MinaServer.java b/lmp_v0.3.9_del/src/com/lpro/iot/server/MinaServer.java deleted file mode 100644 index f62d5f6..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/server/MinaServer.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.lpro.iot.server; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.apache.mina.core.service.IoAcceptor; -import org.apache.mina.core.session.ExpiringSessionRecycler; -import org.apache.mina.core.session.IoSessionConfig; -import org.apache.mina.filter.executor.ExecutorFilter; -import org.apache.mina.transport.socket.DatagramSessionConfig; -import org.apache.mina.transport.socket.SocketSessionConfig; -import org.apache.mina.transport.socket.nio.NioDatagramAcceptor; -import org.apache.mina.transport.socket.nio.NioSocketAcceptor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lpro.iot.common.Config; -import com.lpro.iot.mqtt.MqttService; -import com.lpro.iot.serviceImpl.MsgHandlerServiceImpl; -import com.lpro.iot.serviceImpl.TaskServiceImpl; - -/** - * 入口方法 - * - */ -public class MinaServer { - - public static Logger LOGGER = null; - - public static ExecutorService threadPool = Executors.newFixedThreadPool(15); - - public static void main(String[] args) throws IOException { - try { - if (args != null && args.length > 0) { - // 设置端口参数 - // 端口参数: args[0] - // LPM key: args[1] - Config.loadExtenalConfig(args); - } - // logger 初始化 - System.setProperty("lpmKey", Config.IOT_LPM_KEY); - LOGGER = (Logger) LoggerFactory.getLogger(MinaServer.class); - - // 根据协议类型,动态加载相应的服务 - - ServerIoHandler.msgHandlerService = new MsgHandlerServiceImpl(); - - // 创建一个非阻塞的Server端Socket - IoAcceptor acceptor = new NioSocketAcceptor(); - // 设置Handler - acceptor.setHandler(new ServerIoHandler()); - - IoSessionConfig cfg = acceptor.getSessionConfig(); - if (cfg instanceof SocketSessionConfig) { - ((SocketSessionConfig) cfg).setReceiveBufferSize(2 * 1024); - ((SocketSessionConfig) cfg).setReadBufferSize(2 * 1024); - ((SocketSessionConfig) cfg).setKeepAlive(true); - ((SocketSessionConfig) cfg).setSoLinger(0); - ((SocketSessionConfig) cfg).setTcpNoDelay(true); - ((SocketSessionConfig) cfg).setWriteTimeout(1000 * 5); - } - // 绑定监听端口 - acceptor.bind(new InetSocketAddress(Config.IOT_PORT)); - - // 任务线程池 - threadPool.execute(new TaskServiceImpl()); - - // mqtt 启动 - MqttService mqtt = new MqttService(); - - // udp server - if(Config.IOT_UDP_SWITCH){ - // ** Acceptor设置 - NioDatagramAcceptor acceptorUdp = new NioDatagramAcceptor(); - // 此行代码能让你的程序整体性能提升10倍 - acceptorUdp.getFilterChain() - .addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool())); - // 设置MINA2的IoHandler实现类 - acceptorUdp.setHandler(new UdpSeverHandler()); - // 设置会话超时时间(单位:毫秒),不设置则默认是10秒,请按需设置 - acceptorUdp.setSessionRecycler(new ExpiringSessionRecycler(15 * 1000)); - // ** UDP通信配置 - DatagramSessionConfig dcfg = acceptorUdp.getSessionConfig(); - dcfg.setReuseAddress(true); - // 设置输入缓冲区的大小,压力测试表明:调整到2048后性能反而降低 - dcfg.setReceiveBufferSize(1024); - // 设置输出缓冲区的大小,压力测试表明:调整到2048后性能反而降低 - dcfg.setSendBufferSize(1024); - // ** UDP服务端开始侦听 - acceptorUdp.bind(new InetSocketAddress(Config.IOT_UDP_PORT)); - LOGGER.info("udp server startup listening on port:" + Config.IOT_UDP_PORT); - } - - } catch (Exception e) { - LOGGER.error("server startup error!" + e.getMessage()); - return; - } - LOGGER.info("tcp server startup listening on port:" + Config.IOT_PORT); - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/server/ServerIoHandler.java b/lmp_v0.3.9_del/src/com/lpro/iot/server/ServerIoHandler.java deleted file mode 100644 index 43c0dce..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/server/ServerIoHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.lpro.iot.server; - -import org.apache.mina.core.service.IoHandlerAdapter; -import org.apache.mina.core.session.IdleStatus; -import org.apache.mina.core.session.IoSession; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lpro.iot.service.MsgHandlerService; - - -public class ServerIoHandler extends IoHandlerAdapter -{ - protected static MsgHandlerService msgHandlerService = null; - - public final static Logger LOGGER = (Logger) LoggerFactory.getLogger(ServerIoHandler.class); - - //自定义异常处理 - @Override - public void exceptionCaught( IoSession session, Throwable cause ) throws Exception - { - LOGGER.error(cause.getMessage()); - } - - //对接收到的消息(已经解码)进行下一步处理 - @Override - public void messageReceived( IoSession session, Object message ) throws Exception - { - try{ - msgHandlerService.MsgHandler(session, message); - }catch(Exception e){ - e.printStackTrace(); - LOGGER.error(e.getMessage()); - } - } - //当Session处于IDLE状态的时候,输出空闲状态次数 - @Override - public void sessionIdle( IoSession session, IdleStatus status ) throws Exception - { - System.out.println( "IDLE Count:" + session.getIdleCount( status )); - } - - - @Override - public void sessionOpened(IoSession session) throws Exception { - String ip = session.getRemoteAddress().toString().split("\\:")[0]; - LOGGER.info(ip+" connection is open!"); - } - - @Override - public void sessionClosed(IoSession session) throws Exception { - msgHandlerService.sessionClosed(session); - } - -} \ No newline at end of file diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/server/UdpSeverHandler.java b/lmp_v0.3.9_del/src/com/lpro/iot/server/UdpSeverHandler.java deleted file mode 100644 index bac50e5..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/server/UdpSeverHandler.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.lpro.iot.server; - -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; - -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.future.WriteFuture; -import org.apache.mina.core.service.IoHandlerAdapter; -import org.apache.mina.core.session.IoSession; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lpro.iot.protocal.ProtocalFactory; -import com.lpro.iot.utils.Util; - -public class UdpSeverHandler extends IoHandlerAdapter { - private static Logger logger = (Logger) LoggerFactory.getLogger(UdpSeverHandler.class); - - public static final CharsetDecoder decoder = (Charset.forName("UTF-8")).newDecoder(); - - /** - * MINA的异常回调方法。 - *

- * 本类中将在异常发生时,立即close当前会话。 - * - * @param session - * 发生异常的会话 - * @param cause - * 异常内容 - * @see IoSession#close(boolean) - */ - @Override - public void exceptionCaught(IoSession session, Throwable cause) throws Exception { - logger.error("[IMCORE]exceptionCaught捕获到错了,原因是:" + cause.getMessage(), cause); - session.close(true); - } - - /** - * MINA框架中收到客户端消息的回调方法。 - *

- * 本类将在此方法中实现完整的即时通讯数据交互和处理策略。 - *

- * 为了提升并发性能,本方法将运行在独立于MINA的IoProcessor之外的线程池中, 详见 - * {@link ServerLauncher#initAcceptor()}中的MINA设置代码 。 - * - * @param session - * 收到消息对应的会话引用 - * @param message - * 收到的MINA的原始消息封装对象,本类中是 {@link IoBuffer}对象 - * @throws Exception - * 当有错误发生时将抛出异常 - */ - @Override - public void messageReceived(IoSession session, Object message) throws Exception { - // *********************************************** 接收数据 - // 读取收到的数据 - IoBuffer ioBuffer = (IoBuffer) message; - byte[] data = new byte[ioBuffer.limit()]; - ioBuffer.get(data); - StringBuffer stringBuffer = new StringBuffer(); - for (int i = 0; i < data.length; i++) { - stringBuffer.append((char) data[i]); - } - - // 注意:当客户使用不依赖于MINA库的情况下,以下官方推 - // 荐的读取方法会在数据首部出现几个字节的未知乱码 - // message.toString() - - ServerIoHandler.LOGGER.info("udp orgin byte data: " + Util.binhexoct.bytesToHex(data)); - ServerIoHandler.LOGGER.info("udp orgin String data:" + stringBuffer.toString()); - - - } - - @Override - public void sessionOpened(IoSession session) throws Exception { - String ip = session.getRemoteAddress().toString().split("\\:")[0]; - logger.info(ip+" connection is open!"); - } - - @Override - public void sessionClosed(IoSession session) throws Exception { - logger.info("session is closed!"); - } - -} \ No newline at end of file diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/service/MsgHandlerService.java b/lmp_v0.3.9_del/src/com/lpro/iot/service/MsgHandlerService.java deleted file mode 100644 index f5e2747..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/service/MsgHandlerService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.lpro.iot.service; - -import org.apache.mina.core.session.IoSession; - -public interface MsgHandlerService { - - public void MsgHandler(IoSession session, Object message); - - public void sessionClosed(IoSession session); -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/NodeHeartTask.java b/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/NodeHeartTask.java deleted file mode 100644 index 07a8337..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/NodeHeartTask.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.lpro.iot.service.impl.task; - -import java.util.Iterator; -import java.util.Map; -import java.util.TimerTask; - -import org.apache.mina.core.session.IoSession; - -import com.lpro.iot.common.Cache; -import com.lpro.iot.common.Constants; -import com.lpro.iot.mqtt.MqttService; -import com.lpro.iot.protocal.ProtocalFactory; - - -/** - * 网关状态请求 - * - * - */ -public class NodeHeartTask extends TimerTask { - - @Override - public void run() { - try { - // 后面用线程处理业务 - Iterator> entries = Cache.nodeIdsessionMap.entrySet().iterator(); - while(entries.hasNext()){ - Map.Entry entry = entries.next(); - IoSession session = entry.getValue(); - if(session.isConnected() && !session.isClosing()){ - ProtocalFactory.getInstance(entry.getValue().getAttribute(Constants.PROTOCOL_CATEGORY).toString() ).handbert(entry.getValue()); - }else{ - // 关闭连接 -// session.close(true); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/SysHealthExam.java b/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/SysHealthExam.java deleted file mode 100644 index 7e3d468..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/service/impl/task/SysHealthExam.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.lpro.iot.service.impl.task; - -import java.util.Date; -import java.util.Iterator; -import java.util.Map; -import java.util.TimerTask; - -import com.lpro.iot.common.Cache; -import com.lpro.iot.mqtt.MqttService; -import com.lpro.iot.utils.ObjectUtil; - - -/** - * 系统健康检测 - * 处理mqtt是否处于连接 - * - * - */ -public class SysHealthExam extends TimerTask { - - @Override - public void run() { - try { - // mqtt 健康检测 - if( ObjectUtil.isNotEmpty(MqttService.client) && ! MqttService.client.isConnected() ){ - MqttService.connect(); - } - - - // 检测过期数据 - Iterator> entries = Cache.deviceMap.entrySet().iterator(); - while(entries.hasNext()){ - Map.Entry entry = entries.next(); - if( entry.getValue() + 3*60*1000 < new Date().getTime() ){ - entries.remove(); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.java b/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.java deleted file mode 100644 index 076fbb4..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/MsgHandlerServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.lpro.iot.serviceImpl; - -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.session.IoSession; - -import com.lpro.iot.common.Cache; -import com.lpro.iot.common.Constants; -import com.lpro.iot.protocal.Protocal; -import com.lpro.iot.protocal.ProtocalFactory; -import com.lpro.iot.server.ServerIoHandler; -import com.lpro.iot.service.MsgHandlerService; -import com.lpro.iot.utils.ObjectUtil; -import com.lpro.iot.utils.Util; - -public class MsgHandlerServiceImpl implements MsgHandlerService { - - @Override - public void MsgHandler(IoSession session, Object message) { - IoBuffer ioBuffer = (IoBuffer) message; - byte[] data = new byte[ioBuffer.limit()]; - String msg = "" ; - try { - ioBuffer.get(data); - StringBuffer stringBuffer = new StringBuffer(); - for (int i = 0; i < data.length; i++) { - stringBuffer.append((char) data[i]); - } - msg = stringBuffer.toString(); - - if(ObjectUtil.isNotEmpty(msg)){ - if(msg.contains(Constants.IOT_LPM_TYPE)){ - // iot server find LPM - Protocal.execServer(session,data,msg); - }else{ - // gateway find LPM - // 判断网关是否已经登录注册 - if( session.containsAttribute(Constants.DEVICECODE) ){ - // 是否需要转发 - if( session.containsAttribute(Constants.DEVICE_FLAG) ) { - IoSession destSession = (IoSession) session.getAttribute(Constants.DEVICE_SESSION) ; - Util.mina.write(destSession, data); - }else { - // 已注册登录 - if(Cache.nodeIdsessionMap.containsKey(session.getAttribute(Constants.DEVICECODE))){ - Protocal.analysisData(session,data,msg); - }else{ - session.close(true); - } - } - }else if( session.containsAttribute(Constants.DEVICE_TRANSFER)) { - // 转发 - IoSession destSession = (IoSession) session.getAttribute(Constants.DEVICE_SESSION) ; - Util.mina.write(destSession, data); - }else{ - // 注册登录 - Protocal.loginProtocal(session, data, msg); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void sessionClosed(IoSession session) { - // 有些没有注册成功的 - if(session.containsAttribute(Constants.DEVICECODE) ){ - // 活跃NodeId Session 去除 - Cache.nodeIdsessionMap.remove(session.getAttribute(Constants.DEVICECODE).toString()); - String deviceCategory = session.getAttribute(Constants.PROTOCOL_CATEGORY).toString() ; - ProtocalFactory.getInstance(deviceCategory).logout(session); - session.removeAttribute(Constants.DEVICECODE); - } - - if(ObjectUtil.isNotEmpty(session.getAttribute(Constants.DEVICE_SESSION))) { - // 转发 - IoSession destSession = (IoSession) session.getAttribute(Constants.DEVICE_SESSION) ; - destSession.close(true) ; - } - - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/TaskServiceImpl.java b/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/TaskServiceImpl.java deleted file mode 100644 index 37b45b2..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/serviceImpl/TaskServiceImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.lpro.iot.serviceImpl; - -import java.util.Date; -import java.util.Timer; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lpro.iot.service.impl.task.NodeHeartTask; -import com.lpro.iot.service.impl.task.SysHealthExam; - - - -public class TaskServiceImpl implements Runnable { - - private static Logger LOGGER = (Logger) LoggerFactory.getLogger(TaskServiceImpl.class); - - @Override - public void run() { - try { - - // 10s 一次心跳 - new Timer().schedule(new NodeHeartTask(), new Date(), 10 * 1000); - - new Timer().schedule(new SysHealthExam(),new Date(), 30* 1000); - - } catch (Exception e) { - e.getStackTrace(); - LOGGER.error("timer has error:" + e.getMessage()); - } - - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ArithHelper.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/ArithHelper.java deleted file mode 100644 index 2596d8b..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ArithHelper.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.lpro.iot.utils; - -public class ArithHelper { - // 默认除法运算精度 - private static final int DEF_DIV_SCALE = 16; - - // 这个类不能实例化 - private ArithHelper() { - } - - /** - * 提供精确的加法运算。 - * - * @param v1 被加数 - * @param v2 加数 - * @return 两个参数的和 - */ - - public static double add(double v1, double v2) { - java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1)); - java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2)); - return b1.add(b2).doubleValue(); - } - - public static double add(String v1, String v2) { - java.math.BigDecimal b1 = new java.math.BigDecimal(v1); - java.math.BigDecimal b2 = new java.math.BigDecimal(v2); - return b1.add(b2).doubleValue(); - } - - /** - * 提供精确的减法运算。 - * - * @param v1 被减数 - * @param v2 减数 - * @return 两个参数的差 - */ - - public static double sub(double v1, double v2) { - java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1)); - java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2)); - return b1.subtract(b2).doubleValue(); - } - - public static double sub(String v1, String v2) { - java.math.BigDecimal b1 = new java.math.BigDecimal(v1); - java.math.BigDecimal b2 = new java.math.BigDecimal(v2); - return b1.subtract(b2).doubleValue(); - } - - /** - * 提供精确的乘法运算。 - * - * @param v1 - * 被乘数 - * @param v2 - * 乘数 - * @return 两个参数的积 - */ - - public static double mul(double v1, double v2) { - java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1)); - java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2)); - return b1.multiply(b2).doubleValue(); - } - - public static double mul(String v1, String v2) { - java.math.BigDecimal b1 = new java.math.BigDecimal(v1); - java.math.BigDecimal b2 = new java.math.BigDecimal(v2); - return b1.multiply(b2).doubleValue(); - } - - /** - * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。 - * - * @param v1 - * 被除数 - * @param v2 - * 除数 - * @return 两个参数的商 - */ - - public static double div(double v1, double v2) { - return div(v1, v2, DEF_DIV_SCALE); - } - - public static double div(String v1, String v2) { - java.math.BigDecimal b1 = new java.math.BigDecimal(v1); - java.math.BigDecimal b2 = new java.math.BigDecimal(v2); - return b1.divide(b2, DEF_DIV_SCALE, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); - } - - /** - * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。 - * - * @param v1 被除数 - * @param v2 除数 - * @param scale 表示表示需要精确到小数点以后几位。 - * @return 两个参数的商 - */ - - public static double div(double v1, double v2, int scale) { - if (scale < 0) { - throw new IllegalArgumentException("The scale must be a positive integer or zero"); - } - java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1)); - java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2)); - return b1.divide(b2, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); - } - - /** - * 提供精确的小数位四舍五入处理。 - * - * @param v 需要四舍五入的数字 - * @param scale 小数点后保留几位 - * @return 四舍五入后的结果 - */ - - public static double round(double v, int scale) { - if (scale < 0) { - throw new IllegalArgumentException("The scale must be a positive integer or zero"); - } - java.math.BigDecimal b = new java.math.BigDecimal(Double.toString(v)); - java.math.BigDecimal one = new java.math.BigDecimal("1"); - return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); - } - - public static double round(String v, int scale) { - if (scale < 0) { - throw new IllegalArgumentException("The scale must be a positive integer or zero"); - } - java.math.BigDecimal b = new java.math.BigDecimal(v); - java.math.BigDecimal one = new java.math.BigDecimal("1"); - return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/Calculator.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/Calculator.java deleted file mode 100644 index fd209fa..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/Calculator.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.lpro.iot.utils; - -import java.util.Collections; -import java.util.Stack; - -/** - * 算数表达式求值 直接调用Calculator的类方法conversion() 传入算数表达式,将返回一个浮点值结果 如果计算过程错误,将返回一个NaN - */ -public class Calculator { - private Stack postfixStack = new Stack();// 后缀式栈 - private Stack opStack = new Stack();// 运算符栈 - private int[] operatPriority = new int[] { 0, 3, 2, 1, -1, 1, 0, 2 };// 运用运算符ASCII码-40做索引的运算符优先级 - - public static double conversion(String expression) { - double result = 0; - Calculator cal = new Calculator(); - try { - expression = transform(expression); - result = cal.calculate(expression); - } catch (Exception e) { - // e.printStackTrace(); - // 运算错误返回NaN - return 0.0 / 0.0; - } - // return new String().valueOf(result); - return result; - } - - public static String conversion2String(String expression) { - double result = 0; - Calculator cal = new Calculator(); - try { - expression = transform(expression); - result = cal.calculate(expression); - } catch (Exception e) { - // e.printStackTrace(); - // 运算错误返回NaN - return null; - } - // return new String().valueOf(result); - return Double.toString(result); - } - - /** - * 将表达式中负数的符号更改 - * - * @param expression - * 例如-2+-1*(-3E-2)-(-1) 被转为 ~2+~1*(~3E~2)-(~1) - * @return - */ - private static String transform(String expression) { - char[] arr = expression.toCharArray(); - for (int i = 0; i < arr.length; i++) { - if (arr[i] == '-') { - if (i == 0) { - arr[i] = '~'; - } else { - char c = arr[i - 1]; - if (c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == 'E' || c == 'e') { - arr[i] = '~'; - } - } - } - } - if (arr[0] == '~' || arr[1] == '(') { - arr[0] = '-'; - return "0" + new String(arr); - } else { - return new String(arr); - } - } - - /** - * 按照给定的表达式计算 - * - * @param expression - * 要计算的表达式例如:5+12*(3+5)/7 - * @return - */ - public double calculate(String expression) { - Stack resultStack = new Stack(); - prepare(expression); - Collections.reverse(postfixStack);// 将后缀式栈反转 - String firstValue, secondValue, currentValue;// 参与计算的第一个值,第二个值和算术运算符 - while (!postfixStack.isEmpty()) { - currentValue = postfixStack.pop(); - if (!isOperator(currentValue.charAt(0))) {// 如果不是运算符则存入操作数栈中 - currentValue = currentValue.replace("~", "-"); - resultStack.push(currentValue); - } else {// 如果是运算符则从操作数栈中取两个值和该数值一起参与运算 - secondValue = resultStack.pop(); - firstValue = resultStack.pop(); - - // 将负数标记符改为负号 - firstValue = firstValue.replace("~", "-"); - secondValue = secondValue.replace("~", "-"); - - String tempResult = calculate(firstValue, secondValue, currentValue.charAt(0)); - resultStack.push(tempResult); - } - } - return Double.valueOf(resultStack.pop()); - } - - /** - * 数据准备阶段将表达式转换成为后缀式栈 - * - * @param expression - */ - private void prepare(String expression) { - opStack.push(',');// 运算符放入栈底元素逗号,此符号优先级最低 - char[] arr = expression.toCharArray(); - int currentIndex = 0;// 当前字符的位置 - int count = 0;// 上次算术运算符到本次算术运算符的字符的长度便于或者之间的数值 - char currentOp, peekOp;// 当前操作符和栈顶操作符 - for (int i = 0; i < arr.length; i++) { - currentOp = arr[i]; - if (isOperator(currentOp)) {// 如果当前字符是运算符 - if (count > 0) { - postfixStack.push(new String(arr, currentIndex, count));// 取两个运算符之间的数字 - } - peekOp = opStack.peek(); - if (currentOp == ')') {// 遇到反括号则将运算符栈中的元素移除到后缀式栈中直到遇到左括号 - while (opStack.peek() != '(') { - postfixStack.push(String.valueOf(opStack.pop())); - } - opStack.pop(); - } else { - while (currentOp != '(' && peekOp != ',' && compare(currentOp, peekOp)) { - postfixStack.push(String.valueOf(opStack.pop())); - peekOp = opStack.peek(); - } - opStack.push(currentOp); - } - count = 0; - currentIndex = i + 1; - } else { - count++; - } - } - if (count > 1 || (count == 1 && !isOperator(arr[currentIndex]))) {// 最后一个字符不是括号或者其他运算符的则加入后缀式栈中 - postfixStack.push(new String(arr, currentIndex, count)); - } - - while (opStack.peek() != ',') { - postfixStack.push(String.valueOf(opStack.pop()));// 将操作符栈中的剩余的元素添加到后缀式栈中 - } - } - - /** - * 判断是否为算术符号 - * - * @param c - * @return - */ - private boolean isOperator(char c) { - return c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')'; - } - - /** - * 利用ASCII码-40做下标去算术符号优先级 - * - * @param cur - * @param peek - * @return - */ - public boolean compare(char cur, char peek) {// 如果是peek优先级高于cur,返回true,默认都是peek优先级要低 - boolean result = false; - if (operatPriority[(peek) - 40] >= operatPriority[(cur) - 40]) { - result = true; - } - return result; - } - - /** - * 按照给定的算术运算符做计算 - * - * @param firstValue - * @param secondValue - * @param currentOp - * @return - */ - private String calculate(String firstValue, String secondValue, char currentOp) { - String result = ""; - switch (currentOp) { - case '+': - result = String.valueOf(ArithHelper.add(firstValue, secondValue)); - break; - case '-': - result = String.valueOf(ArithHelper.sub(firstValue, secondValue)); - break; - case '*': - result = String.valueOf(ArithHelper.mul(firstValue, secondValue)); - break; - case '/': - result = String.valueOf(ArithHelper.div(firstValue, secondValue)); - break; - } - return result; - } - - public static void main(String[] args) { - String expression = "(3*(-2.13))+1"; - double result = Calculator.conversion(expression); - System.out.println(expression + " = " + result); - System.out.println(); - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/CoordinateTransformUtil.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/CoordinateTransformUtil.java deleted file mode 100644 index b23a2a0..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/CoordinateTransformUtil.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.lpro.iot.utils; - - - - -import java.math.BigDecimal; - -/** - * 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换的工具 - */ -public class CoordinateTransformUtil { - -// static String BAIDU_GEOCONV_KEY = "XXXXXXXXXXXXXXXXXXXXXXXX"; - static String baiduUrl = "http://api.map.baidu.com/geocoder/v2"; - static int B_DIV_SCALE = 15; - static BigDecimal x_pi = new BigDecimal("3.14159265358979324").multiply(new BigDecimal("3000")).divide(new BigDecimal("180"), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP); - // π - static BigDecimal pi = new BigDecimal("3.1415926535897932384626"); - // 长半轴 - static BigDecimal a = new BigDecimal("6378245"); - // 扁率 - static BigDecimal ee = new BigDecimal("0.00669342162296594323"); - static BigDecimal b_1 = new BigDecimal("-1"); - static BigDecimal b_2 = new BigDecimal("10"); - static BigDecimal b_3 = new BigDecimal("2"); - static BigDecimal b_4 = new BigDecimal("105"); - static BigDecimal b_5 = new BigDecimal("3"); - static BigDecimal b_6 = new BigDecimal("35"); - static BigDecimal b_7 = new BigDecimal("160"); - static BigDecimal b_8 = new BigDecimal("1"); - static BigDecimal b_9 = new BigDecimal("150"); - static BigDecimal b_10 = new BigDecimal("180"); - - static BigDecimal b_11 = new BigDecimal("0.00002"); - static BigDecimal b_12 = new BigDecimal("0.000003"); - static BigDecimal b_13 = new BigDecimal("0.0065"); - static BigDecimal b_14 = new BigDecimal("0.006"); - - /** - * WGS坐标转百度坐标系(BD-09) - * - * @param lng WGS84坐标系的经度 - * @param lat WGS84坐标系的纬度 - * @return 百度坐标数组 - */ - public static double[] wgs84tobd09(double lng, double lat) { - double[] gcj = wgs84togcj02(lng, lat); - double[] bd09 = gcj02tobd09(gcj[0], gcj[1]); - return bd09; - } - - /** - * 火星坐标系(GCJ-02)转百度坐标系(BD-09) - * - * @param lng 火星坐标经度 - * @param lat 火星坐标纬度 - * @return 百度坐标数组 - * @see 谷歌、高德——>百度 - */ - public static double[] gcj02tobd09(double lng, double lat) { - BigDecimal b_lng = new BigDecimal(lng); - BigDecimal b_lat = new BigDecimal(lat); - BigDecimal z = new BigDecimal(Math.sqrt(b_lng.multiply(b_lng).add(b_lat.multiply(b_lat)).doubleValue())).add(b_11.multiply(new BigDecimal(Math.sin(b_lat.multiply(x_pi).doubleValue())))); - BigDecimal theta = new BigDecimal(Math.atan2(b_lat.doubleValue(), b_lng.doubleValue())).add(b_12.multiply(new BigDecimal(Math.cos(b_lng.multiply(x_pi).doubleValue())))); - BigDecimal bd_lng = z.multiply(new BigDecimal(Math.cos(theta.doubleValue()))).add(b_13); -// z * Math.cos(theta) + 0.0065; - BigDecimal bd_lat = z.multiply(new BigDecimal(Math.sin(theta.doubleValue()))).add(b_14); - return new double[]{bd_lng.doubleValue(), bd_lat.doubleValue()}; - } - - /** - * WGS84转GCJ02(火星坐标系) - * - * @param lng WGS84坐标系的经度 - * @param lat WGS84坐标系的纬度 - * @return 火星坐标数组 - */ - public static double[] wgs84togcj02(double lng, double lat) { - BigDecimal b_lng = new BigDecimal(lng + ""); - BigDecimal b_lat = new BigDecimal(lat + ""); - if (out_of_china(b_lng, b_lat)) { - return new double[]{b_lng.doubleValue(), b_lat.doubleValue()}; - } - BigDecimal dlat = transformlat(b_lng.subtract(b_4), b_lat.subtract(b_6)); - BigDecimal dlng = transformlng(b_lng.subtract(b_4), b_lat.subtract(b_6)); - BigDecimal radlat = b_lat.divide(b_10, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi); - BigDecimal magic = new BigDecimal(Math.sin(radlat.doubleValue())); - magic = b_8.subtract(ee.multiply(magic).multiply(magic)); - BigDecimal sqrtmagic = new BigDecimal(Math.sqrt(magic.doubleValue())); - dlat = (dlat.multiply(b_10)).divide((a.multiply(b_8.subtract(ee))).divide((magic.multiply(sqrtmagic)), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP); - dlng = (dlng.multiply(b_10)).divide((a.divide(sqrtmagic, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(Math.cos(radlat.doubleValue())).multiply(pi))), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP); - BigDecimal mglat = b_lat.add(dlat); - BigDecimal mglng = b_lng.add(dlng); - return new double[]{mglng.doubleValue(), mglat.doubleValue()}; - } - - /** - * 纬度转换 - * - * @param lng - * @param lat - * @return - */ - public static BigDecimal transformlat(BigDecimal lng, BigDecimal lat) { - BigDecimal bet = b_1.multiply(b_2).multiply(b_2) - .add(b_3.multiply(lng)) - .add(b_5.multiply(lat)) - .add(b_3.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lat).multiply(lat)) - .add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lng).multiply(lat)) - .add(b_3.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.abs(lng.doubleValue()))))); - bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(b_5).multiply(lng).multiply(pi).doubleValue()))) - .add(b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(lng).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP)); - bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(lat.multiply(pi).doubleValue()))) - .add(b_3.multiply(b_3).multiply(b_2).multiply(new BigDecimal(Math.sin(lat.divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP)); - bet = bet.add((b_7.multiply(new BigDecimal(Math.sin(lat.divide(b_5.multiply(b_3).multiply(b_3), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue()))) - .add(b_7.multiply(b_3).multiply(new BigDecimal(Math.sin(lat.multiply(pi).divide(b_5.multiply(b_2), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP)); - return bet; - } - - /** - * 经度转换 - * - * @param lng - * @param lat - * @return - */ - public static BigDecimal transformlng(BigDecimal lng, BigDecimal lat) { - BigDecimal bet = b_2.multiply(b_2).multiply(b_5).add(lng).add(b_3.multiply(lat)).add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lng).multiply(lng)) - .add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(lng).multiply(lat)).add(b_8.divide(b_2, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.abs(lng.doubleValue()))))); - bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(b_5).multiply(lng).multiply(pi).doubleValue()))) - .add(b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(b_3.multiply(lng).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP)); - bet = bet.add((b_3.multiply(b_2).multiply(new BigDecimal(Math.sin(lng.multiply(pi).doubleValue()))) - .add(b_3.multiply(b_3).multiply(b_2).multiply(new BigDecimal(Math.sin(lng.divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue()))))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP)); - bet = bet.add((b_9.multiply(new BigDecimal(Math.sin(lng.divide(b_3.multiply(b_3).multiply(b_5), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue()))) - .add(b_9.multiply(b_3).multiply(new BigDecimal(Math.sin(lng.divide(b_5.multiply(b_2), B_DIV_SCALE, BigDecimal.ROUND_HALF_UP).multiply(pi).doubleValue())))).multiply(b_3).divide(b_5, B_DIV_SCALE, BigDecimal.ROUND_HALF_UP))); - return bet; - } - - /** - * 判断是否在国内,不在国内不做偏移 - * - * @param lng - * @param lat - * @return - */ - public static boolean out_of_china(BigDecimal lng, BigDecimal lat) { - if (lng.compareTo(new BigDecimal("73.66")) < 0 || lng.compareTo(new BigDecimal("135.05")) > 0) { - return true; - } else if (lat.compareTo(new BigDecimal("3.86")) < 0 || lat.compareTo(new BigDecimal("53.55")) > 0) { - return true; - } - return false; - } - - public static String strwgs2bd(String lonlat){ - String[] lons = lonlat.split(","); - double[] a = wgs84tobd09( Double.parseDouble(lons[0]) , Double.parseDouble(lons[1]) ); - return String.format("%.4f", a[0]) +","+String.format("%.4f", a[1]) ; - } - - public static void main(String[] args) { - double[] a =wgs84tobd09(120.01804 , 30.236946 ); - System.out.println(a[0]+","+a[1]); - } -} - diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/DateUtils.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/DateUtils.java deleted file mode 100644 index 393623f..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/DateUtils.java +++ /dev/null @@ -1,488 +0,0 @@ -package com.lpro.iot.utils; - -import java.sql.Timestamp; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -import org.apache.commons.lang.StringUtils; - - -public class DateUtils { - - /** 年月日时分秒(无下划线) yyyyMMddHHmmss */ - public static final String dtLong = "yyyyMMddHHmmss"; - - /** 年月日时分秒毫秒(无下划线) yyyyMMddHHmmssSSS */ - public static final String dtVeryLong = "yyyyMMddHHmmssSSS"; - - /** 完整时间 yyyy-MM-dd HH:mm */ - public static final String simple = "yyyy-MM-dd HH:mm"; - - /** 完整时间 yyyy/MM/dd HH:mm:ss */ - public static final String simpleALL = "yyyy/MM/dd HH:mm:ss"; - - /** 年月日(无下划线) yyyyMMdd */ - public static final String dtSimple = "yyyy-MM-dd"; - - /** 年月日(无下划线) yyyyMMdd */ - public static final String dtShort = "yyyyMMdd"; - - /** 年月日 yyyy.MM.dd */ - public static final String dtShortPoint = "yyyy.MM.dd"; - /** 年月日 yyyy.MM.dd HH:mm */ - public static final String dtLongPoint = "yyyy.MM.dd HH:mm"; - - /** - * 字符串转日期 - * - * @param pattern - * @param text - * @return - * @throws ParseException - */ - public static Date parse(String pattern, String text) { - try{ - if (StringUtils.isEmpty(text)) { - return null; - } - SimpleDateFormat df = new SimpleDateFormat(pattern); - return df.parse(text); - }catch (Exception e) { - e.printStackTrace(); - return null ; - } - } - - /** - * 日期转字符串 - * - * @param pattern - * @param date - * @return - * @throws ParseException - */ - public static String format(String pattern, Date date) throws ParseException { - if (date == null) { - return "-"; - } - SimpleDateFormat df = new SimpleDateFormat(pattern); - return df.format(date); - } - - /** - * 格式:年月日时分秒(无下划线) yyyyMMddHHmmss - * - * @param text - * @return - * @throws ParseException - */ - public static Date parseDtLong(String text) throws ParseException { - return parse(dtLong, text); - } - - /** - * 格式:完整时间 yyyy-MM-dd HH:mm:ss - * - * @param text - * @return - * @throws ParseException - */ - public static Date parseSimple(String text) throws ParseException { - return parse(simple, text); - } - - /** - * 格式:年月日时分秒毫秒(无下划线) yyyyMMddHHmmssSSS - * - * @param date - * @return - * @throws ParseException - */ - public static String formatDtVeryLong(Date date) throws ParseException { - return format(dtVeryLong, date); - } - - /** - * 格式:年月日时分秒(无下划线) yyyyMMddHHmmss - * - * @param date - * @return - * @throws ParseException - */ - public static String formatDtLong(Date date) throws ParseException { - return format(dtLong, date); - } - - /** - * 格式:完整时间 yyyy-MM-dd HH:mm:ss - * - * @param date - * @return - * @throws ParseException - */ - public static String formatSimple(Date date) throws ParseException { - return format(simple, date); - } - - /** - * 获取当前的时间 格式: 时:分:秒 - * - * @return - */ - public static String getNowTimeStr() { - Calendar calendar = Calendar.getInstance(); - /** - * 小时 - */ - int hour = calendar.get(Calendar.HOUR_OF_DAY); - /** - * 分钟 - */ - int minute = calendar.get(Calendar.MINUTE); - /** - * 秒钟 - */ - int second = calendar.get(Calendar.SECOND); - /** - * 拼接时间(时分秒) - */ - String time = (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute) + ":" - + (second < 10 ? "0" + second : second); - /** - * 返回时分秒 - */ - return time; - } - - /** - * 获取当前时间的前一天 - */ - public static Date getBeforeOneDateTime(Date day) { - - Calendar calendar = Calendar.getInstance(); - - calendar.setTime(day); - - int dateday = calendar.get(Calendar.DATE); - - calendar.set(Calendar.DATE, dateday - 1); - - return calendar.getTime(); - } - - /** - * 获取当前时间的后一天 - */ - public static Date getAfterOneDateTime(Date day) { - - Calendar calendar = Calendar.getInstance(); - - calendar.setTime(day); - - int dateday = calendar.get(Calendar.DATE); - - calendar.set(Calendar.DATE, dateday + 1); - - return calendar.getTime(); - } - - /** - * 获取当前的时间毫秒数,格林尼治时间 格式: 时:分:秒 - * - * @return the number of milliseconds since January 1, 1970, 00:00:00 GMT - * represented by this date. - */ - public static long getNowTime() { - Calendar calendar = Calendar.getInstance(); - /** - * 小时 - */ - int hour = calendar.get(Calendar.HOUR_OF_DAY) - 8; - /** - * 分钟 - */ - int minute = calendar.get(Calendar.MINUTE); - /** - * 秒钟 - */ - int second = calendar.get(Calendar.SECOND); - /** - * 返回毫秒数 - */ - return (hour * 60 * 60 + minute * 60 + second) * 1000; - } - - /** - * 获取当前日期 - * - * @param args - */ - public static Date getCurrentDate() { - // 获取当前日期 - Calendar calendar = new GregorianCalendar(); - GregorianCalendar today = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), - calendar.get(Calendar.DAY_OF_MONTH)); - return today.getTime(); - } - - /** - * 获取当前日期 - * - * @param args - */ - public static Date getCurrentDate(long time) { - // 获取当前日期 - Calendar calendar = new GregorianCalendar(); - calendar.setTimeInMillis(time); - GregorianCalendar today = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), - calendar.get(Calendar.DAY_OF_MONTH)); - return today.getTime(); - } - - /** - * 获取日期 - * - * @param args - */ - public static Date getDate(long time) { - // 获取当前日期 - Calendar calendar = new GregorianCalendar(); - calendar.setTimeInMillis(time); - return calendar.getTime(); - } - - public static Boolean getTimeBeforetimes(Date time, Integer minute) { - Calendar nowTime = Calendar.getInstance(); - nowTime.add(Calendar.MINUTE, -1* minute); - return nowTime.getTime().getTime() < time.getTime() ; - } - - /** - * 获取抽象的时间描述 - * - * @param insert_time - * @return - */ - public static String getTimeDesc(Date insert_time) { - String insert_time_desc = ""; - long inTime = insert_time.getTime(); - long curTime = System.currentTimeMillis(); - // 差值,分钟 - double dValue = Math.ceil((curTime - inTime) / 1000 / 60); - if (dValue < 1) - insert_time_desc = "刚刚"; - else if (dValue < 60) - insert_time_desc = (long) dValue + "分钟前"; - else if (dValue < 60 * 24) - insert_time_desc = (long) Math.floor(dValue / 60) + "小时前"; - else if (dValue < 60 * 24 * 30) - insert_time_desc = (long) Math.floor(dValue / 60 / 24) + "天前"; - else if (dValue < 60 * 24 * 365) - insert_time_desc = (long) Math.floor(dValue / 60 / 24 / 30) + "月前"; - else - insert_time_desc = (long) Math.floor(dValue / 60 / 24 / 365) + "年前"; - return insert_time_desc; - } - - /** - * - * 取得时间 - * - * @param type - * @return - */ - public static Date getDate(int type) { - Date date = null; - try { - switch (type) { - case 1: - // 当天12:00 - date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 12:00"); - break; - case 2: - // 明天12:00 - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, DateUtils.getAfterOneDateTime(new Date())) + " 12:00"); - break; - case 3: - // 后天12:00 - date = DateUtils - .parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, - DateUtils.getAfterOneDateTime(DateUtils.getAfterOneDateTime(new Date()))) - + " 12:00"); - break; - case 4: - // 当天09:00 - date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 09:00"); - break; - case 5: - // 当天00:00 - date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 00:00"); - break; - - case 6: - // 明天00:00 - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, DateUtils.getAfterOneDateTime(new Date())) + " 00:00"); - break; - case 7: - // 昨天00:00 - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, DateUtils.getBeforeOneDateTime(new Date())) + " 00:00"); - break; - case 8: - // 本周一00:00 - // - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, getMondayOfThisWeek()) + " 00:00"); - break; - case 9: - // 本周日23:59 - // - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, getSundayOfThisWeek()) + " 23:59"); - break; - case 10: - // 当天23:59 - // - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, new Date()) + " 23:59"); - break; - case 11: - // 当月第1天 00:00 - // - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, getFirstDayOfThisMonth()) + " 00:00"); - break; - case 12: - // 当月最后一天 23:59 - // - date = DateUtils.parse(DateUtils.simple, - DateUtils.format(DateUtils.dtSimple, getLastDayOfThisMonth()) + " 23:59"); - break; - case 13: - // 当天23:59 - date = DateUtils.parse(DateUtils.simple, DateUtils.format(DateUtils.dtSimple, new Date()) + " 23:59"); - break; - default: - break; - } - } catch (Exception e) { - // TODO: handle exception - } - return date; - } - - public static void main(String[] args) { - getDate(6); - getDate(7); - getDate(13); - - } - - /** - * 得到本周周一 - * - * @return yyyy-MM-dd - */ - public static Date getMondayOfThisWeek() { - Calendar c = Calendar.getInstance(); - int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; - if (day_of_week == 0) - day_of_week = 7; - c.add(Calendar.DATE, -day_of_week + 1); - return c.getTime(); - } - - /** - * 得到本周周日 - * - * @return yyyy-MM-dd - */ - public static Date getSundayOfThisWeek() { - Calendar c = Calendar.getInstance(); - int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; - if (day_of_week == 0) - day_of_week = 7; - c.add(Calendar.DATE, -day_of_week + 7); - return c.getTime(); - } - - - /** - * 当月第一天 - * @return - */ - private static Date getFirstDayOfThisMonth() { - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.DAY_OF_MONTH, calendar - .getActualMinimum(Calendar.DAY_OF_MONTH)); -// calendar.setTime(getDate(5)); - return calendar.getTime(); - } - - /** - * 当月最后一天 - * @return - */ - private static Date getLastDayOfThisMonth() { - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.DAY_OF_MONTH, calendar - .getActualMaximum(Calendar.DAY_OF_MONTH)); - return calendar.getTime(); - } - - /** - * - * 取得时间 - * - * @param type - * @return - */ - public static String getDateStrDt(int type) { - try { - return DateUtils.format(DateUtils.dtSimple, getDate(type)); - } catch (Exception e) { - // TODO: handle exception - } - return ""; - } - - /** - * 取得当前时间与参数时间的差额,如果minus不为空的话,则返回当前时间-参数时间-差额时间 - * - * @param ts - * @param minus_seconds - * 差额 - * @return - */ - public static long getMinusFromCurrent(Timestamp ts, int... minus_seconds) { - long curTimeMill = System.currentTimeMillis(); - if (minus_seconds.length > 0) { - return curTimeMill - ts.getTime() - minus_seconds[0] * 1000; - } - return System.currentTimeMillis() - ts.getTime(); - } - - /** - * @see getMinusFromCurrent() - * - * @param date - * @param minus_seconds - * 差额 - * @return - */ - public static long getMinusFromCurrent(Date date, int... minus_seconds) { - long curTimeMill = System.currentTimeMillis(); - if (minus_seconds.length > 0) { - return curTimeMill - date.getTime() - minus_seconds[0] * 1000; - } - return curTimeMill - date.getTime(); - } -} - - diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/HttpServiceSender.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/HttpServiceSender.java deleted file mode 100644 index 3251688..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/HttpServiceSender.java +++ /dev/null @@ -1,278 +0,0 @@ -package com.lpro.iot.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.DeleteMethod; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.PutMethod; -import org.apache.commons.httpclient.params.HttpMethodParams; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lpro.iot.common.Config; - -public class HttpServiceSender { - protected static final Logger LOGGER = LoggerFactory.getLogger(HttpServiceSender.class); - protected static final int SC_OK = 200;// 请求成功 - protected static final int SC_REDIRECT = 403;// 请求重定向 - protected static final int SC_UNRESOURCE = 404;// 请求失败(找不到对应资源) - protected static final int SC_SERVER_ERROE = 500;// 请求失败(服务器内部错误) - protected static final int SC_ERROR_REQUEST = 503;// 请求失败(服务器非请求类型) - - /** - * 普通get请求 - * - * @param url - * 请求url - * @param bodyString - * 提交参数 - * @return [响应状态头][响应正文] - */ -// public static String[] doGet(String url) { -// String[] response = new String[2]; -// response[0] = "-1"; -// HttpClient client = new HttpClient(); -// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000); -// client.getHttpConnectionManager().getParams().setSoTimeout(2000); -// GetMethod getMethod = new GetMethod(url); -// getMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8"); -// getMethod.setRequestHeader("Content-Type", "application/json"); -// try { -// client.executeMethod(getMethod); -// response[0] = String.valueOf(getMethod.getStatusCode()); -// if (getMethod.getStatusCode() == SC_OK) { -// response[1] = new String(getMethod.getResponseBodyAsString());// .getBytes("ISO-8859-1"),"utf-8"); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// getMethod.releaseConnection(); -// } -// return response; -// } - - public static String[] doGet(String url,String userKey) { - String[] response = new String[2]; - response[0] = "-1"; - HttpClient client = new HttpClient(); - client.getHttpConnectionManager().getParams().setConnectionTimeout(2000); - client.getHttpConnectionManager().getParams().setSoTimeout(2000); - GetMethod getMethod = new GetMethod(url); - getMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8"); - getMethod.setRequestHeader("Content-Type", "application/json"); - if (ObjectUtil.isNotEmpty(userKey)) { - getMethod.setRequestHeader("USER-KEY", userKey); - } - try { - client.executeMethod(getMethod); - response[0] = String.valueOf(getMethod.getStatusCode()); - if (getMethod.getStatusCode() == SC_OK) { -// response[1] = getMethod.getResponseBodyAsString(); - InputStream inputStream = getMethod.getResponseBodyAsStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); - StringBuffer stringBuffer = new StringBuffer(); - String str= ""; - while((str = br.readLine()) != null){ - stringBuffer .append(str ); - } - response[1] = stringBuffer.toString(); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - getMethod.releaseConnection(); - } - return response; - } - - /** - * 普通POST请求 - * - * @param url - * 请求url - * @param bodyString - * 提交参数 - * @return [响应状态头][响应正文] - */ - @SuppressWarnings("deprecation") - public static String[] doPost(String url, String userKey, String bodyString) { - String[] response = new String[2]; - response[0] = "-1"; - HttpClient client = new HttpClient(); - PostMethod postMethod = new PostMethod(url); - postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8"); - postMethod.setRequestHeader("Content-Type", "application/json"); - if (ObjectUtil.isNotEmpty(userKey)) { - postMethod.setRequestHeader("Authorization", userKey); - postMethod.setRequestHeader("USER-KEY", userKey); - } - postMethod.setRequestBody(bodyString); - try { - client.executeMethod(postMethod); - if (postMethod.getStatusCode() == SC_OK) { - response[0] = "200"; -// response[1] = postMethod.getResponseBodyAsString(); - InputStream inputStream = postMethod.getResponseBodyAsStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); - StringBuffer stringBuffer = new StringBuffer(); - String str= ""; - while((str = br.readLine()) != null){ - stringBuffer .append(str ); - } - response[1] = stringBuffer.toString(); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - postMethod.releaseConnection(); - } - return response; - } - - /** - * 普通PUT请求 - * - * @param url - * @return [响应状态头][响应正文] - */ - @SuppressWarnings("deprecation") - public static String[] doPut(String url, String userKey, String bodyString) { - String[] response = new String[2]; - response[0] = "-1"; - HttpClient client = new HttpClient(); - PutMethod putMethod = new PutMethod(url); - putMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8"); - putMethod.setRequestHeader("Content-Type", "application/json"); - if (ObjectUtil.isNotEmpty(userKey)) { -// putMethod.setRequestHeader("Authorization", userKey); - putMethod.setRequestHeader("USER-KEY", userKey); - putMethod.setRequestHeader("CLIENT-KEY", Config.IOT_LPM_KEY); - } - putMethod.setRequestBody(bodyString); - try { - client.executeMethod(putMethod); - if (putMethod.getStatusCode() == SC_OK) { -// response[1] = putMethod.getResponseBodyAsString(); - InputStream inputStream = putMethod.getResponseBodyAsStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); - StringBuffer stringBuffer = new StringBuffer(); - String str= ""; - while((str = br.readLine()) != null){ - stringBuffer .append(str ); - } - response[1] = stringBuffer.toString(); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - putMethod.releaseConnection(); - } - return response; - } - - /** - * 带认证的DELETE请求 - * - * @param url - * 请求地址 - * @param iblueyeKey - * 密钥 - * @return [响应状态头][响应正文] - */ - public static String[] doDelete(String url) { - String[] response = new String[2]; - response[0] = "-1"; - HttpClient client = new HttpClient(); - DeleteMethod deleteMethod = new DeleteMethod(url); - deleteMethod.setRequestHeader("Content-Type", "application/json"); - try { - client.executeMethod(deleteMethod); - response[0] = String.valueOf(deleteMethod.getStatusCode()); - if (deleteMethod.getStatusCode() == SC_OK) { -// response[1] = deleteMethod.getResponseBodyAsString(); - InputStream inputStream = deleteMethod.getResponseBodyAsStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); - StringBuffer stringBuffer = new StringBuffer(); - String str= ""; - while((str = br.readLine()) != null){ - stringBuffer .append(str ); - } - response[1] = stringBuffer.toString(); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - deleteMethod.releaseConnection(); - } - return response; - } - - static String body = ""; - - public static void main(String[] args) { - Calendar cal = Calendar.getInstance(); - String start = "2012-02-01"; - String end = "2012-03-02"; - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Date dBegin; - Date dEnd; - List lDate; - try { - dBegin = sdf.parse(start); - dEnd = sdf.parse(end); - lDate = findDates(dBegin, dEnd); - for (Date date : lDate) { - System.out.println(sdf.format(date)); - System.out.println(date); - } - } catch (ParseException e) { - e.printStackTrace(); - } - } - - public static List findDates(Date dBegin, Date dEnd) { - List lDate = new ArrayList(); - lDate.add(dBegin); - Calendar calBegin = Calendar.getInstance(); - // 使用给定的 Date 设置此 Calendar 的时间 - calBegin.setTime(dBegin); - Calendar calEnd = Calendar.getInstance(); - // 使用给定的 Date 设置此 Calendar 的时间 - calEnd.setTime(dEnd); - // 测试此日期是否在指定日期之后 - while (dEnd.after(calBegin.getTime())) { - // 根据日历的规则,为给定的日历字段添加或减去指定的时间量 - calBegin.add(Calendar.DAY_OF_MONTH, 1); - lDate.add(calBegin.getTime()); - } - return lDate; - } - - - public static String getSpecifiedDayAfter(String specifiedDay) { - Calendar c = Calendar.getInstance(); - Date date = null; - try { - date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay); - } catch (ParseException e) { - e.printStackTrace(); - } - c.setTime(date); - int day = c.get(Calendar.DATE); - c.set(Calendar.DATE, day + 1); - - String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); - return dayAfter; - } -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/MD5Util.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/MD5Util.java deleted file mode 100644 index 5f1f6e3..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/MD5Util.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.lpro.iot.utils; - -import java.security.MessageDigest; - -public class MD5Util { - - private static String byteArrayToHexString(byte b[]) { - StringBuffer resultSb = new StringBuffer(); - for (int i = 0; i < b.length; i++) - resultSb.append(byteToHexString(b[i])); - - return resultSb.toString(); - } - - private static String byteToHexString(byte b) { - int n = b; - if (n < 0) - n += 256; - int d1 = n / 16; - int d2 = n % 16; - return hexDigits[d1] + hexDigits[d2]; - } - - public static String MD5Encode(String origin, String charsetname) { - String resultString = null; - try { - resultString = new String(origin); - MessageDigest md = MessageDigest.getInstance("MD5"); - if (charsetname == null || "".equals(charsetname)) - resultString = byteArrayToHexString(md.digest(resultString - .getBytes())); - else - resultString = byteArrayToHexString(md.digest(resultString - .getBytes(charsetname))); - } catch (Exception exception) { - } - return resultString; - } - - private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5", - "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ObjectUtil.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/ObjectUtil.java deleted file mode 100644 index aac2ac5..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/ObjectUtil.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.lpro.iot.utils; - -import java.util.List; - -import org.apache.commons.lang.StringUtils; - -public class ObjectUtil { - - public static Boolean isEmpty(Object o){ - if(o == null){ - return true ; - } - if(o instanceof List ){ - if(((List) o).size()==0){ - return true ; - } - }else if(o instanceof String){ - if(StringUtils.isBlank((String)o)){ - return true ; - } - } - return false ; - } - - public static Boolean isNotEmpty(Object o){ - return !isEmpty(o) ; - } - - public static Boolean isIntegerOverZero(Integer value){ - if(value != null && value >0){ - return true ; - }else{ - return false ; - } - } - - /** - * 把字符串首字母转换为大写 - * - * @param str - * @return - */ - public static String upFirstChar(String str) { - return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase()); - } - - /** - * 转化成整数值, 错误时返回-9999 - * - * @param o - * @return - */ - public static Integer parseIntData(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Integer.parseInt(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return -9999; - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/PropertiesUtil.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/PropertiesUtil.java deleted file mode 100644 index 6c012cf..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/PropertiesUtil.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.lpro.iot.utils; - -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * - */ -public class PropertiesUtil { - private static Properties p = null; - public static String defaultFilePath = "config.properties"; - - /** - * 获取默认文件的配置值 - * - * @param property - * @return - */ - public static String getProperty(String property) { - if (p == null) { - p = getProperties(defaultFilePath); - } - return (p.containsKey(property)) ? p.getProperty(property) : ""; - } - - /** - * 获取指定文件的配置值 - * - * @param property - * @param path - * @return - */ - public static String getProperty(String property, String path) { - if (p == null) { - p = getProperties(path); - } - return (p.containsKey(property)) ? p.getProperty(property) : ""; - } - - /** - * 读取文件 - * - * @param filePath - * @return - */ - private static Properties getProperties(String filePath) { - InputStream in = null; - Properties p = new Properties(); - try { - in = new BufferedInputStream(new FileInputStream(filePath)); - p.load(in); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return p; - } - -} diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/SortList.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/SortList.java deleted file mode 100644 index 05407a8..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/SortList.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.lpro.iot.utils; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.List; - -/** - * 这是一个自定义排序的类,专门针对列表(List)中的数据进行排序;可按指定方法进行。 - * 目前实现对字符串(String)、日期(Date)、整型(Integer)等三种对象进行排序。 - * - * @author acer - * - * @param - */ -public class SortList { - - /** - * 对列表中的数据按指定字段进行排序。要求类必须有相关的方法返回字符串、整型、日期等值以进行比较。 - * - * @param list - * @param field - * @param reverseFlag - * 默认正序 - */ - public void sortByField(List list, final String fieldName, final boolean... reverseFlag) { - Collections.sort(list, new Comparator() { - @SuppressWarnings("unchecked") - public int compare(Object arg1, Object arg2) { - int result = 0; - try { - String methodName = "get" + Util.Obj.upperFirstChar(fieldName); - Method m1 = ((E) arg1).getClass().getMethod(methodName, null); - Method m2 = ((E) arg2).getClass().getMethod(methodName, null); - Object obj1 = m1.invoke(((E) arg1), null); - Object obj2 = m2.invoke(((E) arg2), null); - if (obj1 instanceof String) { - // 字符串 - result = obj1.toString().compareTo(obj2.toString()); - } else if (obj1 instanceof Date) { - // 日期 - long l = ((Date) obj1).getTime() - ((Date) obj2).getTime(); - if (l > 0) { - result = 1; - } else if (l < 0) { - result = -1; - } else { - result = 0; - } - } else if (obj1 instanceof Integer || obj1 instanceof Long) { - result = (int) ((Long) obj1 - (Long) obj2); - } else if (obj1 instanceof Double) { - double result_double = (Double) obj1 - (Double) obj2; - if (result_double > 0) { - result = 1; - } else if (result_double < 0) { - result = -1; - } else { - result = 0; - } - } else if (obj1 instanceof Integer || obj1 instanceof Long || obj1 instanceof Double) { - result = (Integer) obj1 - (Integer) obj2; - } else { - // 目前尚不支持的对象,直接转换为String,然后比较,后果未知 - result = obj1.toString().compareTo(obj2.toString()); - } - if (reverseFlag != null &&reverseFlag.length>0 &&reverseFlag[0] == true) { - // 倒序 - result = -result; - } - } catch (NoSuchMethodException nsme) { - nsme.printStackTrace(); - } catch (IllegalAccessException iae) { - iae.printStackTrace(); - } catch (InvocationTargetException ite) { - ite.printStackTrace(); - } - return result; - } - }); - } -} \ No newline at end of file diff --git a/lmp_v0.3.9_del/src/com/lpro/iot/utils/Util.java b/lmp_v0.3.9_del/src/com/lpro/iot/utils/Util.java deleted file mode 100644 index 0c2ba19..0000000 --- a/lmp_v0.3.9_del/src/com/lpro/iot/utils/Util.java +++ /dev/null @@ -1,2455 +0,0 @@ -package com.lpro.iot.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Method; -import java.math.BigInteger; -import java.net.URISyntaxException; -import java.nio.ByteOrder; -import java.sql.Timestamp; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.Enumeration; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.regex.Pattern; - -import com.alibaba.fastjson.JSON; -import org.apache.commons.lang.StringUtils; -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.session.AbstractIoSession; -import org.apache.mina.core.session.IoSession; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.type.TypeFactory; -import org.codehaus.jackson.type.JavaType; - -import com.alibaba.fastjson.JSON; -import com.lpro.iot.bean.IotNodeInfo; -import com.lpro.iot.bean.IotNodeInfoBO; -import com.lpro.iot.bean.ReturnObj; -import com.lpro.iot.common.Code.IOT_NODE_STATUS; -import com.lpro.iot.common.Config; -import com.lpro.iot.common.Constants; - -/** - * 工具类 - * - */ -public class Util { - - public static class NodeDevice{ - - /** - * 普通无返回值 - * @param deviceCode - * @return - */ - public static ReturnObj login(String deviceCode){ - IotNodeInfo iotNodeInfo = new IotNodeInfo(); - iotNodeInfo.setDevice_code( deviceCode ); ; - iotNodeInfo.setIot_node_status(IOT_NODE_STATUS.online); - iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY); - String body = Util.json.object2Json(iotNodeInfo); - String url = Constants.URL.NODE_INFO; - String[] reponse = HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); -// return (ReturnObj) Util.json.string2Object(reponse[1], ReturnObj.class); - return JSON.parseObject(reponse[1], ReturnObj.class); - } - - /** - * 普通有返回值, - * @param deviceCode - * @return - */ - public static ReturnObj loginReturn(String deviceCode){ - IotNodeInfo iotNodeInfo = new IotNodeInfo(); - iotNodeInfo.setDevice_code( deviceCode ); ; - iotNodeInfo.setIot_node_status(IOT_NODE_STATUS.online); - iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY); - String body = Util.json.object2Json(iotNodeInfo); - String url = Constants.URL.NODE_INFO; - String[] reponse = HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - return JSON.parseObject(reponse[1], ReturnObj.class); - } - - - public static ReturnObj syncDeviceReturn(String deviceCode){ - IotNodeInfo iotNodeInfo = new IotNodeInfo(); - iotNodeInfo.setDevice_code( deviceCode ); ; - iotNodeInfo.setLpmKey(Config.IOT_LPM_KEY); - String body = Util.json.object2Json(iotNodeInfo); - String url = Constants.URL.SYNC_NODE ; - String[] reponse = HttpServiceSender.doPut(url, Config.IOT_USER_KEY, body); - return JSON.parseObject(reponse[1], ReturnObj.class); - } - - } - - //获取 整数 num 的第 i 位的值 - public static boolean getBit(int num, int i){ - return ((num & (1 << i)) != 0);//true 表示第i位为1,否则为0 - } - - /** - * 进制转换 - * - */ - public static class binhexoct { - - public static void main(String[] args) { - - String str = "114200000001 0040 1040 20500.00 30500.02\r\n"; - System.out.println(Arrays.toString(str.getBytes()).replace(",", "")); - System.out.println(bytesToHex(str.getBytes())); - - String hex = "01 0d 00 00 00 10 01 03 00 45 00 02 d5 de"; - System.out.println(Arrays.toString(hexToBytes(hex, " "))); - - System.out.println(binaryToHex("0000000010101000")); - - } - - - - - /***************************** - * int To Hex - ******************************/ - /** - * 自动补零 - * - * @param i - * @return - */ - public static String intToHex(int i) { - String str = Integer.toHexString(i); - if (str.length() % 2 != 0) - str = "0" + str; - return str; - } - - /****************************** - * hex To byte - *******************************/ - // 16进制字符串,转10进制数[10进制byte类型,范围:127~-128] - // 一字节一字节的读取,即2位16进制数一读。 - public static byte[] hexToBytes(String str) { // 格式01 0d 00 00 00 10 01 - // 03 00 45 00 02 d5 - // de,中间无分割 - byte[] bytes = null; - if (str.length() > 0 && str.length() % 2 == 0) { - bytes = new byte[str.length() / 2]; - for (int i = 0; i < bytes.length; i++) { - bytes[i] = hexToByte(str.substring(2 * i, 2 * i + 2)); - } - } - return bytes; - } - - public static byte[] hexToBytes(String str, String separator) { // 格式01 - // 0d 00 - // 00 00 - // 10 01 - // 03 00 - // 45 00 - // 02 d5 - // de - byte[] bytes = null; - str = str.replace(separator, ""); - if (str.length() > 0 && str.length() % 2 == 0) { - bytes = new byte[str.length() / 2]; - for (int i = 0; i < bytes.length; i++) { - bytes[i] = hexToByte(str.substring(2 * i, 2 * i + 2)); - } - } - return bytes; - } - - // 16进制字符,转10进制数[10进制byte类型,范围:127~-128] - public static byte hexToByte(String str) { - int i = Integer.parseInt(str, 16); - byte b = (byte) i; - return b; - } - - /****************************** - * byte To hex - *******************************/ - // 10进制数,转16进制字符串[10进制byte类型,范围:127~-128] - public static String bytesToHex(byte[] bytes) { - StringBuffer hex = new StringBuffer(); - for (int i = 0; i < bytes.length; i++) { - hex.append(byteToHex(bytes[i]) + " "); - } - return hex.toString(); - } - - // 10进制数,转16进制字符[10进制byte类型,范围:127~-128] - public static String byteToHex(byte b) { - int i = b & 0xff; // byte一字节 8位。&0xFF 高24位清0 - return (0x00 <= i && i < 0x10) ? "0" + Integer.toHexString(i) : Integer.toHexString(i); - } - - /****************************** - * binary To hex - *******************************/ - // 2进制字符串,转16进制字符串 - public static String binaryToHex(String binary) { - StringBuffer hex = new StringBuffer(); - // 一字节,一字节的转换 - if (binary.length() % 8 == 0) { - for (int i = 0; i < binary.length() - 7; i += 8) { - // 二进制字符串转换为10进制数 - int temp = Integer.parseInt(binary.substring(i, i + 8), 2); - System.out.println(binary.substring(i, i + 8)); - // 10进制转16进制 - hex.append(temp < 16 ? "0" + Integer.toHexString(temp) + " " : Integer.toHexString(temp) + " "); - - } - } - return hex.toString(); - } - - /****************************** - * hex To binary - *******************************/ - // 2进制字符串,转16进制字符串 - public static String hexToBinary(String hex) { - int tem = Integer.parseInt(hex, 16); - return Integer.toBinaryString(tem); - } - - /****************************** - * hex To ASCII - *******************************/ - /** - * 16进制字符串转换成ASCII码字符 - * - * @param hex - * @return - */ - public static String hexToASCII(String hex) { - byte[] b = hexToBytes(hex); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < b.length; i++) { - sb.append((char) b[i]); - } - return sb.toString(); - } - - public static String hexToASCII(String hex, String separator) { - hex = hex.replace(separator, ""); - byte[] b = hexToBytes(hex); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < b.length; i++) { - sb.append((char) b[i]); - } - return sb.toString(); - } - - /** - * 字节数值相等 - * - * @param param1 - * @param param2 - * @return - */ - public static boolean byteValueEqual(Object param1, Object param2) { - if (param1 != null && param2 != null) { - try { - int p1 = Integer.parseInt(param1.toString()); - int p2 = Integer.parseInt(param2.toString()); - if (p1 < 0) { - p1 = 256 + p1; - } - if (p2 < 0) { - p2 = 256 + p2; - } - return p1 == p2; - } catch (Exception e) { - e.printStackTrace(); - } - } - return false; - } - - /** - * 字节数值转化, 如果<0的加上256 - * - * @param param - * @return - */ - public static int byteValue(Object param) { - if (param != null) { - try { - int p = Integer.parseInt(param.toString()); - if (p < 0) { - p = 256 + p; - } - return p; - } catch (Exception e) { - e.printStackTrace(); - } - } - return -9999; - } - } - - /** - * 对象处理 - * - * - */ - public static class Obj extends StringUtils { - /** - * 取得字符串中的第position个位置开始的capacity个(默认为1个)字符 - * - * @param str - * 原字符串 - * @param position - * 开始位置 - * @param n - * 字符个数,可选, 默认为1,超过长度,则截取剩余长度 - * - * @return - */ - public static String getCharacterString(String str, int position, int... capacity) { - String s = null; - if (StringUtils.isNotEmpty(str)) { - int size = str.length(); - // 如果超过最大长度, 则返回null - if (position >= size) { - return null; - } - int n = 1; - if (capacity.length > 0) { - n = capacity[0]; - } - if (n <= 0) { - n = 1; - } else if (n > size - position) { - n = size - position; - } - return str.substring(position, n + position); - } - return s; - } - - /** - * 测试对象列表是否存在空对象 - * - * @param objs - * @return - */ - public static boolean hasNull(Object... objs) { - if (objs == null || objs.length == 0) { - return true; - } else { - for (int i = 0; i < objs.length; i++) { - if (objs[i] == null && "".equals(getString(objs[i]))) { - return true; - } - } - } - return false; - } - - /** - * 判断变量列表是否都不为空 - * - * @param obj - * @return - */ - public static Boolean hasNoEmpty(Object... obj) { - for (int i = 0; i < obj.length; i++) { - // 有一个为空的话,就返回 - if (isEmpty(getString(obj[i]))) { - return false; - } - } - return true; - } - - /** - * 是否是整型正数 - * - * @param data - * @return - */ - public static boolean isActiveNumber(Object data) { - if (data != null && Obj.isNotEmpty(data.toString())) { - Pattern pattern = Pattern.compile("[1-9][0-9]*"); - return pattern.matcher(data.toString()).matches(); - } - return false; - } - - /** - * - * 获取字符串 - * - * @param str - * @return - */ - public static String getString(String str) { - if (isNotEmpty(str)) { - return str.trim().replaceAll("\t", "").replace("\n", "").replace("\r", ""); - } - return StringUtils.EMPTY; - } - - /** - * 判断变量列表是否至少有一个为空 - * - * @param obj - * @return - */ - public static Boolean hasOneEmpty(Object... obj) { - for (int i = 0; i < obj.length; i++) { - // 有一个不为空的话就返回 - if (isEmpty(getString(obj[i]))) { - return true; - } - } - return false; - } - - /** - * - * 获取字符串 - * - * @param str - * @return - */ - public static String getString(Object o) { - if (o == null) { - return StringUtils.EMPTY; - } - return getString(o.toString()); - } - - /** - * 判断变量列表是否都为空 - * - * @param obj - * @return - */ - public static Boolean isAllEmpty(Object... obj) { - for (int i = 0; i < obj.length; i++) { - // 有一个不为空的话,就返回 - if (isNotEmpty(getString(obj[i]))) { - return false; - } - } - return true; - } - - /** - * 获取字符串 - * - * @param obj - * @return - */ - public static String getTrimString(Object obj) { - if (obj == null) { - return StringUtils.EMPTY; - } - return obj.toString().trim(); - } - - /** - * 首字符大写 - * - * @param obj - * @return - */ - public static String upperFirstChar(String str) { - return str.substring(0, 1).toUpperCase() + str.substring(1); - } - - /** - * 是否为相同字符 - * - * @param s - * @return - */ - public static boolean isSameCharacter(String str) { - if (StringUtils.isNotEmpty(str)) { - String s = StringUtils.trimToEmpty(str).toLowerCase(); - return StringUtils.isEmpty(s.replace(s.substring(0, 1), StringUtils.EMPTY)); - } - return false; - } - - /** - * 是否为连续字符 - * - * @param s - * @return - */ - public static boolean isContinuityCharacter(String str) { - String s = StringUtils.trimToEmpty(str).toLowerCase(); - if (StringUtils.isNotEmpty(str)) { - boolean continuity = true; - char[] data = s.toCharArray(); - for (int i = 0; i < data.length - 1; i++) { - int a = data[i]; - int b = data[i + 1]; - continuity = continuity && (a + 1 == b || a - 1 == b); - } - return continuity; - } else { - return false; - } - } - - /** - * 将带分隔符的字符串转化为整型数组 - * - * @param str - * @param split - * @return - */ - public static Integer[] convert2IntArray(String str, String split) { - if (hasOneEmpty(str, split)) { - return null; - } - Integer[] rst = null; - try { - String[] strs = str.split(split); - rst = new Integer[strs.length]; - for (int i = 0; i < strs.length; i++) { - rst[i] = parseInteger(strs[i]); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return rst; - } - - /** - * 将带分隔符的字符串转化为长整型数组 - * - * @param str - * @param split - * @return - */ - public static Long[] convert2LongArray(String str, String split) { - if (hasOneEmpty(str, split)) { - return null; - } - Long[] rst = null; - try { - String[] strs = str.split(split); - rst = new Long[strs.length]; - for (int i = 0; i < strs.length; i++) { - rst[i] = parseLong(strs[i]); - } - } catch (Exception e) { - e.printStackTrace(); - } - - return rst; - } - - /** - * 比较两个整数值是否相等 - * - * @param o1 - * @param o2 - * @return - */ - public static boolean equalInt(Object o1, Object o2) { - int o1Int = parseIntData(o1); - int o2Int = parseIntData(o2); - if (o1Int != -9999 && o2Int != -9999 && o1Int == o2Int) { - return true; - } - return false; - } - - /** - * 比较两个长整数值是否相等 - * - * @param o1 - * @param o2 - * @return - */ - public static boolean equalLong(Object o1, Object o2) { - long o1Long = parseLongData(o1); - long o2Long = parseLongData(o2); - if (o1Long != -9999L && o2Long != -9999L && o1Long == o2Long) { - return true; - } - return false; - } - - /** - * 转化成长整型数值, 错误时返回null - * - * @param o - * @return - */ - public static Long parseLong(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Long.parseLong(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * 转化成长整型数值, 错误时返回-9999 - * - * @param o - * @return - */ - public static Long parseLongData(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Long.parseLong(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return -9999L; - } - - /** - * 转化成浮点数,错误时返回null - * - * @param o - * @return - */ - public static Float parseFloat(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Float.parseFloat(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * 转化成浮点数值,错误时返回-9999F - * - * @param o - * @return - */ - public static Float parseFloatData(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Float.parseFloat(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return -9999F; - } - - /** - * 转化成布尔值,错误时返回null - * - * @param o - * @return - */ - public static Boolean parseBoolean(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - if ("false".equalsIgnoreCase(Obj.getString(o)) || "0".equals(Obj.getString(o))) { - return false; - } - return true; - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * 转化成长整型, 错误时返回null - * - * @param o - * @return - */ - public static Double parseDouble(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Double.parseDouble(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * 转化成长整数值, 错误时返回-9999.99 - * - * @param o - * @return - */ - public static Double parseDoubleData(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Double.parseDouble(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return -9999.99; - } - - /** - * 转化成整数值, 错误时返回-9999 - * - * @param o - * @return - */ - public static Integer parseIntData(Object o) { - try { - if (o != null && isNotEmpty(o.toString().trim())) { - return Integer.parseInt(o.toString().trim()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return -9999; - } - - /** - * 转化成整型,错误时返回null - * - * @param o - * @return - */ - public static Integer parseInteger(Object o) { - Integer result = null; - try { - result = Integer.valueOf(getTrimString(o)); - } catch (Exception e) { - // TODO: handle exception - } - return result; - } - - /** - * 把字符串首字母转换为大写 - * - * @param str - * @return - */ - public static String upFirstChar(String str) { - return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase()); - } - - /** - * 从字符输入流转字符串 - * - * @param in - * @return - * @throws Exception - */ - public static String inputStream2String(InputStream is) { - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - StringBuilder sb = new StringBuilder(); - String line = null; - try { - while ((line = reader.readLine()) != null) { - sb.append(line); - } - } catch (IOException e) { - // TODO: handle exception - } finally { - try { - is.close(); - } catch (IOException e) { - // TODO: handle exception - } - } - return sb.toString(); - } - - /** - * 填充目标对象的字符串到固定长度 - * - * @param src - * @param quote - * @param size - * @return - */ - public static String fillStringWithQuote(Object src, String quote, int size) { - String str = getString(src); - int strSize = str.length(); - // 只有在源长度小于需要填补的长度时才进行填充 - String result = str; - if (strSize < size) { - for (int i = size - strSize; i > 0; i--) { - result = quote + result; - } - } - return result; - } - - // GENERAL_PUNCTUATION 判断中文的“号 - // CJK_SYMBOLS_AND_PUNCTUATION 判断中文的。号 - // HALFWIDTH_AND_FULLWIDTH_FORMS 判断中文的,号 - - /** - * 是否为中文字符 - * - * @param c - * @return - */ - public static boolean isChinese(char c) { - Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); - if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS - || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS - || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A - || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION - || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION - || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) { - return true; - } - return false; - } - - /** - * 是否为中文字符串 - * - * @param c - * @return - */ - public static boolean isChinese(String strName) { - if (strName.getBytes().length == strName.length()) - return false; - return true; - } - - /** - * 获取英文单词 - * - * @param words - * @return - */ - public static List getEnword(List words) { - List enwords = new ArrayList(); - for (int i = 0; i < words.size(); i++) { - String word = words.get(i); - if (isChinese(word)) - enwords.add(word); - } - return words; - } - - /** - * - * 转换字符串格式 - * - * @param str - * @return - * @throws UnsupportedEncodingException - */ - public static String getUTF8(String str) throws UnsupportedEncodingException { - return new String(str.getBytes("iso-8859-1"), "UTF-8"); - } - - } - - /** - * JSON处理 - * - * @author - * - */ - public static class json { - - // -------------------------------json字符串转换成java对象列表-------------------------------- - public static List string2ObjectList(String jsonData, Class target) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); - List result = null; - try { - result = mapper.readValue(jsonData, TypeFactory.collectionType(List.class, target)); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - return result; - } - - /** - * json字符串转换成java对象 - * - * @param jsonData - * 源json串 - * @param target - * 目标对象 - * @return 转化后的对象 - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static Object string2Object(String jsonData, Class target) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); - Object obj = null; - try { - obj = mapper.readValue(new StringReader(jsonData), target); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - return obj; - } - - /** - * java对象转换为json字符串 - */ - public static String object2Json(Object obj) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); - String json = null; - try { - json = mapper.writeValueAsString(obj); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - return json; - } - - /** - * - * 转化为对象列表 - * - * @param src - * @param target - * @return - * @throws IOException - * @throws JsonMappingException - * @throws JsonParseException - */ - @SuppressWarnings("rawtypes") - public static List unmarshal2Objects(String src, Class target) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); - List result = null; - result = mapper.readValue(new StringReader(src), TypeFactory.collectionType(ArrayList.class, target)); - return result; - } - - /** - * 转化为对象 - * - * @param src - * @param target - * @return - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static E unmarshal(String src, Class target) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); - return (E) mapper.readValue(new StringReader(src), target); - } - - /** - * 提取的http response的data数据,并转化为对象/对象列表 - * - * @param jsonStr - * @param target - * @return - */ - - @SuppressWarnings("unchecked") - public static T convertLspJsonStr2Object(String jsonStr, Class target) { - ObjectMapper mapper = new ObjectMapper(); - try { - Map m = mapper.readValue(jsonStr, Map.class); - if ("2".equals("" + m.get("status"))) { - Object data = m.get("data"); - if (data instanceof List) { - JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, target); - return (T) mapper.readValue(mapper.writeValueAsString(data), javaType); - } else { - Object destData = ((Map) data).get("data"); - if (destData instanceof List) { - JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, - target); - return (T) mapper.readValue(mapper.writeValueAsString(destData), javaType); - } else { - return (T) mapper.readValue(mapper.writeValueAsString(data), target); - } - } - } else { - return null; - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public static void main(String[] args) { - - } - } - - /** - * 处理协议工具 - * - * - */ - public static class protocal { - - public static String getHexFromByte(byte data){ - String val = Util.binhexoct.intToHex(data) ; - if(data < 0 ){ - val = Util.binhexoct.intToHex(data+256) ; - } - return val ; - } - - public static Integer getOtcFromByte(byte data){ - int val = data ; - if(data < 0 ){ - val = data+256 ; - } - return val ; - } - - public static String getOtcStrFromByte(byte data){ - int val = data ; - if(data < 0 ){ - val = data+256 ; - } - return val+"" ; - } - - public static String getOtcStrFromByte2l(byte data){ - int val = data ; - if(data < 0 ){ - val = data+256 ; - } - String sval =val+"" ; - if( sval.length() < 2){ - sval = "0"+val ; - } - return sval ; - } - - /** - * byte数组,变为string hex形式 - * @param data - * @return - */ - public static String getHexStringFromBytes(byte[] data){ - StringBuffer sb = new StringBuffer(); - if (data != null && data.length > 0 ) { - for(int i =0 ;i< data.length ; i++){ - String val = Util.binhexoct.intToHex(data[i]) ; - if(data[i] < 0 ){ - val = Util.binhexoct.intToHex(data[i]+256) ; - } - sb.append(val) ; - } - } - return sb.toString(); - } - - /** - * 取得十制数组的from~to位,并按照十六进制转化值 - * - * @param data - * @param from - * @param to - * @return - */ - public static String getOctFromHexBytes(byte[] data, Object from, Object... to) { - if (data != null && data.length > 0 && from != null) { - try { - byte[] value; - int fromIndex = Integer.parseInt(from.toString()); - if (to != null && to.length > 0) { - int toIndex = Integer.parseInt(to[0].toString()); - if (fromIndex >= toIndex || toIndex <= 0) { - value = Arrays.copyOfRange(data, fromIndex, fromIndex + 1); - } else { - value = Arrays.copyOfRange(data, fromIndex, toIndex + 1); - } - } else { - value = Arrays.copyOfRange(data, fromIndex, fromIndex + 1); - } - if (value != null && value.length > 0) { - long octValue = 0L; - int j = -1; - for (int i = value.length - 1; i >= 0; i--, j++) { - int d = value[i]; - if (d < 0) { - d += 256; - } - octValue += Math.round(d * Math.pow(16, 2 * j + 2)); - } - return new Long(octValue).toString(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - return null; - } - - /** - * 取得十制数组的from~to位,并按照十六进制转化值 - * 小端数据,低位在前,高位再后 - * @param data - * @param from - * @param to - * @return - */ - public static String getOctFromHexBytesLittle(byte[] data, Object from, Object... to) { - if (data != null && data.length > 0 && from != null) { - try { - byte[] value; - int fromIndex = Integer.parseInt(from.toString()); - if (to != null && to.length > 0) { - int toIndex = Integer.parseInt(to[0].toString()); - if (fromIndex >= toIndex || toIndex <= 0) { - value = Arrays.copyOfRange(data, fromIndex, fromIndex + 1); - } else { - value = Arrays.copyOfRange(data, fromIndex, toIndex + 1); - } - } else { - value = Arrays.copyOfRange(data, fromIndex, fromIndex + 1); - } - if (value != null && value.length > 0) { - long octValue = 0L; - int j = -1; - for (int i = 0; i <= value.length - 1; i++, j++) { - int d = value[i]; - if (d < 0) { - d += 256; - } - octValue += Math.round(d * Math.pow(16, 2 * j + 2)); - } - return new Long(octValue).toString(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - return null; - } - - /** - * byte[] ->char[] -> askII string - * @param data - * @param from - * @param to - * @return - */ - public static String bytesToString(byte[] data, Integer from, Integer to){ - char[] tmp = new char[to-from]; - for(int i = from,j=0 ; i < to;i++){ - tmp[j++] = (char) data[i]; - } - return String.valueOf(tmp); - } - /** - * String -> char[] -> byte[] - * @param data - * @return - */ - public static byte[] StringToBytes(String data){ - char[] bb = data.toCharArray() ; - byte[] array = new byte[bb.length]; - for(int i=0;i 0 && capacity[0] >= length) { - size = capacity[0]; - } - final byte[] byteArray = new byte[size]; - int k = 0; - for (int i = 0; i < size; i++) { - if (i < size - length) { - byteArray[i] = 0; - } else { - byte high = (byte) (Character.digit(hexString.charAt(k), 16) & 0xff); - if (k + 1 < hexString.length()) { - byte low = (byte) (Character.digit(hexString.charAt(k + 1), 16) & 0xff); - byteArray[i] = (byte) (high << 4 | low); - } else { - byteArray[i] = (byte) (high); - } - k += 2; - } - } - return byteArray; - } - return null; - } - - /** - * 16进制的字符串表示转成字节 - * - * @param hexString - * 16进制格式的字符串 - * @return 转换后的字节 - **/ - public static Byte hexString2Byte(String hexString) { - byte[] data = hexString2ByteArray(hexString); - if (data != null) { - return data[0]; - } - return null; - } - - /** - * 10进制的数字表示转成字节 - * - * @param octInt - * 16进制格式的整型 - * @return 转换后的字节 - **/ - public static Byte oct2Byte(int octInt) { - return hexString2Byte(Integer.toHexString(octInt)); - } - - /** - * 10进制的数字字符串数字表示转成字节 - * - * @param octString - * 10进制格式的字符串 - * @return 转换后的字节 - **/ - public static Byte octString2Byte(String octString) { - return hexString2Byte(Integer.toHexString(Integer.parseInt(octString))); - } - - /** - * 字节数组转成16进制表示格式的字符串 - * - * @param byteArray - * 需要转换的字节数组 - * @return 16进制表示格式的字符串 - **/ - public static String toHexString(byte[] byteArray) { - if (byteArray != null && byteArray.length > 0) { - final StringBuilder hexString = new StringBuilder(); - for (int i = 0; i < byteArray.length; i++) { - if ((byteArray[i] & 0xff) < 0x10) { - hexString.append("0"); - } - hexString.append(Integer.toHexString(0xFF & byteArray[i])); - } - return hexString.toString().toLowerCase(); - } - return null; - } - - /** - * 十六进制转出十进制字符串 - * - * @param data - * @return - */ - public static String byte2OctString(byte[] data) { - return new BigInteger(Util.protocal.toHexString(data), 16).toString(); - } - - /** - * 根据节点类型拼接某字节流 - * - * @param hexString - * 十六进制字符串 - * @return 转换后的字节数组 - **/ - public static byte[] getBytesByParam(String hexString, Object from, Object to) { - if (StringUtils.isNotEmpty(hexString)) { - int start = Integer.parseInt(from.toString()); - int end = Integer.parseInt(to.toString()); - return hexString2ByteArray(hexString, end - start + 1); - } - return null; - } - - public static byte[] subByte(byte[] data , int srcPos,int length ){ - byte[] dbyte = new byte[length]; - System.arraycopy(data, srcPos, dbyte, 0, length); - return dbyte; - } - - /** - * 字节流拼接 - * - * @param data - * 字节流 - * @return 拼接后的字节数组 - **/ - public static byte[] concat(byte[]... data) { - if (data != null && data.length > 0) { - int size = 0; - for (int i = 0; i < data.length; i++) { - size += data[i].length; - } - byte[] byteArray = new byte[size]; - int pos = 0; - for (int i = 0; i < data.length; i++) { - byte[] b = data[i]; - for (int j = 0; j < b.length; j++) { - byteArray[pos++] = b[j]; - } - } - return byteArray; - } - return null; - } - - /** - * 连接字节流 - * - * @return - */ - public static byte[] append(byte[] datas, byte[] data) { - if (datas == null) { - return data; - } - if (data == null) { - return datas; - } else { - return concat(datas, data); - } - } - - /** - * 连接字节流 - * - * @return - */ - public static byte[] append(byte[] datas, Byte data) { - if (datas == null) { - return new byte[] { data }; - } - if (data == null) { - return datas; - } else { - return concat(datas, new byte[] { data }); - } - } - - /** - * 连接字节流 - * - * @return - */ - public static byte[] append(byte[] datas, Byte... data) { - if (data != null && data.length > 0) { - byte[] result = datas; - for (int i = 0; i < data.length; i++) { - result = append(result, data[i]); - } - return result; - } else { - return datas; - } - } - - } - - /** - * mina辅助工具 - * - * @author - * - */ - public static class mina { - - /** - * 向会话里写字节流 - * - * @param session - * @param data - */ - public static int write(IoSession session, byte[] data) { - int result = 0; - try { - if (session != null && session.isConnected()) { - IoBuffer buffer = IoBuffer.allocate(10); - buffer.setAutoExpand(true); - buffer.put(data); - buffer.flip(); - session.write(buffer); - }else{ - result = 1; - } - } catch (Exception e) { - result = 1; - } - return result; - } - - public static void sessionFlush(IoSession session){ - ((AbstractIoSession) session).getProcessor().flush(session); - } - - /** - * 向会话里写字节流 - * - * @param session - * @param data - */ - public static int writeStr(IoSession session, String data) { - int result = 0; - try { - // 这边确认data没有中文 - IoBuffer buffer = IoBuffer.allocate(10); - buffer.setAutoExpand(true); - buffer.put( data.getBytes()); - buffer.flip(); - session.write(buffer); - } catch (Exception e) { - result = 1; - } - return result; - } - -// public static void main(String[] args) throws IOException { -// String aa = "TCPOK"; -// byte[] ss = aa.getBytes(); -// ByteArrayOutputStream outputPacket = new ByteArrayOutputStream(); -// DataOutputStream dos = new DataOutputStream(outputPacket); -// dos.writeUTF(aa); -// dos.flush(); -// outputPacket.toByteArray(); -// } - - } - - /** - * 关于文件的工具 - * - * @author - * - */ - public static class file { - /** - * 获取指定package下的完整类名 - * - * @param packageName - * @return - * @throws URISyntaxException - */ - public static List getClassName(String packageName) throws URISyntaxException { - String jarPath = Util.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); - File file = new File(jarPath); - if (file.isDirectory()) { - String filePath = ClassLoader.getSystemResource("").getPath() + packageName.replace(".", "\\"); - return getClassName(filePath, null); - } else { - return getClasssFromJarFile(jarPath, packageName); - } - } - - /** - * 从jar文件中读取指定目录下面的所有的class文件 - * - * @param jarPaht - * jar文件存放的位置 - * @param filePaht - * 指定的文件目录 - * @return 所有的的class的对象 - */ - public static List getClasssFromJarFile(String jarPaht, String packageName) { - List names = new ArrayList(); - JarFile jarFile = null; - try { - jarFile = new JarFile(jarPaht); - Enumeration ee = jarFile.entries(); - while (ee.hasMoreElements()) { - JarEntry entry = (JarEntry) ee.nextElement(); - String name = entry.getName().replaceAll("/", "."); - if (name.contains(packageName) && name.matches("^.*class$")) { - names.add(name.substring(0, name.length() - 6)); - } - } - } catch (IOException e1) { - e1.printStackTrace(); - } finally { - if (null != jarFile) { - try { - jarFile.close(); - } catch (Exception e) { - } - } - } - return names; - } - - /** - * - * @param filePath - * @param className - * @return - */ - private static List getClassName(String filePath, List className) { - List myClassName = new ArrayList(); - File file = new File(filePath); - File[] childFiles = file.listFiles(); - for (File childFile : childFiles) { - if (childFile.isDirectory()) { - myClassName.addAll(getClassName(childFile.getPath(), myClassName)); - } else { - String childFilePath = childFile.getPath(); - int startPos = childFilePath.indexOf("\\classes") + 9; - if (startPos == 8) { - startPos = childFilePath.indexOf("\\bin") + 5; - } - childFilePath = childFilePath.substring(startPos, childFilePath.lastIndexOf(".")); - childFilePath = childFilePath.replace("\\", "."); - myClassName.add(childFilePath); - } - } - - return myClassName; - } - } - - /** - * 关于map的工具 - * - * @author - * - */ - public static class map { - /** - * 根据value移除map中相应数据 - * - * @param map - * @param value - */ - public static Object remove(Map map, Object value) { - if (map.containsValue(value)) { - for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); - if (map.get(key).equals(value)) { - map.remove(key); - return key; - } - } - } - return null; - } - - } - - /** - * 反射 - * - * - */ - public static class reflect { - /** - * 取得字段的值 - * - * @param clazz - * @param fieldName - * @return - */ - public static Object getFieldValue(Object obj, String fieldName) { - try { - if (obj == null) { - return null; - } - Method getter = obj.getClass().getMethod("get" + Obj.upperFirstChar(fieldName)); - return getter.invoke(obj); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * 设置字段的值 - * - * @param clazz - * @param fieldName - * @return - * @throws NoSuchFieldException - * @throws SecurityException - */ - public static Object setFieldValue(Object obj, String fieldName, Object fieldValue) { - try { - if (obj == null || fieldName == null || fieldValue == null) { - return null; - } - Method setter = obj.getClass().getMethod("set" + Obj.upperFirstChar(fieldName), - new Class[] { fieldValue.getClass() }); - return setter.invoke(obj, fieldValue); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - } - - public static void main(String[] args) { - // IotNodeInfoBO node = new IotNodeInfoBO(); - // node.setId(100L); - // System.out.println(reflect.getFieldValue(node, "id")); - // reflect.setFieldValue(node, "id", 300L); - file.getClasssFromJarFile("c:/lsm.jar", "com.loygra.lsm.service.impl.camel.task"); - } - - /** - * - * - * - */ - public static class crc { - private static final char CTCTAB16[] = { 0X0000, 0X1189, 0X2312, 0X329B, 0X4624, 0X57AD, 0X6536, 0X74BF, 0X8C48, - 0X9DC1, 0XAF5A, 0XBED3, 0XCA6C, 0XDBE5, 0XE97E, 0XF8F7, 0X1081, 0X0108, 0X3393, 0X221A, 0X56A5, 0X472C, - 0X75B7, 0X643E, 0X9CC9, 0X8D40, 0XBFDB, 0XAE52, 0XDAED, 0XCB64, 0XF9FF, 0XE876, 0X2102, 0X308B, 0X0210, - 0X1399, 0X6726, 0X76AF, 0X4434, 0X55BD, 0XAD4A, 0XBCC3, 0X8E58, 0X9FD1, 0XEB6E, 0XFAE7, 0XC87C, 0XD9F5, - 0X3183, 0X200A, 0X1291, 0X0318, 0X77A7, 0X662E, 0X54B5, 0X453C, 0XBDCB, 0XAC42, 0X9ED9, 0X8F50, 0XFBEF, - 0XEA66, 0XD8FD, 0XC974, 0X4204, 0X538D, 0X6116, 0X709F, 0X0420, 0X15A9, 0X2732, 0X36BB, 0XCE4C, 0XDFC5, - 0XED5E, 0XFCD7, 0X8868, 0X99E1, 0XAB7A, 0XBAF3, 0X5285, 0X430C, 0X7197, 0X601E, 0X14A1, 0X0528, 0X37B3, - 0X263A, 0XDECD, 0XCF44, 0XFDDF, 0XEC56, 0X98E9, 0X8960, 0XBBFB, 0XAA72, 0X6306, 0X728F, 0X4014, 0X519D, - 0X2522, 0X34AB, 0X0630, 0X17B9, 0XEF4E, 0XFEC7, 0XCC5C, 0XDDD5, 0XA96A, 0XB8E3, 0X8A78, 0X9BF1, 0X7387, - 0X620E, 0X5095, 0X411C, 0X35A3, 0X242A, 0X16B1, 0X0738, 0XFFCF, 0XEE46, 0XDCDD, 0XCD54, 0XB9EB, 0XA862, - 0X9AF9, 0X8B70, 0X8408, 0X9581, 0XA71A, 0XB693, 0XC22C, 0XD3A5, 0XE13E, 0XF0B7, 0X0840, 0X19C9, 0X2B52, - 0X3ADB, 0X4E64, 0X5FED, 0X6D76, 0X7CFF, 0X9489, 0X8500, 0XB79B, 0XA612, 0XD2AD, 0XC324, 0XF1BF, 0XE036, - 0X18C1, 0X0948, 0X3BD3, 0X2A5A, 0X5EE5, 0X4F6C, 0X7DF7, 0X6C7E, 0XA50A, 0XB483, 0X8618, 0X9791, 0XE32E, - 0XF2A7, 0XC03C, 0XD1B5, 0X2942, 0X38CB, 0X0A50, 0X1BD9, 0X6F66, 0X7EEF, 0X4C74, 0X5DFD, 0XB58B, 0XA402, - 0X9699, 0X8710, 0XF3AF, 0XE226, 0XD0BD, 0XC134, 0X39C3, 0X284A, 0X1AD1, 0X0B58, 0X7FE7, 0X6E6E, 0X5CF5, - 0X4D7C, 0XC60C, 0XD785, 0XE51E, 0XF497, 0X8028, 0X91A1, 0XA33A, 0XB2B3, 0X4A44, 0X5BCD, 0X6956, 0X78DF, - 0X0C60, 0X1DE9, 0X2F72, 0X3EFB, 0XD68D, 0XC704, 0XF59F, 0XE416, 0X90A9, 0X8120, 0XB3BB, 0XA232, 0X5AC5, - 0X4B4C, 0X79D7, 0X685E, 0X1CE1, 0X0D68, 0X3FF3, 0X2E7A, 0XE70E, 0XF687, 0XC41C, 0XD595, 0XA12A, 0XB0A3, - 0X8238, 0X93B1, 0X6B46, 0X7ACF, 0X4854, 0X59DD, 0X2D62, 0X3CEB, 0X0E70, 0X1FF9, 0XF78F, 0XE606, 0XD49D, - 0XC514, 0XB1AB, 0XA022, 0X92B9, 0X8330, 0X7BC7, 0X6A4E, 0X58D5, 0X495C, 0X3DE3, 0X2C6A, 0X1EF1, - 0X0F78, }; - - /** - * - * @param vData - * 待校验的数据 16进制字符串 - * @param code - * 校验码 - * @return - */ - public static boolean validation(String vData, String code) { - int calCrc16 = getCrc16(vData); - int codeVal = Integer.parseInt(code.replace(" ", ""), 16); - return calCrc16 == codeVal; - } - - /** - * @param hex - * 16进制字符串 获取给定字符串的循环冗余校验 - */ - public static int getCrc16(String hex) { - String[] hexArr = hex.split(" "); - byte[] data = new byte[hexArr.length]; - for (int i = 0; i < hexArr.length; i++) { - // data[i]=Byte.parseByte(hexArr[i],16); - data[i] = (byte) Integer.parseInt(hexArr[i], 16); - } - - return getCrc16(data, data.length); - } - - /** - * 查表法 - * - * @param pData - * @param nLength - * @return - */ - // 计算给定长度数据的16位CRC。 - public static int getCrc16(byte[] pData, int nLength) { - int fcs = 0xffff; // 初始化 - int i = 0; - while (nLength > 0) { - fcs = (fcs >> 8) ^ CTCTAB16[(fcs ^ pData[i]) & 0xff]; - nLength--; - i++; - } - // return ~fcs; // 取反 - return ~fcs & 0xFFFF; - } - - /** - * 查表法 - * - * @param pData - * @return - */ - public static int getCrc16(byte[] pData) { - return getCrc16(pData, pData.length); - } - - /** - * ModBus 通信协议的 CRC ( 冗余循环校验码含2个字节, 即 16 位二进制数 ) - * @param bytes - * @param flag 高位在前,还是高位在后 - * @return - */ - public static String getCRC16(byte[] bytes,Boolean flag) { - int CRC = 0x0000ffff; - int POLYNOMIAL = 0x0000a001; - - int i, j; - for (i = 0; i < bytes.length; i++) { - CRC ^= (int) bytes[i]; - for (j = 0; j < 8; j++) { - if ((CRC & 0x00000001) == 1) { - CRC >>= 1; - CRC ^= POLYNOMIAL; - } else { - CRC >>= 1; - } - } - } - //高低位转换,看情况使用(譬如本人这次对led彩屏的通讯开发就规定校验码高位在前低位在后,也就不需要转换高低位) - if(flag){ - CRC = ( (CRC & 0x0000FF00) >> 8) | ( (CRC & 0x000000FF ) << 8); - } - return Integer.toHexString(CRC); - } - - public static Integer getCRC162Int(byte[] bytes,Boolean flag) { - int CRC = 0x0000ffff; - int POLYNOMIAL = 0x0000a001; - - int i, j; - for (i = 0; i < bytes.length; i++) { -// CRC ^= (int) bytes[i]; - - if(bytes[i] <0 ){ - CRC ^= (int) (bytes[i]+256) ; - }else{ - CRC ^= (int) bytes[i] ; - } - - - for (j = 0; j < 8; j++) { - if ((CRC & 0x00000001) == 1) { - CRC >>= 1; - CRC ^= POLYNOMIAL; - } else { - CRC >>= 1; - } - } - } - //高低位转换,看情况使用(譬如本人这次对led彩屏的通讯开发就规定校验码高位在前低位在后,也就不需要转换高低位) - if(flag){ - CRC = ( (CRC & 0x0000FF00) >> 8) | ( (CRC & 0x000000FF ) << 8); - } - return CRC; - } - - public static Integer getCRC162Int(byte[] bytes,Boolean flag,Integer from ,Integer to) { - int CRC = 0x0000ffff; - int POLYNOMIAL = 0x0000a001; - if(to > bytes.length ) - to = bytes.length ; - int i, j; - for (i = from; i < to; i++) { - CRC ^= (int) bytes[i]; - for (j = 0; j < 8; j++) { - if ((CRC & 0x00000001) == 1) { - CRC >>= 1; - CRC ^= POLYNOMIAL; - } else { - CRC >>= 1; - } - } - } - //高低位转换,看情况使用(譬如本人这次对led彩屏的通讯开发就规定校验码高位在前低位在后,也就不需要转换高低位) - if(flag){ - CRC = ( (CRC & 0x0000FF00) >> 8) | ( (CRC & 0x000000FF ) << 8); - } - return CRC; - } - - /** - * 特殊自定义crc16 - * @param bytes - * @param from - * @param to - * @return - */ - public static Integer getLocalCRC16(byte[] bytes ){ - int i, j; - int CRC = 0x0000ffff; - for (i = 0; i < bytes.length; i++) { - if(bytes[i] <0 ){ - CRC ^= (int) (bytes[i]+256) ; - }else{ - CRC ^= (int) bytes[i] ; - } -// CRC ^= (int) bytes[i] ; - for (j = 0; j < 8; j++) { - if ((CRC & 0x00000001) == 1) { - CRC >>= 1; - CRC ^= 0x1021; - } else { - CRC >>= 1; - } - } - } - CRC = ( (CRC & 0x0000FF00) >> 8) | ( (CRC & 0x000000FF ) << 8); - - return CRC; - - } - - /** - * 特殊自定义crc16 - * @param bytes - * @param from - * @param to - * @return - */ - public static Integer getLocalCRC16(byte[] bytes,Integer from ,Integer to ){ - int i, j; - int CRC = 0x0000ffff; - for (i = from; i < to; i++) { -// CRC ^= (int) bytes[i]; - if(bytes[i] <0 ){ - CRC ^= (int) (bytes[i]+256) ; - }else{ - CRC ^= (int) bytes[i] ; - } - for (j = 0; j < 8; j++) { - if ((CRC & 0x00000001) == 1) { - CRC >>= 1; - CRC ^= 0x1021; - } else { - CRC >>= 1; - } - } - } - CRC = ( (CRC & 0x0000FF00) >> 8) | ( (CRC & 0x000000FF ) << 8); - - return CRC; - - } - - public static void main(String args[]) throws InterruptedException {} - } - - /** - * 时间工具类 - * - * @author - * - */ - public static class date { - /** 年月日时分秒(无下划线) yyyyMMddHHmmss */ - public static final String dtLong = "yyyyMMddHHmmss"; - - /** 年月日时分秒毫秒(无下划线) yyyyMMddHHmmssSSS */ - public static final String dtVeryLong = "yyyyMMddHHmmssSSS"; - - /** 完整时间 yyyy-MM-dd HH:mm */ - public static final String simple = "yyyy-MM-dd HH:mm"; - - /** 年月日(无下划线) yyyyMMdd */ - public static final String dtSimple = "yyyy-MM-dd"; - - /** 年月日(无下划线) yyyyMMdd */ - public static final String dtShort = "yyyyMMdd"; - - /** 年月日 yyyy.MM.dd */ - public static final String dtShortPoint = "yyyy.MM.dd"; - /** 年月日 yyyy.MM.dd HH:mm */ - public static final String dtLongPoint = "yyyy.MM.dd HH:mm"; - - /** - * 字符串转日期 - * - * @param pattern - * @param text - * @return - * @throws ParseException - */ - public static Date parse(String pattern, String text) throws ParseException { - SimpleDateFormat df = new SimpleDateFormat(pattern); - return df.parse(text); - } - - /** - * 日期转字符串 - * - * @param pattern - * @param date - * @return - * @throws ParseException - */ - public static String format(String pattern, Date date) throws ParseException { - if (date == null) { - return "-"; - } - SimpleDateFormat df = new SimpleDateFormat(pattern); - return df.format(date); - } - - /** - * 格式:年月日时分秒(无下划线) yyyyMMddHHmmss - * - * @param text - * @return - * @throws ParseException - */ - public static Date parseDtLong(String text) throws ParseException { - return parse(dtLong, text); - } - - /** - * 格式:完整时间 yyyy-MM-dd HH:mm:ss - * - * @param text - * @return - * @throws ParseException - */ - public static Date parseSimple(String text) throws ParseException { - return parse(simple, text); - } - - /** - * 格式:年月日时分秒毫秒(无下划线) yyyyMMddHHmmssSSS - * - * @param date - * @return - * @throws ParseException - */ - public static String formatDtVeryLong(Date date) throws ParseException { - return format(dtVeryLong, date); - } - - /** - * 格式:年月日时分秒(无下划线) yyyyMMddHHmmss - * - * @param date - * @return - * @throws ParseException - */ - public static String formatDtLong(Date date) throws ParseException { - return format(dtLong, date); - } - - /** - * 格式:完整时间 yyyy-MM-dd HH:mm:ss - * - * @param date - * @return - * @throws ParseException - */ - public static String formatSimple(Date date) throws ParseException { - return format(simple, date); - } - - /** - * 返回yy yy mm mm数组 - * - * @param date - * @return - */ - public static String[] getSpotData(Date date) throws ParseException { - if (date != null) { - String yyyymm = formatDtVeryLong(date); - String[] data = new String[4]; - data[0] = yyyymm.substring(0, 2); - data[1] = yyyymm.substring(2, 4); - data[2] = yyyymm.substring(4, 6); - data[3] = yyyymm.substring(6, 8); - return data; - } - return null; - } - - /** - * 返回yy yy mm mm数组 - * - * @param date - * @return - */ - public static String[] getSpotData(String date) throws ParseException { - if (Util.Obj.isNotEmpty(date)) { - String[] data = new String[4]; - data[0] = date.substring(0, 2); - data[1] = date.substring(2, 4); - data[2] = date.substring(4, 6); - data[3] = date.substring(6, 8); - return data; - } - return null; - } - - /** - * 获取当前的时间 格式: 时:分:秒 - * - * @return - */ - public static String getNowTimeStr() { - Calendar calendar = Calendar.getInstance(); - /** - * 小时 - */ - int hour = calendar.get(Calendar.HOUR_OF_DAY); - /** - * 分钟 - */ - int minute = calendar.get(Calendar.MINUTE); - /** - * 秒钟 - */ - int second = calendar.get(Calendar.SECOND); - /** - * 拼接时间(时分秒) - */ - String time = (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute) + ":" - + (second < 10 ? "0" + second : second); - /** - * 返回时分秒 - */ - return time; - } - - /** - * 获取当前时间的前一天 - */ - public static Date getBeforeOneDateTime(Date day) { - - Calendar calendar = Calendar.getInstance(); - - calendar.setTime(day); - - int dateday = calendar.get(Calendar.DATE); - - calendar.set(Calendar.DATE, dateday - 1); - - return calendar.getTime(); - } - - /** - * 获取当前时间的后一天 - */ - public static Date getAfterOneDateTime(Date day) { - - Calendar calendar = Calendar.getInstance(); - - calendar.setTime(day); - - int dateday = calendar.get(Calendar.DATE); - - calendar.set(Calendar.DATE, dateday + 1); - - return calendar.getTime(); - } - - /** - * 获取当前的时间毫秒数,格林尼治时间 格式: 时:分:秒 - * - * @return the number of milliseconds since January 1, 1970, 00:00:00 - * GMT represented by this date. - */ - public static long getNowTime() { - Calendar calendar = Calendar.getInstance(); - /** - * 小时 - */ - int hour = calendar.get(Calendar.HOUR_OF_DAY) - 8; - /** - * 分钟 - */ - int minute = calendar.get(Calendar.MINUTE); - /** - * 秒钟 - */ - int second = calendar.get(Calendar.SECOND); - /** - * 返回毫秒数 - */ - return (hour * 60 * 60 + minute * 60 + second) * 1000; - } - - /** - * 获取当前日期 - * - * @param args - */ - public static Date getCurrentDate() { - // 获取当前日期 - Calendar calendar = new GregorianCalendar(); - GregorianCalendar today = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), - calendar.get(Calendar.DAY_OF_MONTH)); - return today.getTime(); - } - - /** - * 获取当前日期 - * - * @param args - */ - public static Date getCurrentDate(long time) { - // 获取当前日期 - Calendar calendar = new GregorianCalendar(); - calendar.setTimeInMillis(time); - GregorianCalendar today = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), - calendar.get(Calendar.DAY_OF_MONTH)); - return today.getTime(); - } - - /** - * 长整型数值是否能转化为时间 - * - * @param data - * @return - */ - public static boolean isDateFromLong(Object data) { - if (data != null && Obj.isActiveNumber(data)) { - try { - new Date(Obj.parseLong(data)); - } catch (Exception e) { - return false; - } - return true; - } - return false; - } - - /** - * 获取抽象的时间描述 - * - * @param insert_time - * @return - */ - public static String getTimeDesc(Date insert_time) { - String insert_time_desc = ""; - long inTime = insert_time.getTime(); - long curTime = System.currentTimeMillis(); - // 差值,分钟 - double dValue = Math.ceil((curTime - inTime) / 1000 / 60); - if (dValue < 1) - insert_time_desc = "刚刚"; - else if (dValue < 60) - insert_time_desc = (long) dValue + "分钟前"; - else if (dValue < 60 * 24) - insert_time_desc = (long) Math.floor(dValue / 60) + "小时前"; - else if (dValue < 60 * 24 * 30) - insert_time_desc = (long) Math.floor(dValue / 60 / 24) + "天前"; - else if (dValue < 60 * 24 * 365) - insert_time_desc = (long) Math.floor(dValue / 60 / 24 / 30) + "月前"; - else - insert_time_desc = (long) Math.floor(dValue / 60 / 24 / 365) + "年前"; - return insert_time_desc; - } - - /** - * 取得当前时间与参数时间的差额,如果minus不为空的话,则返回当前时间-参数时间-差额时间 - * - * @param ts - * @param minus_seconds - * 差额 - * @return - */ - public static long getMinusFromCurrent(Timestamp ts, int... minus_seconds) { - long curTimeMill = System.currentTimeMillis(); - if (minus_seconds.length > 0) { - return curTimeMill - ts.getTime() - minus_seconds[0] * 1000; - } - return System.currentTimeMillis() - ts.getTime(); - } - - /** - * @see getMinusFromCurrent() - * - * @param date - * @param minus_seconds - * 差额 - * @return - */ - public static long getMinusFromCurrent(Date date, int... minus_seconds) { - long curTimeMill = System.currentTimeMillis(); - if (minus_seconds.length > 0) { - return curTimeMill - date.getTime() - minus_seconds[0] * 1000; - } - return curTimeMill - date.getTime(); - } - } - - public static class ByteArrayConveter { - - public static byte strOtc2Byte(String c){ - return (byte) Integer.parseInt(c) ; - } - - // char转换为byte[2]数组 - public static byte[] getByteArray(char c) { - byte[] b = new byte[2]; - b[0] = (byte) ((c & 0xff00) >> 8); - b[1] = (byte) (c & 0x00ff); - return b; - } - - // 从byte数组的index处的连续两个字节获得一个char - public static char getChar(byte[] arr, int index) { - return (char) (0xff00 & arr[index] << 8 | (0xff & arr[index + 1])); - } - // short转换为byte[2]数组 - public static byte[] getByteArray(short s) { - byte[] b = new byte[2]; - b[0] = (byte) ((s & 0xff00) >> 8); - b[1] = (byte) (s & 0x00ff); - return b; - } - // 从byte数组的index处的连续两个字节获得一个short - public static short getShort(byte[] arr, int index) { - return (short) (0xff00 & arr[index] << 8 | (0xff & arr[index + 1])); - } - // int转换为byte[4]数组 - public static byte[] getByteArray(int i) { - byte[] b = new byte[4]; - b[0] = (byte) ((i & 0xff000000) >> 24); - b[1] = (byte) ((i & 0x00ff0000) >> 16); - b[2] = (byte) ((i & 0x0000ff00) >> 8); - b[3] = (byte) (i & 0x000000ff); - return b; - } - /** - * int 转byte 转2位字节,舍弃2位 - * @param i - * @return - */ - public static byte[] getByteArrayLittle(int i) { - byte[] b = new byte[2]; - b[1] = (byte) ((i & 0x0000ff00) >> 8); - b[0] = (byte) (i & 0x000000ff); - return b; - } - - // 从byte数组的index处的连续4个字节获得一个int - public static int getInt(byte[] arr, int index) { - return (0xff000000 & (arr[index+0] << 24)) | - (0x00ff0000 & (arr[index+1] << 16)) | - (0x0000ff00 & (arr[index+2] << 8)) | - (0x000000ff & arr[index+3]); - } - // float转换为byte[4]数组 - public static byte[] getByteArray(float f) { - int intbits = Float.floatToIntBits(f);//将float里面的二进制串解释为int整数 - return getByteArray(intbits); - } - // 从byte数组的index处的连续4个字节获得一个float (正常顺序 ) 高位在前,地位在后 1234 - public static float getFloat(byte[] arr, int index) { - return Float.intBitsToFloat(getInt(arr, index)); - } - - public static float getFloat3412(byte[] arr, int index) { - return Float.intBitsToFloat(getInt3412(arr, index)); - } - - public static float getFloat4321(byte[] arr, int index) { - return Float.intBitsToFloat(getInt4321(arr, index)); - } - - public static float getFloat2143(byte[] arr, int index) { - return Float.intBitsToFloat(getInt2143(arr, index)); - } - - public static int getInt2143(byte[] arr, int index) { - return (0xff000000 & (arr[index+1] << 24)) | - (0x00ff0000 & (arr[index+0] << 16)) | - (0x0000ff00 & (arr[index+3] << 8)) | - (0x000000ff & arr[index+2]); - } - - public static int getInt3412(byte[] arr, int index) { - return (0xff000000 & (arr[index+2] << 24)) | - (0x00ff0000 & (arr[index+3] << 16)) | - (0x0000ff00 & (arr[index+0] << 8)) | - (0x000000ff & arr[index+1]); - } - - public static int getInt4321(byte[] arr, int index) { - return (0xff000000 & (arr[index+3] << 24)) | - (0x00ff0000 & (arr[index+2] << 16)) | - (0x0000ff00 & (arr[index+1] << 8)) | - (0x000000ff & arr[index+0]); - } - - // long转换为byte[8]数组 - public static byte[] getByteArray(long l) { - byte b[] = new byte[8]; - b[0] = (byte) (0xff & (l >> 56)); - b[1] = (byte) (0xff & (l >> 48)); - b[2] = (byte) (0xff & (l >> 40)); - b[3] = (byte) (0xff & (l >> 32)); - b[4] = (byte) (0xff & (l >> 24)); - b[5] = (byte) (0xff & (l >> 16)); - b[6] = (byte) (0xff & (l >> 8)); - b[7] = (byte) (0xff & l); - return b; - } - // 从byte数组的index处的连续8个字节获得一个long - public static long getLong(byte[] arr, int index) { - return (0xff00000000000000L & ((long)arr[index+0] << 56)) | - (0x00ff000000000000L & ((long)arr[index+1] << 48)) | - (0x0000ff0000000000L & ((long)arr[index+2] << 40)) | - (0x000000ff00000000L & ((long)arr[index+3] << 32)) | - (0x00000000ff000000L & ((long)arr[index+4] << 24)) | - (0x0000000000ff0000L & ((long)arr[index+5] << 16)) | - (0x000000000000ff00L & ((long)arr[index+6] << 8)) | - (0x00000000000000ffL & (long)arr[index+7]); - } - // double转换为byte[8]数组 - public static byte[] getByteArray(double d) { - long longbits = Double.doubleToLongBits(d); - return getByteArray(longbits); - } - // 从byte数组的index处的连续8个字节获得一个double - public static double getDouble(byte[] arr, int index) { - return Double.longBitsToDouble(getLong(arr, index)); - } - - public static void main(String[] args) { - System.out.println(ByteOrder.nativeOrder()); - if(args.length < 1){ - System.out.println("enter 'char' test method about char"); - System.out.println("enter 'short' test method about short"); - System.out.println("enter 'int' test method about int"); - System.out.println("enter 'float' test method about float"); - System.out.println("enter 'long' test method about long"); - System.out.println("enter 'double' test method about double"); - return; - } - if(args[0].equals("char")){ - char c = '\u0000'; - while( c < '\uffff'){ - System.out.println(getChar(getByteArray(c),0)); - c++; - } - }else if(args[0].equals("short")){ - short s = Short.MIN_VALUE; - while( s < Short.MAX_VALUE){ - System.out.println(getShort(getByteArray(s), 0)); - s++; - } - }else if(args[0].equals("int")){ - int i = Integer.MIN_VALUE; - while( i < Integer.MAX_VALUE){ - System.out.println(getInt(getByteArray(i), 0)); - i++; - } - }else if(args[0].equals("float")){ - float f = Float.MIN_VALUE; - while(f < Float.MAX_VALUE){ - System.out.println(getFloat(getByteArray(f), 0)); - f+=1.1111f; - } - }else if(args[0].equals("long")){ - long l = Long.MIN_VALUE; - while(l < Long.MAX_VALUE){ - System.out.println(getLong(getByteArray(l), 0)); - l++; - } - }else if(args[0].equals("double")){ - double d = Double.MIN_VALUE; - while(d < Double.MAX_VALUE){ - System.out.println(getDouble(getByteArray(d), 0)); - d+=1.111D; - } - } - } - } - -} diff --git a/lmp_v0.3.9_del/src/log4j.properties b/lmp_v0.3.9_del/src/log4j.properties deleted file mode 100644 index 6d3a782..0000000 --- a/lmp_v0.3.9_del/src/log4j.properties +++ /dev/null @@ -1,41 +0,0 @@ -############################################################################# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################# -log4j.rootLogger=INFO,CONSOLE,R -log4j.additivity.org.apache=true - -#全局的日志级别(打印sql必须要该属性) -log4j.appender.Threshold=INFO - -#ConsoleAppender -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=DEBUG -log4j.appender.CONSOLE.Target=System.out -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p [%t] -%l - %m%n - -log4j.appender.R=org.apache.log4j.RollingFileAppender -log4j.appender.R.Threshold=DEBUG -log4j.appender.R.File=/log/lpm/${lpmKey}/${lpmKey}.log -log4j.appender.R.MaxFileSize=2048KB -log4j.appender.R.Append=true -log4j.appender.R.MaxBackupIndex=20 -log4j.appender.R.layout=org.apache.log4j.PatternLayout - -log4j.appender.R.layout.ConversionPattern=%d %p [%c] - <%m>%n - - - diff --git a/lmp_v0.3.9_del/test/test.java b/lmp_v0.3.9_del/test/test.java deleted file mode 100644 index 4d9f957..0000000 --- a/lmp_v0.3.9_del/test/test.java +++ /dev/null @@ -1,42 +0,0 @@ -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -public class test { - public static void main(String[] args) { - String packageName = "com.loygra.lsm.service.impl.gumi.task"; - - List classNames = getClassName(packageName); - for (String className : classNames) { - System.out.println(className); - } - } - - public static List getClassName(String packageName) { - String filePath = ClassLoader.getSystemResource("").getPath() + packageName.replace(".", "\\"); - List fileNames = getClassName(filePath, null); - return fileNames; - } - - private static List getClassName(String filePath, List className) { - List myClassName = new ArrayList(); - File file = new File(filePath); - File[] childFiles = file.listFiles(); - for (File childFile : childFiles) { - if (childFile.isDirectory()) { - myClassName.addAll(getClassName(childFile.getPath(), myClassName)); - } else { - String childFilePath = childFile.getPath(); - int startPos = childFilePath.indexOf("\\classes") + 9; - if(startPos==8) { - startPos= childFilePath.indexOf("\\bin") + 5; - } - childFilePath = childFilePath.substring(startPos, childFilePath.lastIndexOf(".")); - childFilePath = childFilePath.replace("\\", "."); - myClassName.add(childFilePath); - } - } - - return myClassName; - } -}