YgEnumInterface.java 5.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/**
 * @date 2020年3月23日  
 * @author 翁东州
 * @方法中文名称:
 */
package cn.timer.api.config.enuminterface;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
东州 翁 committed
12 13 14
import java.util.HashMap;
import java.util.List;
import java.util.Map;
15 16
import java.util.regex.Pattern;

东州 翁 committed
17
import cn.timer.api.dto.yggl.YgbintuDto;
18
import lombok.Getter;
东州 翁 committed
19
import net.sf.ehcache.search.expression.Between;
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174

/**
 * @date 2020年3月23日  
 * @author 翁东州
 * @方法中文名称:
 */

public interface YgEnumInterface {
	/**
	 * 男女
	 */
	@Getter
	enum sex implements YgEnumInterface{
		MAN(0,"男"),WOMAN(1,"女");
		
		private Integer type;

		private String name;
		
		sex(Integer type, String name) {
			this.type = type;
			this.name = name;
		}
		public static String isMan(String index) {
			sex mow = (index == null || index.length() == 0) ? sex.MAN : (index.indexOf(sex.MAN.name)!= -1)||(index.indexOf(sex.MAN.type)!= -1) ? sex.MAN:sex.WOMAN;
			return mow.type.toString();			
		}
	}
	/**
	 * 员工类型
	 */
	@Getter
	enum YgJobType  implements YgEnumInterface{
		QUANZHI(1, "全"),SHIXI(2, "实习"),JIANZHI(3, "兼"),LWPQ(4, "劳务派遣"),
		LAOWU(5, "劳务"),PAIQIAN(6, "派遣"),WAIBAO(7, "外包"),TUIXIU(8, "退休");

		private Integer type;

		private String name;

		YgJobType(Integer type, String name) {
			this.type = type;
			this.name = name;
		}

		public static String choose(String index) {
			YgJobType result = YgJobType.QUANZHI;
			if(index == null || index.length() == 0) return result.type.toString();
			for (YgJobType item : YgJobType.values()) {
				if (index.indexOf(item.getType()) !=-1 ||index.indexOf(item.getName()) !=-1 ) result = item;
			}
			return result.type.toString();
		}
	}
	
	/**
	 * 员工状态
	 */
	@Getter
	enum jobStatus implements YgEnumInterface{
		ZHENSHI(0,"正式"),SHIYONG(1,"试用");
		
		private Integer type;

		private String name;
		
		jobStatus(Integer type, String name) {
			this.type = type;
			this.name = name;
		}
		public static String isZhen(String index) {
			jobStatus zos = (index == null || index.length() == 0) ? YgEnumInterface.jobStatus.ZHENSHI: (index.indexOf(jobStatus.ZHENSHI.name)!= -1)||(index.indexOf(jobStatus.ZHENSHI.type)!= -1) ? jobStatus.ZHENSHI:jobStatus.SHIYONG;
			return zos.type.toString();
		}
	}
	
	/**
	 * 入职日期
	 */
	@Getter
	enum rzTime  implements YgEnumInterface{
		ZHEN("--","yyyy-M-d"),XIE("//","yyyy/M/d"),
		DIAN("..","yyyy.M.d"),NYR("年月日","yyyy年M月d日");
		
		private String type;

		private String name;

		rzTime(String type, String name) {
			this.type = type;
			this.name = name;
		}
		
		public static String tranTime(String index) {
			DateFormat zhenFormat = new SimpleDateFormat(ZHEN.name);
			String result = zhenFormat.format(new Date());
			if (index == null || index.length() == 0) return result;
			Pattern pattern = Pattern.compile("^[0-9]{8}$"); 
		    if (pattern.matcher(index).matches()) {
				result = index.substring(0, 4) + "-" + index.substring(4, 6) + "-" + index.substring(6, 8);
				return result;
			}
			String s = index.replaceAll("([1-9]+[0-9]*|0)(\\.[\\d]+)?", "");
			for (rzTime item : rzTime.values()) {
				if (s.indexOf(item.type) != -1) {
					  DateFormat dateFormat = new SimpleDateFormat(item.name);
					try {
						result = new SimpleDateFormat(ZHEN.name).format(dateFormat.parse(index));
						return result;
					} catch (ParseException e) {
						e.printStackTrace();
						return result;
					}
				}
			}
			return result;
		}
		
		
		public static String tranTime2(String result) {
			String isYear ="^(?:(?!0000)[0-9]{4} -(?:(?:0[1-9]|1[0-2]) -(?:0[1-9]|1[0-9]|2[0-8]) |(?:0[13-9]|1[0-2]) -(?:29|30) |(?:0[13578]|1[02]) -31 )|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00) -02 -29 )$";
			Pattern pattern = Pattern.compile(isYear);
			if (pattern.matcher(result).matches()) {
				return result;
			}else {
				 result = new SimpleDateFormat(ZHEN.name).format(new Date());
				return result;
			}
			
		}
	}
	/**
	 * 试用期
	 */
	@Getter
	enum syq implements YgEnumInterface{
		ZERO(0,"无"),ONE(1,"一"),TWO(2,"二"),THREE(3,"三"),FOUR(4,"四"),FIVE(5,"五"),SIX(6,"六");
		
		private Integer type;

		private String name;
		
		syq(Integer type, String name) {
			this.type = type;
			this.name = name;
		}
		public static String choose(String index) {
			syq result = syq.ZERO;
			if (index == null || index.length() == 0) result.type.toString();
			for (syq item : syq.values()) {
				if (index.indexOf(item.getName()) !=-1 ||index.indexOf(item.getType()) !=-1 ) result=item;
			}
			return result.type.toString();
		}
	}
东州 翁 committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
	
	/**
	 * 工龄
	 */
	@Getter
	enum workage implements YgEnumInterface{
		//NEW(0,183),HALF(1,365),ONE(2,548),ONEHALF(3,730),TWO(4,913),LONG(5,10000);
		NEW(0,183,0),HALF(184,365,0),ONE(366,548,0),ONEHALF(549,730,0),TWO(731,1000,0),LONG(1001,10000,0);
		
		private Integer begin;
		private Integer end;
		private Integer number;
		
		workage(Integer begin, Integer end,Integer number) {
			this.begin = begin;
			this.end = end;
			this.number = number;
		}
		
		public static Map<String, Integer> choose(List<YgbintuDto> bintu) {
			
			for (YgbintuDto b : bintu) {
				Integer index = b.getWorkage();
				for (workage item : workage.values()) {
					if (index>= item.begin && index<=item.end) {
						item.number++;
						System.out.println("item"+ item+":"+item.number);
					}
				}
			}
			Map<String, Integer> result = new HashMap<String, Integer>();
			result.put("x<0.5", NEW.number);
			result.put("0.5<x<1", HALF.number);
			result.put("1<x<1.5", ONE.number);
			result.put("1.5<x<2", ONEHALF.number);
			result.put("2<x<3", TWO.number);
			result.put("x++", LONG.number);
			return result;
		}
		
		
	}
	
218
}