`

小工具

阅读更多
!/usr/bin/env node

'use strict';

var os         = require('os');

var sendpay =process.argv[2]
var pos = parseInt(process.argv.slice(3)) - 1;

console.log(sendpay[pos]);

 ./sendpay  123431423   2 

 

{
  "_source": {
    "includes": [
      "id",
      "createdate",
      "memberid",
      "yn"
    ]
  },
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "orderdetails.productid": "100012043978"
          }
        },
        {
          "range": {
            "createdate": {
              "gte": "2020-04-03 09:30:00",
              "lt": "2020-04-03 10:00:00"
            }
          }
        }
      ],
      "must_not": [],
      "should": []
    }
  },
  "from": 0,
  "size": 10000,
  "sort": [],
  "aggs": {}
}

 

 

import java.util.concurrent.Callable;

import lombok.Getter;
import lombok.Setter;

public class Retryer {
	/**
	 * default value is 3.
	 */
	@Getter @Setter
	private int times = 3;
	
	/**
	 * default value is 0,meaning immediately execute next loop.
	 */
	@Getter @Setter
	private int timeInterval = 0;
	
	@Getter @Setter
	private Strategy strategy;
	
	private Retryer() {}
	
	public static Retryer newBuilder() {
		return new Retryer();
	}
	
	public Retryer withTimes(int times) {
		this.times = times;
		return this;
	}
	
	public Retryer withtimeInterval(int timeInterval) {
		this.timeInterval = timeInterval;
		return this;
	}
	
	public Retryer withStrategy(Strategy strategy) {
		this.strategy = strategy;
		return this;
	}
	
	public <T> T retry(Callable<T> executor) throws Exception{
		if(executor == null) {
			throw new IllegalArgumentException("executor can't be null.");
		}
		
		int times = this.getTimes();
		int timeInterval = this.getTimeInterval();
		Strategy strategy = this.getStrategy();
		Exception error = null;
		
		while(times-- > 0) {
			try {
				return executor.call();
			} catch (Exception e) {
				e.printStackTrace();
				error = e;
				
				if(strategy != null && strategy.isShortcut(e)) {
					break;
				}
					
				if(timeInterval > 0) {
					Thread.sleep(timeInterval);
				}
			}
		}
		
		throw error;
	}
}

 

 <!--mysql库 分库配置 -->
    <bean id="parentDataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="username" value="${mysql.jdbc.rw.username.order}" />
        <property name="password" value="${mysql.jdbc.rw.password.order}" />
        <!--maxWait: 超时等待时间以毫秒为单位-->
        <property name="maxWait" value="1000" />
        <!--maxActive: 最大连接数量-->
        <property name="maxActive" value="30" />
        <!--initialSize: 初始化连接-->
        <property name="initialSize" value="5" />
        <!--maxIdle: 最大空闲连接-->
        <property name="maxIdle" value="30" />
        <!--minIdle: 最小空闲连接-->
        <property name="minIdle" value="5" />
        <!-- 在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位. -->
        <property name="timeBetweenEvictionRunsMillis" value="30000" />
        <property name="minEvictableIdleTimeMillis" value="530000" />
        <property name="numTestsPerEvictionRun" value="30" />

        <property name="testWhileIdle" value="true" />
        <!-- 指明是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个.注意: 设置为true后如果要生效,validationQuery参数必须设置为非空字符串 -->
        <property name="testOnBorrow" value="false" />
        <!-- 指明是否在归还到池中前进行检验,注意: 设置为true后如果要生效,validationQuery参数必须设置为非空字符串 -->
        <property name="testOnReturn" value="false" />
        <!-- SQL查询,用来验证从连接池取出的连接,在将连接返回给调用者之前.如果指定,则查询必须是一个SQL SELECT并且必须返回至少一行记录 -->
        <property name="validationQuery" value="select 1" />
        <!--removeAbandoned: 是否自动回收超时连接-->
        <property name="removeAbandoned" value="true" />
        <!--removeAbandonedTimeout: 超时时间(以秒数为单位)-->
        <property name="removeAbandonedTimeout" value="30" />
    </bean>

 

import org.apache.commons.lang.StringUtils;

public enum OrderSignEnum {

    SHUI_JIA_FEN_LI(1, 195, "税价分离195位是1"),

    PAYMENT_IS_COMPLETED(2, 59, "支付即完成59位2"),

    KUAN_DAI(7, 58, "新loc业务宽带业务58位7"),

    SHIPIN_KUNBANG(1, 111, "视频业务捆绑订单111位1"),

    SHIPIN_1(2, 111, "视频业务订单111位2"),

    SHIPIN_2(3, 111, "视频业务订单111位3"),

    FRESH_MENDIAN(1, 132, "生鲜店中店第132位是1"),

    FORCE_BOT_ORDER(new int[]{2, 3}, 140, "140位 2. 全链路压测测试订单, 3. 预发环境全链路压测订单"),

    SOP_ZITI_O2O(1,159,"SOP自提O2O"),

    SHARE_CARGO(2,138,"一盘货标记"),

    JING_ZUN_DA(1, 135, "京尊达订单第135位为1"),

    MENDIAN_ORDER(new int[]{3, 4, 5}, 187, "门店标记。商家分单:京东分单"),

    SHOP_MENDIAN_ORDER(5, 187, "门店标记。商家分单"),

    JD_MENDIAN(new int[]{3, 4}, 187, "门店标记。京东分单"),

    IDMOBILESTROE_ORDER_TYPE1(1, 159, "履约门店"),

    IDMOBILESTROE_ORDER_TYPE2(new int[]{3, 4,5}, 187, "履约门店");

    /**
     * 业务标志
     */
    private String[] signs;

    /**
     * sendpay截取开始位 从1 开始
     */
    private int positionStart;

    /**
     * sendpay截取结束位 从1 开始
     */
    private int positionEnd;

    /**
     * 描述
     */
    private String desc;


    /**
     * @param sign
     * @param position 从1开始数
     * @param desc     描述
     */
    OrderSignEnum(int sign, int position, String desc) {
        this(new int[]{sign}, position - 1, position, desc);
    }

    /**
     * @param signs
     * @param position 从1开始数
     * @param desc     描述
     */
    OrderSignEnum(int[] signs, int position, String desc) {
        this(signs, position - 1, position, desc);
    }


    OrderSignEnum(int[] signs, int positionStart, int positionEnd, String desc) {
        if (signs.length == 0) {
            throw new IllegalArgumentException();
        }
        this.signs = new String[signs.length];
        for (int i = 0; i < signs.length; i++) {
            this.signs[i] = String.valueOf(signs[i]);
        }
        this.positionStart = positionStart;
        this.positionEnd = positionEnd;
        this.desc = desc;
    }



    public boolean check(String orderSign) {
        if (StringUtils.isBlank(orderSign)) {
            return false;
        }
        //noinspection SimplifiableIfStatement
        if (orderSign.length() < this.positionEnd) {
            return false;
        }
        for (String sign : signs) {
            if (sign.equals(orderSign.substring(this.positionStart, this.positionEnd))) {
                return true;
            }
        }
        return false;
    }

    public String[] getSigns() {
        return signs;
    }

    public int getPositionStart() {
        return positionStart;
    }


    public int getPositionEnd() {
        return positionEnd;
    }


    public String getDesc() {
        return desc;
    }

}

 

 

orderver puy

change #!/usr/bin/python to #!/usr/bin/env python

change 可替换成modify 和 update

 

#!/usr/bin/python
# -*- coding: UTF-8 -*-

from requestutil.jdrequestutil import erp_factory
from requestutil.requestutil import Request

erp = erp_factory()
dict = {}

orderList = [117099381792,117099362592,117099448352]

for orderId in orderList:
    try:
        orderxml = erp.get(Request("http://orderver.jd.care/orderXml.xml?orderId={0}&ver=0".format(orderId)))
        sourceType = orderxml.content.split("AutoCancelTimeSource</Key>")[1].split("<Val>")[1].split("</Val>")[0]
    except:
        continue

    dict[sourceType] = orderId

print dict.values()



 

 

检测器每隔30秒动一下,每次检测30个链接,发现该链接空闲大于10分钟了就回收掉

 

//replace all the images with local one
var fs      = require("fs");

var LOCAL_ROOT_DIR = "/Users/jervyshi/workspace/source/jd-tone/jd-tone-admin/src/main/webapp/"

var DOMAIN_REGEX = /^http:\/\/tone.jd.net\//;

var CONTENT_TYPE_MAP = {
    "image/png": /\.(png|gif|jpg|jpeg)$/,
    "text/html": /\.(html)$/,
    "text/css": /\.(css)$/,
    "application/javascript": /\.(js)$/,
}

module.exports = {

    summary:function(){
        return "replace all the images with local one";
    },

    //mark if use local response
    shouldUseLocalResponse : function(req,reqBody){
        if (DOMAIN_REGEX.test(req.url)) {
            for(var content_type in CONTENT_TYPE_MAP){
                var regex = CONTENT_TYPE_MAP[content_type];
                if (regex.test(req.url)) {
                    req.replaceLocalFile = true;
                    req._custom_type = content_type;
                    req._local_file = req.url.replace(DOMAIN_REGEX, LOCAL_ROOT_DIR);
                    return true;
                }
            }
            return false;
        } else {
            return false;
        }
    },

    dealLocalResponse : function(req,reqBody,callback){
        if(req.replaceLocalFile){
            callback(200, {"content-type":req._custom_type}, fs.readFileSync(req._local_file));
        }
    }
};

 

 

!/usr/bin/env node

const { semver, error } = require('@vue/cli-shared-utils')
const requiredVersion = require('../package.json').engines.node

if (!semver.satisfies(process.version, requiredVersion)) {
  error(
    `You are using Node ${process.version}, but vue-cli-service ` +
    `requires Node ${requiredVersion}.\nPlease upgrade your Node version.`
  )
  process.exit(1)
}

const Service = require('../lib/Service')
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())

const rawArgv = process.argv.slice(2)
const args = require('minimist')(rawArgv, {
  boolean: [
    // build
    'modern',
    'report',
    'report-json',
    'inline-vue',
    'watch',
    // serve
    'open',
    'copy',
    'https',
    // inspect
    'verbose'
  ]
})
const command = args._[0]

service.run(command, args, rawArgv).catch(err => {
  error(err)
  process.exit(1)
})

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics