trick9191 8 лет назад
Родитель
Сommit
a7192a370a

+ 33 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ValueComparator.java

@ -0,0 +1,33 @@
package com.yihu.wlyy.util;
import org.json.JSONObject;
import java.util.Comparator;
import java.util.Map;
import java.util.jar.JarEntry;
/**
 * Created by Trick on 2017/5/24.
 */
public class ValueComparator implements Comparator<String> {
    Map<String, JSONObject> base;
    //这里需要将要比较的map集合传进来
    public ValueComparator(Map<String, JSONObject> base) {
        this.base = base;
    }
    // Note: this comparator imposes orderings that are inconsistent with equals.
    //比较的时候,传入的两个参数应该是map的两个key,根据上面传入的要比较的集合base,可以获取到key对应的value,然后按照value进行比较
    public int compare(String a, String b) {
        JSONObject j1 =  base.get(a);
        JSONObject j2 =  base.get(b);
        j1.get("amount");
        j2.get("amount");
        if((Long)j1.get("amount")>=(Long)j2.get("amount")){
            return -1;
        }
        return 1;
    }
}

+ 8 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.statistic;
import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.util.ValueComparator;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -258,12 +259,15 @@ public class StatisticsController extends BaseController {
                }
            } else {
                //如果是2个指标的时候,分别放入map中,以减少查询次数
                Map<String,JSONObject> index1=new HashMap<>();
                Map<String,JSONObject> index2=new HashMap<>();
                Map<String,JSONObject> in =new TreeMap<>();
                ValueComparator vc = new ValueComparator(in);
                Map<String,JSONObject> index2=new TreeMap<>();
                for (int i = 0; i < jsonArrays.get(0).length(); i++) {
                    JSONObject map1 = jsonArrays.get(0).getJSONObject(i);
                    index1.put(map1.get("code").toString(),map1);
                    in.put(map1.get("code").toString(),map1);
                }
                Map<String,JSONObject> index1 =new TreeMap<>(vc);
                index1.putAll(in);
                for (int i = 0; i < jsonArrays.get(1).length(); i++) {
                    JSONObject map1 = jsonArrays.get(1).getJSONObject(i);
@ -701,4 +705,5 @@ public class StatisticsController extends BaseController {
        }
    }
}

+ 33 - 33
patient-co-wlyy/src/main/resources/application.properties

@ -52,23 +52,23 @@
#redis.testOnBorrow=true
##------------------------------------�����������ݿ�����------------------------------------#
#### mysql database setting
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#jdbc.username=root
#jdbc.password=123456
#
##### health index
#health.jdbc.driver=com.mysql.jdbc.Driver
#health.jdbc.url=jdbc:mysql://172.19.103.77/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#health.jdbc.username=root
#health.jdbc.password=123456
#
##### suifang
#fv.jdbc.driver=com.mysql.jdbc.Driver
#fv.jdbc.url=jdbc:mysql://172.19.103.77/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=root
#fv.jdbc.password=123456
### mysql database setting
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
jdbc.username=root
jdbc.password=123456
#### health index
health.jdbc.driver=com.mysql.jdbc.Driver
health.jdbc.url=jdbc:mysql://172.19.103.77/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
health.jdbc.username=root
health.jdbc.password=123456
#### suifang
fv.jdbc.driver=com.mysql.jdbc.Driver
fv.jdbc.url=jdbc:mysql://172.19.103.77/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
fv.jdbc.username=root
fv.jdbc.password=123456
#### redis
redis.host=172.19.103.47
@ -76,23 +76,23 @@ redis.port=6379
redis.password=
#---------------------------------���Ի������ݿ�����---------------------------------------#
##### mysql database setting
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
jdbc.username=linzhou
jdbc.password=linzhou
##### health index
health.jdbc.driver=com.mysql.jdbc.Driver
health.jdbc.url=jdbc:mysql://172.19.103.85/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
health.jdbc.username=linzhou
health.jdbc.password=linzhou
##### suifang
fv.jdbc.driver=com.mysql.jdbc.Driver
fv.jdbc.url=jdbc:mysql://172.19.103.85/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
fv.jdbc.username=linzhou
fv.jdbc.password=linzhou
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#jdbc.username=linzhou
#jdbc.password=linzhou
#
###### health index
#health.jdbc.driver=com.mysql.jdbc.Driver
#health.jdbc.url=jdbc:mysql://172.19.103.85/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#health.jdbc.username=linzhou
#health.jdbc.password=linzhou
#
###### suifang
#fv.jdbc.driver=com.mysql.jdbc.Driver
#fv.jdbc.url=jdbc:mysql://172.19.103.85/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=linzhou
#fv.jdbc.password=linzhou
##
###### redis
#redis.host=172.19.103.88
#redis.port=6379

+ 4 - 4
patient-co-wlyy/src/main/webapp/WEB-INF/spring-mvc.xml

@ -77,14 +77,14 @@
	</bean>
	
	<mvc:interceptors>
		<mvc:interceptor>
<!--		<mvc:interceptor>
	        <mvc:mapping path="/patient/**"/>
	        <bean class="com.yihu.wlyy.interceptors.PatientInterceptor"/>
	    </mvc:interceptor>
	    <mvc:interceptor>
	    </mvc:interceptor>-->
	    <!--<mvc:interceptor>
	        <mvc:mapping path="/doctor/**"/>
	        <bean class="com.yihu.wlyy.interceptors.DoctorInterceptor"/>
	    </mvc:interceptor>
	    </mvc:interceptor>-->
	    <mvc:interceptor>
	        <mvc:mapping path="/user/**"/>
	        <bean class="com.yihu.wlyy.interceptors.UserInterceptor"/>