|  |  | 1 | +package com.sy.groovy | 
|  |  | 2 | + | 
|  |  | 3 | +import com.sy.crossDomain.BuildBarCode | 
|  |  | 4 | +import com.sy.mapper.LandListDao | 
|  |  | 5 | +import com.sy.model.GatherInfo | 
|  |  | 6 | +import com.sy.model.LandBusinessTypeList | 
|  |  | 7 | +import com.sy.service.CommandLogService | 
|  |  | 8 | +import com.sy.service.LandBusListService | 
|  |  | 9 | +import com.sy.service.RedisService | 
|  |  | 10 | +import org.basis.enhance.groovy.entity.ExecuteParams | 
|  |  | 11 | +import org.slf4j.Logger | 
|  |  | 12 | +import org.slf4j.LoggerFactory | 
|  |  | 13 | +import org.springframework.context.ApplicationContext | 
|  |  | 14 | + | 
|  |  | 15 | +/** | 
|  |  | 16 | + * 流转申请-核销 | 
|  |  | 17 | + * 1. 单进单出即核销判定 | 
|  |  | 18 | + * 2. 根据申请单中的通道类型及通道信息判定没有未走完的通道类型,可以核销.比如 申请单证的通道只有进通道,车可以走进一,进二,进二入场,走完进一,即可核销.(一线进) | 
|  |  | 19 | + * 3. 只要有进记录或者出记录 就核销 | 
|  |  | 20 | + * 4. 用来布尔类型的核销,一般放在其他布尔验放规则的最后. | 
|  |  | 21 | + */ | 
|  |  | 22 | +class X21FormSingileReleaseCheckWithTrue extends Script implements ChannelCheckScript{ | 
|  |  | 23 | + | 
|  |  | 24 | +    private final Logger log = LoggerFactory.getLogger(getClass()); | 
|  |  | 25 | + | 
|  |  | 26 | + | 
|  |  | 27 | +    /**x21指令判定 | 
|  |  | 28 | +    * 传入gatherInfo | 
|  |  | 29 | +     * | 
|  |  | 30 | +     * 传入从redis读取的申请表体实体,验证 | 
|  |  | 31 | +     * 进行通道比对 | 
|  |  | 32 | +    */ | 
|  |  | 33 | +    Boolean check(ExecuteParams executeParams) { | 
|  |  | 34 | +        try { | 
|  |  | 35 | +            int count = 0; | 
|  |  | 36 | +            // 获取product对象 | 
|  |  | 37 | +            GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo"); | 
|  |  | 38 | +            if (gatherInfo!=null){ | 
|  |  | 39 | +                // 调用方法 | 
|  |  | 40 | +                ApplicationContext context = getContext(); | 
|  |  | 41 | +                LandBusListService landBusListService = context.getBean(LandBusListService.class) | 
|  |  | 42 | +                count = landBusListService.selectHistoryCount(gatherInfo.getBarcode()); | 
|  |  | 43 | +                if (count>0){ | 
|  |  | 44 | +                    log.info("[Singile-Release-Success]-{}-{}",gatherInfo.getBarcode(),gatherInfo.getVename()) | 
|  |  | 45 | +                    releaseBarCode(gatherInfo,executeParams); | 
|  |  | 46 | +                    return true; | 
|  |  | 47 | +                }else { | 
|  |  | 48 | +                    log.error("[Singile-Release-Faild]-{}-{}",gatherInfo.getBarcode(),gatherInfo.getVename()) | 
|  |  | 49 | +                } | 
|  |  | 50 | +            }else { | 
|  |  | 51 | +                log.error("[Singile-Release-Faild]-核销失败,缺少关键过卡信息"); | 
|  |  | 52 | +            } | 
|  |  | 53 | + | 
|  |  | 54 | +        } catch (Exception e){ | 
|  |  | 55 | +            e.printStackTrace(); | 
|  |  | 56 | +            log.error("[LockNoticeCheck-ERR]:",e); | 
|  |  | 57 | +        } | 
|  |  | 58 | +        return false; | 
|  |  | 59 | +    } | 
|  |  | 60 | + | 
|  |  | 61 | +    @Override | 
|  |  | 62 | +    Object run() { | 
|  |  | 63 | +        return false; | 
|  |  | 64 | +    } | 
|  |  | 65 | + | 
|  |  | 66 | +    // 获取spring容器 | 
|  |  | 67 | +    ApplicationContext getContext() { | 
|  |  | 68 | +        // 获取spring IOC容器 | 
|  |  | 69 | +        ApplicationContext context = applicationContext; | 
|  |  | 70 | +        return context; | 
|  |  | 71 | +    } | 
|  |  | 72 | + | 
|  |  | 73 | +    void releaseBarCode(GatherInfo info,ExecuteParams executeParams){ | 
|  |  | 74 | +        ApplicationContext context = getContext(); | 
|  |  | 75 | +        // 获取容器中的bean | 
|  |  | 76 | +        LandListDao landListDao = context.getBean(LandListDao.class); | 
|  |  | 77 | +        Boolean devdebug = (Boolean)context.getBean("devdebug"); | 
|  |  | 78 | + | 
|  |  | 79 | +        if (!devdebug){ | 
|  |  | 80 | +            BuildBarCode.cancleBarCode(info.getVename()); | 
|  |  | 81 | +            log.info("[流转申请]-二维码已释放:"+info.getVename()); | 
|  |  | 82 | +        } | 
|  |  | 83 | + | 
|  |  | 84 | +        int rc = landListDao.releaseBarcode(info.getBarcode()); | 
|  |  | 85 | +        if (rc>0) { | 
|  |  | 86 | +            log.info("[进出场核销]-{}流转已核销:{}",info.getVename(),info.getBarcode()); | 
|  |  | 87 | +        }else{ | 
|  |  | 88 | +            log.error("[进出场核销-ERROR]-{}流转未核销成功:{}",info.getVename(),info.getBarcode()); | 
|  |  | 89 | +        } | 
|  |  | 90 | +        //车辆流转申请缓存删除 | 
|  |  | 91 | +        releaseCache(info,executeParams); | 
|  |  | 92 | + | 
|  |  | 93 | +    } | 
|  |  | 94 | + | 
|  |  | 95 | +    void releaseCache(GatherInfo info,ExecuteParams executeParams){ | 
|  |  | 96 | + | 
|  |  | 97 | +        ApplicationContext context = getContext(); | 
|  |  | 98 | +        // 获取容器中的bean | 
|  |  | 99 | +        RedisService redisService = context.getBean(RedisService.class); | 
|  |  | 100 | + | 
|  |  | 101 | +        //车辆流转申请缓存删除 | 
|  |  | 102 | +        redisService.del(info.getVename()); | 
|  |  | 103 | +        //流转申请时生成的临时核碰场站代码列表 | 
|  |  | 104 | +        redisService.del(info.getVename()+"_endstationList"); | 
|  |  | 105 | +        //车辆过卡信息缓存删除-X22金二判定时候生成的这个缓存 | 
|  |  | 106 | +        redisService.del(info.getSeqno()); | 
|  |  | 107 | +        log.info("[流转缓存]-{}缓存已核销",info.getVename()); | 
|  |  | 108 | +        //核销记录 | 
|  |  | 109 | +        releaseRecord(info,executeParams); | 
|  |  | 110 | +    } | 
|  |  | 111 | + | 
|  |  | 112 | +    /** | 
|  |  | 113 | +     * 核销记录 | 
|  |  | 114 | +     */ | 
|  |  | 115 | +    void releaseRecord(GatherInfo info,ExecuteParams executeParams){ | 
|  |  | 116 | +        LandBusinessTypeList chanelFormInfo = (LandBusinessTypeList) executeParams.get("ChanelFormInfo"); | 
|  |  | 117 | +        ApplicationContext context = getContext(); | 
|  |  | 118 | +        CommandLogService commandLogService = context.getBean(CommandLogService.class); | 
|  |  | 119 | +        commandLogService.commandlog(info,true,"流转核销",chanelFormInfo,null,0.0,0.0,0.0,0.0); | 
|  |  | 120 | +    } | 
|  |  | 121 | + | 
|  |  | 122 | +} |