@ -17,6 +17,8 @@ import com.biutag.lan.domain.Work;
import com.biutag.lan.domain.bo.MailQuery ;
import com.biutag.lan.domain.bo.MailQuery ;
import com.biutag.lan.domain.vo.WorkVo ;
import com.biutag.lan.domain.vo.WorkVo ;
import com.biutag.lan.enums.WorkType ;
import com.biutag.lan.enums.WorkType ;
import com.biutag.lan.flow.FlowNameEnum ;
import com.biutag.lan.flow.FlowNodeEnum ;
import com.biutag.lan.mapper.MailLabelMapper ;
import com.biutag.lan.mapper.MailLabelMapper ;
import com.biutag.lan.mapper.WorkMapper ;
import com.biutag.lan.mapper.WorkMapper ;
import jakarta.annotation.Resource ;
import jakarta.annotation.Resource ;
@ -30,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException ;
import java.io.IOException ;
import java.net.URLEncoder ;
import java.net.URLEncoder ;
import java.time.LocalDateTime ;
import java.time.LocalDateTime ;
import java.util.Collection ;
import java.util.List ;
import java.util.List ;
import java.util.Objects ;
import java.util.Objects ;
import java.util.stream.Collectors ;
import java.util.stream.Collectors ;
@ -56,7 +59,8 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
. setSignRoleId ( RoleEnum . MUNICIPAL_DEPT_CLASSES . getRoleId ( ) )
. setSignRoleId ( RoleEnum . MUNICIPAL_DEPT_CLASSES . getRoleId ( ) )
. setMainDeptFlag ( true )
. setMainDeptFlag ( true )
. setCreateTime ( now )
. setCreateTime ( now )
. setUpdateTime ( now ) ;
. setUpdateTime ( now )
. setFlowName ( FlowNameEnum . PENDING_SIGN . getName ( ) ) ;
return work ;
return work ;
} ) . collect ( Collectors . toList ( ) ) ;
} ) . collect ( Collectors . toList ( ) ) ;
return saveBatch ( list ) ;
return saveBatch ( list ) ;
@ -64,7 +68,6 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Exception . class )
public boolean saveExcelBatch ( List < WorkVo > mailSources ) {
public boolean saveExcelBatch ( List < WorkVo > mailSources ) {
LocalDateTime now = LocalDateTime . now ( ) ;
List < Work > list = mailSources . stream ( ) . map ( mail - > {
List < Work > list = mailSources . stream ( ) . map ( mail - > {
Work work = new Work ( ) ;
Work work = new Work ( ) ;
BeanUtils . copyProperties ( mail , work ) ;
BeanUtils . copyProperties ( mail , work ) ;
@ -84,7 +87,7 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
return save ( work ) ;
return save ( work ) ;
}
}
public boolean saveOrUpdate ( Mail mail , Integer roleId , Integer deptId , LocalDateTime time , Boolean mainDeptFlag ) {
public boolean saveOrUpdate ( Mail mail , Integer roleId , Integer deptId , LocalDateTime time , Boolean mainDeptFlag , String flowName ) {
Work work = getOne ( mail . getId ( ) , roleId , deptId ) ;
Work work = getOne ( mail . getId ( ) , roleId , deptId ) ;
if ( Objects . isNull ( work ) ) {
if ( Objects . isNull ( work ) ) {
work = new Work ( ) ;
work = new Work ( ) ;
@ -94,11 +97,11 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
. setSignDeptId ( deptId )
. setSignDeptId ( deptId )
. setCreateTime ( time ) ;
. setCreateTime ( time ) ;
}
}
work . setWorkState ( Work . State . todo . name ( ) ) . setUpdateTime ( time ) . setMainDeptFlag ( mainDeptFlag ) ;
work . setWorkState ( Work . State . todo . name ( ) ) . setUpdateTime ( time ) . setMainDeptFlag ( mainDeptFlag ) . setFlowName ( flowName ) ;
return saveOrUpdate ( work ) ;
return saveOrUpdate ( work ) ;
}
}
public boolean saveOrUpdate ( Mail mail , String empNo , LocalDateTime time ) {
public boolean saveOrUpdate ( Mail mail , String empNo , LocalDateTime time , String flowName ) {
Work work = getOne ( mail . getId ( ) , empNo ) ;
Work work = getOne ( mail . getId ( ) , empNo ) ;
if ( Objects . isNull ( work ) ) {
if ( Objects . isNull ( work ) ) {
work = new Work ( ) ;
work = new Work ( ) ;
@ -107,7 +110,7 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
. setPoliceEmpNo ( empNo )
. setPoliceEmpNo ( empNo )
. setCreateTime ( time ) ;
. setCreateTime ( time ) ;
}
}
work . setWorkState ( Work . State . todo . name ( ) ) . setUpdateTime ( time ) ;
work . setWorkState ( Work . State . todo . name ( ) ) . setUpdateTime ( time ) . setFlowName ( flowName ) ;
return saveOrUpdate ( work ) ;
return saveOrUpdate ( work ) ;
}
}
@ -124,7 +127,8 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
. setCreateTime ( time )
. setCreateTime ( time )
. setUpdateTime ( time )
. setUpdateTime ( time )
// 部门会签
// 部门会签
. setWorkType ( WorkType . dept_countersign . name ( ) ) ;
. setWorkType ( WorkType . dept_countersign . name ( ) )
. setFlowName ( FlowNameEnum . PENDING_COUNTERSIGN . getName ( ) ) ;
return work ;
return work ;
} ) . collect ( Collectors . toList ( ) ) ;
} ) . collect ( Collectors . toList ( ) ) ;
return saveBatch ( collect ) ;
return saveBatch ( collect ) ;
@ -160,15 +164,15 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
}
}
public boolean updateTodo ( String mailId , Integer roleId , LocalDateTime time ) {
public boolean updateTodo ( String mailId , Integer roleId , LocalDateTime time , String flowName ) {
Work work = getByRoleId ( mailId , roleId ) ;
Work work = getByRoleId ( mailId , roleId ) ;
work . setUpdateTime ( time ) . setWorkState ( Work . State . todo . name ( ) ) . setPoliceEmpNo ( null ) ;
work . setUpdateTime ( time ) . setWorkState ( Work . State . todo . name ( ) ) . setPoliceEmpNo ( null ) . setFlowName ( flowName ) ;
return updateById ( work ) ;
return updateById ( work ) ;
}
}
public boolean updateTodo ( String mailId , Integer roleId , String workType , LocalDateTime time ) {
public boolean updateTodo ( String mailId , Integer roleId , String workType , LocalDateTime time , String flowName ) {
Work work = getByRoleId ( mailId , roleId ) ;
Work work = getByRoleId ( mailId , roleId ) ;
work . setUpdateTime ( time ) . setWorkState ( Work . State . todo . name ( ) ) . setPoliceEmpNo ( null ) . setWorkType ( workType ) ;
work . setUpdateTime ( time ) . setWorkState ( Work . State . todo . name ( ) ) . setPoliceEmpNo ( null ) . setWorkType ( workType ) . setFlowName ( flowName ) ;
return updateById ( work ) ;
return updateById ( work ) ;
}
}
@ -181,7 +185,10 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
. eq ( StrUtil . isNotBlank ( todoQuery . getMailLevel ( ) ) , "m.mail_level" , todoQuery . getMailLevel ( ) )
. eq ( StrUtil . isNotBlank ( todoQuery . getMailLevel ( ) ) , "m.mail_level" , todoQuery . getMailLevel ( ) )
. eq ( StrUtil . isNotBlank ( todoQuery . getMailCategory ( ) ) , "m.mail_category" , todoQuery . getMailCategory ( ) )
. eq ( StrUtil . isNotBlank ( todoQuery . getMailCategory ( ) ) , "m.mail_category" , todoQuery . getMailCategory ( ) )
. like ( StrUtil . isNotBlank ( todoQuery . getThreeDeptName ( ) ) , "m.three_dept_name" , todoQuery . getThreeDeptName ( ) )
. like ( StrUtil . isNotBlank ( todoQuery . getThreeDeptName ( ) ) , "m.three_dept_name" , todoQuery . getThreeDeptName ( ) )
. eq ( StrUtil . isNotBlank ( todoQuery . getFlowKey ( ) ) , "m.flow_key" , todoQuery . getFlowKey ( ) ) ;
. eq ( StrUtil . isNotBlank ( todoQuery . getFlowKey ( ) ) , "m.flow_key" , todoQuery . getFlowKey ( ) )
. and ( query - > {
query . isNull ( "m.flow_key" ) . or ( ) . ne ( "m.flow_key" , FlowNodeEnum . COMPLETION . getKey ( ) ) ;
} ) ;
Integer roleId = AdminThreadLocal . getRoleId ( ) ;
Integer roleId = AdminThreadLocal . getRoleId ( ) ;
// 与角色相关的件
// 与角色相关的件
if ( roleId . equals ( RoleEnum . MUNICIPAL_DEPT_CLASSES . getRoleId ( ) ) | |
if ( roleId . equals ( RoleEnum . MUNICIPAL_DEPT_CLASSES . getRoleId ( ) ) | |
@ -210,7 +217,14 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
}
}
// 排序
// 排序
queryWrapper . orderByDesc ( "w.update_time" ) ;
queryWrapper . orderByDesc ( "w.update_time" ) ;
return baseMapper . selectPageTodo ( page , queryWrapper ) ;
Page < WorkVo > workVoPage = baseMapper . selectPageTodo ( page , queryWrapper ) ;
workVoPage . getRecords ( ) . forEach ( item - > {
// 会签中
if ( FlowNameEnum . COUNTERSIGNING . getName ( ) . equals ( item . getFlowName ( ) ) ) {
item . setFlowName ( String . format ( "%s(%s/%s)" , item . getFlowName ( ) , item . getCountersignCompleted ( ) , item . getCountersignTotal ( ) ) ) ;
}
} ) ;
return workVoPage ;
}
}
public Work getOne ( String mailId , String empNo ) {
public Work getOne ( String mailId , String empNo ) {
@ -253,7 +267,6 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
public Work getxByUnSign ( String mailId , Integer roleId , Integer deptId ) {
public Work getxByUnSign ( String mailId , Integer roleId , Integer deptId ) {
LambdaQueryWrapper < Work > queryWrapper = new LambdaQueryWrapper < Work > ( )
LambdaQueryWrapper < Work > queryWrapper = new LambdaQueryWrapper < Work > ( )
. eq ( Work : : getMailId , mailId )
. eq ( Work : : getMailId , mailId )
. isNull ( Work : : getPoliceEmpNo )
. eq ( Work : : getSignRoleId , roleId )
. eq ( Work : : getSignRoleId , roleId )
// 如果不是市局专班,则需要查询签收部门ID
// 如果不是市局专班,则需要查询签收部门ID
. eq ( ! RoleEnum . MUNICIPAL_DEPT_CLASSES . getRoleId ( ) . equals ( roleId ) , Work : : getSignDeptId , deptId ) ;
. eq ( ! RoleEnum . MUNICIPAL_DEPT_CLASSES . getRoleId ( ) . equals ( roleId ) , Work : : getSignDeptId , deptId ) ;
@ -264,6 +277,14 @@ public class WorkService extends ServiceImpl<WorkMapper, Work> {
return baseMapper . selectCount ( flowKey , deptId ) ;
return baseMapper . selectCount ( flowKey , deptId ) ;
}
}
public Integer count ( Collection < String > flowKeys , Integer deptId ) {
return baseMapper . selectCountByFlowKey ( flowKeys , deptId ) ;
}
public Integer count ( Boolean extensionFlag , Integer deptId ) {
return baseMapper . selectCountByExtensionFlag ( extensionFlag , deptId ) ;
}
public List < Work > list ( String mailId , Integer roleId , String workType ) {
public List < Work > list ( String mailId , Integer roleId , String workType ) {
return list ( new LambdaQueryWrapper < Work > ( ) . eq ( Work : : getMailId , mailId ) . eq ( Work : : getSignRoleId , roleId ) . eq ( Work : : getWorkType , workType ) ) ;
return list ( new LambdaQueryWrapper < Work > ( ) . eq ( Work : : getMailId , mailId ) . eq ( Work : : getSignRoleId , roleId ) . eq ( Work : : getWorkType , workType ) ) ;
}
}