郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
package com.gkhy.safePlatform.safeCheck.rpc.service;
 
import com.gkhy.safePlatform.safeCheck.entity.SafeCheckTaskAndQuota;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckPageGrByStatusOrByTimeRespDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckSmartScreenRepsDTO;
import com.gkhy.safePlatform.safeCheck.rpc.apimodel.SafeCheckTaskDataService;
import com.gkhy.safePlatform.safeCheck.rpc.apimodel.model.resp.*;
import com.gkhy.safePlatform.safeCheck.service.SafeCheckSmartScreenService;
import com.gkhy.safePlatform.safeCheck.service.baseService.SafeCheckTaskAndQuotaService;
import com.gkhy.safePlatform.safeCheck.service.impl.SafeCheckSmartScreenServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
 
import java.util.List;
import java.util.stream.Collectors;
 
 
@DubboService(version = "0.0.1")
public class SafeCheckTaskDataServiceProvider implements SafeCheckTaskDataService {
 
    @Autowired
    private SafeCheckTaskAndQuotaService safeCheckTaskAndQuotaService;
 
    @Autowired
    private SafeCheckSmartScreenService smartScreenService;
 
    /**
     * @description 根据taskid获取巡检链数据并根据rfid进行分组
     */
    @Override
    public SafeCheckTaskAndQuotaGBRfidAndExcpOrderRPCRespDTO getTaskAndQuotaDataGBrfidDataByTaskId(Long taskId) {
        SafeCheckTaskAndQuotaGBRfidAndExcpOrderRPCRespDTO rpcRespDTO = new SafeCheckTaskAndQuotaGBRfidAndExcpOrderRPCRespDTO();
        List<SafeCheckSmartScreenRepsDTO> screenDataByTaskId = smartScreenService.getSmartScreenData(taskId);
        if (screenDataByTaskId == null){
            return null;
        }
        List<SafeCheckTaskAndQuotaGBRfidRPCRespDTO> datas = screenDataByTaskId.stream().map((screenData)->{
            SafeCheckTaskAndQuotaGBRfidRPCRespDTO dataRPCRespDTO = new SafeCheckTaskAndQuotaGBRfidRPCRespDTO();
            BeanUtils.copyProperties(screenData,dataRPCRespDTO);
            List<SafeCheckTaskAndQuotaRPCRespDTO> quotaRPCRespDTOS = screenData.getPoints().stream().map((point)->{
                SafeCheckTaskAndQuotaRPCRespDTO quotaRPCRespDTO = new SafeCheckTaskAndQuotaRPCRespDTO();
                BeanUtils.copyProperties(point,quotaRPCRespDTO);
                return quotaRPCRespDTO;
            }).collect(Collectors.toList());
            dataRPCRespDTO.setPoints(quotaRPCRespDTOS);
            return dataRPCRespDTO;
        }).collect(Collectors.toList());
        rpcRespDTO.setRfidInfos(datas);
 
        List<SafeCheckTaskAndQuotaExcepOrderRPCRespDTO> orderInfos = smartScreenService.getSmartScreenExcepOrderInfos(taskId);
        rpcRespDTO.setExcepOrder(orderInfos);
        return rpcRespDTO;
    }
 
    /**
     * @description 根据taskid获取所有的巡检链数据(因为之前上面序列化失败,现在可以了。所以现在这个方法不用)
     */
    @Override
    public List<SafeCheckTaskAndQuotasRPCRespDTO> getTaskAndQuotaRPCByTaskId(Long taskId) {
        List<SafeCheckTaskAndQuota> taskAndQuotas = safeCheckTaskAndQuotaService.listTaskAndQuotaByTaskId(taskId);
        List<SafeCheckTaskAndQuotasRPCRespDTO> datas = taskAndQuotas.stream().map((taskAndQuota)->{
            SafeCheckTaskAndQuotasRPCRespDTO quotasRPCRespDTO = new SafeCheckTaskAndQuotasRPCRespDTO();
            BeanUtils.copyProperties(taskAndQuota,quotasRPCRespDTO);
            return quotasRPCRespDTO;
        }).collect(Collectors.toList());
        return datas;
    }
}