@ -6,22 +6,34 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import com.biutag.supervision.common.UserContextHolder ;
import com.biutag.supervision.constants.enums.DepartLevelEnum ;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum ;
import com.biutag.supervision.mapper.NegativeWorkMapper ;
import com.biutag.supervision.pojo.entity.Negative ;
import com.biutag.supervision.pojo.entity.NegativeBlame ;
import com.biutag.supervision.pojo.entity.NegativeWork ;
import com.biutag.supervision.pojo.model.NegativeWorkModel ;
import com.biutag.supervision.pojo.model.UserAuth ;
import com.biutag.supervision.pojo.param.NegativeQueryParam ;
import com.biutag.supervision.pojo.param.WorkParam ;
import com.biutag.supervision.pojo.vo.DepartTree ;
import com.biutag.supervision.pojo.vo.NegativeQueryVo ;
import com.biutag.supervision.util.TimeUtil ;
import lombok.RequiredArgsConstructor ;
import org.springframework.stereotype.Service ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Objects ;
import java.util.stream.Collectors ;
@RequiredArgsConstructor
@Service
public class NegativeWorkService extends ServiceImpl < NegativeWorkMapper , NegativeWork > {
public Page < NegativeWorkModel > page ( WorkParam workParam , String workStatus ) {
private final SupDepartService departService ;
public Page < NegativeWorkModel > page ( NegativeQueryParam param , String workStatus ) {
UserAuth user = UserContextHolder . getCurrentUser ( ) ;
if ( user . getRoleCodes ( ) . isEmpty ( ) | | user . getAuthDepartIds ( ) . isEmpty ( ) | | user . getAuthSources ( ) . isEmpty ( ) ) {
return new Page < NegativeWorkModel > ( ) . setTotal ( 0 ) . setRecords ( new ArrayList < > ( ) ) ;
@ -31,20 +43,89 @@ public class NegativeWorkService extends ServiceImpl<NegativeWorkMapper, Negativ
. in ( "w.depart_id" , user . getAuthDepartIds ( ) )
. in ( "w.problem_sources_code" , user . getAuthSources ( ) )
. eq ( "w.status" , workStatus )
. eq ( StrUtil . isNotBlank ( workParam . getProblemSourcesCode ( ) ) , "n.problemSourcesCode" , workParam . getProblemSourcesCode ( ) )
. eq ( StrUtil . isNotBlank ( workParam . getBusinessTypeCode ( ) ) , "n.businessTypeCode" , workParam . getBusinessTypeCode ( ) )
. like ( StrUtil . isNotBlank ( workParam . getInvolveProblem ( ) ) , "n.involveProblem" , workParam . getInvolveProblem ( ) )
. like ( StrUtil . isNotBlank ( workParam . getThingDesc ( ) ) , "n.thingDesc" , workParam . getThingDesc ( ) )
. eq ( StrUtil . isNotBlank ( workParam . getInvolveDepartId ( ) ) , "n.involveDepartId" , workParam . getInvolveDepartId ( ) )
. eq ( StrUtil . isNotBlank ( workParam . getHandleThreeDepartId ( ) ) , "n.handle_three_depart_id" , workParam . getHandleThreeDepartId ( ) )
. eq ( StrUtil . isNotBlank ( workParam . getProcessingStatus ( ) ) , "n.processing_status" , workParam . getProcessingStatus ( ) )
. eq ( StrUtil . isNotBlank ( workParam . getCheckStatus ( ) ) , "n.checkStatus" , workParam . getCheckStatus ( ) )
. in ( Objects . nonNull ( workParam . getHandleResultCode ( ) ) & & ! workParam . getHandleResultCode ( ) . isEmpty ( ) , "nb.handleResultCode" , workParam . getHandleResultCode ( ) )
. and ( StrUtil . isNotBlank ( param . getOriginId ( ) ) , ( qw ) - > {
qw . like ( "n.originId" , param . getOriginId ( ) ) . or ( ) . eq ( "n.id" , param . getOriginId ( ) ) ;
} )
. eq ( StrUtil . isNotBlank ( param . getProblemSourcesCode ( ) ) , "n.problemSourcesCode" , param . getProblemSourcesCode ( ) )
. eq ( StrUtil . isNotBlank ( param . getBusinessTypeCode ( ) ) , "n.businessTypeCode" , param . getBusinessTypeCode ( ) )
. like ( StrUtil . isNotBlank ( param . getThingDesc ( ) ) , "n.thingDesc" , param . getThingDesc ( ) )
. eq ( StrUtil . isNotBlank ( param . getInvolveDepartId ( ) ) , "n.involveDepartId" , param . getInvolveDepartId ( ) )
. in ( Objects . nonNull ( param . getProcessingStatus ( ) ) & & ! param . getProcessingStatus ( ) . isEmpty ( ) , "n.processing_status" , param . getProcessingStatus ( ) )
. eq ( StrUtil . isNotBlank ( param . getCheckStatus ( ) ) , "n.checkStatus" , param . getCheckStatus ( ) )
. eq ( StrUtil . isNotBlank ( param . getIsRectifyCode ( ) ) , "n.isRectifyCode" , param . getIsRectifyCode ( ) )
. eq ( StrUtil . isNotBlank ( param . getSpecialSupervision ( ) ) , "n.special_supervision" , param . getSpecialSupervision ( ) )
. eq ( StrUtil . isNotBlank ( param . getFlowKey ( ) ) , "n.flow_key" , param . getFlowKey ( ) )
. eq ( StrUtil . isNotBlank ( param . getSpecialSupervision ( ) ) , "n.special_supervision" , param . getSpecialSupervision ( ) )
. eq ( Objects . nonNull ( param . getCrtDepartLevel ( ) ) , "n.crt_depart_level" , param . getCrtDepartLevel ( ) )
. like ( StrUtil . isNotBlank ( param . getReportNumber ( ) ) , "n.report_number" , param . getReportNumber ( ) )
. in ( Objects . nonNull ( param . getHandleResultCode ( ) ) & & ! param . getHandleResultCode ( ) . isEmpty ( ) , "nb.handleResultCode" , param . getHandleResultCode ( ) )
. orderByDesc ( "w.create_time" ) ;
if ( workParam . getHappenTime ( ) . size ( ) = = 2 ) {
queryWrapper . between ( "n.happenTime" , workParam . getHappenTime ( ) . get ( 0 ) , workParam . getHappenTime ( ) . get ( 1 ) ) ;
if ( param . getHappenTime ( ) . size ( ) = = 2 ) {
queryWrapper . between ( "n.happenTime" , param . getHappenTime ( ) . get ( 0 ) , param . getHappenTime ( ) . get ( 1 ) ) ;
}
if ( param . getDiscoveryTime ( ) . size ( ) = = 2 ) {
queryWrapper . between ( "n.discoveryTime" , param . getDiscoveryTime ( ) . get ( 0 ) , param . getDiscoveryTime ( ) . get ( 1 ) ) ;
}
if ( param . getCrtTime ( ) . size ( ) = = 2 ) {
queryWrapper . between ( "b.crtTime" , param . getCrtTime ( ) . get ( 0 ) , param . getCrtTime ( ) . get ( 1 ) ) ;
}
if ( StrUtil . isNotBlank ( param . getResponderKey ( ) ) & & StrUtil . isNotBlank ( param . getResponderValue ( ) ) ) {
switch ( param . getResponderKey ( ) ) {
case "name" :
queryWrapper . like ( "n.responderName" , param . getResponderValue ( ) ) ;
break ;
case "phone" :
queryWrapper . like ( "n.contactPhone" , param . getResponderValue ( ) ) ;
break ;
}
}
if ( StrUtil . isNotBlank ( param . getBlameKey ( ) ) & & StrUtil . isNotBlank ( param . getBlameValue ( ) ) ) {
switch ( param . getResponderKey ( ) ) {
case "name" :
queryWrapper . like ( "nb.blameName" , param . getBlameValue ( ) ) ;
break ;
case "empNo" :
queryWrapper . like ( "nb.blameEmpNo" , param . getBlameValue ( ) ) ;
break ;
case "idCode" :
queryWrapper . like ( "nb.blameIdCode" , param . getBlameValue ( ) ) ;
break ;
}
}
if ( Objects . nonNull ( param . getTimeoutFlag ( ) ) ) {
if ( param . getTimeoutFlag ( ) ) {
queryWrapper . eq ( "n.processing_status" , ProcessingStatusEnum . completed . name ( ) ) . gt ( "n.handle_timeout" , 0 ) ;
} else {
queryWrapper
. and ( query - > {
query . ne ( "n.processing_status" , ProcessingStatusEnum . completed . name ( ) ) . or ( ) . gt ( "n.handle_timeout" , 0 ) ;
} ) ;
}
}
// 办理单位
if ( StrUtil . isNotBlank ( param . getHandleDepartId ( ) ) ) {
List < DepartTree > nodes = departService . getAllNode ( List . of ( param . getHandleDepartId ( ) ) ) ;
List < String > secondIds = nodes . stream ( ) . filter ( node - > DepartLevelEnum . SECOND . getValue ( ) . equals ( node . getLevel ( ) ) ) . map ( DepartTree : : getId ) . toList ( ) ;
if ( ! secondIds . isEmpty ( ) ) {
queryWrapper . in ( "n.handle_second_depart_id" , secondIds ) ;
} else {
queryWrapper . in ( "n.handle_three_depart_id" , nodes . stream ( ) . filter ( node - > DepartLevelEnum . THREE . getValue ( ) . equals ( node . getLevel ( ) ) ) . map ( DepartTree : : getId ) . toList ( ) ) ;
}
}
// 是否延期
if ( Objects . nonNull ( param . getExtensionFlag ( ) ) ) {
if ( param . getExtensionFlag ( ) ) {
queryWrapper . and ( query - > {
query . eq ( "n.extension_apply_flag" , false ) . or ( ) . gt ( "n.extension_days" , 0 ) ;
} ) ;
} else {
queryWrapper . eq ( "n.extension_apply_flag" , true ) . or ( ) . isNull ( "n.extension_days" ) ;
}
}
Page < NegativeWorkModel > modelPage = baseMapper . queryPage ( Page . of ( workParam . getCurrent ( ) , workParam . getSize ( ) ) , queryWrapper ) ;
Page < NegativeWorkModel > modelPage = baseMapper . queryPage ( Page . of ( p aram. getCurrent ( ) , p aram. getSize ( ) ) , queryWrapper ) ;
modelPage . getRecords ( ) . forEach ( item - > {
item . setRemainingDuration ( TimeUtil . getRemainingDuration ( item . getFirstDistributeTime ( ) , item . getMaxSignDuration ( ) , item . getMaxHandleDuration ( ) , item . getExtensionDays ( ) , item . getFlowKey ( ) ) ) ;
} ) ;