package com.cim.idm.service.Impl;

import com.cim.idm.exception.GlobalException;
import com.cim.idm.framework.IDMFrameServiceProxy;
import com.cim.idm.model.CheckRecord;
import com.cim.idm.service.IMaterialCheckService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

@Service
public class MaterialCheckServiceImpl implements IMaterialCheckService {

	@Override
	public Map<String, Object> bitsCheckConfirm(CheckRecord checkRecord) throws Throwable {
		// 参数非空校验
		String site = checkRecord.getSiteName();
		String billNo = checkRecord.getCheckPlanName();
		String barCode = checkRecord.getMaterialPackingName();
		String kw = checkRecord.getActLocation();
		Integer qty = checkRecord.getMaterialQuantity();
		String userId = checkRecord.getOperatorId();

	
		Map<String, Object> map = new HashMap<String, Object>();
		// 将前端传入的参数和存储过程中的参数对应起来
		map.put("V_SITE",site);
		map.put("V_BILLNO",billNo);
		map.put("V_BARCODE",barCode);
		map.put("V_KW",kw);
		map.put("V_QTY",qty);
		map.put("V_USERID",userId);
		String procedureName = "CHECKSTOCK_BITSCHECK";
		try {
			// 调用存储过程返回参数
			Map<String, Object> queryResult = IDMFrameServiceProxy.getSqlTemplate().executeProcedure(procedureName,map);
			if(Objects.nonNull(queryResult)) {
				return queryResult;
			}
			throw new GlobalException("未查询到对应参数");
			
		}catch(Throwable e) {
			throw e;
		}
	
	}

}
