package com.zjsgfa.project.zjsgfa.service.impl;

import java.nio.charset.StandardCharsets;
import java.util.List;

import cn.hutool.core.codec.Base64;
import com.zjsgfa.common.utils.DateUtils;
import com.zjsgfa.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zjsgfa.project.zjsgfa.mapper.SgfambKcSggyMapper;
import com.zjsgfa.project.zjsgfa.domain.SgfambKcSggy;
import com.zjsgfa.project.zjsgfa.service.ISgfambKcSggyService;

/**
 * 施工方案模板管理—开次-施工概要Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-09-23
 */
@Service
public class SgfambKcSggyServiceImpl implements ISgfambKcSggyService 
{
    @Autowired
    private SgfambKcSggyMapper sgfambKcSggyMapper;

    /**
     * 查询施工方案模板管理—开次-施工概要
     * 
     * @param id 施工方案模板管理—开次-施工概要主键
     * @return 施工方案模板管理—开次-施工概要
     */
    @Override
    public SgfambKcSggy selectSgfambKcSggyById(Long id)
    {
        SgfambKcSggy sgfambKcSggy = sgfambKcSggyMapper.selectSgfambKcSggyById(id);
        return sgfambKcSggy;
    }

    /**
     * 查询施工方案模板管理—开次-施工概要列表
     * 
     * @param sgfambKcSggy 施工方案模板管理—开次-施工概要
     * @return 施工方案模板管理—开次-施工概要
     */
    @Override
    public List<SgfambKcSggy> selectSgfambKcSggyList(SgfambKcSggy sgfambKcSggy)
    {
        return sgfambKcSggyMapper.selectSgfambKcSggyList(sgfambKcSggy);
    }

    /**
     * 新增施工方案模板管理—开次-施工概要
     * 
     * @param sgfambKcSggy 施工方案模板管理—开次-施工概要
     * @return 结果
     */
    @Override
    public int insertSgfambKcSggy(SgfambKcSggy sgfambKcSggy)
    {

        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjzh())){
            sgfambKcSggy.setZjzh(new String(Base64.decode(sgfambKcSggy.getZjzh()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjzhzysx())){
            sgfambKcSggy.setZjzhzysx(new String(Base64.decode(sgfambKcSggy.getZjzhzysx()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getFxts())){
            sgfambKcSggy.setFxts(new String(Base64.decode(sgfambKcSggy.getFxts()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjgccs())){
            sgfambKcSggy.setZjgccs(new String(Base64.decode(sgfambKcSggy.getZjgccs()), StandardCharsets.UTF_8));
        }

        if(StringUtils.isNotEmpty(sgfambKcSggy.getGjfx())){
            sgfambKcSggy.setGjfx(new String(Base64.decode(sgfambKcSggy.getGjfx()), StandardCharsets.UTF_8));
        }

        if(StringUtils.isNotEmpty(sgfambKcSggy.getGjyh())){
            sgfambKcSggy.setGjyh(new String(Base64.decode(sgfambKcSggy.getGjyh()), StandardCharsets.UTF_8));
        }

        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjycs())){
            sgfambKcSggy.setZjycs(new String(Base64.decode(sgfambKcSggy.getZjycs()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getFxgkcs())){
            sgfambKcSggy.setFxgkcs(new String(Base64.decode(sgfambKcSggy.getFxgkcs()), StandardCharsets.UTF_8));
        }
        int i = sgfambKcSggyMapper.insertSgfambKcSggy(sgfambKcSggy);
        return i;
    }

    /**
     * 修改施工方案模板管理—开次-施工概要
     * 
     * @param sgfambKcSggy 施工方案模板管理—开次-施工概要
     * @return 结果
     */
    @Override
    public int updateSgfambKcSggy(SgfambKcSggy sgfambKcSggy)
    {
        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjzh())){
            sgfambKcSggy.setZjzh(new String(Base64.decode(sgfambKcSggy.getZjzh()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjzhzysx())){
            sgfambKcSggy.setZjzhzysx(new String(Base64.decode(sgfambKcSggy.getZjzhzysx()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getFxts())){
            sgfambKcSggy.setFxts(new String(Base64.decode(sgfambKcSggy.getFxts()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjgccs())){
            sgfambKcSggy.setZjgccs(new String(Base64.decode(sgfambKcSggy.getZjgccs()), StandardCharsets.UTF_8));
        }

        if(StringUtils.isNotEmpty(sgfambKcSggy.getGjfx())){
            sgfambKcSggy.setGjfx(new String(Base64.decode(sgfambKcSggy.getGjfx()), StandardCharsets.UTF_8));
        }

        if(StringUtils.isNotEmpty(sgfambKcSggy.getGjyh())){
            sgfambKcSggy.setGjyh(new String(Base64.decode(sgfambKcSggy.getGjyh()), StandardCharsets.UTF_8));
        }

        if(StringUtils.isNotEmpty(sgfambKcSggy.getZjycs())){
            sgfambKcSggy.setZjycs(new String(Base64.decode(sgfambKcSggy.getZjycs()), StandardCharsets.UTF_8));
        }
        if(StringUtils.isNotEmpty(sgfambKcSggy.getFxgkcs())){
            sgfambKcSggy.setFxgkcs(new String(Base64.decode(sgfambKcSggy.getFxgkcs()), StandardCharsets.UTF_8));
        }
        sgfambKcSggy.setUpdateTime(DateUtils.getNowDate());
        return sgfambKcSggyMapper.updateSgfambKcSggy(sgfambKcSggy);
    }

    public static void main(String[] args) {
        String s=new String(Base64.decode("PHA+77yIMe+8ieS4iumDqOmYsueisO+8jOS4gOW8gOW6lOS4i+WFpeWumuWQkeW3peWFt++8jOaWveW3peS4reWPr+S7peiAg+iZkemHh+eUqOS4jumCu+S6leebuOWQjOeahOmSu+WFt+e7hOWQiOOAgeebuOWQjOeahOaWveW3peWPguaVsOadpeaWveW3peOAgjwvcD4="), StandardCharsets.UTF_8);
        System.out.println(s);
    }

    /**
     * 批量删除施工方案模板管理—开次-施工概要
     * 
     * @param ids 需要删除的施工方案模板管理—开次-施工概要主键
     * @return 结果
     */
    @Override
    public int deleteSgfambKcSggyByIds(Long[] ids)
    {
        return sgfambKcSggyMapper.deleteSgfambKcSggyByIds(ids);
    }

    /**
     * 删除施工方案模板管理—开次-施工概要信息
     * 
     * @param id 施工方案模板管理—开次-施工概要主键
     * @return 结果
     */
    @Override
    public int deleteSgfambKcSggyById(Long id)
    {
        return sgfambKcSggyMapper.deleteSgfambKcSggyById(id);
    }

    @Override
    public List<SgfambKcSggy> selectSgfambKcSggyListByQk(SgfambKcSggy sgfambKcSggy) {
        return sgfambKcSggyMapper.selectSgfambKcSggyListByQk(sgfambKcSggy);
    }
}
