package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;

import cn.estsh.i3plus.ext.mes.pcn.api.base.IQualityDecisionService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.ISxRepairWorkService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.ISxSyncBusiService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesBadCellDetail;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.RepairRequestModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: wangjie
 * @CreateDate: 2019/8/30 1:39 PM
 * @Description:
 **/
@Service
public class SxSyncBusiService implements ISxSyncBusiService {

    @Autowired
    private IQualityDecisionService qualityDecisionService;

    @Autowired
    private ISxRepairWorkService sxRepairWorkService;

    @Override
    public synchronized void doRepairOrQualityDecision(Object obj, Integer flag) {
        if (flag == 1) {
            qualityDecisionService.insertMesBadCellAndDetail((RepairRequestModel) obj);
        } else if (flag == 2) {
            sxRepairWorkService.insertMesBadCellDetail((MesBadCellDetail) obj);
        } else if (flag == 3) {
            sxRepairWorkService.insertMesRepairDefectRecord((RepairRequestModel) obj);
        }
    }
}
