package com.tofly.feesapi.cbgl.service.impl;

import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxSync;
import com.tofly.feesapi.cbgl.entity.ZnbCbLog;
import com.tofly.feesapi.cbgl.entity.dto.ReadResult;
import com.tofly.feesapi.cbgl.service.CjService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Service("cjService#2")
public class DefaultCjServiceImpl implements CjService {

    @Override
    public List<ReadResult> read(List<String> sbbhs) {
        return sbbhs.stream().map(e -> new ReadResult(e,
                        new BigDecimal(RandomUtils.nextInt(199, 213))))
                .collect(Collectors.toList());
    }

    @Override
    public void close(List<ZnbCbLog> qfList) {
        String sbbhs = qfList.stream().map(e -> e.getBjbh()).collect(Collectors.joining());
        log.info("关阀:{}", sbbhs);
    }

    @Override
    public void syncSyje(List<ZnbCbLog> znbCbLogs) {
        String sbbhs = znbCbLogs.stream().map(e -> e.getBjbh()).collect(Collectors.joining());
        log.info("同步智能表余额:{}", sbbhs);
    }

    @Override
    public void syncMeters(List<YhCbkxxSync> cbkxxList) {

    }
}
