package com.mortals.xhx.module.perform.service.impl;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.check.model.CheckOtherRecordEntity;
import com.mortals.xhx.module.check.service.CheckOtherRecordService;
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.PerformOtherRecordDao;
import com.mortals.xhx.module.perform.model.PerformOtherRecordEntity;
import com.mortals.xhx.module.perform.service.PerformOtherRecordService;
import lombok.extern.slf4j.Slf4j;
/**
* PerformOtherRecordService
* 其它绩效记录信息 service实现
*
* @author zxfei
* @date 2023-05-18
*/
@Service("performOtherRecordService")
@Slf4j
public class PerformOtherRecordServiceImpl extends AbstractCRUDServiceImpl<PerformOtherRecordDao, PerformOtherRecordEntity, Long> implements PerformOtherRecordService {

    @Autowired
    private CheckOtherRecordService checkOtherRecordService;

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