@@ -0,0 +1,191 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ProjectInspectionProfilesVisibleTreeState"> | |||
<entry key="Project Default"> | |||
<profile-state> | |||
<expanded-state> | |||
<State /> | |||
<State> | |||
<id>Abstraction issuesJava</id> | |||
</State> | |||
<State> | |||
<id>Android</id> | |||
</State> | |||
<State> | |||
<id>Assignment issuesGroovy</id> | |||
</State> | |||
<State> | |||
<id>Assignment issuesJava</id> | |||
</State> | |||
<State> | |||
<id>Assignment issuesJavaScript and TypeScript</id> | |||
</State> | |||
<State> | |||
<id>Async code and promisesJavaScript and TypeScript</id> | |||
</State> | |||
<State> | |||
<id>CSS</id> | |||
</State> | |||
<State> | |||
<id>Chrome OSCorrectnessLintAndroid</id> | |||
</State> | |||
<State> | |||
<id>Class structureJava</id> | |||
</State> | |||
<State> | |||
<id>Code style issuesJava</id> | |||
</State> | |||
<State> | |||
<id>CodePlugin DevKit</id> | |||
</State> | |||
<State> | |||
<id>CodeSpring CoreSpring</id> | |||
</State> | |||
<State> | |||
<id>CoffeeScript</id> | |||
</State> | |||
<State> | |||
<id>CommonReactive Streams</id> | |||
</State> | |||
<State> | |||
<id>CorrectnessLintAndroid</id> | |||
</State> | |||
<State> | |||
<id>Declaration redundancyJava</id> | |||
</State> | |||
<State> | |||
<id>EmbeddedPerformanceJava</id> | |||
</State> | |||
<State> | |||
<id>Error handlingJava</id> | |||
</State> | |||
<State> | |||
<id>General</id> | |||
</State> | |||
<State> | |||
<id>GeneralCoffeeScript</id> | |||
</State> | |||
<State> | |||
<id>GeneralJava</id> | |||
</State> | |||
<State> | |||
<id>GeneralJavaScript and TypeScript</id> | |||
</State> | |||
<State> | |||
<id>Groovy</id> | |||
</State> | |||
<State> | |||
<id>IconsUsabilityLintAndroid</id> | |||
</State> | |||
<State> | |||
<id>InitializationJava</id> | |||
</State> | |||
<State> | |||
<id>Java</id> | |||
</State> | |||
<State> | |||
<id>Java 5Java language level migration aidsJava</id> | |||
</State> | |||
<State> | |||
<id>Java 8Java language level migration aidsJava</id> | |||
</State> | |||
<State> | |||
<id>Java language level migration aidsJava</id> | |||
</State> | |||
<State> | |||
<id>JavaScript and TypeScript</id> | |||
</State> | |||
<State> | |||
<id>JavadocJava</id> | |||
</State> | |||
<State> | |||
<id>Kotlin</id> | |||
</State> | |||
<State> | |||
<id>LintAndroid</id> | |||
</State> | |||
<State> | |||
<id>MessagesCorrectnessLintAndroid</id> | |||
</State> | |||
<State> | |||
<id>Naming conventionsJava</id> | |||
</State> | |||
<State> | |||
<id>OSGi</id> | |||
</State> | |||
<State> | |||
<id>PerformanceJava</id> | |||
</State> | |||
<State> | |||
<id>PerformanceLintAndroid</id> | |||
</State> | |||
<State> | |||
<id>Plugin DevKit</id> | |||
</State> | |||
<State> | |||
<id>PortabilityJava</id> | |||
</State> | |||
<State> | |||
<id>Potentially confusing code constructsGroovy</id> | |||
</State> | |||
<State> | |||
<id>Potentially confusing code constructsJavaScript and TypeScript</id> | |||
</State> | |||
<State> | |||
<id>Probable bugsCSS</id> | |||
</State> | |||
<State> | |||
<id>Probable bugsKotlin</id> | |||
</State> | |||
<State> | |||
<id>Reactive Streams</id> | |||
</State> | |||
<State> | |||
<id>ReactorReactive Streams</id> | |||
</State> | |||
<State> | |||
<id>SQL</id> | |||
</State> | |||
<State> | |||
<id>SecurityJava</id> | |||
</State> | |||
<State> | |||
<id>SecurityLintAndroid</id> | |||
</State> | |||
<State> | |||
<id>Spring</id> | |||
</State> | |||
<State> | |||
<id>Spring BootSpring</id> | |||
</State> | |||
<State> | |||
<id>Spring CoreSpring</id> | |||
</State> | |||
<State> | |||
<id>Spring DataSpring</id> | |||
</State> | |||
<State> | |||
<id>TypeScriptJavaScript and TypeScript</id> | |||
</State> | |||
<State> | |||
<id>UI form</id> | |||
</State> | |||
<State> | |||
<id>UsabilityLintAndroid</id> | |||
</State> | |||
<State> | |||
<id>WebSocket</id> | |||
</State> | |||
<State> | |||
<id>toString() issuesJava</id> | |||
</State> | |||
</expanded-state> | |||
<selected-state> | |||
<State> | |||
<id>Android</id> | |||
</State> | |||
</selected-state> | |||
</profile-state> | |||
</entry> | |||
</component> | |||
</project> |
@@ -0,0 +1,8 @@ | |||
# Default ignored files | |||
/shelf/ | |||
/workspace.xml | |||
# Datasource local storage ignored files | |||
/dataSources/ | |||
/dataSources.local.xml | |||
# Editor-based HTTP Client requests | |||
/httpRequests/ |
@@ -0,0 +1,13 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="CompilerConfiguration"> | |||
<annotationProcessing> | |||
<profile name="Maven default annotation processors profile" enabled="true"> | |||
<sourceOutputDir name="target/generated-sources/annotations" /> | |||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> | |||
<outputRelativeToContentRoot value="true" /> | |||
<module name="algorithm-lib" /> | |||
</profile> | |||
</annotationProcessing> | |||
</component> | |||
</project> |
@@ -0,0 +1,7 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="Encoding"> | |||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> | |||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> | |||
</component> | |||
</project> |
@@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="RemoteRepositoriesConfiguration"> | |||
<remote-repository> | |||
<option name="id" value="spring-snapshots" /> | |||
<option name="name" value="spring-snapshots" /> | |||
<option name="url" value="http://repo.spring.io/libs-snapshot" /> | |||
</remote-repository> | |||
<remote-repository> | |||
<option name="id" value="central" /> | |||
<option name="name" value="Central Repository" /> | |||
<option name="url" value="https://repo.maven.apache.org/maven2" /> | |||
</remote-repository> | |||
<remote-repository> | |||
<option name="id" value="central" /> | |||
<option name="name" value="Maven Central repository" /> | |||
<option name="url" value="https://repo1.maven.org/maven2" /> | |||
</remote-repository> | |||
<remote-repository> | |||
<option name="id" value="jboss.community" /> | |||
<option name="name" value="JBoss Community repository" /> | |||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> | |||
</remote-repository> | |||
</component> | |||
</project> |
@@ -0,0 +1,10 @@ | |||
<component name="libraryTable"> | |||
<library name="libMacAlgorithm-aicare"> | |||
<CLASSES /> | |||
<JAVADOC /> | |||
<NATIVE> | |||
<root url="file://$PROJECT_DIR$/src/main/resources" /> | |||
</NATIVE> | |||
<SOURCES /> | |||
</library> | |||
</component> |
@@ -0,0 +1,10 @@ | |||
<component name="libraryTable"> | |||
<library name="libMacAlgorithm-icomon"> | |||
<CLASSES /> | |||
<JAVADOC /> | |||
<NATIVE> | |||
<root url="file://$PROJECT_DIR$/src/main/resources" /> | |||
</NATIVE> | |||
<SOURCES /> | |||
</library> | |||
</component> |
@@ -0,0 +1,14 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ExternalStorageConfigurationManager" enabled="true" /> | |||
<component name="MavenProjectsManager"> | |||
<option name="originalFiles"> | |||
<list> | |||
<option value="$PROJECT_DIR$/pom.xml" /> | |||
</list> | |||
</option> | |||
</component> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |||
<output url="file://$PROJECT_DIR$/out" /> | |||
</component> | |||
</project> |
@@ -0,0 +1,124 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="Palette2"> | |||
<group name="Swing"> | |||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" /> | |||
</item> | |||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" /> | |||
</item> | |||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" /> | |||
</item> | |||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true"> | |||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" /> | |||
</item> | |||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" /> | |||
<initial-values> | |||
<property name="text" value="Button" /> | |||
</initial-values> | |||
</item> | |||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | |||
<initial-values> | |||
<property name="text" value="RadioButton" /> | |||
</initial-values> | |||
</item> | |||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" /> | |||
<initial-values> | |||
<property name="text" value="CheckBox" /> | |||
</initial-values> | |||
</item> | |||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" /> | |||
<initial-values> | |||
<property name="text" value="Label" /> | |||
</initial-values> | |||
</item> | |||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | |||
<preferred-size width="150" height="-1" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | |||
<preferred-size width="150" height="-1" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1"> | |||
<preferred-size width="150" height="-1" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |||
<preferred-size width="150" height="50" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |||
<preferred-size width="150" height="50" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |||
<preferred-size width="150" height="50" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" /> | |||
</item> | |||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |||
<preferred-size width="150" height="50" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3"> | |||
<preferred-size width="150" height="50" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3"> | |||
<preferred-size width="150" height="50" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | |||
<preferred-size width="200" height="200" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3"> | |||
<preferred-size width="200" height="200" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true"> | |||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | |||
</item> | |||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" /> | |||
</item> | |||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" /> | |||
</item> | |||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" /> | |||
</item> | |||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1"> | |||
<preferred-size width="-1" height="20" /> | |||
</default-constraints> | |||
</item> | |||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false"> | |||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" /> | |||
</item> | |||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> | |||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> | |||
</item> | |||
</group> | |||
</component> | |||
</project> |
@@ -0,0 +1,2 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<module type="JAVA_MODULE" version="4" /> |
@@ -0,0 +1,110 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<groupId>com.elink</groupId> | |||
<artifactId>algorithm-lib</artifactId> | |||
<version>1.0</version> | |||
<packaging>jar</packaging> | |||
<name>algorithm-lib</name> | |||
<url>http://maven.apache.org</url> | |||
<parent> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-parent</artifactId> | |||
<version>1.5.6.RELEASE</version> | |||
</parent> | |||
<properties> | |||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | |||
<java.version>1.8</java.version> | |||
<spring-cloud.version>Dalston.RELEASE</spring-cloud.version> | |||
</properties> | |||
<dependencies> | |||
<dependency> | |||
<groupId>com.sun.jna</groupId> | |||
<artifactId>jna</artifactId> | |||
<version>3.0.9</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.alibaba</groupId> | |||
<artifactId>fastjson</artifactId> | |||
<version>1.2.59</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-web</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-test</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.cloud</groupId> | |||
<artifactId>spring-cloud-starter-feign</artifactId> | |||
</dependency> | |||
</dependencies> | |||
<dependencyManagement> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.springframework.cloud</groupId> | |||
<artifactId>spring-cloud-dependencies</artifactId> | |||
<version>${spring-cloud.version}</version> | |||
<type>pom</type> | |||
<scope>import</scope> | |||
</dependency> | |||
</dependencies> | |||
</dependencyManagement> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-maven-plugin</artifactId> | |||
<configuration> | |||
<mainClass>com.elink.aicare.AicareDemoAppApplication</mainClass> | |||
<layout>JAR</layout> | |||
</configuration> | |||
</plugin> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-compiler-plugin</artifactId> | |||
<configuration> | |||
<source>8</source> | |||
<target>8</target> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
<!--打包时将resource下的文件一起打包--> | |||
<resources> | |||
<resource> | |||
<directory>src/main/resources</directory> | |||
<includes> | |||
<include>**/**</include> | |||
</includes> | |||
<filtering>false</filtering> | |||
</resource> | |||
</resources> | |||
</build> | |||
<repositories> | |||
<repository> | |||
<id>spring-snapshots</id> | |||
<url>http://repo.spring.io/libs-snapshot</url> | |||
</repository> | |||
</repositories> | |||
<pluginRepositories> | |||
<pluginRepository> | |||
<id>spring-snapshots</id> | |||
<url>http://repo.spring.io/libs-snapshot</url> | |||
</pluginRepository> | |||
</pluginRepositories> | |||
</project> |
@@ -0,0 +1,13 @@ | |||
package com.elink.aicare; | |||
import org.springframework.boot.SpringApplication; | |||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||
import org.springframework.cache.annotation.EnableCaching; | |||
@SpringBootApplication | |||
@EnableCaching | |||
public class AicareDemoAppApplication { | |||
public static void main(String args[]){ | |||
SpringApplication.run(com.elink.aicare.AicareDemoAppApplication.class, args); | |||
} | |||
} |
@@ -0,0 +1,133 @@ | |||
package com.elink.aicare; | |||
/** | |||
* 调用体脂算法动态库 | |||
*/ | |||
import com.sun.jna.Library; | |||
import com.sun.jna.Native; | |||
public interface BodyFatAlgorithmAicare extends Library { | |||
String osName = System.getProperty("os.name"); // 获取当前操作系统的类型 | |||
String rootResource = BodyFatAlgorithmAicare.class.getResource("/").getPath(); | |||
String libWindows = "/libalgorithm-aicare.dll"; | |||
String libMacOS = rootResource+ "libMacAlgorithm-aicare.so"; | |||
//System调用so时,调用了:java.lang.System.mapLibraryName()方法。这个方法会在咱们的给定的名字前拼接上”lib” | |||
//此种调用方式,linux系统对应的so库,需要放在usr/lib下 | |||
String liblinux = "algorithm-aicare"; | |||
//根据不同的操作系统,使用不同的库 | |||
String libPath = (osName != null && osName.startsWith("Windows")) ? libWindows : ((osName != null && osName.startsWith("Mac")) ? libMacOS : liblinux); | |||
BodyFatAlgorithmAicare INSTANTCE = (BodyFatAlgorithmAicare) Native.synchronizedLibrary( | |||
(BodyFatAlgorithmAicare) Native.loadLibrary(libPath, BodyFatAlgorithmAicare.class) | |||
); | |||
/** | |||
* 身高单位换算 CM 换算为 M | |||
* @param height 身高,单位:CM | |||
* @return 身高,单位:M | |||
*/ | |||
double getHeight(int height); | |||
/** | |||
* 计算用户BMI | |||
* @param weight 用户体重,单位:kg | |||
* @param height 用户身高,单位:M | |||
* @return 用户的BMI | |||
*/ | |||
double getBMI(double weight, double height); | |||
/** | |||
* 计算用户BM | |||
* @param sex | |||
* @param bmi | |||
* @param height | |||
* @param age | |||
* @param adc | |||
* @param weight | |||
* @return | |||
*/ | |||
double getBM(int sex, double bmi, double height, int age, int adc, double weight); | |||
/** | |||
* 计算用户ROM | |||
* @param sex | |||
* @param weight | |||
* @param height | |||
* @param age | |||
* @param adc | |||
* @return | |||
*/ | |||
double getROM(int sex, double weight, double height, int age, int adc); | |||
/** | |||
* 计算用户VMC | |||
* @param sex | |||
* @param bmi | |||
* @param adc | |||
* @param age | |||
* @return | |||
*/ | |||
double getVWC(int sex, double bmi, int adc, int age); | |||
/** | |||
* 计算用户BFR | |||
* @param sex | |||
* @param bmi | |||
* @param adc | |||
* @param age | |||
* @return | |||
*/ | |||
double getBFR(int sex, double bmi, int adc, int age); | |||
/** | |||
* 计算用户SFR | |||
* @param sex | |||
* @param age | |||
* @param bfr | |||
* @return | |||
*/ | |||
double getSFR(int sex, int age, double bfr); | |||
double getROSM(int age, int sex, double moi, double bfr); | |||
/** | |||
* 计算用户PP | |||
* @param bfr | |||
* @param moi | |||
* @param bm | |||
* @param weight | |||
* @param age | |||
* @param sex | |||
* @return | |||
*/ | |||
double getPP(double bfr, double moi, double bm, double weight, int age, int sex); | |||
/** | |||
* 计算用户UVI | |||
* @param sex | |||
* @param weight | |||
* @param height | |||
* @param age | |||
* @param adc | |||
* @return | |||
*/ | |||
int getUVI(int sex, double weight, double height, int age, int adc); | |||
/** | |||
* 计算用户BMR | |||
* @param sex | |||
* @param weight | |||
* @param height | |||
* @param age | |||
* @param adc | |||
* @return | |||
*/ | |||
int getBMR(int sex, double weight, double height, int age, int adc); | |||
/** | |||
* 计算用户BodyAge | |||
* @param age | |||
* @param bmi | |||
* @param sex | |||
* @return | |||
*/ | |||
int getBodyAge(int age, double bmi, int sex); | |||
} |
@@ -0,0 +1,81 @@ | |||
package com.elink.aicare; | |||
import com.alibaba.fastjson.JSON; | |||
/** | |||
* | |||
*/ | |||
public class BodyFatAlgorithmUtils { | |||
public static void main(String args[]){ | |||
int sex=1; | |||
int age=24; | |||
double weight = 60.5; | |||
int height = 180; | |||
int adc = 500; | |||
System.out.println("品网算法"); | |||
System.out.println(JSON.toJSONString(getBodyFatData(0,sex,age,weight,height,adc))); | |||
} | |||
/** | |||
* 获取基础身体指标 | |||
* @param algorithmType 身体指标算法类型,可取值:0或1,0:品网算法;1:沃莱算法; | |||
* ps: 年龄、体重、身高、阻抗的取值范围仅当algorithmType=0时有效,超出取值范围,将返回空; | |||
* @param sex 性别,可取值:1或2;1:男;2:女 | |||
* @param age 年龄,单位:年,取值范围:0<=age<=120 | |||
* @param weight 体重;单位:kg,取值范围:0.0< weight < 220 | |||
* @param height 身高;单位:cm,取值范围:0< height <=270 | |||
* @param adc 阻抗;取值范围:0 < adc <= 1000 | |||
* @return | |||
*/ | |||
public static BodyFatData getBodyFatData(int algorithmType,int sex, int age, double weight,int height, int adc){ | |||
if (age < 0 || age > 120){ | |||
System.out.println("年龄age取值不正确,取值范围:0<=age<=120 ;单位:年"); | |||
return null; | |||
} | |||
if (weight <= 0.0 && weight > 220.0){ | |||
System.out.println("体重weight取值不正确,取值范围:0.0< weight < 220 ;单位:kg"); | |||
return null; | |||
} | |||
if (height <= 0 && height > 270){ | |||
System.out.println("身高height取值不正确,取值范围:0< height <=270 ;单位:cm"); | |||
return null; | |||
} | |||
if (adc < 0 && adc > 1000){ | |||
System.out.println("阻抗adc取值不正确,取值范围:0 < adc <= 1000"); | |||
return null; | |||
} | |||
return getDataByAicare(sex, age, weight,height, adc); | |||
} | |||
private static BodyFatData getDataByAicare(int sex, int age, double weight,int heightCM, int adc){ | |||
BodyFatAlgorithmAicare bodyFatAlgorithmAicare = BodyFatAlgorithmAicare.INSTANTCE; | |||
double height = bodyFatAlgorithmAicare.getHeight(heightCM); | |||
double bmi = bodyFatAlgorithmAicare.getBMI(weight,height); | |||
double bm = bodyFatAlgorithmAicare.getBM(sex,bmi, height, age, adc, weight); | |||
double rom = bodyFatAlgorithmAicare.getROM( sex, weight, height, age, adc); | |||
double vwc = bodyFatAlgorithmAicare.getVWC( sex, bmi, adc, age); | |||
double bfr = bodyFatAlgorithmAicare.getBFR( sex, bmi, adc, age); | |||
double sfr = bodyFatAlgorithmAicare.getSFR( sex, age, bfr); | |||
double rosm = bodyFatAlgorithmAicare.getROSM( age, sex, vwc, bfr); | |||
double pp = bodyFatAlgorithmAicare.getPP( bfr, vwc, bm, weight, age, sex); | |||
int uvi = bodyFatAlgorithmAicare.getUVI( sex, weight, height, age, adc); | |||
int bmr = bodyFatAlgorithmAicare.getBMR( sex, weight, height, age, adc); | |||
int bodyAge = bodyFatAlgorithmAicare.getBodyAge( age, bmi, sex); | |||
//处理返回数据 | |||
BodyFatData fatData = new BodyFatData(); | |||
fatData.setBmi(bmi); | |||
fatData.setBfr(Math.round(bfr * 10) / 10.0); | |||
fatData.setSfr(Math.floor(sfr * 10) / 10); | |||
fatData.setUvi(uvi); | |||
fatData.setRom(Math.floor(rom * 10) / 10); | |||
fatData.setBmr(bmr); | |||
fatData.setBm(Math.floor(bm * 10) / 10); | |||
fatData.setVwc(Math.floor(vwc * 10) / 10); | |||
fatData.setBodyAge(bodyAge); | |||
fatData.setPp(Math.floor(pp * 10) / 10); | |||
return fatData; | |||
} | |||
} |
@@ -0,0 +1,125 @@ | |||
package com.elink.aicare; | |||
public class BodyFatData { | |||
/** | |||
* 身体质量指数 | |||
*/ | |||
private double bmi; | |||
/** | |||
* 体脂率 body fat rate | |||
*/ | |||
private double bfr; | |||
/** | |||
* 皮下脂肪率 | |||
*/ | |||
private double sfr; | |||
/** | |||
* 内脏脂肪指数 | |||
*/ | |||
private int uvi; | |||
/** | |||
* 肌肉率 | |||
*/ | |||
private double rom; | |||
/** | |||
* 基础代谢率 | |||
*/ | |||
private int bmr; | |||
/** | |||
* 骨骼质量 | |||
*/ | |||
private double bm; | |||
/** | |||
* 水含量 | |||
*/ | |||
private double vwc; | |||
/** | |||
* 身体年龄 | |||
*/ | |||
private int bodyAge; | |||
/** | |||
* 蛋白率 | |||
*/ | |||
private double pp; | |||
public double getBmi() { | |||
return bmi; | |||
} | |||
public void setBmi(double bmi) { | |||
this.bmi = bmi; | |||
} | |||
public double getBfr() { | |||
return bfr; | |||
} | |||
public void setBfr(double bfr) { | |||
this.bfr = bfr; | |||
} | |||
public double getSfr() { | |||
return sfr; | |||
} | |||
public void setSfr(double sfr) { | |||
this.sfr = sfr; | |||
} | |||
public int getUvi() { | |||
return uvi; | |||
} | |||
public void setUvi(int uvi) { | |||
this.uvi = uvi; | |||
} | |||
public double getRom() { | |||
return rom; | |||
} | |||
public void setRom(double rom) { | |||
this.rom = rom; | |||
} | |||
public int getBmr() { | |||
return bmr; | |||
} | |||
public void setBmr(int bmr) { | |||
this.bmr = bmr; | |||
} | |||
public double getBm() { | |||
return bm; | |||
} | |||
public void setBm(double bm) { | |||
this.bm = bm; | |||
} | |||
public double getVwc() { | |||
return vwc; | |||
} | |||
public void setVwc(double vwc) { | |||
this.vwc = vwc; | |||
} | |||
public int getBodyAge() { | |||
return bodyAge; | |||
} | |||
public void setBodyAge(int bodyAge) { | |||
this.bodyAge = bodyAge; | |||
} | |||
public double getPp() { | |||
return pp; | |||
} | |||
public void setPp(double pp) { | |||
this.pp = pp; | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.elink.aicare; | |||
import com.alibaba.fastjson.JSON; | |||
import org.springframework.validation.BindingResult; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import javax.servlet.http.HttpServletRequest; | |||
@RestController | |||
@RequestMapping(value="/",produces={"application/json;charset=UTF-8"}) | |||
public class DemoController { | |||
/** | |||
* 获取体脂数据 | |||
* | |||
*/ | |||
@RequestMapping(value = "getBodyFat") | |||
public Object sendCode(@RequestBody BodyFatData bodyFatData, HttpServletRequest request, BindingResult result) { | |||
int sex=1; | |||
int age=24; | |||
double weight = 60.5; | |||
int height = 180; | |||
int adc = 500; | |||
System.out.println("品网算法"); | |||
System.out.println(JSON.toJSONString(BodyFatAlgorithmUtils.getBodyFatData(0,sex,age,weight,height,adc))); | |||
System.out.println("沃莱算法"); | |||
System.out.println(JSON.toJSONString(BodyFatAlgorithmUtils.getBodyFatData(1,sex,age,weight,height,adc))); | |||
return bodyFatData; | |||
} | |||
} |
@@ -0,0 +1,4 @@ | |||
spring.application.name=elink-demo | |||
server.port=8001 | |||
@@ -0,0 +1,5 @@ | |||
spring.profiles.active=dev | |||
#allow upload size | |||
spring.http.multipart.maxFileSize = 20Mb | |||
spring.http.multipart.maxRequestSize=100Mb |