WeightCheckAllocateOrDispatch.groovy 2.6 KB
package com.sy.groovy

import com.sy.model.GatherInfo
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO
import com.sy.model.LandBusinessTypeList
import com.sy.service.WeightCheckHandleService
import com.sy.service.impl.GatherInfoHandle
import org.basis.enhance.groovy.entity.ExecuteParams
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext

//过卡重量验放-分拨调拨验放
class WeightCheckAllocateOrDispatch extends Script {

    private final Logger logger = LoggerFactory.getLogger(getClass());
    private final String GROWSSEXCETION =      "禁止通行,重量不在可控范围";

    /**过磅重量判定
    * 传入gatherInfo,三大属性验证,二维码/车牌/过卡重量
     * 适用于分拨业务或者调拨业务
    */
    Boolean check(ExecuteParams executeParams) {
        try{
            GatherInfo gatherInfo = (GatherInfo) executeParams.get("gatherInfo");
            LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
            Double selfWt = (Double) executeParams.get("selfWt");
            Double goodsWt = (Double) executeParams.get("goodsWt");
            Double inAisleWT = (Double) executeParams.get("inAisleWT");
            List<LAND_BUSINEESTYPE_LIST_INFO> listinfos = (List<LAND_BUSINEESTYPE_LIST_INFO>) executeParams.get("ChanelFormBillLists");

            //3.车辆备案验证
            // 调用方法
            ApplicationContext context = getContext();
            // 获取容器中的bean
            GatherInfoHandle gatherInfoHandle = context.getBean(GatherInfoHandle.class);
            //重量校验算法
            WeightCheckHandleService weightCheckHandleService = context.getBean(WeightCheckHandleService.class);

            logger.info("[进出场申请]-业务类型为:{}-{}",landBusinessTypeList.getCocode(),landBusinessTypeList.getBusinesstype());
            if (weightCheckHandleService.checkAllocateOrDispatch(gatherInfo.getGrosswt(), selfWt, goodsWt,inAisleWT)){
                return true;
            }else {
                gatherInfoHandle.sendBw(gatherInfo,false,GROWSSEXCETION,landBusinessTypeList,listinfos);
                return false;
            }
        }catch (Exception e){
            e.printStackTrace();
            logger.error("[ExportUnloadWeightCheck-ERROR]:",e);
            return false;
        }
    }

    @Override
    Object run() {
        return null
    }

    // 获取spring容器
    ApplicationContext getContext() {
        // 获取spring IOC容器
        ApplicationContext context = applicationContext;
        return context;
    }
}