ZhuDongming
2019-08-19 7928995b3f8508a50d594a91e195655826a47740
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.moral.util;
 
import java.util.HashMap;
import java.util.Map;
 
public class TempAllocationUtils {
    
    public static Map<String, Object> tempAllocation(Map<String, Object> map){
        Map<String, Object> tempMap = new HashMap<>();
        Double tempDay = Double.parseDouble(map.get("tempDay").toString());
        Double tempNight = Double.parseDouble(map.get("tempNight").toString());
        Double time5 = tempNight;
        Double time13 = tempDay;
        Double difference = tempDay-tempNight;
        Double dif_8 = difference/8;
        Double dif_16 = difference/16;
        tempMap.put("5", time5);
        tempMap.put("13", time13);
        String time = null;
        Double t = time5;
        for(int i=4;i>=0;i--) {
            time = ""+i;
            t = t+dif_16;
            String tempLast = ""+Math.round(t);
            tempMap.put(time, tempLast);
        }
        Double y = time5;
        for(int i=6;i<13;i++) {
            time = ""+i;
            y = y+dif_8;
            String tempLast = ""+Math.round(y);
            tempMap.put(time, tempLast);
        }
        Double z = time13;
        for(int i=14;i<=23;i++) {
            time = ""+i;
            z = z-dif_16;
            String tempLast = ""+Math.round(z);
            tempMap.put(time, tempLast);
        }
        return tempMap;
    }
    
}