package com.sifang.modules.customer.Service;

import com.sifang.modules.customer.constant.ExamineConstants;
import com.sifang.modules.customer.dao.CustomerEntryToExamineDao;
import com.sifang.modules.customer.entity.CustomerEntryToExamine;
import com.sifang.modules.sys.common.persistence.Parameter;
import com.sifang.modules.sys.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class CustomerEntryToExamineService extends BaseService {

    @Autowired
    CustomerEntryToExamineDao customerEntryToExamineDao;

    public void updateToExamine(String enteyId,String type,String examineRemarks,String operator){

        CustomerEntryToExamine examine = customerEntryToExamineDao.getByHql("from CustomerEntryToExamine where entry_id =:p1", new Parameter(enteyId));
        if(examine == null){
            examine= new CustomerEntryToExamine();
            examine.setEntryId(enteyId);
        }
        if(ExamineConstants.ONE.equals(type)){
            examine.setExamineOne(examineRemarks);
            examine.setExamineTime(new Date());
            examine.setOperatorOne(operator);
        }
        if(ExamineConstants.TWO.equals(type)){
            examine.setExamineTwo(examineRemarks);
            examine.setExamineTimeTwo(new Date());
            examine.setOperatorTwo(operator);
        }
        if(ExamineConstants.THREE.equals(type)){
            examine.setExamineThree(examineRemarks);
            examine.setExamineTimeThree(new Date());
            examine.setOperatorThree(operator);
        }
        if(ExamineConstants.FOUR.equals(type)){
            examine.setExamineFour(examineRemarks);
            examine.setExamineTimeFour(new Date());
            examine.setOperatorFour(operator);
        }
        if(ExamineConstants.FIVE.equals(type)){
            examine.setExamineFive(examineRemarks);
            examine.setExamineTimeFive(new Date());
            examine.setOperatorFive(operator);
        }
        if(ExamineConstants.SIX.equals(type)){
            examine.setExamineSix(examineRemarks);
            examine.setExamineTimeSix(new Date());
            examine.setOperatorSix(operator);
        }
        if(ExamineConstants.SEVEN.equals(type)){
            examine.setExamineSeven(examineRemarks);
            examine.setExamineTimeSeven(new Date());
            examine.setOperatorSeven(operator);
        }
        if(ExamineConstants.EIGHT.equals(type)){
            examine.setExamineEight(examineRemarks);
            examine.setExamineTimeEight(new Date());
            examine.setOperatorEight(operator);
        }
        if(ExamineConstants.NINE.equals(type)){
            examine.setExamineNine(examineRemarks);
            examine.setExamineTimeNine(new Date());
            examine.setOperatorNine(operator);
        }
        customerEntryToExamineDao.save(examine);

    }


    public CustomerEntryToExamine findEntryId(String entryId){
        CustomerEntryToExamine examine = customerEntryToExamineDao.getByHql("from CustomerEntryToExamine where entry_id =:p1", new Parameter(entryId));
        return examine;
    }

}
