2023-09-25 16:35:58 +08:00
package com.engine.recruit.service.impl ;
import com.engine.core.impl.Service ;
import com.engine.recruit.entity.recruitflow.po.RecruitButton ;
2023-10-12 13:33:49 +08:00
import com.engine.recruit.entity.recruitflow.po.RecruitStepPo ;
import com.engine.recruit.entity.recruitflow.po.RecruitTabPo ;
import com.engine.recruit.exception.CustomizeRunTimeException ;
2023-09-25 16:35:58 +08:00
import com.engine.recruit.service.RecruitFlowService ;
2023-10-12 16:57:35 +08:00
import com.engine.recruit.util.RecruitFlowUtil ;
2023-09-25 16:35:58 +08:00
import org.apache.commons.lang3.StringUtils ;
import weaver.conn.RecordSet ;
import weaver.general.Util ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
/ * *
* @author : dxfeng
* @createTime : 2023 / 09 / 22
* @version : 1 . 0
* /
public class RecruitFlowServiceImpl extends Service implements RecruitFlowService {
@Override
2023-10-12 13:33:49 +08:00
public Map < String , Object > getButtonList ( Map < String , Object > param ) {
2023-09-25 16:35:58 +08:00
Map < String , Object > returnMap = new HashMap < > ( ) ;
2023-10-12 13:33:49 +08:00
String billId = Util . null2String ( param . get ( " billId " ) ) ;
2023-09-25 16:35:58 +08:00
2023-10-12 13:33:49 +08:00
// 招聘阶段ID
String stageId = " " ;
// 招聘流程ID
int recruitFlowId = - 1 ;
2023-09-25 16:35:58 +08:00
RecordSet rs = new RecordSet ( ) ;
2023-10-12 13:33:49 +08:00
rs . executeQuery ( " select zplc,zpjd from uf_jcl_yppc where id = ? " , billId ) ;
if ( rs . next ( ) ) {
recruitFlowId = rs . getInt ( " zplc " ) ;
stageId = rs . getString ( " zpjd " ) ;
}
if ( - 1 = = recruitFlowId ) {
throw new CustomizeRunTimeException ( " 未设置对应招聘流程 " ) ;
}
2023-09-25 16:35:58 +08:00
if ( StringUtils . isBlank ( stageId ) ) {
// 查询开始环节
2023-10-12 13:33:49 +08:00
rs . executeQuery ( " select id from uf_jcl_zpjdsz where zplc = ? and hj = 0 " , recruitFlowId ) ;
2023-09-25 16:35:58 +08:00
if ( rs . next ( ) ) {
stageId = rs . getString ( " id " ) ;
}
if ( StringUtils . isBlank ( stageId ) ) {
throw new RuntimeException ( " 未找到对应招聘阶段 " ) ;
}
}
2023-10-12 16:57:35 +08:00
rs . executeQuery ( " select a.id,a.zdyxsmc as buttonName, a.tzymbt as tabName, a.tzymdz as tabLink, a.zssx as orderNum, b.anbs as buttonKey, b.andz as buttonType from uf_jcl_zpjdsz_dt1 a inner join uf_jcl_lcczan b on a.czan = b.id where a.sfqy = 0 and mainid = ? order by zssx " , stageId ) ;
2023-10-12 13:33:49 +08:00
List < RecruitButton > buttonList = new ArrayList < > ( ) ;
List < RecruitTabPo > tabList = new ArrayList < > ( ) ;
2023-09-25 16:35:58 +08:00
while ( rs . next ( ) ) {
buttonList . add ( RecruitButton . builder ( )
2023-10-12 13:33:49 +08:00
. key ( rs . getString ( " id " ) )
2023-09-25 16:35:58 +08:00
. buttonName ( rs . getString ( " buttonName " ) )
. buttonKey ( rs . getString ( " buttonKey " ) )
2023-10-12 16:57:35 +08:00
. tabName ( rs . getString ( " tabName " ) )
. tabLink ( RecruitFlowUtil . replaceURL ( rs . getString ( " tabLink " ) , billId ) )
. buttonType ( rs . getString ( " buttonType " ) )
2023-09-25 16:35:58 +08:00
. orderNum ( rs . getInt ( " orderNum " ) )
. build ( ) ) ;
}
2023-10-12 16:57:35 +08:00
rs . executeQuery ( " select ymbt as title,ymdz as url,zssx as orderNum from uf_jcl_zpjdsz_dt2 where mainid = ? order by orderNum " , stageId ) ;
2023-10-12 13:33:49 +08:00
int tabIndex = 0 ;
while ( rs . next ( ) ) {
tabList . add ( RecruitTabPo . builder ( )
. key ( String . valueOf ( tabIndex ) )
. viewcondition ( String . valueOf ( tabIndex ) )
. title ( rs . getString ( " title " ) )
2023-10-12 16:57:35 +08:00
. url ( RecruitFlowUtil . replaceURL ( rs . getString ( " url " ) , billId ) )
2023-10-12 13:33:49 +08:00
. billId ( billId )
. build ( ) ) ;
tabIndex + + ;
}
2023-09-25 16:35:58 +08:00
// 当前阶段所有按钮信息
returnMap . put ( " buttonList " , buttonList ) ;
2023-10-12 13:33:49 +08:00
returnMap . put ( " tabList " , tabList ) ;
return returnMap ;
}
@Override
public Map < String , Object > getRecruitStepList ( Map < String , Object > param ) {
Map < String , Object > returnMap = new HashMap < > ( ) ;
String billId = Util . null2String ( param . get ( " billId " ) ) ;
// 招聘阶段ID
2023-10-12 16:57:35 +08:00
String stageId = " " ;
2023-10-12 13:33:49 +08:00
int currentStageId = 0 ;
// 招聘流程ID
int recruitFlowId = - 1 ;
RecordSet rs = new RecordSet ( ) ;
rs . executeQuery ( " select zplc,zpjd from uf_jcl_yppc where id = ? " , billId ) ;
if ( rs . next ( ) ) {
recruitFlowId = rs . getInt ( " zplc " ) ;
stageId = rs . getString ( " zpjd " ) ;
}
if ( - 1 = = recruitFlowId ) {
throw new CustomizeRunTimeException ( " 未设置对应招聘流程 " ) ;
}
rs . executeQuery ( " select id,jdmc from uf_jcl_zpjdsz where sfqy = 0 and zplc = ? order by zssx " , recruitFlowId ) ;
int stepIndex = 0 ;
List < RecruitStepPo > stepList = new ArrayList < > ( ) ;
while ( rs . next ( ) ) {
String id = rs . getString ( " id " ) ;
if ( stageId . equals ( id ) ) {
currentStageId = stepIndex ;
}
stepList . add ( RecruitStepPo . builder ( ) . key ( stepIndex ) . description ( rs . getString ( " jdmc " ) ) . build ( ) ) ;
stepIndex + + ;
}
2023-10-12 16:57:35 +08:00
if ( " -1 " . equals ( stageId ) ) {
currentStageId = stepList . size ( ) ;
}
2023-10-12 13:33:49 +08:00
returnMap . put ( " stepList " , stepList ) ;
returnMap . put ( " currentStageId " , currentStageId ) ;
2023-09-25 16:35:58 +08:00
return returnMap ;
}
}