优化下面的代码：
public  void shiftAuditTk(Map params){

        AbstractElementDO abstractElementDO = queryTK(params);
        if (abstractElementDO == null || abstractElementDO.getTicketId().intValue() != -1 || StringUtil.isBlank(
            abstractElementDO.getPropertyStr())) {
            featureLog.warn("Shift TK,Fail to  audit tk,keyId={},productId={},muuid={},mid={}", params.get("elementId"),
                params.get("productId"), params.get("muuid"), params.get("mid"));
            return ;
        }

        abstractElementDO.setElementType((String)params.get("elementType"));

        /**
         * 先进行工单转换菜单查找，若查找不到，则马上返回，不做任何操作
         */
        TaskInfo taskInfo = queryShiftTask(abstractElementDO);
        if (null == taskInfo) {
            featureLog.warn("Not found shift taskInfo, keyId={}", abstractElementDO.getId());
            return;
        }

        RiskTraceLog traceLog = basicTraceLog(abstractElementDO.getId(), (String)params.get("elementType"),
            Integer.parseInt(abstractElementDO.getProductId() + ""),(String)params.get("muuid"),taskInfo);
        fullpathlog.info(traceLog.toString());

        /**
         * 向转移的菜单，填充新的流程信息
         */
        fillFlowInfo(abstractElementDO, taskInfo);
        String config = String.format("%d_%s", abstractElementDO.getProductId(), taskInfo.getBizNodeId());

        List<ShiftMetaConfig> shiftMetaConfigs = SwitchCenter.asyncShiftConfig;
        if (CollectionUtil.isEmpty(shiftMetaConfigs)) {
            return;
        }

        Map<String, ShiftMetaConfig> shiftMetaConfigMap = shiftMetaConfigs.stream().collect(
            Collectors.toMap(x -> x.getFrom() + "_" + x.getTo(), x -> x));

        if (shiftMetaConfigMap.get(config) == null) {
            return;
        }

        ShiftMetaConfig shiftMetaConfig = shiftMetaConfigMap.get(config);

        /**
         * 如果是预跑，则记录预跑数据
         */
        if (ShiftTkUtil.dryRun(shiftMetaConfig)) {
            dryRunShiftAuditTk(abstractElementDO,config);
            return;
        }
        /**
         * 转换成目标菜单需要DO对象
         */
        boolean hitGrayStrategy = ShiftTkUtil.hitGray(shiftMetaConfig);
        if (hitGrayStrategy) {

            traceLog.addExtData("hitGraySrategy", true);
            /**
             * 如果有转移菜单操作，则先上锁，防止该记录
             * 被人领取
             */
            int lockResult = lock(abstractElementDO.getPrimaryKey(), LOCK_MAGIC_NUM);
            boolean lockSuccess = lockResult > 0 ? true : false;
            if (!lockSuccess) {
                featureLog.warn("Shift tk: fail to lock,params: " + JSON.toJSONString(params));
                return;
            }

            ElementModel elementModel = abs2ElementModel(abstractElementDO,taskInfo);
            /**
             * 转换后的菜单入库，入库成功后，需要删除原菜单里面的数据
             */
            boolean success = auditInputDomainService.processAsyncInput(elementModel, elementModel.getElementType());
            if (success) {
                traceLog.addExtData("shiftMenu", "success");
                boolean result = cleanSourceTK(abstractElementDO.getPrimaryKey());
                if (!result) {
                    traceLog.addExtData("cleanSourceTk", "fail");
                }
            } else {
                traceLog.addExtData("shiftMenu", "fail");
                unlock(abstractElementDO.getPrimaryKey());
            }

            fullpathlog.info(traceLog.toString());
            return;
        }
        traceLog.addExtData("hitGrayStrategy", "Not hit");
        fullpathlog.info(traceLog.toString());
        featureLog.warn("Not hit gray strategy,config={}", config);
    }