审查视图

src/main/java/com/sy/groovy/X21FormSingileReleaseCheck.groovy 4.4 KB
1 2
package com.sy.groovy
3 4
import com.sy.crossDomain.BuildBarCode
import com.sy.mapper.LandListDao
5 6
import com.sy.model.GatherInfo
import com.sy.model.LandBusinessTypeList
7 8 9
import com.sy.service.CommandLogService
import com.sy.service.LandBusListService
import com.sy.service.RedisService
10 11 12 13 14 15 16 17 18 19 20 21
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

import java.util.stream.Collectors

/**
 * 流转申请-核销
 * 1. 单进单出即核销判定
 * 2. 根据申请单中的通道类型及通道信息判定没有未走完的通道类型,可以核销.比如 申请单证的通道只有进通道,车可以走进一,进二,进二入场,走完进一,即可核销.(一线进)
22
 * 3. 只要有进记录或者出记录 就核销
23 24 25
 */
class X21FormSingileReleaseCheck extends Script {
26
    private final Logger log = LoggerFactory.getLogger(getClass());
27 28 29 30 31 32 33 34 35


    /**x21指令判定
    * 传入gatherInfo
     *
     * 传入从redis读取的申请表体实体,验证
     * 进行通道比对
    */
    void check(ExecuteParams executeParams) {
36 37
        try {
            int count = 0;
38 39
            // 获取product对象
            GatherInfo gatherInfo = (GatherInfo) executeParams.get("GatherInfo");
40 41 42 43 44 45 46 47 48 49 50 51 52
            if (gatherInfo!=null){
                // 调用方法
                ApplicationContext context = getContext();
                LandBusListService landBusListService = context.getBean(LandBusListService.class)
                count = landBusListService.selectHistoryCount(gatherInfo.getBarcode());
                if (count>0){
                    log.info("[Singile-Release-Success]-{}-{}",gatherInfo.getBarcode(),gatherInfo.getVename())
                    releaseBarCode(gatherInfo,executeParams);
                }else {
                    log.error("[Singile-Release-Faild]-{}-{}",gatherInfo.getBarcode(),gatherInfo.getVename())
                }
            }else {
                log.error("[Singile-Release-Faild]-核销失败,缺少关键过卡信息");
53 54
            }
55
        } catch (Exception e){
56
            e.printStackTrace();
57
            log.error("[LockNoticeCheck-ERR]:",e);
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
        }
    }

    @Override
    Object run() {
        return false;
    }

    // 获取spring容器
    ApplicationContext getContext() {
        // 获取spring IOC容器
        ApplicationContext context = applicationContext;
        return context;
    }
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    void releaseBarCode(GatherInfo info,ExecuteParams executeParams){
        ApplicationContext context = getContext();
        // 获取容器中的bean
        LandListDao landListDao = context.getBean(LandListDao.class);
        Boolean devdebug = (Boolean)context.getBean("devdebug");

        if (!devdebug){
            BuildBarCode.cancleBarCode(info.getVename());
            log.info("[流转申请]-二维码已释放:"+info.getVename());
        }

        int rc = landListDao.releaseBarcode(info.getBarcode());
        if (rc>0) {
            log.info("[进出场核销]-{}流转已核销:{}",info.getVename(),info.getBarcode());
        }else{
            log.error("[进出场核销-ERROR]-{}流转未核销成功:{}",info.getVename(),info.getBarcode());
        }
        //车辆流转申请缓存删除
        releaseCache(info,executeParams);

    }

    void releaseCache(GatherInfo info,ExecuteParams executeParams){

        ApplicationContext context = getContext();
        // 获取容器中的bean
        RedisService redisService = context.getBean(RedisService.class);

        //车辆流转申请缓存删除
        redisService.del(info.getVename());
        //流转申请时生成的临时核碰场站代码列表
        redisService.del(info.getVename()+"_endstationList");
        //车辆过卡信息缓存删除-X22金二判定时候生成的这个缓存
        redisService.del(info.getSeqno());
        log.info("[流转缓存]-{}缓存已核销",info.getVename());
        //核销记录
        releaseRecord(info,executeParams);
    }

    /**
     * 核销记录
     */
    void releaseRecord(GatherInfo info,ExecuteParams executeParams){
        LandBusinessTypeList chanelFormInfo = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
        ApplicationContext context = getContext();
        CommandLogService commandLogService = context.getBean(CommandLogService.class);
        commandLogService.commandlog(info,true,"流转核销",chanelFormInfo,null,0.0,0.0,0.0,0.0);
    }
122
}