package com.ho.filecenter.service.impl;


import com.ho.filecenter.entity.Power;
import com.ho.filecenter.entity.PowerDetail;
import com.ho.filecenter.mapper.PowerDetailMapper;
import com.ho.filecenter.service.PowerDetailService;
import com.ho.filecenter.service.PowerService;
import com.ho.filecenter.vo.DetailVo;
import com.ho.filecenter.vo.PowerDetailVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yy
 * @description 针对表【power_detail】的数据库操作Service实现
 * @createDate 2023-03-16 10:59:17
 */
@Service
@Slf4j
public class PowerDetailServiceImpl implements PowerDetailService {
    @Autowired
    PowerDetailMapper powerDetailMapper;

    @Autowired
    PowerService powerService;

    @Override
    public List<PowerDetail> selectByPid(Integer id) {
        List<PowerDetail> detailList = powerDetailMapper.selectByPid(id);
        return detailList;
    }

    @Override
    public int deleteBatch(List<Integer> ids, List<Integer> pids) {
        return powerDetailMapper.deleteBatch(ids, pids);
    }

    @Override
    public void addBatch(List<PowerDetail> powerDetailList) {
        powerDetailMapper.addBatch(powerDetailList);
    }

    @Override
    public PowerDetailVo selectDetails(DetailVo vo) {
        PowerDetailVo powerDetailVo = new PowerDetailVo();
        //根据id/月份/项目名称查询表信息
        Power power = powerService.selectById(vo);
        if (power == null) {
            return powerDetailVo;
        }
        //在根据主表id查询改主表的所有
        List<PowerDetail> powerDetails = selectByPid(power.getId());
        powerDetailVo.setPowerP(power.getPowerP());
        powerDetailVo.setPowerG(power.getPowerG());
        powerDetailVo.setPowerF(power.getPowerF());
        powerDetailVo.setPowerJ(power.getPowerJ());
        powerDetailVo.setPowerSelf(power.getPowerSelf());
        powerDetailVo.setPowerSigle(power.getPowerSigle());
        powerDetailVo.setPowerUp(power.getPowerUp());
        powerDetailVo.setProjectName(power.getProjectName());
        powerDetailVo.setReceivableFee(power.getReceivableFee());
        powerDetailVo.setSettleMonth(power.getSettleMonth());
        powerDetailVo.setBiCycle(power.getBiCycle());
        powerDetailVo.setChecker(power.getChecker());
        powerDetailVo.setConsumeRatio(power.getConsumeRatio());
        powerDetailVo.setCreateTime(power.getCreateTime());
        powerDetailVo.setCreator(power.getCreator());
        powerDetailVo.setDiscountPriceF(power.getDiscountPriceF());
        powerDetailVo.setDiscountPriceP(power.getDiscountPriceP());
        powerDetailVo.setDiscountPriceG(power.getDiscountPriceG());
        powerDetailVo.setDiscountPriceJ(power.getDiscountPriceJ());
        powerDetailVo.setDiscountPriceSigle(power.getDiscountPriceSigle());
        powerDetailVo.setFeeF(power.getFeeF());
        powerDetailVo.setFeeG(power.getFeeG());
        powerDetailVo.setFeeJ(power.getFeeJ());
        powerDetailVo.setFeeP(power.getFeeP());
        powerDetailVo.setFeeSigle(power.getFeeSigle());
        powerDetailVo.setId(power.getId());
        powerDetailVo.setMeterMan(power.getMeterMan());
        powerDetailVo.setOrigPriceF(power.getOrigPriceF());
        powerDetailVo.setOrigPriceG(power.getOrigPriceG());
        powerDetailVo.setOrigPriceJ(power.getOrigPriceJ());
        powerDetailVo.setOrigPriceP(power.getOrigPriceP());
        powerDetailVo.setOrigPriceSigle(power.getOrigPriceSigle());
        powerDetailVo.setPowerAll(power.getPowerAll());
        powerDetailVo.setPowerDetailList(powerDetails);
        return powerDetailVo;
    }
}
