guoshilong
2023-08-02 818113e9a0cf7c20d836291e2a151f7346aad8a7
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
package cn.gistack.nky.service.impl;
 
import cn.gistack.nky.entity.HstPredict;
import cn.gistack.nky.mapper.HstPredictMapper;
import cn.gistack.nky.requestpojo.HstPredictReqPo;
import cn.gistack.nky.requestpojo.QueryReqPo;
import cn.gistack.nky.resultpojo.DataResChildrenPo;
import cn.gistack.nky.service.IHstPredictService;
import cn.gistack.nky.service.INkyService;
import cn.gistack.nky.service.IZtApiService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@AllArgsConstructor
@Service
public class HstPredictServiceImpl extends ServiceImpl<HstPredictMapper, HstPredict> implements IHstPredictService {
 
    private final INkyService nkyService;
    private final IZtApiService ztApiService;
    @Override
    public void getData(String type) {
        List<DataResChildrenPo> cdList = getCdList(type);
 
        cdList.forEach(dataResChildrenPo -> {
            //循环请求预测结果
            QueryReqPo queryReqPo = new QueryReqPo(dataResChildrenPo,type);
            //请求预测结果
            HstPredict hstPredict = nkyService.hstQuery(queryReqPo);
            if (hstPredict != null){
                //存储预测结果至数据库
                save(hstPredict);
            }
        });
    }
 
    @Override
    public void predictData(String type) {
        List<DataResChildrenPo> cdList = getCdList(type);
        cdList.forEach(dataResChildrenPo -> {
            HstPredictReqPo arimaPredictReqPo = new HstPredictReqPo(dataResChildrenPo, type);
            //循环预测请求
            nkyService.hstPredict(arimaPredictReqPo);
        });
    }
 
    @Override
    public boolean save(HstPredict entity) {
 
        if (ObjectUtil.isEmpty(entity.getCreateTime())){
            return false;
        }
 
        HstPredict params = new HstPredict();
        params.setDamId(entity.getDamId());
        params.setPointId(entity.getPointId());
        params.setType(entity.getType());
        params.setCreateTime(entity.getCreateTime());
 
        List<HstPredict> list = list(Condition.getQueryWrapper(params));
 
        if (list.size()>0){
            return false;
        }else {
            return super.save(entity);
        }
    }
 
    public  List<DataResChildrenPo> getCdList(String type){
        List<DataResChildrenPo> cdList = new ArrayList<>();
        if (type.equals("1")){
            //获取渗压测点
            cdList = ztApiService.getSy();
        }else if (type.equals("2")){
            //获取渗流测点
            return null;
        }else if (type.equals("3") || type.equals("4") || type.equals("5")){
            //获取位移测点
            cdList = ztApiService.getWy();
        }else {
            return null;
        }
        return cdList;
    }
}