CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package com.ld.igds.m.view;
 
 
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.ld.igds.common.CoreCommonService;
import com.ld.igds.dto.GrainSupportData;
import com.ld.igds.m.service.HGrainSupportService;
import com.ld.igds.models.Depot;
import com.ld.igds.models.Grain;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.text.ParseException;
import java.util.*;
 
/**
 * 决策辅助
 *
 * @author:
 */
@Component
public class GrainSupportPR {
 
    @Autowired
    private CoreCommonService coreCommonService;
    @Autowired
    private HGrainSupportService grainSupportService;
 
    /**
     * grainSupportPR#getQuery
     * @return
     */
    @DataProvider
    public Map<String, Object> getQuery() {
        Map<String, Object> result = new HashMap<String, Object>();
 
        result.put("curr", new Date());
        Date last = DateUtil.getNewByDay(new Date(), -7);
        result.put("last", last);
 
        return result;
    }
 
    /**
     * grainSupportPR#getGrainSupportData
     * @param param
     * @return
     */
    @Expose
    public GrainSupportData getGrainSupportData(Map<String,Object> param) throws ParseException {
 
        //获取仓库信息
        String str = (String) param.get("depotId");
        if (StringUtils.isEmpty(str)) {
            return null;
        }
        Depot depotData = coreCommonService.getCacheDepot(ContextUtil.getCompanyId(), str);
 
        GrainSupportData grainSupportData = new GrainSupportData();
        //设置仓库信息
        grainSupportData.setDepotId(depotData.getId());
        grainSupportData.setName(depotData.getName());
        grainSupportData.setDepotType(depotData.getDepotType());
        grainSupportData.setStorageMax(depotData.getStorageMax());
        grainSupportData.setStorageReal(depotData.getStorageReal());
        grainSupportData.setDepotStatus(depotData.getDepotStatus());
        grainSupportData.setFoodVariety(depotData.getFoodVariety());
        grainSupportData.setFoodType(depotData.getFoodType());
        grainSupportData.setFoodLocation(depotData.getFoodLocation());
        grainSupportData.setStoreDate(depotData.getStoreDate());
        grainSupportData.setStoreKeeperName(depotData.getStoreKeeperName());
 
        Date curr = (Date) param.get("curr");
        Date last = (Date) param.get("last");
 
        boolean flag1 = false;
        //查询当前时间最近的粮情信息,往前查10天
        if (null != curr) {
            List<Grain> grain1 = grainSupportService.listGrain(str,DateUtil.getNewByDay(curr, -10),curr);
            if (null != grain1 && grain1.size()>0) {
                flag1 = true;
                //设置当前时间最近的粮情信息
                grainSupportData.setTempAveCurr(grain1.get(0).getTempAve());
                grainSupportData.setTempMaxCurr(grain1.get(0).getTempMax());
                grainSupportData.setTempMinCurr(grain1.get(0).getTempMin());
                grainSupportData.setHumidityInCurr(grain1.get(0).getHumidityIn());
                grainSupportData.setTempInCurr(grain1.get(0).getTempIn());
                grainSupportData.setReceiveDateCurr(grain1.get(0).getReceiveDate());
            }
        }
 
        boolean flag2 = false;
        //查询上批时间最近的粮情信息,往前查10天
        if (null != last) {
            List<Grain> grain2 = grainSupportService.listGrain(str,DateUtil.getNewByDay(last, -10),last);
            if (null != grain2 && grain2.size()>0) {
                flag2 = true;
                //设置上批时间最近的粮情信息
                grainSupportData.setTempAveLast(grain2.get(0).getTempAve());
                grainSupportData.setTempMaxLast(grain2.get(0).getTempMax());
                grainSupportData.setTempMinLast(grain2.get(0).getTempMin());
                grainSupportData.setHumidityInLast(grain2.get(0).getHumidityIn());
                grainSupportData.setTempInLast(grain2.get(0).getTempIn());
                grainSupportData.setReceiveDateLast(grain2.get(0).getReceiveDate());
            }
        }
 
        if(flag1 && flag2){
            //设置通风指导
            grainSupportData.setRegionalism("中温高湿储粮区");
            grainSupportData.setZoologyTrait("15℃以上有效积温1029℃·d~3180℃·d,15℃以上的时间121~253d;  年降水量800 mm~1600 mm;  年平均相对湿度34%~98%;1月气温0℃~10℃,7月气温28℃左右;  主要粮油作物为单、双季稻、冬小麦;  代表性储粮害虫为玉米象、谷蠹、麦蛾、锯谷盗、长角扁谷盗、大谷盗、赤拟谷盗;  夏季高温、高湿;  晚稻水分含量高。");
            grainSupportData.setMeasures("1.收后机械通风、烘干                2.冬春通风降温\n3.次年春季干燥高水分粮             4.春季气温回升前密封\n5.施用防护剂,害虫多时熏蒸      6.密切注意过夏粮粮温、水分,及时采取措施");
 
            //决策说明图片url
            grainSupportData.setExplain("./static/images/grainSupport.png");
        }
 
        return grainSupportData;
    }
}