package com.fgkj.services;
|
|
import com.fgkj.dto.User_inf;
|
import com.fgkj.dto.User_task;
|
import com.fgkj.mapper.impl.User_infMapper;
|
import com.fgkj.mapper.impl.User_taskMapper;
|
import com.fgkj.util.ActionUtil;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class UtilityFactoryService {
|
@Resource
|
private User_infMapper userInfMapper;
|
@Resource
|
private User_taskMapper userTaskMapper;
|
|
//字符串的uids转换为unames
|
/*public String UidsToUnames(String uids){
|
String uname[]=uids.split(",");
|
String unames="";
|
for(int i=0;i<uname.length;i++){
|
int uid=Integer.parseInt(uname[i]);
|
User_inf uinf=new User_inf();
|
uinf.setuId(uid);
|
List<User_inf> list=new User_infImpl().serchUname(uinf);
|
if(list!=null&&list.size()>0){
|
unames+=list.get(0).getuName();
|
}
|
unames+=",";
|
}
|
//System.out.println(unames.substring(0,unames.length()-1));
|
return unames.substring(0,unames.length()-1);
|
}*/
|
|
public String UidsToUnames(String uids) {
|
// String unames = "";
|
// List list = userInfMapper.searchUnams(uids);
|
// //System.out.println(uids+"****");
|
// //System.out.println(list.size()+"****");
|
// if(list != null && list.size()>0){
|
// unames = list.get(0).toString();
|
// //System.out.println(unames);
|
// }
|
return userInfMapper.searchUnams(uids);
|
}
|
|
//增加员工时自动生成员工的name
|
public String CreateUname() {
|
String name = "name";
|
//String []uname=new String[20]; //后台uname数据按照name1,name2排序
|
ArrayList<String> uname = new ArrayList<String>();
|
String nameNew = "";
|
List<User_inf> list = userInfMapper.serchinfoUname();
|
//System.out.println(list.size());
|
if (list != null && list.size() > 0) {
|
for (int i = 0; i < list.size(); i++) {
|
if (list.get(i).getuName().equals("name")) {
|
uname.add("0");
|
} else {
|
uname.add(list.get(i).getuName().replace("name", ""));
|
}
|
|
}
|
}
|
// for(String s:uname){
|
// System.out.println(s);
|
// }
|
// System.out.println("----------------");
|
for (int i = uname.size() - 1; i > 0; i--) {
|
for (int j = 0; j < i; j++) {
|
if (Integer.parseInt(uname.get(j)) >= Integer.parseInt(uname.get(j + 1))) {
|
String change = "";
|
change = uname.get(j);
|
uname.set(j, uname.get(j + 1));
|
uname.set(j + 1, change);
|
}
|
}
|
}
|
// for(String s:uname){
|
// System.out.println(s);
|
// }
|
int j = 1;
|
//System.out.println(uname.size());
|
while (j < uname.size()) {
|
if (j != Integer.parseInt(uname.get(j))) {
|
nameNew = name + String.valueOf(j);
|
break;
|
}
|
j++;
|
}
|
if (j == uname.size()) {
|
nameNew = name + String.valueOf(j);
|
}
|
//System.out.println(nameNew);
|
return nameNew;
|
}
|
|
//uSnId,uPassword,uName,uShenFenId,uEmployeeId,uTelephone,uMobilephone,uEmail,uAddr,uBirthday,uAccessionDay," +
|
//"uSex,uDepartment,uProTitle,uAuthority,uJobGroup,uDuties,uTasks,uBaojiusr,uNote
|
public User_inf CreateUinf() {
|
User_inf uinf = new User_inf();
|
List<User_inf> list = userInfMapper.searchAll();
|
|
if (list != null && list.size() > 0) {
|
uinf = list.get(list.size() - 1);
|
uinf.setuSnId("123456");
|
uinf.setUpassword((String) ActionUtil.EncryptionMD5(uinf.getuSnId()));
|
uinf.setuName(CreateUname());
|
} else {
|
uinf.setuId(0);
|
uinf.setuSnId("admin");
|
uinf.setUpassword((String) ActionUtil.EncryptionMD5(uinf.getuSnId()));
|
uinf.setuName("admin");
|
uinf.setuShenFenId("admin");
|
uinf.setuEmployeeId("employeeid");
|
uinf.setuTelephone("12345678");
|
|
uinf.setuMobilephone("12345678912");
|
|
uinf.setuEmail("abcde@mail.com");
|
|
uinf.setuAddr("abcde");
|
|
uinf.setuBirthDay(ActionUtil.getSimpDate(new Date(1980, 1, 1)));
|
|
uinf.setuAccessionDay(ActionUtil.getSimpDate(new Date(2001, 01, 01)));
|
|
uinf.setuSex("男");
|
|
uinf.setuDepartment("一枢纽");
|
|
uinf.setuProTitle("protitle");
|
|
uinf.setuAuthority("authority");
|
|
uinf.setuJobGroup("jobgroup");
|
|
uinf.setuDuties("duties");
|
|
uinf.setuTasks("tasks");
|
|
uinf.setuBaojiusr(0);
|
|
uinf.setuNote("note");
|
}
|
|
return uinf;
|
}
|
|
//获取新增的utask的task_id
|
public int CreateTask() {
|
int task_id = 0;//存放自动生成的task_id
|
List<User_task> list = userTaskMapper.serchMaxId();
|
if (list != null && list.size() > 0) {
|
// System.out.println(list.get(list.size()-1));
|
task_id = list.get(list.size() - 1).getTask_id() + 1;
|
}
|
return task_id;
|
}
|
|
//两个uids合并并去除相同项
|
public String concatString(String str1, String str2) {
|
String[] strArray1 = str1.split(","); //拆分字符为"," ,然后把结果交给数组strArray
|
ArrayList<String> listStr1 = new ArrayList<String>();
|
for (int i = 0; i < strArray1.length; i++) {
|
listStr1.add(strArray1[i]);
|
}
|
String[] strArray2 = str2.split(","); //拆分字符为"," ,然后把结果交给数组strArray
|
ArrayList<String> listStr2 = new ArrayList<String>();
|
for (int i = 0; i < strArray2.length; i++) {
|
listStr2.add(strArray2[i]);
|
}
|
List<String> temp = new ArrayList<String>(listStr1);//用来保存两者共同有的数据
|
temp.retainAll(listStr2);//temp中只保留两者共同的数据
|
listStr1.removeAll(temp);//l1中去掉两者共同有的数据
|
List<String> listStr3 = new ArrayList<String>();
|
listStr3.addAll(listStr1);
|
listStr3.addAll(listStr2);
|
String uids = "";//存放最后的结果
|
for (String s : listStr3) {
|
uids += s;
|
uids += ",";
|
}
|
return uids.substring(0, uids.length() - 1);
|
}
|
}
|