package cn.huge.module.mediate.utils;
|
|
import cn.huge.base.common.constant.GzRegionBaseEnum;
|
import cn.huge.base.common.utils.DateUtils;
|
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
|
/**
|
* @title: 事项编号生成工具
|
* @description: 事项编号生成工具
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2021-11-05 16:51:48
|
* @version: 1.0.0
|
*/
|
public class CaseRefUtils {
|
|
/**
|
* 常量前缀
|
*/
|
public static String CASE_REF_SIGN_TH = "GZTH";
|
public static String CASE_REF_SIGN_HZ = "GZHZ";
|
public static String CASE_REF_SIGN_LW = "GZLW";
|
public static String CASE_REF_SIGN_YX = "GZYX";
|
public static String CASE_REF_SIGN_PY = "GZPY";
|
public static String CASE_REF_SIGN_HD = "GZHD";
|
public static String CASE_REF_SIGN_BY = "GZBY";
|
public static String CASE_REF_SIGN_NS = "GZNS";
|
public static String CASE_REF_SIGN_HP = "GZHP";
|
public static String CASE_REF_SIGN_ZC = "GZZC";
|
public static String CASE_REF_SIGN_CH = "GZCH";
|
public static String CASE_REF_SIGN_GZ = "GZ";
|
|
public static String NEW_CASE_REF_SIGN_TH = "06";
|
public static String NEW_CASE_REF_SIGN_HZ = "05";
|
public static String NEW_CASE_REF_SIGN_LW = "03";
|
public static String NEW_CASE_REF_SIGN_YX = "04";
|
public static String NEW_CASE_REF_SIGN_PY = "13";
|
public static String NEW_CASE_REF_SIGN_HD = "14";
|
public static String NEW_CASE_REF_SIGN_BY = "11";
|
public static String NEW_CASE_REF_SIGN_NS = "15";
|
public static String NEW_CASE_REF_SIGN_HP = "12";
|
public static String NEW_CASE_REF_SIGN_ZC = "18";
|
public static String NEW_CASE_REF_SIGN_CH = "17";
|
|
/**
|
* 序号
|
*/
|
public static int CASE_REF_COUNT_CITY = 0;
|
public static int CASE_REF_COUNT_TH = 0;
|
public static int CASE_REF_COUNT_HZ = 0;
|
public static int CASE_REF_COUNT_LW = 0;
|
public static int CASE_REF_COUNT_YX = 0;
|
public static int CASE_REF_COUNT_PY = 0;
|
public static int CASE_REF_COUNT_HD = 0;
|
public static int CASE_REF_COUNT_BY = 0;
|
public static int CASE_REF_COUNT_NS = 0;
|
public static int CASE_REF_COUNT_HP = 0;
|
public static int CASE_REF_COUNT_ZC = 0;
|
public static int CASE_REF_COUNT_CH = 0;
|
public static int CASE_REF_COUNT_GZ = 0;
|
|
/**
|
* 是否要重新查询,true是
|
*/
|
public static boolean CASE_REF_FLAG_TH = true;
|
public static boolean CASE_REF_FLAG_HZ = true;
|
public static boolean CASE_REF_FLAG_LW = true;
|
public static boolean CASE_REF_FLAG_YX = true;
|
public static boolean CASE_REF_FLAG_PY = true;
|
public static boolean CASE_REF_FLAG_HD = true;
|
public static boolean CASE_REF_FLAG_BY = true;
|
public static boolean CASE_REF_FLAG_NS = true;
|
public static boolean CASE_REF_FLAG_HP = true;
|
public static boolean CASE_REF_FLAG_ZC = true;
|
public static boolean CASE_REF_FLAG_CH = true;
|
public static boolean CASE_REF_FLAG_GZ = true;
|
|
/**
|
* 判断是否要重新查询
|
*
|
* @return
|
*/
|
public synchronized static Boolean getFlag(String area) {
|
if (GzRegionBaseEnum.AREA_1.getIndex().equals(area)) {
|
return CASE_REF_FLAG_TH;
|
} else if (GzRegionBaseEnum.AREA_2.getIndex().equals(area)) {
|
return CASE_REF_FLAG_HZ;
|
} else if (GzRegionBaseEnum.AREA_3.getIndex().equals(area)) {
|
return CASE_REF_FLAG_LW;
|
} else if (GzRegionBaseEnum.AREA_4.getIndex().equals(area)) {
|
return CASE_REF_FLAG_YX;
|
} else if (GzRegionBaseEnum.AREA_5.getIndex().equals(area)) {
|
return CASE_REF_FLAG_PY;
|
} else if (GzRegionBaseEnum.AREA_6.getIndex().equals(area)) {
|
return CASE_REF_FLAG_HD;
|
} else if (GzRegionBaseEnum.AREA_7.getIndex().equals(area)) {
|
return CASE_REF_FLAG_BY;
|
} else if (GzRegionBaseEnum.AREA_8.getIndex().equals(area)) {
|
return CASE_REF_FLAG_NS;
|
} else if (GzRegionBaseEnum.AREA_9.getIndex().equals(area)) {
|
return CASE_REF_FLAG_HP;
|
} else if (GzRegionBaseEnum.AREA_10.getIndex().equals(area)) {
|
return CASE_REF_FLAG_ZC;
|
} else if (GzRegionBaseEnum.AREA_11.getIndex().equals(area)) {
|
return CASE_REF_FLAG_CH;
|
} else {
|
return CASE_REF_FLAG_GZ;
|
}
|
}
|
|
/**
|
* 设置是否要重新查询
|
*
|
* @return
|
*/
|
public synchronized static void setFlag(String area, boolean flag) {
|
if (GzRegionBaseEnum.AREA_1.getIndex().equals(area)) {
|
CASE_REF_FLAG_TH = flag;
|
} else if (GzRegionBaseEnum.AREA_2.getIndex().equals(area)) {
|
CASE_REF_FLAG_HZ = flag;
|
} else if (GzRegionBaseEnum.AREA_3.getIndex().equals(area)) {
|
CASE_REF_FLAG_LW = flag;
|
} else if (GzRegionBaseEnum.AREA_4.getIndex().equals(area)) {
|
CASE_REF_FLAG_YX = flag;
|
} else if (GzRegionBaseEnum.AREA_5.getIndex().equals(area)) {
|
CASE_REF_FLAG_PY = flag;
|
} else if (GzRegionBaseEnum.AREA_6.getIndex().equals(area)) {
|
CASE_REF_FLAG_HD = flag;
|
} else if (GzRegionBaseEnum.AREA_7.getIndex().equals(area)) {
|
CASE_REF_FLAG_BY = flag;
|
} else if (GzRegionBaseEnum.AREA_8.getIndex().equals(area)) {
|
CASE_REF_FLAG_NS = flag;
|
} else if (GzRegionBaseEnum.AREA_9.getIndex().equals(area)) {
|
CASE_REF_FLAG_HP = flag;
|
} else if (GzRegionBaseEnum.AREA_10.getIndex().equals(area)) {
|
CASE_REF_FLAG_ZC = flag;
|
} else if (GzRegionBaseEnum.AREA_11.getIndex().equals(area)) {
|
CASE_REF_FLAG_CH = flag;
|
} else {
|
CASE_REF_FLAG_GZ = flag;
|
}
|
}
|
|
/**
|
* 获取前缀
|
*
|
* @return
|
*/
|
public synchronized static String getSign(String area) {
|
SimpleDateFormat sdf = new SimpleDateFormat("yy");
|
String nowYear = sdf.format(new Date());
|
if (GzRegionBaseEnum.AREA_1.getIndex().equals(area)) {
|
return CASE_REF_SIGN_TH + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_2.getIndex().equals(area)) {
|
return CASE_REF_SIGN_HZ + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_3.getIndex().equals(area)) {
|
return CASE_REF_SIGN_LW + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_4.getIndex().equals(area)) {
|
return CASE_REF_SIGN_YX + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_5.getIndex().equals(area)) {
|
return CASE_REF_SIGN_PY + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_6.getIndex().equals(area)) {
|
return CASE_REF_SIGN_HD + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_7.getIndex().equals(area)) {
|
return CASE_REF_SIGN_BY + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_8.getIndex().equals(area)) {
|
return CASE_REF_SIGN_NS + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_9.getIndex().equals(area)) {
|
return CASE_REF_SIGN_HP + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_10.getIndex().equals(area)) {
|
return CASE_REF_SIGN_ZC + "-" + nowYear;
|
} else if (GzRegionBaseEnum.AREA_11.getIndex().equals(area)) {
|
return CASE_REF_SIGN_CH + "-" + nowYear;
|
} else {
|
return CASE_REF_SIGN_GZ + "-" + nowYear;
|
}
|
}
|
|
/**
|
* 设置常量数
|
*
|
* @return
|
*/
|
public synchronized static void setCount(String area, int num) {
|
if (GzRegionBaseEnum.AREA_1.getIndex().equals(area)) {
|
CASE_REF_COUNT_TH = num;
|
} else if (GzRegionBaseEnum.AREA_2.getIndex().equals(area)) {
|
CASE_REF_COUNT_HZ = num;
|
} else if (GzRegionBaseEnum.AREA_3.getIndex().equals(area)) {
|
CASE_REF_COUNT_LW = num;
|
} else if (GzRegionBaseEnum.AREA_4.getIndex().equals(area)) {
|
CASE_REF_COUNT_YX = num;
|
} else if (GzRegionBaseEnum.AREA_5.getIndex().equals(area)) {
|
CASE_REF_COUNT_PY = num;
|
} else if (GzRegionBaseEnum.AREA_6.getIndex().equals(area)) {
|
CASE_REF_COUNT_HD = num;
|
} else if (GzRegionBaseEnum.AREA_7.getIndex().equals(area)) {
|
CASE_REF_COUNT_BY = num;
|
} else if (GzRegionBaseEnum.AREA_8.getIndex().equals(area)) {
|
CASE_REF_COUNT_NS = num;
|
} else if (GzRegionBaseEnum.AREA_9.getIndex().equals(area)) {
|
CASE_REF_COUNT_HP = num;
|
} else if (GzRegionBaseEnum.AREA_10.getIndex().equals(area)) {
|
CASE_REF_COUNT_ZC = num;
|
} else if (GzRegionBaseEnum.AREA_11.getIndex().equals(area)) {
|
CASE_REF_COUNT_CH = num;
|
} else {
|
CASE_REF_COUNT_GZ = num;
|
}
|
}
|
|
/**
|
* 获取事项编号
|
*
|
* @return
|
*/
|
public synchronized static String getCaseRsf(String area) {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
|
String nowDay = sdf.format(new Date());
|
StringBuffer caseRef = new StringBuffer();
|
// 获取对应区的编码
|
if (GzRegionBaseEnum.AREA_1.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_TH += 1;
|
if (CASE_REF_COUNT_TH > 99999) {
|
CASE_REF_COUNT_TH = 1;
|
}
|
// 设置前缀
|
caseRef.append(CASE_REF_SIGN_TH);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_TH));
|
} else if (GzRegionBaseEnum.AREA_2.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_HZ += 1;
|
if (CASE_REF_COUNT_HZ > 99999) {
|
CASE_REF_COUNT_HZ = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_HZ);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_HZ));
|
} else if (GzRegionBaseEnum.AREA_3.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_LW += 1;
|
if (CASE_REF_COUNT_LW > 99999) {
|
CASE_REF_COUNT_LW = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_LW);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_LW));
|
} else if (GzRegionBaseEnum.AREA_4.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_YX += 1;
|
if (CASE_REF_COUNT_YX > 99999) {
|
CASE_REF_COUNT_YX = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_YX);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_YX));
|
} else if (GzRegionBaseEnum.AREA_5.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_PY += 1;
|
if (CASE_REF_COUNT_PY > 99999) {
|
CASE_REF_COUNT_PY = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_PY);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_PY));
|
} else if (GzRegionBaseEnum.AREA_6.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_HD += 1;
|
if (CASE_REF_COUNT_HD > 99999) {
|
CASE_REF_COUNT_HD = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_HD);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_HD));
|
} else if (GzRegionBaseEnum.AREA_7.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_BY += 1;
|
if (CASE_REF_COUNT_BY > 99999) {
|
CASE_REF_COUNT_BY = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_BY);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_BY));
|
} else if (GzRegionBaseEnum.AREA_8.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_NS += 1;
|
if (CASE_REF_COUNT_NS > 99999) {
|
CASE_REF_COUNT_NS = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_NS);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_NS));
|
} else if (GzRegionBaseEnum.AREA_9.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_HP += 1;
|
if (CASE_REF_COUNT_HP > 99999) {
|
CASE_REF_COUNT_HP = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_HP);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_HP));
|
} else if (GzRegionBaseEnum.AREA_10.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_ZC += 1;
|
if (CASE_REF_COUNT_ZC > 99999) {
|
CASE_REF_COUNT_ZC = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_ZC);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_ZC));
|
} else if (GzRegionBaseEnum.AREA_11.getIndex().equals(area)) {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_CH += 1;
|
if (CASE_REF_COUNT_CH > 99999) {
|
CASE_REF_COUNT_CH = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_CH);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_CH));
|
} else {
|
// 当前事项序号+1,大于99999就重置0
|
CASE_REF_COUNT_GZ += 1;
|
if (CASE_REF_COUNT_GZ > 99999) {
|
CASE_REF_COUNT_GZ = 1;
|
}
|
caseRef.append(CASE_REF_SIGN_GZ);
|
// 设置当天日期
|
caseRef.append("-").append(nowDay);
|
// 设置事项序号
|
caseRef.append("-").append(String.format("%05d", CASE_REF_COUNT_GZ));
|
}
|
System.out.println(caseRef.toString());
|
return caseRef.toString();
|
}
|
|
public synchronized static String getCaseRsfNew(String area, String source, String business) {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
|
String nowDay = sdf.format(new Date());
|
StringBuffer caseRef = new StringBuffer();
|
CASE_REF_COUNT_CITY += 1;
|
if (CASE_REF_COUNT_CITY > 99999) {
|
CASE_REF_COUNT_CITY = 1;
|
}
|
// 设置当天日期
|
caseRef.append(nowDay);
|
// 获取对应区的编码
|
if (GzRegionBaseEnum.AREA_1.getIndex().equals(area)) {
|
// 设置区域
|
caseRef.append(NEW_CASE_REF_SIGN_TH);
|
|
} else if (GzRegionBaseEnum.AREA_2.getIndex().equals(area)) {
|
|
// 设置区域
|
caseRef.append(NEW_CASE_REF_SIGN_HZ);
|
|
} else if (GzRegionBaseEnum.AREA_3.getIndex().equals(area)) {
|
|
// 设置区域
|
caseRef.append(NEW_CASE_REF_SIGN_LW);
|
|
|
} else if (GzRegionBaseEnum.AREA_4.getIndex().equals(area)) {
|
|
// 设置区域
|
caseRef.append(NEW_CASE_REF_SIGN_YX);
|
|
|
} else if (GzRegionBaseEnum.AREA_5.getIndex().equals(area)) {
|
|
// 设置区域
|
caseRef.append(NEW_CASE_REF_SIGN_PY);
|
|
|
} else if (GzRegionBaseEnum.AREA_6.getIndex().equals(area)) {
|
|
// 设置区域
|
caseRef.append(NEW_CASE_REF_SIGN_HD);
|
|
|
} else if (GzRegionBaseEnum.AREA_7.getIndex().equals(area)) {
|
|
caseRef.append(NEW_CASE_REF_SIGN_BY);
|
|
} else if (GzRegionBaseEnum.AREA_8.getIndex().equals(area)) {
|
|
caseRef.append(NEW_CASE_REF_SIGN_NS);
|
|
} else if (GzRegionBaseEnum.AREA_9.getIndex().equals(area)) {
|
|
caseRef.append(NEW_CASE_REF_SIGN_HP);
|
|
} else if (GzRegionBaseEnum.AREA_10.getIndex().equals(area)) {
|
|
caseRef.append(NEW_CASE_REF_SIGN_ZC);
|
|
} else if (GzRegionBaseEnum.AREA_11.getIndex().equals(area)) {
|
|
caseRef.append(NEW_CASE_REF_SIGN_CH);
|
|
} else {
|
caseRef.append(CASE_REF_SIGN_GZ);
|
|
}
|
// 设置业务
|
caseRef.append(business);
|
// 设置来源
|
caseRef.append(source);
|
// 设置事项序号
|
caseRef.append(String.format("%07d", CASE_REF_COUNT_CITY));
|
System.out.println(caseRef.toString());
|
return caseRef.toString();
|
}
|
}
|
/**
|
* -------------------_ooOoo_-------------------
|
* ------------------o8888888o------------------
|
* ------------------88" . "88------------------
|
* ------------------(| -_- |)------------------
|
* ------------------O\ = /O------------------
|
* ---------------____/`---'\____---------------
|
* -------------.' \\| |// `.-------------
|
* ------------/ \\||| : |||// \------------
|
* -----------/ _||||| -:- |||||- \-----------
|
* -----------| | \\\ - /// | |-----------
|
* -----------| \_| ''\---/'' | |-----------
|
* -----------\ .-\__ `-` ___/-. /-----------
|
* ---------___`. .' /--.--\ `. . __----------
|
* ------."" '< `.___\_<|>_/___.' >'"".-------
|
* -----| | : `- \`.;`\ _ /`;.`/ - ` : | |-----
|
* -----\ \ `-. \_ __\ /__ _/ .-` / /-----
|
* ======`-.____`-.___\_____/___.-`____.-'======
|
* -------------------`=---='
|
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
* ---------佛祖保佑---hugeinfo---永无BUG----------
|
*/
|