Commit 00232db0 by 太阳与水

重新从服务器拉代码,再重新上传新代码

parent 965434d0
/**
* @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;
import java.util.regex.Pattern;
import lombok.Getter;
/**
* @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();
}
}
}
......@@ -60,6 +60,7 @@ import cn.timer.api.dto.yggl.YgmzDto;
import cn.timer.api.bean.zzgl.ZzglBmgwM;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enuminterface.YgEnumInterface;
import cn.timer.api.config.enums.CommonEnum;
import cn.timer.api.dao.qyzx.QyzxEmpLoginMapper;
import cn.timer.api.dao.yggl.YgAreaDtoMapper;
......@@ -1054,17 +1055,12 @@ public class YgglController {
public Result<List<YgDrjqbDto>> ygdr(@CurrentUser UserBean userBean,@RequestBody YgDrsDto drList) {
drList.setOrgCode(userBean.getOrgCode());
YgDrsDto tofList = errorFilter(drList);//滤嘴,过滤信息
if (tofList.getDrList().size()==0) {
return ResultUtil.data(tofList.getErrorList(), "导入发生错误人员名单");
}
if (tofList.getDrList().size()==0) return ResultUtil.data(tofList.getErrorList(), "导入发生错误人员名单");
YgDrsDto tof = optFilter(tofList);//彻底规范好数据
List<YgDrjqbDto> trueList = tof.getDrList();//拿出正确的信息
List<YgDrjqbDto> errorList = tof.getErrorList();//拿出错误的信息
if (trueList.size()==0) {
return ResultUtil.data(errorList, "导入发生错误人员名单");
}
if (trueList.size()==0) return ResultUtil.data(errorList, "导入发生错误人员名单");
for (YgDrjqbDto e : trueList) {
QyzxEmpLogin login = new LambdaQueryChainWrapper<QyzxEmpLogin>(qyzxEmpLoginMapper).eq(QyzxEmpLogin::getPhone,e.getPhone()).one();
//证件类型为0
Integer jobType = Integer.valueOf(e.getJobType());//工作类型
......@@ -1072,17 +1068,14 @@ public class YgglController {
Integer sex=Integer.valueOf(e.getSex());//性别,还差一个岗位
Integer gw= e.getHavebmid();
String jobNum = e.getYgnbgh();
Integer jg = e.getJg();
Date birthday = e.getBirthday();
//入职日期
Date rzdate = new Date();
SimpleDateFormat straight = new SimpleDateFormat("yyyy-MM-dd");//正杠
SimpleDateFormat italics = new SimpleDateFormat("yyyy/MM/dd");//斜杠
SimpleDateFormat drop = new SimpleDateFormat("yyyy.MM.dd");//点
SimpleDateFormat didnot = new SimpleDateFormat("yyyyMMdd");//没有
if (e.getRzTime().indexOf("-")!=-1) {
try {
rzdate = straight.parse(e.getRzTime());
} catch (ParseException PException) {
PException.printStackTrace();
e.setError("请填写正确的时间格式");
......@@ -1092,7 +1085,7 @@ public class YgglController {
}
//判断是否已有员工登录表
if (login==null) {
if (login==null) {// 添加三张表
QyzxEmpLogin qyzxEmpLogin = QyzxEmpLogin.builder().phone(e.getPhone()).pw(Md5.md5("123456"))
.sts(CommonEnum.U_STS_ON.getType()).orgId(userBean.getOrgCode()).username(e.getName()).build();
if (!qyzxEmpLogin.insert()) {
......@@ -1101,7 +1094,6 @@ public class YgglController {
errorList.add(e);
continue;
}
// 添加三张表
// 员工权限表(未定)
// 员工企业关联表和员工档案,员工成长表(未定)
QyzxEmpEntAsso.builder().empNum(qyzxEmpLogin.getId()).orgCode(userBean.getOrgCode())
......@@ -1113,15 +1105,19 @@ public class YgglController {
.sex(sex).jobNum(jobNum).bmgwId(gw)
.empNum(qyzxEmpLogin.getId()).orgCode(userBean.getOrgCode()).build();
emp.insert();
boolean wanshan = new LambdaUpdateChainWrapper<YgglMainEmp>(ygglMainEmpMapper)
.eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
.eq(YgglMainEmp::getId, emp.getId())
.set(birthday!=null, YgglMainEmp::getBirthday, birthday)
.set(jg!=null && jg!=0, YgglMainEmp::getJg, jg).update();
//return ResultUtil.data(ygglMainEmp, "新添加员工档案成功!");
}else {
// 添加两张表
YgglMainEmp ishad = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>()
.eq("phone", e.getPhone()).eq("org_code", userBean.getOrgCode()));
if (ishad == null) {
// 员工权限表(未定)
QyzxEmpEntAsso.builder().empNum(login.getId()).orgCode(userBean.getOrgCode()).userType(2).build().insert();// 2普通员工
YgglMainEmp emp = YgglMainEmp.builder().name(e.getName()).phone(e.getPhone())
......@@ -1131,6 +1127,11 @@ public class YgglController {
.syq(syq).sex(sex)
.jobNum(jobNum).empNum(login.getId()).orgCode(userBean.getOrgCode()).build();
emp.insert();
boolean wanshan = new LambdaUpdateChainWrapper<YgglMainEmp>(ygglMainEmpMapper)
.eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
.eq(YgglMainEmp::getId, emp.getId())
.set(birthday!=null, YgglMainEmp::getBirthday, birthday)
.set(jg!=null && jg!=0, YgglMainEmp::getJg, jg).update();
//return ResultUtil.data(emp, "添加员工档案成功!");
} else {
e.setError("该手机号码已被使用");
......@@ -1160,7 +1161,7 @@ public class YgglController {
YgDrjqbDto d = newList.get(i);//计数器
if (itDr.hasNext()) {
a=itDr.next();
System.out.println("a为:"+a+"此时i为"+i);
}
//请填写必填项
String name = newList.get(i).getName(); String phone = newList.get(i).getPhone();
......@@ -1184,7 +1185,6 @@ public class YgglController {
boolean isMatch = m.matches();
if(!isMatch){
d.setError("手机号格式不对");
System.out.println("错误的手机号"+d);
errorList.add(d);itDr.remove();i++;continue;
}
//手机号码已被使用
......@@ -1201,8 +1201,12 @@ public class YgglController {
String regularExpression = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|" +
"(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)";
boolean matches = zj.matches(regularExpression);
if (zj.length() == 18) {
if (!matches) {
d.setError("证件号码信息有误");
errorList.add(d);itDr.remove();i++;continue;
}
try {
if (zj.length() == 18) {
char[] charArray = zj.toCharArray();
//前十七位加权因子
int[] idCardWi = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
......@@ -1217,7 +1221,12 @@ public class YgglController {
char idCardLast = charArray[17];
int idCardMod = sum % 11;
if (idCardY[idCardMod].toUpperCase().equals(String.valueOf(idCardLast).toUpperCase())) {
//System.out.println("成功");
//System.out.println("成功,接着完善员工的个人信息");
String birth = zj.substring(6, 14);
String birthday =birth.substring(0, 4)+"-"+birth.substring(4, 6)+"-"+birth.substring(6,8);
SimpleDateFormat straight = new SimpleDateFormat("yyyy-MM-dd");
d.setBirthday(straight.parse(birthday));
d.setJg(Integer.parseInt(zj.substring(0, 6)));
} else {
//System.out.println("身份证最后一位:" + String.valueOf(idCardLast).toUpperCase() +
// "错误,正确的应该是:" + idCardY[idCardMod].toUpperCase());
......@@ -1225,6 +1234,14 @@ public class YgglController {
d.setError("证件号码信息有误");
errorList.add(d);itDr.remove();i++;continue;
}
}else {
//给15位数的添加生日籍贯
String birth = zj.substring(6, 12);
String birthday = "19" + birth.substring(0, 2) + "-" + birth.substring(2, 4) + "-" + birth.substring(4, 6);
SimpleDateFormat straight = new SimpleDateFormat("yyyy-MM-dd");
d.setBirthday(straight.parse(birthday));
d.setJg(Integer.parseInt(zj.substring(0, 6)));
}
} catch (Exception e) {
e.printStackTrace();
//System.out.println("异常:" + zj);
......@@ -1232,7 +1249,6 @@ public class YgglController {
d.setError("证件号码信息有误");
errorList.add(d);itDr.remove();i++;continue;
}
}
//部门岗位有误
String oneb = newList.get(i).getOneb();String twob = newList.get(i).getTwob();
String threeb = newList.get(i).getThreeb();String fourb = newList.get(i).getFourb();
......@@ -1270,7 +1286,7 @@ public class YgglController {
Iterator<YgDrjqbDto> itDr = drList.iterator();
YgDrjqbDto a = drList.get(0);//一个员工导入
Integer size = drList.size();
for (Integer i=0; i<size;) {//
for (Integer i=0; i<size;i++) {//
YgDrjqbDto d = newList.get(i);//计数器
if (itDr.hasNext()) {
a=itDr.next();
......@@ -1297,96 +1313,17 @@ public class YgglController {
String bh = format.format(new Date())+orgCode+i+System.currentTimeMillis();
d.setYgnbgh(bh);
}
//男女
if (sex != null && sex.length() != 0) {
if (sex.indexOf("1")!=-1 || sex.indexOf("男")!=-1) {
d.setSex("1");
}
if (sex.indexOf("2")!=-1 || sex.indexOf("女")!=-1) {
d.setSex("2");
}
}else {
d.setSex("1");
}
//工作性质(需要优化)
if (jobType != null && jobType.length() != 0) {
//8种情况
if ((jobType.indexOf("1"))!=-1 || jobType.indexOf("全") !=-1) {
d.setJobType("1");
}
if ((jobType.indexOf("2"))!=-1 || jobType.indexOf("实习") !=-1) {
d.setJobType("2");
}
if ((jobType.indexOf("3"))!=-1 || jobType.indexOf("兼") !=-1) {
d.setJobType("3");
}
if ((jobType.indexOf("5"))!=-1 || jobType.indexOf("劳务") !=-1) {
d.setJobType("5");
}
if ((jobType.indexOf("6"))!=-1 || jobType.indexOf("派遣") !=-1) {
d.setJobType("6");
}
if ((jobType.indexOf("4"))!=-1 || jobType.indexOf("劳务派遣") !=-1) {
d.setJobType("4");
}
if ((jobType.indexOf("7"))!=-1 || jobType.indexOf("外包") !=-1) {
d.setJobType("7");
}
if ((jobType.indexOf("8"))!=-1 || jobType.indexOf("退休") !=-1) {
d.setJobType("8");
}
if (Integer.valueOf(d.getJobType())>8 ||Integer.valueOf(d.getJobType())<1 ) {
d.setError("填写工作性质有误!");
errorList.add(d);itDr.remove();i++;continue;
}
}else {
d.setJobType("1");
}
//员工状态(需要优化)
if (jobStatus != null && jobStatus.length() != 0) {
if ((jobStatus.indexOf("1"))!=-1 || jobStatus.indexOf("正") !=-1) {
d.setJobStatus("1");
}
if ((jobStatus.indexOf("2"))!=-1 || jobStatus.indexOf("试") !=-1) {
d.setJobStatus("2");
}
}else {
d.setJobStatus("1");
}
//入职日期(需要枚举)
//SimpleDateFormat straight = new SimpleDateFormat("yyyy-MM-dd");//正杠
//SimpleDateFormat italics = new SimpleDateFormat("yyyy/MM/dd");//斜杠
//SimpleDateFormat drop = new SimpleDateFormat("yyyy.MM.dd");//点
//SimpleDateFormat didnot = new SimpleDateFormat("yyyyMMdd");//没有
//试用期
if (syq != null && syq.length() != 0) {
if ((syq.indexOf("0"))!=-1 || syq.indexOf("无") !=-1) {
d.setSyq("0");
}
if ((syq.indexOf("1"))!=-1 || syq.indexOf("一") !=-1) {
d.setSyq("1");
}
if ((syq.indexOf("2"))!=-1 || syq.indexOf("二") !=-1) {
d.setSyq("2");
}
if ((syq.indexOf("3"))!=-1 || syq.indexOf("三") !=-1) {
d.setSyq("3");
}
if ((syq.indexOf("4"))!=-1 || syq.indexOf("四") !=-1) {
d.setSyq("4");
}
if ((syq.indexOf("5"))!=-1 || syq.indexOf("五") !=-1) {
d.setSyq("5");
}
if ((syq.indexOf("6"))!=-1 || syq.indexOf("六") !=-1) {
d.setSyq("6");
}
}else {
d.setSyq("0");
}
i++;
//男女(最大优化)
d.setSex(YgEnumInterface.sex.isMan(sex));
//工作性质(最大优化)
d.setJobType(YgEnumInterface.YgJobType.choose(jobType));
//员工状态(最大优化)
d.setJobStatus(YgEnumInterface.jobStatus.isZhen(jobStatus));
//入职日期(已优化)
d.setRzTime(YgEnumInterface.rzTime.tranTime2(YgEnumInterface.rzTime.tranTime(rzTime)));
//试用期(已优化)
d.setSyq(YgEnumInterface.syq.choose(syq));
}
YgDrsDto clear = new YgDrsDto(drList, errorList, orgCode);
return clear;
......@@ -1513,7 +1450,7 @@ public class YgglController {
String isCity =id.toString().substring(4,6);
if ("00".equals(isPro)) {
YgProDto pro = new LambdaQueryChainWrapper<YgProDto>(ygProDtoMapper).select(YgProDto::getId,YgProDto::getName).eq(YgProDto::getId, id).one();
if (pro!=null ) { return ResultUtil.data(pro.getName(),"显示所在籍贯"); }}
if (pro!=null) { return ResultUtil.data(pro.getName(),"显示所在籍贯"); }}
if ("00".equals(isCity)) {
YgCityDto city = new LambdaQueryChainWrapper<YgCityDto>(ygCityDtoMapper).select(YgCityDto::getId,YgCityDto::getName).eq(YgCityDto::getId, id).one();
if (city!=null ) { return ResultUtil.data(city.getName(),"显示所在籍贯"); }}
......
package cn.timer.api.dto.yggl;
import java.util.Date;
import javax.persistence.Transient;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -79,6 +85,14 @@ public class YgDrjqbDto {
@ApiModelProperty(value="个人邮箱 ",example="个人邮箱")
private String email;
@Transient
@TableField(exist = false)//籍贯
private Integer jg;
@Transient
@TableField(exist = false)//生日
private Date birthday;
@ApiModelProperty(value="错误信息",example="错误信息")
private String error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment