package com.mortals.xhx.module.perform.service.impl;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.check.model.CheckEffectRecordEntity;
import com.mortals.xhx.module.check.service.CheckEffectRecordService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.perform.dao.PerformEffectRecordDao;
import com.mortals.xhx.module.perform.model.PerformEffectRecordEntity;
import com.mortals.xhx.module.perform.service.PerformEffectRecordService;
import lombok.extern.slf4j.Slf4j;
/**
* PerformEffectRecordService
* 效能绩效记录信息 service实现
*
* @author zxfei
* @date 2023-05-18
*/
@Service("performEffectRecordService")
@Slf4j
public class PerformEffectRecordServiceImpl extends AbstractCRUDServiceImpl<PerformEffectRecordDao, PerformEffectRecordEntity, Long> implements PerformEffectRecordService {

    @Autowired
    private CheckEffectRecordService checkEffectRecordService;

    @Override
    protected void saveAfter(PerformEffectRecordEntity entity, Context context) throws AppException {
        CheckEffectRecordEntity checkEffectRecordEntity = new CheckEffectRecordEntity();
        checkEffectRecordEntity.initAttrValue();
        BeanUtils.copyProperties(entity,checkEffectRecordEntity, BeanUtil.getNullPropertyNames(entity));
        checkEffectRecordEntity.setRecordId(entity.getId());
        if(entity.getSubMethod()==1){
            checkEffectRecordEntity.setCheckStatus(2);     //自动扣分相设置为已处理
        }else {
            checkEffectRecordEntity.setCheckStatus(1);      //非自动扣分相设置为未处理
        }
        checkEffectRecordService.save(checkEffectRecordEntity,context);
    }
}