package com.kcim.dao.repository;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcim.common.util.UserContext;
import com.kcim.dao.mapper.ComputeProjectCostDetailMapper;
import com.kcim.dao.model.ComputeProjectCostDetail;
import com.kcim.service.impl.BaseBatchServiceImpl;
import com.kcim.vo.ComputeProjectCostPageDto;
import com.kcim.vo.SessionUserVO;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-01-15 20:32
 **/
@Repository
public class ComputeProjectCostDetailRepository extends BaseBatchServiceImpl<ComputeProjectCostDetailMapper, ComputeProjectCostDetail> {


    public void removeByComputeDate(String computeDate, SessionUserVO currentUser) {
        UpdateWrapper<ComputeProjectCostDetail> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ComputeProjectCostDetail::getDelFlag, 0)
                .eq(ComputeProjectCostDetail::getHospId, currentUser.getHospId())
                .eq(ComputeProjectCostDetail::getComputeDate, computeDate)
                .set(ComputeProjectCostDetail::getDeleteTime,new Date())
                .set(ComputeProjectCostDetail::getDeleteUser,String.valueOf(currentUser.getId()))
                .set(ComputeProjectCostDetail::getDelFlag, 1);
        this.update(updateWrapper);
    }

    public List<ComputeProjectCostPageDto> getByProjectCostId(String computeDate, List<Integer> collect1) {
        return this.baseMapper.getByProjectCostId( computeDate, UserContext.getHospId(),collect1);

    }
}
