/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.znb.service.impl;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.znb.common.exception.FeesErrorCode;
import com.tofly.znb.common.exception.FeesException;
import com.tofly.znb.entity.Dto.YycblrDto;
import com.tofly.znb.entity.YyCblr;
import com.tofly.znb.service.YyCblrService;
import org.springframework.stereotype.Service;
import com.tofly.znb.mapper.YyCblrMapper;

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

/**
 * 抄表计划_抄表录入
 *
 * @author admin
 * @date Fri Aug 01 00:00:00 CST 2025
 */
@Service("yyCblrService")
public class YyCblrServiceImpl extends ServiceImpl<YyCblrMapper, YyCblr> implements YyCblrService {

    /**
     * 更新抄表计划智能表信息
     */
    public void updateZnbZxds(String cbkid, String zxcbrq, BigDecimal znbcbCbZs) {
        YyCblr cblr = this.lambdaQuery().eq(YyCblr::getCbkid, cbkid).one();
        if (ObjectUtil.isNull(cblr)) {
            throw new FeesException("未找到智能表抄表计划", FeesErrorCode.BUSINESS_ERROR);
        }

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

    public List<YycblrDto> getCblrByYcb() {
        return this.baseMapper.getCblrByYcb();
    }

}
