package com.tofly.third.service;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.third.common.exception.BusinessException;
import com.tofly.third.entity.YyCblr;
import com.tofly.third.mapper.YyCblrMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;

@Slf4j
@Service
public class YyCblrService extends ServiceImpl<YyCblrMapper, YyCblr> {

    /**
     *  更新抄表计划智能表信息
     */
    public void updateZnbZxds(String cbkid, String zxcbrq, BigDecimal znbcbCbZs) {
        YyCblr cblr = getById(cbkid);
        if (ObjectUtil.isNull(cblr)) {
            throw new BusinessException("未找到智能表抄表计划");
        }

        cblr.setNbzxds(znbcbCbZs);
        Date znbZxcbrq = DateUtil.parse(zxcbrq, DatePattern.NORM_DATETIME_PATTERN);
        cblr.setNbzxcbrq(znbZxcbrq);
        updateById(cblr);
    }

    public Integer fbsjtj(String yhbh, String cbkh) {
        return baseMapper.fbsjtj(yhbh, cbkh);
    }
}
