@ -8,7 +8,6 @@ import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.core.impl.Service ;
import com.engine.core.impl.Service ;
import com.engine.organization.component.OrganizationWeaTable ;
import com.engine.organization.component.OrganizationWeaTable ;
import com.engine.organization.entity.extend.ExtendInfoOperateType ;
import com.engine.organization.entity.extend.ExtendInfoOperateType ;
import com.engine.organization.entity.extend.param.ExtendInfoParams ;
import com.engine.organization.entity.extend.po.ExtendInfoPO ;
import com.engine.organization.entity.extend.po.ExtendInfoPO ;
import com.engine.organization.entity.fieldset.param.FieldTransferParam ;
import com.engine.organization.entity.fieldset.param.FieldTransferParam ;
import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO ;
import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO ;
@ -16,14 +15,9 @@ import com.engine.organization.entity.jclimport.vo.JclImportHistoryDetailVO;
import com.engine.organization.entity.scheme.po.GradePO ;
import com.engine.organization.entity.scheme.po.GradePO ;
import com.engine.organization.entity.scheme.po.LevelPO ;
import com.engine.organization.entity.scheme.po.LevelPO ;
import com.engine.organization.entity.scheme.po.SchemePO ;
import com.engine.organization.entity.scheme.po.SchemePO ;
import com.engine.organization.enums.LogModuleNameEnum ;
import com.engine.organization.enums.OperateTypeEnum ;
import com.engine.organization.enums.OrgImportEnum ;
import com.engine.organization.enums.OrgImportEnum ;
import com.engine.organization.exception.OrganizationRunTimeException ;
import com.engine.organization.mapper.comp.CompMapper ;
import com.engine.organization.mapper.department.DepartmentMapper ;
import com.engine.organization.mapper.department.DepartmentMapper ;
import com.engine.organization.mapper.employee.EmployeeMapper ;
import com.engine.organization.mapper.employee.EmployeeMapper ;
import com.engine.organization.mapper.extend.ExtMapper ;
import com.engine.organization.mapper.extend.ExtendInfoMapper ;
import com.engine.organization.mapper.extend.ExtendInfoMapper ;
import com.engine.organization.mapper.hrmresource.SystemDataMapper ;
import com.engine.organization.mapper.hrmresource.SystemDataMapper ;
import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper ;
import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper ;
@ -33,8 +27,6 @@ import com.engine.organization.mapper.scheme.GradeMapper;
import com.engine.organization.mapper.scheme.LevelMapper ;
import com.engine.organization.mapper.scheme.LevelMapper ;
import com.engine.organization.mapper.scheme.SchemeMapper ;
import com.engine.organization.mapper.scheme.SchemeMapper ;
import com.engine.organization.service.ImportCommonService ;
import com.engine.organization.service.ImportCommonService ;
import com.engine.organization.thread.JobTriggerRunnable ;
import com.engine.organization.thread.OrganizationSyncEc ;
import com.engine.organization.util.HasRightUtil ;
import com.engine.organization.util.HasRightUtil ;
import com.engine.organization.util.OrganizationAssert ;
import com.engine.organization.util.OrganizationAssert ;
import com.engine.organization.util.db.MapperProxyFactory ;
import com.engine.organization.util.db.MapperProxyFactory ;
@ -232,8 +224,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
returnMap . put ( "pId" , DepartmentImport . saveImport ( operateType , excelFile , user ) ) ;
returnMap . put ( "pId" , DepartmentImport . saveImport ( operateType , excelFile , user ) ) ;
break ;
break ;
case "jobtitle" :
case "jobtitle" :
returnMap . put ( "pId" , jobImport ( operateType , excelFile ) ) ;
break ;
case "resource" :
case "resource" :
returnMap . put ( "pId" , ResourceImport . saveImport ( operateType , excelFile , user , request ) ) ;
returnMap . put ( "pId" , ResourceImport . saveImport ( operateType , excelFile , user , request ) ) ;
break ;
break ;
@ -353,272 +343,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
return lsGroup ;
return lsGroup ;
}
}
/ * *
* 岗 位 导 入
* /
private Long jobImport ( String operateType , String excelFile ) {
Long importHistoryId = OrgImportUtil . saveImportLog ( "jobtitle" , operateType , user ) ;
JclImportHistoryDetailPO historyDetailPO ;
ImageFileManager manager = new ImageFileManager ( ) ;
manager . getImageFileInfoById ( Util . getIntValue ( excelFile ) ) ;
XSSFWorkbook workbook ;
try {
workbook = new XSSFWorkbook ( manager . getInputStream ( ) ) ;
} catch ( IOException e ) {
throw new RuntimeException ( e ) ;
}
// 当前sheet
XSSFSheet sheetAt = workbook . getSheetAt ( 0 ) ;
int lastRow = sheetAt . getLastRowNum ( ) ;
List < ExtendInfoPO > extendInfoPOS = new ArrayList < > ( ) ;
OrganizationAssert . isTrue ( lastRow > 0 , "导入数据为空" ) ;
short lastCellNum = sheetAt . getRow ( 0 ) . getLastCellNum ( ) ;
// 遍历每一行数据
nextRow :
for ( int i = 0 ; i < = lastRow ; i + + ) {
historyDetailPO = new JclImportHistoryDetailPO ( ) ;
historyDetailPO . setPid ( importHistoryId ) ;
XSSFRow row = sheetAt . getRow ( i ) ;
if ( null = = row ) {
continue ;
}
// 组装待处理数据
Map < String , Object > map = new HashMap < > ( ) ;
Integer parentCompanyId = null ;
Integer parentDepartmentId = null ;
Long parentJobId = null ;
String jobName = "" ;
historyDetailPO . setRowNums ( String . valueOf ( i + 1 ) ) ;
for ( int cellIndex = 0 ; cellIndex < lastCellNum ; cellIndex + + ) {
XSSFCell cell = row . getCell ( ( short ) cellIndex ) ;
String cellValue = getCellValue ( cell ) . trim ( ) ;
if ( i = = 0 ) {
// 首行 初始化字段信息
List < ExtendInfoPO > infoPOList = getExtendInfoMapper ( ) . getInfoByExtendAndLabelName ( JOB_TYPE , cellValue ) ;
boolean isBreak = OrgImportUtil . isBreak ( historyDetailPO , cellValue , infoPOList ) ;
if ( isBreak ) {
break nextRow ;
}
ExtendInfoPO extendInfoPO = infoPOList . get ( 0 ) ;
extendInfoPOS . add ( extendInfoPO ) ;
} else {
ExtendInfoPO infoPO = extendInfoPOS . get ( cellIndex ) ;
// 数据校验
if ( infoPO . getIsrequired ( ) = = 1 & & StringUtils . isBlank ( cellValue ) & & ! "job_no" . equalsIgnoreCase ( infoPO . getFieldName ( ) ) ) {
historyDetailPO . setOperateDetail ( infoPO . getFieldNameDesc ( ) + "为必填项" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
Object reallyValue ;
try {
reallyValue = OrgImportUtil . getReallyValue ( infoPO , cellValue ) ;
} catch ( Exception e ) {
historyDetailPO . setOperateDetail ( cellValue + "转换失败" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
if ( StringUtils . isNotBlank ( cellValue ) & & StringUtils . isBlank ( Util . null2String ( reallyValue ) ) & & ! "ec_company" . equals ( infoPO . getFieldName ( ) ) & & ! "ec_department" . equals ( infoPO . getFieldName ( ) ) ) {
historyDetailPO . setOperateDetail ( infoPO . getFieldNameDesc ( ) + "数据转换失败,未找到对应数据" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
map . put ( infoPO . getFieldName ( ) , reallyValue ) ;
// 上级分部
if ( "ec_company" . equals ( infoPO . getFieldName ( ) ) ) {
String [ ] split = cellValue . split ( ">" ) ;
if ( split . length > 0 ) {
if ( split . length > 8 ) {
historyDetailPO . setOperateDetail ( "分部层级不能大于10" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
for ( String s : split ) {
parentCompanyId = MapperProxyFactory . getProxy ( CompMapper . class ) . getIdByNameAndPid ( s , parentCompanyId = = null ? 0 : parentCompanyId ) ;
if ( null = = parentCompanyId ) {
historyDetailPO . setOperateDetail ( cellValue + "分部未找到对应数据" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
}
}
}
if ( "ec_department" . equals ( infoPO . getFieldName ( ) ) ) {
String [ ] split = cellValue . split ( ">" ) ;
if ( split . length > 0 ) {
if ( split . length > 8 ) {
historyDetailPO . setOperateDetail ( "部门层级不能大于10" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
for ( String s : split ) {
parentDepartmentId = MapperProxyFactory . getProxy ( DepartmentMapper . class ) . getIdByNameAndPid ( s , parentCompanyId , parentDepartmentId = = null ? 0 : parentDepartmentId ) ;
if ( null = = parentDepartmentId ) {
historyDetailPO . setOperateDetail ( cellValue + "部门未找到对应数据" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
}
}
}
if ( "job_name" . equals ( infoPO . getFieldName ( ) ) ) {
if ( null = = parentCompanyId ) {
historyDetailPO . setOperateDetail ( cellValue + "所属分部未找到" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
historyDetailPO . setRelatedName ( cellValue ) ;
String [ ] split = cellValue . split ( ">" ) ;
if ( split . length > 0 ) {
if ( split . length > 8 ) {
historyDetailPO . setOperateDetail ( "岗位层级不能大于10" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
for ( int index = 0 ; index < split . length - 1 ; index + + ) {
parentJobId = MapperProxyFactory . getProxy ( JobMapper . class ) . getIdByNameAndPid ( split [ index ] , parentCompanyId , parentDepartmentId = = null ? 0 : parentDepartmentId , parentJobId = = null ? 0 : parentJobId ) ;
if ( null = = parentJobId ) {
historyDetailPO . setOperateDetail ( split [ index ] + "岗位未找到对应数据" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue nextRow ;
}
}
}
map . put ( "parent_comp" , parentCompanyId ) ;
map . put ( "parent_dept" , parentDepartmentId ) ;
map . put ( "ec_company" , parentCompanyId ) ;
map . put ( "ec_department" , parentDepartmentId ) ;
map . put ( "parent_job" , parentJobId ) ;
jobName = split [ split . length - 1 ] ;
map . put ( "job_name" , jobName ) ;
map . put ( "is_key" , StringUtils . isBlank ( Util . null2String ( map . get ( "is_key" ) ) ) ? 0 : map . get ( "is_key" ) ) ;
}
}
}
// 校验、数据交互
if ( i = = 0 ) {
continue ;
}
String jobNo = ( String ) map . get ( "job_no" ) ;
Long jobId = MapperProxyFactory . getProxy ( JobMapper . class ) . getIdByNameAndPid ( jobName , parentCompanyId , parentDepartmentId = = null ? 0 : parentDepartmentId , parentJobId = = null ? 0 : parentJobId ) ;
if ( "add" . equals ( operateType ) ) {
if ( jobId ! = null ) {
historyDetailPO . setOperateDetail ( "数据已存在" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue ;
}
// 自动编号
try {
jobNo = JobServiceImpl . repeatDetermine ( jobNo ) ;
} catch ( OrganizationRunTimeException e ) {
historyDetailPO . setOperateDetail ( e . getMessage ( ) ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue ;
}
map . put ( "job_no" , jobNo ) ;
map . put ( "creator" , user . getUID ( ) ) ;
map . put ( "delete_type" , 0 ) ;
map . put ( "create_time" , new Date ( ) ) ;
// 禁用表示为空,默认启用
if ( StringUtils . isBlank ( Util . null2String ( map . get ( "forbidden_tag" ) ) ) ) {
map . put ( "forbidden_tag" , 0 ) ;
}
String showOrder = Util . null2String ( map . get ( "show_order" ) ) ;
if ( StringUtils . isBlank ( showOrder ) ) {
Integer maxShowOrder = MapperProxyFactory . getProxy ( JobMapper . class ) . getMaxShowOrder ( ) ;
if ( null = = maxShowOrder ) {
maxShowOrder = 0 ;
}
map . put ( "show_order" , maxShowOrder + 1 ) ;
}
ExtendInfoParams infoParams = ExtendInfoParams . builder ( ) . tableName ( "JCL_ORG_JOB" ) . params ( map ) . build ( ) ;
map . put ( "jobactivityid" , JobServiceImpl . JOB_ACTIVITY_ID ) ;
Map < String , Object > syncMap = new OrganizationSyncEc ( user , LogModuleNameEnum . JOB , OperateTypeEnum . ADD , map , false ) . sync ( ) ;
if ( OrgImportUtil . isThrowError ( syncMap ) ) {
boolean assertNameRepeat = JobServiceImpl . assertNameRepeat ( null , Util . null2String ( map . get ( "ec_department" ) ) , Util . null2String ( map . get ( "parent_job" ) ) , Util . null2String ( map . get ( "job_name" ) ) ) ;
if ( assertNameRepeat ) {
map . remove ( "jobactivityid" ) ;
MapperProxyFactory . getProxy ( ExtMapper . class ) . insertTable ( infoParams ) ;
// 更新组织架构图
new JobTriggerRunnable ( infoParams . getId ( ) ) . run ( ) ;
historyDetailPO . setOperateDetail ( "添加成功" ) ;
historyDetailPO . setStatus ( "1" ) ;
} else {
historyDetailPO . setOperateDetail ( "岗位名称已存在" ) ;
historyDetailPO . setStatus ( "0" ) ;
}
} else {
historyDetailPO . setOperateDetail ( Util . null2String ( syncMap . get ( "message" ) ) ) ;
historyDetailPO . setStatus ( "0" ) ;
}
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
} else if ( "update" . equals ( operateType ) ) {
// 查询对应ID
if ( StringUtils . isNotBlank ( jobNo ) ) {
if ( jobId = = null ) {
historyDetailPO . setOperateDetail ( "未找到对应数据" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
continue ;
}
if ( checkRepeatNo ( jobNo , JOB_TYPE , jobId ) ) {
map . put ( "update_time" , new Date ( ) ) ;
map . put ( "jobactivityid" , JobServiceImpl . JOB_ACTIVITY_ID ) ;
map . put ( "id" , jobId ) ;
Map < String , Object > syncMap = new OrganizationSyncEc ( user , LogModuleNameEnum . JOB , OperateTypeEnum . UPDATE , map , MapperProxyFactory . getProxy ( JobMapper . class ) . getJobById ( jobId ) , false ) . sync ( ) ;
if ( OrgImportUtil . isThrowError ( syncMap ) ) {
boolean assertNameRepeat = JobServiceImpl . assertNameRepeat ( jobId . toString ( ) , Util . null2String ( map . get ( "ec_department" ) ) , Util . null2String ( map . get ( "parent_job" ) ) , Util . null2String ( map . get ( "job_name" ) ) ) ;
if ( assertNameRepeat ) {
map . remove ( "id" ) ;
map . remove ( "jobactivityid" ) ;
MapperProxyFactory . getProxy ( ExtMapper . class ) . updateTable ( ExtendInfoParams . builder ( ) . id ( jobId ) . tableName ( "JCL_ORG_JOB" ) . params ( map ) . build ( ) ) ;
// 更新组织架构图
new JobTriggerRunnable ( jobId ) . run ( ) ;
historyDetailPO . setOperateDetail ( "更新成功" ) ;
historyDetailPO . setStatus ( "1" ) ;
} else {
historyDetailPO . setOperateDetail ( "岗位名称已存在" ) ;
historyDetailPO . setStatus ( "0" ) ;
}
} else {
historyDetailPO . setOperateDetail ( Util . null2String ( syncMap . get ( "message" ) ) ) ;
historyDetailPO . setStatus ( "0" ) ;
}
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
} else {
historyDetailPO . setOperateDetail ( jobNo + "编号已存在" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
}
} else {
historyDetailPO . setOperateDetail ( "编号为空,更新失败" ) ;
historyDetailPO . setStatus ( "0" ) ;
OrgImportUtil . saveImportDetailLog ( historyDetailPO ) ;
}
}
}
return importHistoryId ;
}
/ * *
/ * *
* 方 案 职 等 职 级 导 入
* 方 案 职 等 职 级 导 入
* /
* /