Browse Source

人员组织导入导出

luojing 5 years ago
parent
commit
bd6a3ddb34

+ 183 - 23
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/export/ActionExportAll.java

@@ -66,6 +66,8 @@ public class ActionExportAll extends BaseAction {
 			this.listUnit(business);
 			this.listUnit(business);
 			this.listPerson(business);
 			this.listPerson(business);
 			this.listIdentity(business);
 			this.listIdentity(business);
+			this.listDuty(business);
+			this.listGroup(business);
 		} catch (Exception e) {
 		} catch (Exception e) {
 			logger.info("系统在查询所有组织人员信息时发生异常。" );
 			logger.info("系统在查询所有组织人员信息时发生异常。" );
 			e.printStackTrace();
 			e.printStackTrace();
@@ -87,7 +89,17 @@ public class ActionExportAll extends BaseAction {
 
 
 		// 将人员身份信息结果组织成EXCEL		
 		// 将人员身份信息结果组织成EXCEL		
 		if( ListTools.isNotEmpty(allPersonList) ) {
 		if( ListTools.isNotEmpty(allPersonList) ) {
-			this.composePerson( business, "人员身份信息", allPersonList );
+			this.composeIdentity( business, "人员身份信息", allIdentityList );
+		}
+		
+		// 将职务信息结果组织成EXCEL		
+		if( ListTools.isNotEmpty(allDutyList) ) {
+			this.composeDuty( business, "职务信息", allDutyList );
+		}
+		
+		// 将群组信息结果组织成EXCEL		
+		if( ListTools.isNotEmpty(allGroupList) ) {
+			this.composeGroup( business, "群组信息", allGroupList );
 		}
 		}
 		
 		
 		if( wb != null ) {
 		if( wb != null ) {
@@ -138,6 +150,22 @@ public class ActionExportAll extends BaseAction {
 		Root<Identity> root = cq.from(Identity.class);
 		Root<Identity> root = cq.from(Identity.class);
 		allIdentityList = em.createQuery(cq.select(root)).getResultList();
 		allIdentityList = em.createQuery(cq.select(root)).getResultList();
 	}
 	}
+	
+	private void listDuty(Business business) throws Exception {
+		EntityManager em = business.entityManagerContainer().get(UnitDuty.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<UnitDuty> cq = cb.createQuery(UnitDuty.class);
+		Root<UnitDuty> root = cq.from(UnitDuty.class);
+		allDutyList = em.createQuery(cq.select(root)).getResultList();
+	}
+	
+	private void listGroup(Business business) throws Exception {
+		EntityManager em = business.entityManagerContainer().get(Group.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<Group> cq = cb.createQuery(Group.class);
+		Root<Group> root = cq.from(Group.class);
+		allGroupList = em.createQuery(cq.select(root)).getResultList();
+	}
 
 
 	private List<Unit> listTopUnit(Business business) throws Exception {
 	private List<Unit> listTopUnit(Business business) throws Exception {
 		EntityManager em = business.entityManagerContainer().get(Unit.class);
 		EntityManager em = business.entityManagerContainer().get(Unit.class);
@@ -243,10 +271,10 @@ public class ActionExportAll extends BaseAction {
 			// 先创建表头
 			// 先创建表头
 			row = sheet.createRow(0);
 			row = sheet.createRow(0);
 			row.createCell(0).setCellValue("人员行姓名 *");
 			row.createCell(0).setCellValue("人员行姓名 *");
-			row.createCell(1).setCellValue("人员编号 *");
-			row.createCell(2).setCellValue("登录账号 *");
-			row.createCell(3).setCellValue("手机号码 *");
-			row.createCell(4).setCellValue("身份证号 *");
+			row.createCell(1).setCellValue("员工账号 *");
+			row.createCell(2).setCellValue("手机号码 *");
+			row.createCell(3).setCellValue("人员编号");
+			row.createCell(4).setCellValue("办公电话");
 			row.createCell(5).setCellValue("性别");
 			row.createCell(5).setCellValue("性别");
 			row.createCell(6).setCellValue("邮件");
 			row.createCell(6).setCellValue("邮件");
 
 
@@ -255,19 +283,9 @@ public class ActionExportAll extends BaseAction {
 				row = sheet.createRow(i + 1);
 				row = sheet.createRow(i + 1);
 				row.createCell(0).setCellValue(person.getName());
 				row.createCell(0).setCellValue(person.getName());
 				row.createCell(1).setCellValue(person.getUnique());
 				row.createCell(1).setCellValue(person.getUnique());
-				row.createCell(2).setCellValue(person.getEmployee());
-				row.createCell(3).setCellValue(person.getMobile());
-				
-				if(StringUtils.isNotEmpty(person.getId())){
-					List<PersonAttribute> personAttributeList = this.listAttributeWithPerson(business,person.getId());
-					if(ListTools.isNotEmpty(personAttributeList)){
-						for(PersonAttribute o : personAttributeList){
-							if("idNumber".equals(o.getName())){
-								row.createCell(4).setCellValue(o.getAttributeList().get(0));
-							}
-						}
-					}
-				}
+				row.createCell(2).setCellValue(person.getMobile());
+				row.createCell(3).setCellValue(person.getEmployee());
+				row.createCell(4).setCellValue(person.getOfficePhone());
 				row.createCell(5).setCellValue(person.getGenderType().toString());
 				row.createCell(5).setCellValue(person.getGenderType().toString());
 				row.createCell(6).setCellValue(person.getMail());
 				row.createCell(6).setCellValue(person.getMail());
 				
 				
@@ -285,11 +303,10 @@ public class ActionExportAll extends BaseAction {
 			
 			
 			// 先创建表头
 			// 先创建表头
 			row = sheet.createRow(0);
 			row = sheet.createRow(0);
-			row.createCell(0).setCellValue("人员编号 *");
+			row.createCell(0).setCellValue("员工账号 *");
 			row.createCell(1).setCellValue("组织编号 *");
 			row.createCell(1).setCellValue("组织编号 *");
-			row.createCell(2).setCellValue("登录账号 *");
-			row.createCell(3).setCellValue("职务编号");
-			row.createCell(4).setCellValue("主兼职");
+			row.createCell(2).setCellValue("职务编号");
+			row.createCell(3).setCellValue("主兼职");
 
 
 			for (int i = 0; i < identityList.size(); i++) {
 			for (int i = 0; i < identityList.size(); i++) {
 				identity = identityList.get(i);
 				identity = identityList.get(i);
@@ -299,15 +316,158 @@ public class ActionExportAll extends BaseAction {
 				if(person != null){
 				if(person != null){
 					row.createCell(0).setCellValue(person.getUnique());
 					row.createCell(0).setCellValue(person.getUnique());
 					if(unit != null){
 					if(unit != null){
+						String iduty = "";
+						String unitId = "";
+						unitId = unit.getId();
 						row.createCell(1).setCellValue(unit.getUnique());
 						row.createCell(1).setCellValue(unit.getUnique());
 						List<UnitDuty> unitDutyList =  this.listDutyWithIdentity(business,identity.getId());
 						List<UnitDuty> unitDutyList =  this.listDutyWithIdentity(business,identity.getId());
+						
 						if(ListTools.isNotEmpty(unitDutyList)){
 						if(ListTools.isNotEmpty(unitDutyList)){
+							for(UnitDuty duty :unitDutyList){
+								if(unitId.equals(duty.getUnit())){
+									iduty = duty.getUnique();
+								}
+							}
+							
+						}
+						row.createCell(2).setCellValue(iduty);
+						row.createCell(3).setCellValue(String.valueOf(identity.getMajor()));
+					}
+				}	
+				
+			}
+		}
+	}
+	
+	private void composeDuty(Business business, String sheetName, List<UnitDuty> dutyList) throws Exception {
+		UnitDuty duty = null;
+		
+		Row row = null;
+		if (ListTools.isNotEmpty(dutyList) ) {
+			// 创建新的表格
+			Sheet sheet = wb.createSheet(sheetName);
+			
+			// 先创建表头
+			row = sheet.createRow(0);
+			row.createCell(0).setCellValue("职务编号 *");
+			row.createCell(1).setCellValue("职务名称 *");
+			row.createCell(2).setCellValue("职务描述");
+
+			for (int i = 0; i < dutyList.size(); i++) {
+				duty = dutyList.get(i);
+				row = sheet.createRow(i + 1);
+				row.createCell(0).setCellValue(duty.getUnique());
+				row.createCell(1).setCellValue(duty.getName());
+				row.createCell(2).setCellValue(duty.getDescription());
+			}
+		}
+	}
+	
+	private void composeGroup(Business business, String sheetName, List<Group> groupList) throws Exception {
+		Group group = null;
+		
+		Row row = null;
+		if (ListTools.isNotEmpty(groupList) ) {
+			EntityManagerContainer emc = business.entityManagerContainer();
+			// 创建新的表格
+			Sheet sheet = wb.createSheet(sheetName);
+			
+			// 先创建表头
+			row = sheet.createRow(0);
+			row.createCell(0).setCellValue("群组名称 *");
+			row.createCell(1).setCellValue("群组编号 *");
+			row.createCell(2).setCellValue("人员编号");
+			row.createCell(3).setCellValue("组织编号");
+			row.createCell(4).setCellValue("群组编号");
+			row.createCell(5).setCellValue("描述");
+
+			for (int i = 0; i < groupList.size(); i++) {
+				group = groupList.get(i);
+				row = sheet.createRow(i + 1);
+				List<String> personList = group.getPersonList();
+				List<String> unitList = group.getUnitList();
+				List<String> groupsList = group.getGroupList();
+				System.out.println("personList="+personList.size());
+				System.out.println("unitList="+unitList.size());
+				System.out.println("groupsList="+groupsList.size());
+				if(ListTools.isNotEmpty(personList)){
+					for(String personId : personList){
+						Person person = emc.flag(personId, Person.class);
+						if(person != null){
+							row.createCell(0).setCellValue(group.getName());
+							row.createCell(1).setCellValue(group.getUnique());
+							row.createCell(2).setCellValue(person.getUnique());
+							row.createCell(3).setCellValue("");
+							row.createCell(4).setCellValue("");
+						}else{
+							row.createCell(0).setCellValue(group.getName());
+							row.createCell(1).setCellValue(group.getUnique());
 							row.createCell(2).setCellValue("");
 							row.createCell(2).setCellValue("");
+							row.createCell(3).setCellValue("");
+							row.createCell(4).setCellValue("");
 						}
 						}
+					} 
+					
+					/*if(ListTools.isNotEmpty(unitList)){
+						for(String unitId : unitList){
+							Unit unit = emc.flag(unitId, Unit.class);
+							if(unit != null){
+								row.createCell(0).setCellValue(group.getName());
+								row.createCell(1).setCellValue(group.getUnique());
+								row.createCell(2).setCellValue("");
+								row.createCell(3).setCellValue(unit.getUnique());
+								row.createCell(4).setCellValue("");
+							}else{
+								row.createCell(0).setCellValue(group.getName());
+								row.createCell(1).setCellValue(group.getUnique());
+								row.createCell(2).setCellValue("");
+								row.createCell(3).setCellValue("");
+								row.createCell(4).setCellValue("");
+							}
+						} 
+					}else{
+						row.createCell(0).setCellValue(group.getName());
+						row.createCell(1).setCellValue(group.getUnique());
+						row.createCell(2).setCellValue("");
 						row.createCell(3).setCellValue("");
 						row.createCell(3).setCellValue("");
+						row.createCell(4).setCellValue("");
 					}
 					}
-				}	
+					
+					if(ListTools.isNotEmpty(groupsList)){
+						for(String groupId : groupsList){
+							Group grouptemp = emc.flag(groupId, Group.class);
+							if(grouptemp != null){
+								row.createCell(0).setCellValue(group.getName());
+								row.createCell(1).setCellValue(group.getUnique());
+								row.createCell(2).setCellValue("");
+								row.createCell(3).setCellValue("");
+								row.createCell(4).setCellValue(grouptemp.getUnique());
+							}else{
+								row.createCell(0).setCellValue(group.getName());
+								row.createCell(1).setCellValue(group.getUnique());
+								row.createCell(2).setCellValue("");
+								row.createCell(3).setCellValue("");
+								row.createCell(4).setCellValue("");
+							}
+						} 
+					}else{
+						row.createCell(0).setCellValue(group.getName());
+						row.createCell(1).setCellValue(group.getUnique());
+						row.createCell(2).setCellValue("");
+						row.createCell(3).setCellValue("");
+						row.createCell(4).setCellValue("");
+					}*/
+					
+				}else{
+					row.createCell(0).setCellValue(group.getName());
+					row.createCell(1).setCellValue(group.getUnique());
+					row.createCell(2).setCellValue("");
+					row.createCell(3).setCellValue("");
+					row.createCell(4).setCellValue("");
+				}
+				
 				
 				
+				row.createCell(5).setCellValue(group.getDescription());
 			}
 			}
 		}
 		}
 	}
 	}

+ 17 - 16
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionInputAll.java

@@ -186,8 +186,6 @@ class ActionInputAll extends BaseAction {
 			if(!dutyFlag){
 			if(!dutyFlag){
 				wholeFlag = this.checkIdentity(business, workbook, configuratorIdentity, sheet,persons,units); 
 				wholeFlag = this.checkIdentity(business, workbook, configuratorIdentity, sheet,persons,units); 
 				if(wholeFlag){
 				if(wholeFlag){
-						//校验群组
-						wholeFlag = this.checkGroup(business,workbook,person,unit);
 						
 						
 						if(wholeFlag){
 						if(wholeFlag){
 							//保存组织,人员
 							//保存组织,人员
@@ -201,6 +199,8 @@ class ActionInputAll extends BaseAction {
 							this.persistDuty(workbook, configuratorDuty, duty);
 							this.persistDuty(workbook, configuratorDuty, duty);
 							
 							
 							//保存群组
 							//保存群组
+							//校验群组
+							wholeFlag = this.checkGroup(business,workbook,person,unit);
 							this.scanGroup(business,workbook,person,unit);
 							this.scanGroup(business,workbook,person,unit);
 							this.persistGroup(business,workbook, configuratorGroup, group);
 							this.persistGroup(business,workbook, configuratorGroup, group);
 						}
 						}
@@ -351,25 +351,26 @@ class ActionInputAll extends BaseAction {
 					personItem.setName(name);
 					personItem.setName(name);
 					personItem.setGenderType(genderType);
 					personItem.setGenderType(genderType);
 					personItem.setMobile(mobile);
 					personItem.setMobile(mobile);
-					if (null != configurator.getUniqueColumn()) {
-						String unique = configurator.getCellStringValue(row.getCell(configurator.getUniqueColumn()));
-						unique = StringUtils.trimToEmpty(unique);
-						personItem.setUnique(unique);
-					}
+			
 					if (null != configurator.getEmployeeColumn()) {
 					if (null != configurator.getEmployeeColumn()) {
 						String employee = configurator
 						String employee = configurator
 								.getCellStringValue(row.getCell(configurator.getEmployeeColumn()));
 								.getCellStringValue(row.getCell(configurator.getEmployeeColumn()));
 						employee = StringUtils.trimToEmpty(employee);
 						employee = StringUtils.trimToEmpty(employee);
 						personItem.setEmployee(employee);
 						personItem.setEmployee(employee);
-						if(null == configurator.getUniqueColumn()){
-							personItem.setUnique(employee);
+					}
+					if (null != configurator.getUniqueColumn()) {
+						String unique = configurator.getCellStringValue(row.getCell(configurator.getUniqueColumn()));
+						unique = StringUtils.trimToEmpty(unique);
+						personItem.setUnique(unique);
+						
+						if(null == configurator.getEmployeeColumn()){
+							personItem.setEmployee(unique);
 						}
 						}
 					}
 					}
-					
 					if (null != configurator.getOfficePhoneColumn()) {
 					if (null != configurator.getOfficePhoneColumn()) {
 						String officePhone = configurator.getCellStringValue(row.getCell(configurator.getOfficePhoneColumn()));
 						String officePhone = configurator.getCellStringValue(row.getCell(configurator.getOfficePhoneColumn()));
 						officePhone = StringUtils.trimToEmpty(officePhone);
 						officePhone = StringUtils.trimToEmpty(officePhone);
-						personItem.setUnique(officePhone);
+						personItem.setOfficePhone(officePhone);
 					}
 					}
 					if (null != configurator.getMailColumn()) {
 					if (null != configurator.getMailColumn()) {
 						String mail = configurator.getCellStringValue(row.getCell(configurator.getMailColumn()));
 						String mail = configurator.getCellStringValue(row.getCell(configurator.getMailColumn()));
@@ -627,8 +628,8 @@ class ActionInputAll extends BaseAction {
 				validate = false;
 				validate = false;
 				continue;
 				continue;
 			}*/
 			}*/
-			if (StringUtils.isEmpty(o.getEmployee())) {
-				this.setPersonMemo(workbook, configurator, o, "登录账号不能为空.");
+			if (StringUtils.isEmpty(o.getUnique())) {
+				this.setPersonMemo(workbook, configurator, o, "员工账号不能为空.");
 				validate = false;
 				validate = false;
 				continue;
 				continue;
 			}
 			}
@@ -647,7 +648,7 @@ class ActionInputAll extends BaseAction {
 			for (PersonItem o : person) {
 			for (PersonItem o : person) {
 				for (PersonItem item : person) {
 				for (PersonItem item : person) {
 					if (o != item) {
 					if (o != item) {
-						if (StringUtils.isNotEmpty(o.getEmployee()) && StringUtils.equals(o.getEmployee(), item.getEmployee())) {
+						if (StringUtils.isNotEmpty(o.getUnique()) && StringUtils.equals(o.getUnique(), item.getUnique())) {
 							this.setPersonMemo(workbook, configurator, o, "员工账号冲突,本次导入中不唯一.");
 							this.setPersonMemo(workbook, configurator, o, "员工账号冲突,本次导入中不唯一.");
 							validate = false;
 							validate = false;
 							continue;
 							continue;
@@ -658,7 +659,7 @@ class ActionInputAll extends BaseAction {
 				Person p = null;
 				Person p = null;
 				p = emc.flag(o.getUnique(), Person.class);
 				p = emc.flag(o.getUnique(), Person.class);
 				if (null != p) {
 				if (null != p) {
-					this.setPersonMemo(workbook, configurator, o, "人员: " + o.getName() + " 与已经存在人员: " + p.getName() + " 冲突.");
+					this.setPersonMemo(workbook, configurator, o, "员工账号: " + o.getUnique() + " 与已经存在人员: " + p.getName() + " 冲突.");
 					validate = false;
 					validate = false;
 					continue;
 					continue;
 				}
 				}
@@ -718,7 +719,7 @@ class ActionInputAll extends BaseAction {
 					personcheck = true;
 					personcheck = true;
 				}else{
 				}else{
 					for (PersonItem personItem : persons) {
 					for (PersonItem personItem : persons) {
-						if (StringUtils.isNotEmpty(personItem.getEmployee()) && StringUtils.equals(personItem.getEmployee(), unique)) {
+						if (StringUtils.isNotEmpty(personItem.getUnique()) && StringUtils.equals(personItem.getUnique(), unique)) {
 							personcheck = true;
 							personcheck = true;
 						}
 						}
 					}
 					}

+ 1 - 1
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ExceptionEmployeeColumnEmpty.java

@@ -7,6 +7,6 @@ class ExceptionEmployeeColumnEmpty extends PromptException {
 	private static final long serialVersionUID = -2139584911736169462L;
 	private static final long serialVersionUID = -2139584911736169462L;
 
 
 	ExceptionEmployeeColumnEmpty() {
 	ExceptionEmployeeColumnEmpty() {
-		super("登录账号列不能为空.");
+		super("员工账号列不能为空.");
 	}
 	}
 }
 }

+ 2 - 2
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/PersonSheetConfigurator.java

@@ -74,8 +74,8 @@ public class PersonSheetConfigurator extends GsonPropertyObject {
 	}
 	}
 
 
 	private static List<String> nameItems = Arrays.asList(new String[] { "人员姓名 *", "人员姓名", "name" });
 	private static List<String> nameItems = Arrays.asList(new String[] { "人员姓名 *", "人员姓名", "name" });
-	private static List<String> uniqueItems = Arrays.asList(new String[] { "人员编号 *", "人员编号", "unique" });
-	private static List<String> employeeItems = Arrays.asList(new String[] { "登录账号 *", "员工账号 *", "employee" });
+	private static List<String> employeeItems = Arrays.asList(new String[] { "人员编号 *", "人员编号", "unique" });
+	private static List<String> uniqueItems = Arrays.asList(new String[] { "登录账号 *", "员工账号 *", "employee" });
 	private static List<String> mobileItems = Arrays.asList(new String[] { "手机号码 *", "手机", "联系电话", "phone", "mobile" });
 	private static List<String> mobileItems = Arrays.asList(new String[] { "手机号码 *", "手机", "联系电话", "phone", "mobile" });
 	private static List<String> officePhoneItems = Arrays.asList(new String[] { "办公电话", "办公室电话", "工作电话", "officePhone" });
 	private static List<String> officePhoneItems = Arrays.asList(new String[] { "办公电话", "办公室电话", "工作电话", "officePhone" });
 	private static List<String> mailItems = Arrays.asList(new String[] { "电子邮件", "邮件", "邮箱", "邮件地址", "mail", "email" });
 	private static List<String> mailItems = Arrays.asList(new String[] { "电子邮件", "邮件", "邮箱", "邮件地址", "mail", "email" });