diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/export/ActionExportAll.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/export/ActionExportAll.java index beedf559b33c9c13add9a907130d55c54b99101c..23e58584ed2cfd5f600a635f32bbd92bcafd7051 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/export/ActionExportAll.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/export/ActionExportAll.java @@ -1,10 +1,8 @@ package com.x.organization.assemble.control.jaxrs.export; import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.util.*; +import java.util.stream.Collectors; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; @@ -13,18 +11,13 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import javax.servlet.http.HttpServletRequest; +import com.x.base.core.project.connection.ActionResponse; import com.x.base.core.project.tools.DateTools; import com.x.base.core.project.tools.ListTools; +import com.x.base.core.project.x_organization_assemble_control; import com.x.organization.assemble.control.Business; -import com.x.organization.core.entity.Group; -import com.x.organization.core.entity.Identity; -import com.x.organization.core.entity.Person; -import com.x.organization.core.entity.PersonAttribute; -import com.x.organization.core.entity.PersonAttribute_; -import com.x.organization.core.entity.Unit; -import com.x.organization.core.entity.UnitDuty; -import com.x.organization.core.entity.UnitDuty_; -import com.x.organization.core.entity.Unit_; +import com.x.organization.assemble.control.ThisApplication; +import com.x.organization.core.entity.*; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -47,7 +40,9 @@ public class ActionExportAll extends BaseAction { private static Logger logger = LoggerFactory.getLogger(ActionExportAll.class); List allUnitList = new ArrayList<>(); + List allUnitAttributeList = new ArrayList<>(); List allPersonList = new ArrayList<>(); + List allPersonAttributeList = new ArrayList<>(); List allIdentityList = new ArrayList<>(); List allDutyList = new ArrayList<>(); List allGroupList = new ArrayList<>(); @@ -79,31 +74,21 @@ public class ActionExportAll extends BaseAction { //创建说明sheet this.createNoticeSheet(); - // 将组织信息结果组织成EXCEL - if( ListTools.isNotEmpty(allUnitList) ) { - this.composeUnit( business, "组织信息", allUnitList ); - } - - // 将人员基础信息结果组织成EXCEL - if( ListTools.isNotEmpty(allPersonList) ) { - this.composePerson( business, "人员基本信息", allPersonList ); - } + // 将组织信息结果组织成EXCEL + this.composeUnit( business, "组织信息", allUnitList ); - // 将人员身份信息结果组织成EXCEL - if( ListTools.isNotEmpty(allPersonList) ) { - this.composeIdentity( business, "人员身份信息", allIdentityList ); - } - - // 将职务信息结果组织成EXCEL - if( ListTools.isNotEmpty(allDutyList) ) { - this.composeDuty( business, "职务信息", allDutyList ); - } - - // 将群组信息结果组织成EXCEL - if( ListTools.isNotEmpty(allGroupList) ) { - this.composeGroup( business, "群组信息", allGroupList ); - } + // 将人员基础信息结果组织成EXCEL + this.composePerson( business, "人员基本信息", allPersonList ); + + // 将人员身份信息结果组织成EXCEL + this.composeIdentity( business, "人员身份信息", allIdentityList ); + // 将职务信息结果组织成EXCEL + this.composeDuty( business, "职务信息", allDutyList ); + + // 将群组信息结果组织成EXCEL + this.composeGroup( business, "群组信息", allGroupList ); + if( wb != null ) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { @@ -134,6 +119,17 @@ public class ActionExportAll extends BaseAction { if(ListTools.isNotEmpty(allUnitList)){ allUnitList = business.unit().sort(allUnitList); + for(Unit unit:allUnitList){ + List us = this.ListUnitAttributes("unitattribute/list/unit/",unit.getId()); + if(ListTools.isNotEmpty(us)){ + for(UnitAttribute u : us){ + String uName = u.getName(); + if(StringUtils.isNotEmpty(uName) && !allUnitAttributeList.contains(uName)){ + allUnitAttributeList.add(uName); + } + } + } + } } } @@ -143,6 +139,17 @@ public class ActionExportAll extends BaseAction { CriteriaQuery cq = cb.createQuery(Person.class); Root root = cq.from(Person.class); allPersonList = em.createQuery(cq.select(root)).getResultList(); + if(ListTools.isNotEmpty(allPersonList)){ + for(Person person:allPersonList){ + List ps = this.listAttributeWithPerson(business,person.getId()); + for(PersonAttribute o:ps){ + String pName = o.getName(); + if(StringUtils.isNotEmpty(pName) && !allPersonAttributeList.contains(pName)){ + allPersonAttributeList.add(pName); + } + } + } + } } private void listIdentity(Business business) throws Exception { @@ -228,6 +235,11 @@ public class ActionExportAll extends BaseAction { row.createCell(3).setCellValue("上级组织编号"); row.createCell(4).setCellValue("描述"); row.createCell(5).setCellValue("排序号"); + if(ListTools.isNotEmpty(allUnitAttributeList)){ + for(int n = 0; n < allUnitAttributeList.size(); n++){ + row.createCell(5+n+1).setCellValue("("+allUnitAttributeList.get(n)+")"); + } + } for (int i = 0; i < unitList.size(); i++) { unit = unitList.get(i); @@ -255,7 +267,20 @@ public class ActionExportAll extends BaseAction { } row.createCell(4).setCellValue(unit.getDescription()); row.createCell(5).setCellValue(unit.getOrderNumber()+""); - + List os= this.ListUnitAttributes("unitattribute/list/unit/",unit.getId()); + if(ListTools.isNotEmpty(allUnitAttributeList) && ListTools.isNotEmpty(os)){ + for(int m = 0; m < allUnitAttributeList.size(); m++){ + String uName = allUnitAttributeList.get(m); + String uValue = ""; + for(UnitAttribute o : os){ + if(uName.equals(o.getName())){ + //uValue = o.getAttributeList().toString(); + uValue = String.join(",", o.getAttributeList().stream().map(String::valueOf).collect(Collectors.toList())); + } + } + row.createCell(5+m+1).setCellValue(uValue); + } + } } } } @@ -277,6 +302,11 @@ public class ActionExportAll extends BaseAction { row.createCell(4).setCellValue("办公电话"); row.createCell(5).setCellValue("性别"); row.createCell(6).setCellValue("邮件"); + if(ListTools.isNotEmpty(allPersonAttributeList)){ + for(int n = 0; n < allPersonAttributeList.size(); n++){ + row.createCell(6+n+1).setCellValue("("+allPersonAttributeList.get(n)+")"); + } + } for (int i = 0; i < personList.size(); i++) { person = personList.get(i); @@ -288,6 +318,20 @@ public class ActionExportAll extends BaseAction { row.createCell(4).setCellValue(person.getOfficePhone()); row.createCell(5).setCellValue(Objects.toString(person.getGenderType(),"")); row.createCell(6).setCellValue(person.getMail()); + List os= this.listAttributeWithPerson(business,person.getId()); + if(ListTools.isNotEmpty(allPersonAttributeList) && ListTools.isNotEmpty(os)){ + for(int m = 0; m < allPersonAttributeList.size(); m++){ + String pName = allPersonAttributeList.get(m); + String pValue = ""; + for(PersonAttribute o : os){ + if(pName.equals(o.getName())){ + //pValue = o.getAttributeList().toString(); + pValue = String.join(",", o.getAttributeList().stream().map(String::valueOf).collect(Collectors.toList())); + } + } + row.createCell(6+m+1).setCellValue(pValue); + } + } } } } @@ -304,8 +348,7 @@ public class ActionExportAll extends BaseAction { row = sheet.createRow(0); row.createCell(0).setCellValue("人员唯一编码 *"); row.createCell(1).setCellValue("组织唯一编码 *"); - row.createCell(2).setCellValue("职务编号"); - row.createCell(3).setCellValue("主兼职"); + row.createCell(2).setCellValue("主兼职"); for (int i = 0; i < identityList.size(); i++) { identity = identityList.get(i); @@ -315,22 +358,21 @@ public class ActionExportAll extends BaseAction { if(person != null){ row.createCell(0).setCellValue(person.getUnique()); if(unit != null){ - String iduty = ""; + List idutyList = new ArrayList<>(); String unitId = ""; unitId = unit.getId(); row.createCell(1).setCellValue(unit.getUnique()); - List unitDutyList = this.listDutyWithIdentity(business,identity.getId()); + /*List unitDutyList = this.listDutyWithIdentity(business,identity.getId()); if(ListTools.isNotEmpty(unitDutyList)){ for(UnitDuty duty :unitDutyList){ - if(unitId.equals(duty.getUnit())){ - iduty = duty.getUnique(); - } + //if(unitId.equals(duty.getUnit())){ + idutyList.add(duty.getUnique()); + //} } - } - row.createCell(2).setCellValue(iduty); - row.createCell(3).setCellValue(String.valueOf(identity.getMajor())); + row.createCell(2).setCellValue(StringUtils.join(idutyList.toArray(), "#"));*/ + row.createCell(2).setCellValue(String.valueOf(identity.getMajor())); } } @@ -340,24 +382,64 @@ public class ActionExportAll extends BaseAction { private void composeDuty(Business business, String sheetName, List dutyList) throws Exception { UnitDuty duty = null; - + EntityManagerContainer emc = business.entityManagerContainer(); 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(0).setCellValue("职务名称 *"); + row.createCell(1).setCellValue("职务所在组织唯一编码 *"); row.createCell(2).setCellValue("职务描述"); - + row.createCell(3).setCellValue("职务所含人员唯一编码"); + row.createCell(4).setCellValue("职务所含人员所在组织唯一编码"); + int currentRow = 0; 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()); + Unit unit = emc.flag(duty.getUnit(), Unit.class); + List identityList = duty.getIdentityList(); + if (ListTools.isNotEmpty(identityList)) { + for (int j = 0; j < identityList.size(); j++) { + String identityId = identityList.get(j); + Identity identity = emc.flag(identityId, Identity.class); + if (identity != null) { + currentRow = currentRow+1; + row = sheet.createRow(currentRow); + row.createCell(0).setCellValue(duty.getName()); + if (unit != null) { + row.createCell(1).setCellValue(unit.getUnique()); + } else { + row.createCell(1).setCellValue(""); + } + row.createCell(2).setCellValue(duty.getDescription()); + Person iperson = emc.flag(identity.getPerson(), Person.class); + Unit iunit = emc.flag(identity.getUnit(), Unit.class); + if (iperson != null) { + row.createCell(3).setCellValue(iperson.getUnique()); + } else { + row.createCell(3).setCellValue(""); + } + if (iunit != null) { + row.createCell(4).setCellValue(iunit.getUnique()); + } else { + row.createCell(4).setCellValue(""); + } + } + } + } else { + currentRow = currentRow+1; + row = sheet.createRow(currentRow); + row.createCell(0).setCellValue(duty.getName()); + if (unit != null) { + row.createCell(1).setCellValue(unit.getUnique()); + } else { + row.createCell(1).setCellValue(""); + } + row.createCell(2).setCellValue(duty.getDescription()); + row.createCell(3).setCellValue(""); + row.createCell(4).setCellValue(""); + } } } } @@ -388,10 +470,6 @@ public class ActionExportAll extends BaseAction { List groupsList = group.getGroupList(); List identityList = group.getIdentityList(); - System.out.println("personList="+personList.size()); - System.out.println("unitList="+unitList.size()); - System.out.println("groupsList="+groupsList.size()); - System.out.println("identityList="+identityList.size()); if(ListTools.isEmpty(personList) && ListTools.isEmpty(unitList) && ListTools.isEmpty(groupsList)){ forNumber = forNumber+1; row = sheet.createRow(forNumber); @@ -491,6 +569,11 @@ public class ActionExportAll extends BaseAction { List os = em.createQuery(cq.select(root).where(p)).getResultList(); return os; } + private List ListUnitAttributes(String path , String unitId) throws Exception{ + ActionResponse resp = ThisApplication.context().applications() + .getQuery(x_organization_assemble_control.class, path+unitId); + return resp.getDataAsList(UnitAttribute.class); + } public static class Wo extends WoFile { public Wo(byte[] bytes, String contentType, String contentDisposition) { diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionInputAll.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionInputAll.java index 8acca28fa61f32ae27844a53754d59014a3dc0d0..764daed87901a2eb965a2a62f85d9bdd47f92bab 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionInputAll.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionInputAll.java @@ -3,13 +3,8 @@ package com.x.organization.assemble.control.jaxrs.inputperson; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Random; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,6 +22,7 @@ import com.x.base.core.entity.annotation.CheckPersistType; import com.x.base.core.project.cache.CacheManager; import com.x.base.core.project.config.StorageMapping; +import com.x.organization.core.entity.*; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; @@ -54,18 +50,9 @@ import com.x.base.core.project.script.ScriptFactory; import com.x.base.core.project.tools.Crypto; import com.x.base.core.project.tools.DateTools; import com.x.base.core.project.tools.ListTools; -import com.x.base.core.project.tools.StringTools; import com.x.general.core.entity.GeneralFile; import com.x.organization.assemble.control.Business; import com.x.organization.assemble.control.ThisApplication; -import com.x.organization.core.entity.Group; -import com.x.organization.core.entity.Identity; -import com.x.organization.core.entity.Identity_; -import com.x.organization.core.entity.Person; -import com.x.organization.core.entity.PersonAttribute; -import com.x.organization.core.entity.Role; -import com.x.organization.core.entity.Unit; -import com.x.organization.core.entity.UnitDuty; class ActionInputAll extends BaseAction { @@ -123,7 +110,7 @@ class ActionInputAll extends BaseAction { private void scanUnit(Business business, XSSFWorkbook workbook) throws Exception { //导入组织信息 - System.out.println("开始导入人员组织所有数据--------start"); + logger.info("开始导入人员组织所有数据--------start"); Sheet sheet = workbook.getSheetAt(1); configuratorUnit = new UnitSheetConfigurator(workbook, sheet); unit = this.scanUnitList(configuratorUnit, sheet); @@ -136,11 +123,11 @@ class ActionInputAll extends BaseAction { private void scanPerson(Business business, XSSFWorkbook workbook) throws Exception { //导入人员信息 - System.out.println("--------scanPerson"); + logger.info("--------scanPerson"); Sheet sheet = workbook.getSheetAt(2); configuratorPerson = new PersonSheetConfigurator(workbook, sheet); person = this.scanPersonList(configuratorPerson, sheet); - System.out.println("person="+person.size()); + logger.info("person="+person.size()); wholeFlag = this.checkPerson(business, workbook, configuratorPerson, person); if(wholeFlag){ this.scanIdentity(business, workbook,person,unit); @@ -149,71 +136,45 @@ class ActionInputAll extends BaseAction { private void scanIdentity(Business business, XSSFWorkbook workbook ,List persons,List units) throws Exception { //导入身份信息 - System.out.println("--------scanIdentity"); + logger.info("--------scanIdentity"); Sheet sheet = workbook.getSheetAt(3); configuratorIdentity = new IdentitySheetConfigurator(workbook, sheet); + wholeFlag = this.checkIdentity(business, workbook, configuratorIdentity, sheet,persons,units); //校验导入的职务信息 - this.scanDuty(business,workbook); - if(!dutyFlag){ - wholeFlag = this.checkIdentity(business, workbook, configuratorIdentity, sheet,persons,units); - if(wholeFlag){ - - if(wholeFlag){ - //保存组织,人员 - System.out.println("开始导入组织信息--------"); - this.persistUnit(business,workbook, configuratorUnit, unit); - System.out.println("开始导入人员信息--------"); - this.persistPerson(business,workbook, configuratorPerson, person); - System.out.println("开始导入身份信息--------"); - identity = this.scanIdentityList(business,configuratorIdentity, sheet); - //保存身份 - this.persistIdentity(workbook, configuratorIdentity, identity); - System.out.println("开始导入职务信息--------"); - //保存职务 - duty = this.scanDutyList(business,identity, sheet); - //this.persistDuty(workbook, configuratorDuty, duty); - this.persistDuty(workbook, configuratorDuty, duty,business); - - //保存群组 - //校验群组 - wholeFlag = this.checkGroup(business,workbook,person,unit); - System.out.println("开始导入群组信息--------"); - this.scanGroup(business,workbook,person,unit); - this.persistGroup(business,workbook, configuratorGroup, group); - System.out.println("开始导入人员组织所有数据--------end"); - } - - } + if(wholeFlag){ + this.scanDuty(business,workbook); } - - } private void scanDuty(Business business, XSSFWorkbook workbook) throws Exception { //导入职务信息 - System.out.println("--------scanDuty"); - Sheet sheet = workbook.getSheetAt(4); - DutySheetConfigurator configurator = new DutySheetConfigurator(workbook, sheet); - for (int i = configurator.getFirstRow(); i <= configurator.getLastRow(); i++) { - Row row = sheet.getRow(i); - if (null != row) { - String name = configurator.getCellStringValue(row.getCell(configurator.getNameColumn())); - String key = configurator.getCellStringValue(row.getCell(configurator.getUniqueColumn())); - String dutyDescription = configurator.getCellStringValue(row.getCell(configurator.getDescriptionColumn())); - //System.out.println("职务name="+name+"_职务value="+key); - if(StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(key)){ - dutyMap.put(key, name); - - }else{ - dutyFlag = true; - } - if(StringUtils.isNotEmpty(dutyDescription) && StringUtils.isNotEmpty(key)){ - dutyDescriptionMap.put(key, dutyDescription); - }else{ - dutyDescriptionMap.put(key, ""); - } - } - } + logger.info("--------scanDuty"); + Sheet identitySheet = workbook.getSheetAt(3); + Sheet dutySheet = workbook.getSheetAt(4); + configuratorDuty = new DutySheetConfigurator(workbook, dutySheet); + wholeFlag = this.checkDuty(business, workbook, configuratorDuty); + if(wholeFlag){ + //保存组织,人员 + logger.info("开始导入组织信息--------"); + this.persistUnit(business,workbook, configuratorUnit, unit); + logger.info("开始导入人员信息--------"); + this.persistPerson(business,workbook, configuratorPerson, person); + logger.info("开始导入身份信息--------"); + identity = this.scanIdentityList(business,configuratorIdentity, identitySheet); + this.persistIdentity(workbook, configuratorIdentity, identity); + + logger.info("开始导入职务信息--------"); + duty = this.scanDutyList(business,configuratorDuty,dutySheet); + this.persistDuty(workbook, configuratorDuty, duty,business); + + //保存群组 + //校验群组 + wholeFlag = this.checkGroup(business,workbook,person,unit); + logger.info("开始导入群组信息--------"); + this.scanGroup(business,workbook,person,unit); + this.persistGroup(business,workbook, configuratorGroup, group); + logger.info("开始导入人员组织所有数据--------end"); + } } private void scanGroup(Business business, XSSFWorkbook workbook ,List persons,List units) throws Exception { //导入群组信息 @@ -398,7 +359,6 @@ class ActionInputAll extends BaseAction { if (null != row) { String unique = configurator.getCellStringValue(row.getCell(configurator.getUniqueColumn())); String unitCode = configurator.getCellStringValue(row.getCell(configurator.getUnitCodeColumn())); - String dutyCode = configurator.getCellStringValue(row.getCell(configurator.getDutyCodeColumn())); String majorStr = configurator.getCellStringValue(row.getCell(configurator.getMajorColumn())); Boolean major = false; if(majorStr.equals("true")){ @@ -411,10 +371,6 @@ class ActionInputAll extends BaseAction { identityItem.setUnitCode(unitCode); identityItem.setMajor(major); - if(StringUtils.isNotEmpty(dutyCode)){ - identityItem.setDutyCode(dutyCode); - } - EntityManagerContainer emc = business.entityManagerContainer(); Person personobj = null; personobj = emc.flag(unique, Person.class); @@ -450,7 +406,7 @@ class ActionInputAll extends BaseAction { } private List scanGroupList(Business business,GroupSheetConfigurator configurator, Sheet sheet) throws Exception { - + EntityManagerContainer emc = business.entityManagerContainer(); List groups = new ArrayList<>(); for (int i = configurator.getFirstRow(); i <= configurator.getLastRow(); i++) { Row row = sheet.getRow(i); @@ -469,8 +425,7 @@ class ActionInputAll extends BaseAction { groupItem.setUnitCode(unitCode); groupItem.setName(name); groupItem.setUnique(unique); - - EntityManagerContainer emc = business.entityManagerContainer(); + Person personobj = null; personobj = emc.flag(personCode, Person.class); if(personobj != null){ @@ -510,69 +465,41 @@ class ActionInputAll extends BaseAction { return groups; } - private List scanDutyList(Business business,List identityItems, Sheet sheet) throws Exception { - + private List scanDutyList(Business business,DutySheetConfigurator configurator, Sheet sheet) throws Exception { + if (null == configurator.getNameColumn()) { + throw new ExceptionDutyNameColumnEmpty(); + } + if (null == configurator.getUnitColumn()) { + throw new ExceptionDutyCodeColumnEmpty(); + } + EntityManagerContainer emc = business.entityManagerContainer(); List dutys = new ArrayList<>(); - for (int i = 0; i < identityItems.size(); i++) { - IdentityItem identutyIt = identityItems.get(i); - if (null != identutyIt) { - String dutyCode = identutyIt.getDutyCode(); - String unitCode = identutyIt.getUnitCode(); - String personCode = identutyIt.getPersonCode(); - List identitys = new ArrayList<>(); - - if(StringUtils.isNotEmpty(dutyCode)){ - DutyItem dutyItem = new DutyItem(); - dutyItem.setRow(i+1); - dutyItem.setName(dutyMap.get(dutyCode)); - dutyItem.setDescription(dutyDescriptionMap.get(dutyCode)); - EntityManagerContainer emc = business.entityManagerContainer(); - - Unit u = null; - String unitId = null; - u = emc.flag(unitCode, Unit.class); - if(u != null){ - dutyItem.setUnit(u.getId()); - unitId = u.getId(); - dutyItem.setUnique(dutyCode+unitId); - } - - Person personObj = null; - personObj = emc.flag(personCode, Person.class); - if(personObj != null){ - EntityManager em = business.entityManagerContainer().get(Identity.class); - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery cq = cb.createQuery(Identity.class); - Root root = cq.from(Identity.class); - //System.out.println("personid="+personObj.getId()); - Predicate p = cb.equal(root.get(Identity_.person), personObj.getId()); - p = cb.and(p,cb.equal(root.get(Identity_.unit), u.getId())); - identitys = em.createQuery(cq.select(root).where(p)).getResultList(); - - if(personCode.equals("zhengping2")){ - System.out.println("identitys="+identitys.size()); - } - } - - - if(ListTools.isNotEmpty(identitys)){ - List didylist = new ArrayList<>(); - /*for (Identity identity : identitys) { - if(unitId.equals(identity.getUnit())){ - //System.out.println("unitCode="+unitCode); - didylist.add(identity.getDistinguishedName()); - } - }*/ - didylist.add(identitys.get(0).getId()); - dutyItem.setIdentityList(didylist); + for (int i = configurator.getFirstRow(); i <= configurator.getLastRow(); i++) { + Row row = sheet.getRow(i); + if (null != row) { + String dutyNmae = configurator.getCellStringValue(row.getCell(configurator.getNameColumn())); + String unitCode = configurator.getCellStringValue(row.getCell(configurator.getUnitColumn())); + String description = configurator.getCellStringValue(row.getCell(configurator.getDescriptionColumn())); + String ipersonCode = configurator.getCellStringValue(row.getCell(configurator.getIpersonColumn())); + String iunitCode = configurator.getCellStringValue(row.getCell(configurator.getIunitColumn())); + + DutyItem dutyItem = new DutyItem(); + dutyItem.setRow(i); + dutyItem.setName(dutyNmae); + dutyItem.setUnique(UUID.randomUUID().toString()+unitCode); + dutyItem.setDescription(description); + + if(StringUtils.isNotEmpty(unitCode)){ + Unit iUnit = emc.flag(unitCode, Unit.class); + if(iUnit !=null) { + dutyItem.setUnit(iUnit.getId()); } - - logger.debug("scan duty:{}.", dutyItem); - dutys.add(dutyItem); + List identityList = new ArrayList<>(); + identityList = this.listIdentityList(business,ipersonCode,iunitCode); + //查询对应身份 + dutyItem.setIdentityList(identityList); } - - - + dutys.add(dutyItem); } } return dutys; @@ -584,7 +511,6 @@ class ActionInputAll extends BaseAction { EntityManagerContainer emc = business.entityManagerContainer(); boolean validate = true; for (UnitItem o : unit) { - //System.out.println("正在校验组织:{}."+ o.getName()); if (StringUtils.isEmpty(o.getName())) { this.setUnitMemo(workbook, configurator, o, "组织名称不能为空."); validate = false; @@ -635,7 +561,6 @@ class ActionInputAll extends BaseAction { EntityManagerContainer emc = business.entityManagerContainer(); boolean validate = true; for (PersonItem o : person) { - //System.out.println("正在校验用户:{}."+ o.getName()); this.setPersonMemo(workbook, configurator, o, "校验通过."); if (StringUtils.isEmpty(o.getName())) { this.setPersonMemo(workbook, configurator, o, "人员姓名不能为空."); @@ -699,7 +624,7 @@ class ActionInputAll extends BaseAction { Person pc = null; pc = emc.flag(o.getMobile(), Person.class); if (null != pc) { - System.out.println("手机号码: " + o.getMobile() + " 与已经存在手机号码: " + pc.getMobile() + " 冲突."); + logger.info("手机号码: " + o.getMobile() + " 与已经存在手机号码: " + pc.getMobile() + " 冲突."); this.setPersonMemo(workbook, configurator, o, "手机号码: " + o.getMobile() + " 与已经存在手机号码: " + pc.getMobile() + " 冲突."); validate = false; continue; @@ -712,7 +637,7 @@ class ActionInputAll extends BaseAction { } private boolean checkIdentity(Business business, XSSFWorkbook workbook, IdentitySheetConfigurator configurator, - Sheet sheet ,List persons,List units) throws Exception { + Sheet sheet ,List persons,List units) throws Exception { //校验导入的身份 if (null == configurator.getUniqueColumn()) { throw new ExceptionUniqueColumnEmpty(); @@ -720,7 +645,7 @@ class ActionInputAll extends BaseAction { if (null == configurator.getUnitCodeColumn()) { throw new ExceptionUnitUniqueColumnEmpty(); } - List identitys = new ArrayList<>(); + List identitys = new ArrayList<>(); EntityManagerContainer emc = business.entityManagerContainer(); boolean validate = true; for (int i = configurator.getFirstRow(); i <= configurator.getLastRow(); i++) { @@ -728,8 +653,6 @@ class ActionInputAll extends BaseAction { if (null != row) { String unique = configurator.getCellStringValue(row.getCell(configurator.getUniqueColumn())); String unitCode = configurator.getCellStringValue(row.getCell(configurator.getUnitCodeColumn())); - String dutyCode = configurator.getCellStringValue(row.getCell(configurator.getDutyCodeColumn())); - //System.out.println("正在校验人员身份 :{}."+ unique); boolean personcheck = false; boolean unitcheck = false; IdentityItem identityItem = new IdentityItem(); @@ -746,16 +669,7 @@ class ActionInputAll extends BaseAction { validate = false; continue; } - if (StringUtils.isNotEmpty(dutyCode)) { - String dutyName = dutyMap.get(dutyCode); - if (StringUtils.isEmpty(dutyName)) { - this.setIdentityMemo(workbook, configurator, identityItem, "系统没有对应的职务."); - validate = false; - continue; - } - - } - + Person person = null; person = emc.flag(unique, Person.class); if(person != null){ @@ -767,7 +681,7 @@ class ActionInputAll extends BaseAction { } } } - + Unit unit = null; unit = emc.flag(unitCode, Unit.class); if(unit != null){ @@ -779,7 +693,7 @@ class ActionInputAll extends BaseAction { } } } - + if (!personcheck) { this.setIdentityMemo(workbook, configurator, identityItem, "系统不存在该人员."); validate = false; @@ -790,14 +704,14 @@ class ActionInputAll extends BaseAction { validate = false; continue; } - + //if (validate) { - //this.setIdentityMemo(workbook, configurator, identityItem, "校验通过."); + //this.setIdentityMemo(workbook, configurator, identityItem, "校验通过."); //} - + } } - + /*if (validate) { for (IdentityItem o : identitys) { this.setIdentityMemo(workbook, configurator, o, "校验通过."); @@ -805,6 +719,54 @@ class ActionInputAll extends BaseAction { }*/ return validate; } + + /*private boolean checkDuty(Business business, XSSFWorkbook workbook, DutySheetConfigurator configurator,List duty) throws Exception { + //校验导入的职务 + List identitys = new ArrayList<>(); + EntityManagerContainer emc = business.entityManagerContainer(); + boolean validate = true; + for (DutyItem o : duty) { + //System.out.println("正在校验组织:{}."+ o.getName()); + if (StringUtils.isEmpty(o.getName())) { + this.setDutyMemo(workbook, configurator, o, "职务名称不能为空."); + validate = false; + continue; + } + if (StringUtils.isEmpty(o.getUnique())) { + this.setDutyMemo(workbook, configurator, o, "职务所在组织唯一编码不能为空."); + validate = false; + continue; + } + this.setDutyMemo(workbook, configurator, o, "校验通过."); + } + return validate; + }*/ + private boolean checkDuty(Business business, XSSFWorkbook workbook, DutySheetConfigurator configurator) throws Exception { + EntityManagerContainer emc = business.entityManagerContainer(); + Sheet sheet = workbook.getSheetAt(4); + boolean validate = true; + for (int i = configurator.getFirstRow(); i <= configurator.getLastRow(); i++) { + Row row = sheet.getRow(i); + if (null != row) { + String name = configurator.getCellStringValue(row.getCell(configurator.getNameColumn())); + String uniCode = configurator.getCellStringValue(row.getCell(configurator.getUnitColumn())); + DutyItem o = new DutyItem(); + o.setRow(i); + if (StringUtils.isEmpty(name)) { + this.setDutyMemo(workbook, configurator, o, "职务名称不能为空."); + validate = false; + continue; + } + if (StringUtils.isEmpty(uniCode)) { + this.setDutyMemo(workbook, configurator, o, "职务所在组织唯一编码不能为空."); + validate = false; + continue; + } + this.setDutyMemo(workbook, configurator, o, "校验通过."); + } + } + return validate; + } private boolean checkGroup(Business business, XSSFWorkbook workbook, List persons,List units) throws Exception { //校验导入的群组 @@ -829,8 +791,7 @@ class ActionInputAll extends BaseAction { String unique = configurator.getCellStringValue(row.getCell(configurator.getUniqueColumn())); String personCode = configurator.getCellStringValue(row.getCell(configurator.getPersonCodeColumn())); String unitCode = configurator.getCellStringValue(row.getCell(configurator.getUnitCodeColumn())); - - //System.out.println("正在校验群组 :{}."+ name); + boolean personcheck = false; boolean unitcheck = false; GroupItem groupItem = new GroupItem(); @@ -926,7 +887,7 @@ class ActionInputAll extends BaseAction { String respAtt = saveUnitAttribute("unitattribute",unitAttribute); if("".equals(respAtt)){ }else{ - System.out.println("respMass="+respAtt); + logger.info("respMass="+respAtt); this.setUnitMemo(workbook, configurator, o, respAtt); } } @@ -935,7 +896,7 @@ class ActionInputAll extends BaseAction { this.setUnitMemo(workbook, configurator, o, "已导入."); } }else{ - System.out.println("respMass="+resp); + logger.info("respMass="+resp); this.setUnitMemo(workbook, configurator, o, resp); } @@ -966,7 +927,7 @@ class ActionInputAll extends BaseAction { String respAtt = savePersonAttribute("personattribute",personAttribute); if("".equals(respAtt)){ }else{ - System.out.println("respMass="+respAtt); + logger.info("respMass="+respAtt); this.setPersonMemo(workbook, configurator, o, respAtt); } } @@ -975,7 +936,7 @@ class ActionInputAll extends BaseAction { this.setPersonMemo(workbook, configurator, o, "已导入."); } }else{ - System.out.println("respMass="+resp); + logger.info("respMass="+resp); this.setPersonMemo(workbook, configurator, o, resp); } @@ -995,7 +956,7 @@ class ActionInputAll extends BaseAction { if("".equals(resp)){ this.setIdentityMemo(workbook, configurator, o, "已导入."); }else{ - System.out.println("respMass="+resp); + logger.info("respMass="+resp); this.setIdentityMemo(workbook, configurator, o, resp); } @@ -1007,15 +968,18 @@ class ActionInputAll extends BaseAction { EntityManagerContainer emc = business.entityManagerContainer(); for (List list : ListTools.batch(dutyItems, 200)) { for (DutyItem o : list) { - if(StringUtils.isNotEmpty(o.getUnique()) && this.getDuty(emc,o)){ + if(StringUtils.isNotEmpty(o.getUnique()) && this.getDuty(business,o)){ + }else{ - logger.debug("正在保存职务:{}.", o.getName()); + logger.info("正在保存职务:{}."+ o.getName()); UnitDuty dutyObject = new UnitDuty(); o.copyTo(dutyObject); String resp = this.saveDuty("unitduty", dutyObject); if("".equals(resp)){ + this.setDutyMemo(workbook,configurator,o,"已导入."); }else{ - System.out.println("respMassduty="+resp); + logger.info("respMassduty="+resp); + this.setDutyMemo(workbook,configurator,o,resp); } } @@ -1057,7 +1021,7 @@ class ActionInputAll extends BaseAction { if("".equals(respEdit)){ this.setGroupMemo(workbook, configurator, o, "已导入."); }else{ - System.out.println("respEditMass="+respEdit); + logger.info("respEditMass="+respEdit); this.setGroupMemo(workbook, configurator, o, respEdit); } @@ -1083,7 +1047,7 @@ class ActionInputAll extends BaseAction { if("".equals(resp)){ this.setGroupMemo(workbook, configurator, o, "已导入."); }else{ - System.out.println("respMass="+resp); + logger.info("respMass="+resp); this.setGroupMemo(workbook, configurator, o, resp); } } @@ -1118,6 +1082,14 @@ class ActionInputAll extends BaseAction { Cell cell = CellUtil.getCell(row, configurator.getMemoColumn()); cell.setCellValue(memo); } + + private void setDutyMemo(XSSFWorkbook workbook, DutySheetConfigurator configurator, DutyItem dutyItem, + String memo) { + Sheet sheet = workbook.getSheetAt(configurator.getSheetIndex()); + Row row = sheet.getRow(dutyItem.getRow()); + Cell cell = CellUtil.getCell(row, configurator.getMemoColumn()); + cell.setCellValue(memo); + } private void setGroupMemo(XSSFWorkbook workbook, GroupSheetConfigurator configurator, GroupItem groupItem, String memo) { @@ -1181,11 +1153,13 @@ class ActionInputAll extends BaseAction { return resp.getMessage(); } - private boolean getDuty(EntityManagerContainer emc, DutyItem dutyItem) throws Exception{ + private boolean getDuty(Business business, DutyItem dutyItem) throws Exception{ boolean checkduty = false; - UnitDuty unitDuty = null; - unitDuty= emc.flag(dutyItem.getUnique(), UnitDuty.class); - if(unitDuty != null){ + List unitDutyList = new ArrayList<>(); + unitDutyList= this.listUnitDutyList(business,dutyItem.getName(),dutyItem.getUnit()); + if(ListTools.isNotEmpty(unitDutyList)){ + UnitDuty unitDuty = unitDutyList.get(0); + logger.info("更新职务:"+unitDuty.getName()); checkduty = true; List identityList = new ArrayList<>(); identityList = unitDuty.getIdentityList(); @@ -1243,6 +1217,40 @@ class ActionInputAll extends BaseAction { return generalFile.getId(); } } + + private List listIdentityList(Business business, String ipersonCode,String iunitCode) throws Exception { + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + Person iperson = emc.flag(ipersonCode, Person.class); + Unit iunit = emc.flag(iunitCode, Unit.class); + List os = new ArrayList<>(); + if(iperson !=null && iunit !=null ){ + EntityManager em = business.entityManagerContainer().get(Identity.class); + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(String.class); + Root root = cq.from(Identity.class); + Predicate p = cb.equal(root.get(Identity_.person), iperson.getId()); + p = cb.and(p, cb.equal(root.get(Identity_.unit), iunit.getId())); + cq.select(root.get(Identity_.id)).where(p); + os = em.createQuery(cq).getResultList(); + } + return os; + } + } + + private List listUnitDutyList(Business business, String iName,String iunitCode) throws Exception { + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + + EntityManager em = business.entityManagerContainer().get(UnitDuty.class); + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(UnitDuty.class); + Root root = cq.from(UnitDuty.class); + Predicate p = cb.equal(root.get(UnitDuty_.name), iName); + p = cb.and(p, cb.equal(root.get(UnitDuty_.unit), iunitCode)); + cq.select(root).where(p); + List os = em.createQuery(cq).getResultList(); + return os; + } + } public static class Wo extends GsonPropertyObject { diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionTemplate.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionTemplate.java index 75a92e3f3996b10d0be9aa91c7b9cfdc97912070..56353e6ec4d597f4347519f2b69c1f7f610fffd8 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionTemplate.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionTemplate.java @@ -122,8 +122,6 @@ public class ActionTemplate extends BaseAction { cell = row.createCell(1); cell.setCellValue("组织唯一编码 *"); cell = row.createCell(2); - cell.setCellValue("职务编号"); - cell = row.createCell(3); cell.setCellValue("主兼职"); CellStyle cellStyle = workbook.createCellStyle(); cellStyle.setWrapText(true); @@ -136,11 +134,15 @@ public class ActionTemplate extends BaseAction { XSSFSheet sheet = workbook.createSheet("职务信息"); Row row = sheet.createRow(0); Cell cell = row.createCell(0); - cell.setCellValue("职务编号 *"); - cell = row.createCell(1); cell.setCellValue("职务名称 *"); + cell = row.createCell(1); + cell.setCellValue("职务所在组织唯一编码 *"); cell = row.createCell(2); cell.setCellValue("职务描述"); + cell = row.createCell(3); + cell.setCellValue("职务所含人员唯一编码"); + cell = row.createCell(4); + cell.setCellValue("职务所含人员所在组织唯一编码"); CellStyle cellStyle = workbook.createCellStyle(); cellStyle.setWrapText(true); IntStream.rangeClosed(0, 6).forEach(i -> { diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionWipeAll.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionWipeAll.java index dac043cbc6cbd68b816712290b60c47df245fac5..a9b2eef7458803cbba9845daa300a62db7766e30 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionWipeAll.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionWipeAll.java @@ -15,16 +15,7 @@ import com.x.base.core.project.cache.CacheManager; import com.x.base.core.project.tools.ListTools; import com.x.organization.assemble.control.Business; import com.x.organization.assemble.control.ThisApplication; -import com.x.organization.core.entity.Group; -import com.x.organization.core.entity.Group_; -import com.x.organization.core.entity.Identity; -import com.x.organization.core.entity.Person; -import com.x.organization.core.entity.PersonAttribute; -import com.x.organization.core.entity.PersonAttribute_; -import com.x.organization.core.entity.Unit; -import com.x.organization.core.entity.UnitDuty; -import com.x.organization.core.entity.UnitDuty_; -import com.x.organization.core.entity.Unit_; +import com.x.organization.core.entity.*; import com.x.base.core.container.EntityManagerContainer; import com.x.base.core.container.factory.EntityManagerContainerFactory; import com.x.base.core.entity.annotation.CheckRemoveType; @@ -44,7 +35,9 @@ public class ActionWipeAll extends BaseAction { private static Logger logger = LoggerFactory.getLogger(ActionWipeAll.class); List allUnitList = new ArrayList<>(); + List allUnitAttributeList = new ArrayList<>(); List allPersonList = new ArrayList<>(); + List allPersonAttributeList = new ArrayList<>(); List allIdentityList = new ArrayList<>(); List allDutyList = new ArrayList<>(); List allGroupList = new ArrayList<>(); @@ -56,10 +49,12 @@ public class ActionWipeAll extends BaseAction { // 先获取需要删除的数据 try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { - System.out.println("开始删除人员组织所有数据--------start"); + logger.info("开始删除人员组织所有数据--------start"); business = new Business(emc); this.listUnit(business); this.listPerson(business); + this.listUnitAttribute(business); + this.listPersonAttribute(business); this.listIdentity(business); this.listDuty(business); this.listGroup(business); @@ -69,26 +64,34 @@ public class ActionWipeAll extends BaseAction { emc.beginTransaction( Identity.class ); emc.beginTransaction( Person.class ); //emc.beginTransaction( Unit.class ); - System.out.println("开始删除职务--------"); + logger.info("开始删除职务--------"); this.deleteDutys(emc,business); - System.out.println("开始删除群组--------"); + logger.info("开始删除群组--------"); this.deleteGroups(emc,business); - System.out.println("开始删除身份--------"); + logger.info("开始删除身份--------"); this.deleteIdentitys(emc,business); - System.out.println("开始删除人员--------"); + + logger.info("开始删除人员属性--------"); + this.deletePersonAttributes(emc,business); + logger.info("开始删除组织属性--------"); + this.deleteUnitAttributes(emc,business); + + logger.info("开始删除人员--------"); this.deletePersons(emc,business); - System.out.println("开始删除组织--------"); + logger.info("开始删除组织--------"); this.deleteUnits(emc,business); emc.commit(); CacheManager.notify(UnitDuty.class); CacheManager.notify(Group.class); CacheManager.notify(Identity.class); + CacheManager.notify(PersonAttribute.class); + CacheManager.notify(UnitAttribute.class); CacheManager.notify(Person.class); CacheManager.notify(Unit.class); wo.setFlag("清空人员数据成功"); - System.out.println("开始删除人员组织所有数据--------end"); + logger.info("开始删除人员组织所有数据--------end"); } catch (Exception e) { logger.info("系统在查询所有组织人员信息时发生异常。" ); wo.setFlag("清空人员数据失败"); @@ -118,6 +121,13 @@ public class ActionWipeAll extends BaseAction { allUnitList = allUnitList.stream().sorted(Comparator.comparing(Unit::getLevel).reversed()).collect(Collectors.toList()); } } + private void listUnitAttribute(Business business) throws Exception { + EntityManager em = business.entityManagerContainer().get(UnitAttribute.class); + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(UnitAttribute.class); + Root root = cq.from(UnitAttribute.class); + allUnitAttributeList = em.createQuery(cq.select(root)).getResultList(); + } private void listPerson(Business business) throws Exception { EntityManager em = business.entityManagerContainer().get(Person.class); @@ -126,6 +136,13 @@ public class ActionWipeAll extends BaseAction { Root root = cq.from(Person.class); allPersonList = em.createQuery(cq.select(root)).getResultList(); } + private void listPersonAttribute(Business business) throws Exception { + EntityManager em = business.entityManagerContainer().get(PersonAttribute.class); + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(PersonAttribute.class); + Root root = cq.from(PersonAttribute.class); + allPersonAttributeList = em.createQuery(cq.select(root)).getResultList(); + } private void listIdentity(Business business) throws Exception { EntityManager em = business.entityManagerContainer().get(Identity.class); @@ -165,6 +182,26 @@ public class ActionWipeAll extends BaseAction { List os = business.unit().listSubNestedObject(unit); return os; } + private void deletePersonAttributes(EntityManagerContainer emc,Business business) throws Exception{ + if(ListTools.isNotEmpty(allPersonAttributeList)){ + for(PersonAttribute pa : allPersonAttributeList){ + business.entityManagerContainer().beginTransaction(PersonAttribute.class); + business.entityManagerContainer().remove(pa, CheckRemoveType.all); + } + business.entityManagerContainer().commit(); + } + + } + private void deleteUnitAttributes(EntityManagerContainer emc,Business business) throws Exception{ + if(ListTools.isNotEmpty(allUnitAttributeList)){ + for(UnitAttribute ua : allUnitAttributeList){ + business.entityManagerContainer().beginTransaction(UnitAttribute.class); + business.entityManagerContainer().remove(ua, CheckRemoveType.all); + } + business.entityManagerContainer().commit(); + } + + } private void deleteUnits(EntityManagerContainer emc,Business business) throws Exception{ if(ListTools.isNotEmpty(allUnitList)){ diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/DutySheetConfigurator.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/DutySheetConfigurator.java index bec7a5f3b5e535558e3acb55ed7e9ee01179ebd2..4bf38e93593fc9508fa9cb25a0afab94a6b80272 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/DutySheetConfigurator.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/DutySheetConfigurator.java @@ -26,8 +26,10 @@ public class DutySheetConfigurator extends GsonPropertyObject { private Integer lastRow; private Integer nameColumn; - private Integer uniqueColumn; + private Integer iunitColumn; private Integer descriptionColumn; + private Integer unitColumn; + private Integer ipersonColumn; private Map attributes = new HashMap<>(); @@ -43,13 +45,17 @@ public class DutySheetConfigurator extends GsonPropertyObject { String str = this.getCellStringValue(cell); //System.out.println("str="+str+"----i="+i); if (StringUtils.isNotEmpty(str)) { - if (uniqueItems.contains(str)) { - this.uniqueColumn = i; + if (iunitItems.contains(str)) { + this.iunitColumn = i; } else if (nameItems.contains(str)) { this.nameColumn = i; }else if (descriptionItems.contains(str)) { this.descriptionColumn = i; - } else { + }else if(unitItems.contains(str)){ + this.unitColumn = i; + }else if(ipersonItems.contains(str)){ + this.ipersonColumn = i; + }else { Matcher matcher = attributePattern.matcher(str); if (matcher.matches()) { String attribute = matcher.group(1); @@ -61,9 +67,11 @@ public class DutySheetConfigurator extends GsonPropertyObject { } } - private static List uniqueItems = Arrays.asList(new String[] { "职务编号 *", "unique" }); private static List nameItems = Arrays.asList(new String[] { "职务名称 *", "name" }); + private static List unitItems = Arrays.asList(new String[] { "职务所在组织唯一编码 *", "unit" }); private static List descriptionItems = Arrays.asList(new String[] { "描述","职务描述", "description" }); + private static List ipersonItems = Arrays.asList(new String[] { "职务所含人员唯一编码", "iperson" }); + private static List iunitItems = Arrays.asList(new String[] { "职务所含人员所在组织唯一编码", "iunit" }); public String getCellStringValue(Cell cell) { if (null != cell) { @@ -95,14 +103,22 @@ public class DutySheetConfigurator extends GsonPropertyObject { return memoColumn; } - public Integer getUniqueColumn() { - return uniqueColumn; + public Integer getIunitColumn() { + return iunitColumn; } public Integer getNameColumn() { return nameColumn; } + public Integer getUnitColumn() { + return unitColumn; + } + + public Integer getIpersonColumn() { + return ipersonColumn; + } + public Map getAttributes() { return attributes; } diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ExceptionDutyCodeColumnEmpty.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ExceptionDutyCodeColumnEmpty.java index 3111fbc37149e863c4524010e6af7a99ce4853d0..8b0efd7ae3e0b5ffeb2b966420cdfe8e4ca0fb53 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ExceptionDutyCodeColumnEmpty.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ExceptionDutyCodeColumnEmpty.java @@ -7,6 +7,6 @@ class ExceptionDutyCodeColumnEmpty extends PromptException { private static final long serialVersionUID = -2139584911736169462L; ExceptionDutyCodeColumnEmpty() { - super("职务编号列不能为空."); + super("职务所在组织唯一编码列不能为空."); } } diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentityItem.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentityItem.java index 3f4697f378b81bb17de988d390e60924b46f1e7f..d441400e53645743c57b990f3f0fa76cebf7c98e 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentityItem.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentityItem.java @@ -13,7 +13,6 @@ public class IdentityItem extends GsonPropertyObject { private String personCode; private String unitCode; - private String dutyCode; private Boolean major; @@ -82,14 +81,6 @@ public class IdentityItem extends GsonPropertyObject { public void setUnitCode(String unitCode) { this.unitCode = unitCode; } - - public String getDutyCode() { - return dutyCode; - } - - public void setDutyCode(String dutyCode) { - this.dutyCode = dutyCode; - } public Boolean getMajor() { return major; diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentitySheetConfigurator.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentitySheetConfigurator.java index 01d1e7151a7162bec13da9bed986d94eba3e08fd..ee922b95f2738859bfa834f4329c813294527a3b 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentitySheetConfigurator.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/IdentitySheetConfigurator.java @@ -27,7 +27,6 @@ public class IdentitySheetConfigurator extends GsonPropertyObject { private Integer uniqueColumn; private Integer unitCodeColumn; - private Integer dutyCodeColumn; private Integer majorColumn; private Map attributes = new HashMap<>(); @@ -42,15 +41,12 @@ public class IdentitySheetConfigurator extends GsonPropertyObject { Cell cell = row.getCell(i); if (null != cell) { String str = this.getCellStringValue(cell); - System.out.println("identityStr = "+str); if (StringUtils.isNotEmpty(str)) { if (uniqueItems.contains(str)) { this.uniqueColumn = i; } else if (unitCodeItems.contains(str)) { this.unitCodeColumn = i; - } else if (dutyCodeItems.contains(str)) { - this.dutyCodeColumn = i; - } else if (majorItems.contains(str)) { + } else if (majorItems.contains(str)) { this.majorColumn = i; } else { Matcher matcher = attributePattern.matcher(str); @@ -66,7 +62,6 @@ public class IdentitySheetConfigurator extends GsonPropertyObject { private static List uniqueItems = Arrays.asList(new String[] { "人员唯一编码 *", "员工账号 *", "unique" }); private static List unitCodeItems = Arrays.asList(new String[] { "组织编号 *", "组织唯一编码 *", "unitCode" }); - private static List dutyCodeItems = Arrays.asList(new String[] { "职务编号", "dutyCode"}); private static List majorItems = Arrays.asList(new String[] { "主兼职","major" }); public String getCellStringValue(Cell cell) { @@ -107,10 +102,6 @@ public class IdentitySheetConfigurator extends GsonPropertyObject { return unitCodeColumn; } - public Integer getDutyCodeColumn() { - return dutyCodeColumn; - } - public Integer getMajorColumn() { return majorColumn; } diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/PersonSheetConfigurator.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/PersonSheetConfigurator.java index c4a44ff0868dae57df47977958d6f3429a3197f2..9e1c8e241215cf986edcfd2446b7744846d2e931 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/PersonSheetConfigurator.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/PersonSheetConfigurator.java @@ -45,7 +45,6 @@ public class PersonSheetConfigurator extends GsonPropertyObject { Cell cell = row.getCell(i); if (null != cell) { String str = this.getCellStringValue(cell); - System.out.println("personStr = "+str); if (StringUtils.isNotEmpty(str)) { if (nameItems.contains(str)) { this.nameColumn = i;