@ -101,6 +101,45 @@ public class ServiceApplicationsService {
@Resource
@Resource
private DictService dictService ;
private DictService dictService ;
/ * *
* 案号重复性校验 ( 用于提交操作 )
* @param addForm 提交表单
* /
private void validateRecordNoUniquenessForSubmit ( ServiceApplicationsAddForm addForm ) {
// 只对TIME类型的服务进行案号校验
if ( ! "TIME" . equals ( addForm . getServiceType ( ) ) ) {
return ;
}
String recordNo = addForm . getRecordNo ( ) ;
if ( recordNo = = null | | recordNo . trim ( ) . isEmpty ( ) ) {
return ;
}
Long currentUserId = AdminRequestUtil . getRequestUser ( ) . getEmployeeId ( ) ;
if ( addForm . getApplicationId ( ) = = null ) {
// 新增操作:检查案号是否已存在
List < ServiceApplicationsVO > existingRecords = serviceApplicationsDao . selectByRecordNo ( recordNo ) ;
if ( ! existingRecords . isEmpty ( ) ) {
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + existingRecords . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
} else {
// 编辑操作:检查案号是否被其他用户使用并且本人也不能使用
List < ServiceApplicationsVO > existingRecords = serviceApplicationsDao . selectByRecordNo ( recordNo ) ;
if ( ! existingRecords . isEmpty ( ) ) {
// 检查是否是当前用户的记录
boolean isCurrentUserRecord = existingRecords . stream ( )
. anyMatch ( record - > record . getUserId ( ) . equals ( currentUserId ) ) ;
if ( ! isCurrentUserRecord | | existingRecords . size ( ) > 1 ) {
// 如果不是当前用户的记录,或者有多条记录(包括当前用户),则不允许
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + existingRecords . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
}
}
}
//查看详情
//查看详情
public ServiceApplicationsVO queryDetail ( Long applicationId ) {
public ServiceApplicationsVO queryDetail ( Long applicationId ) {
ServiceApplicationsVO serviceApplicationsVO = new ServiceApplicationsVO ( ) ;
ServiceApplicationsVO serviceApplicationsVO = new ServiceApplicationsVO ( ) ;
@ -168,7 +207,7 @@ public class ServiceApplicationsService {
}
}
queryForm . setEmployeeIdList ( departmentEmployees ) ;
queryForm . setEmployeeIdList ( departmentEmployees ) ;
// 设置只查看firmAuditStatus为待审核、通过和拒绝的数据
// 律所管理员可以查看部门内所有已审核数据以及自己创建的所有数据(包括未提交的草稿)
queryForm . setIncludeFirmReviewed ( true ) ;
queryForm . setIncludeFirmReviewed ( true ) ;
} else {
} else {
// 律所普通用户:只能看到自己提交的数据,包括所有firmAuditStatus状态
// 律所普通用户:只能看到自己提交的数据,包括所有firmAuditStatus状态
@ -242,7 +281,19 @@ public class ServiceApplicationsService {
if ( "TIME" . equals ( addForm . getServiceType ( ) ) ) {
if ( "TIME" . equals ( addForm . getServiceType ( ) ) ) {
//当前登录人的ID
//当前登录人的ID
Long userId = AdminRequestUtil . getRequestUser ( ) . getEmployeeId ( ) ;
Long userId = AdminRequestUtil . getRequestUser ( ) . getEmployeeId ( ) ;
List < ServiceApplicationsVO > applicationsVOS = serviceApplicationsDao . selectByRecordNoNotMy ( userId , addForm . getRecordNo ( ) ) ;
// 编辑操作:检查案号是否被其他用户使用并且本人也不能使用
List < ServiceApplicationsVO > existingRecords = serviceApplicationsDao . selectByRecordNo ( addForm . getRecordNo ( ) ) ;
if ( ! existingRecords . isEmpty ( ) ) {
// 检查是否是当前用户的记录
boolean isCurrentUserRecord = existingRecords . stream ( )
. anyMatch ( record - > record . getUserId ( ) . equals ( userId ) ) ;
if ( ! isCurrentUserRecord | | existingRecords . size ( ) > 1 ) {
// 如果不是当前用户的记录,或者有多条记录(包括当前用户),则不允许
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + existingRecords . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
}
}
}
serviceApplicationsDao . updateById ( serviceApplicationsEntity ) ;
serviceApplicationsDao . updateById ( serviceApplicationsEntity ) ;
}
}
@ -258,10 +309,17 @@ public class ServiceApplicationsService {
if ( "TIME" . equals ( updateForm . getServiceType ( ) ) ) {
if ( "TIME" . equals ( updateForm . getServiceType ( ) ) ) {
//当前登录人的ID
//当前登录人的ID
Long userId = AdminRequestUtil . getRequestUser ( ) . getEmployeeId ( ) ;
Long userId = AdminRequestUtil . getRequestUser ( ) . getEmployeeId ( ) ;
List < ServiceApplicationsVO > serviceApplicationsEntity = serviceApplicationsDao . selectByRecordNoNotMy ( userId , updateForm . getRecordNo ( ) ) ;
// 编辑操作:检查案号是否被其他用户使用并且本人也不能使用
List < ServiceApplicationsVO > existingRecords = serviceApplicationsDao . selectByRecordNo ( updateForm . getRecordNo ( ) ) ;
if ( ! existingRecords . isEmpty ( ) ) {
// 检查是否是当前用户的记录
boolean isCurrentUserRecord = existingRecords . stream ( )
. anyMatch ( record - > record . getUserId ( ) . equals ( userId ) ) ;
if ( ! serviceApplicationsEntity . isEmpty ( ) ) {
if ( ! isCurrentUserRecord | | existingRecords . size ( ) > 1 ) {
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + serviceApplicationsEntity . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
// 如果不是当前用户的记录,或者有多条记录(包括当前用户),则不允许
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + existingRecords . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
}
}
}
}
ServiceApplicationsEntity serviceApplicationsEntity = SmartBeanUtil . copy ( updateForm , ServiceApplicationsEntity . class ) ;
ServiceApplicationsEntity serviceApplicationsEntity = SmartBeanUtil . copy ( updateForm , ServiceApplicationsEntity . class ) ;
@ -272,51 +330,26 @@ public class ServiceApplicationsService {
/ * *
/ * *
* 提交
* 提交
*
* /
* /
public ResponseDTO < String > submit ( ServiceApplicationsAddForm addForm ) {
public ResponseDTO < String > submit ( ServiceApplicationsAddForm addForm ) {
// 案号重复性校验
validateRecordNoUniquenessForSubmit ( addForm ) ;
if ( "TIME" . equals ( addForm . getServiceType ( ) ) ) {
//当前登录人的ID
Long userId = AdminRequestUtil . getRequestUser ( ) . getEmployeeId ( ) ;
List < ServiceApplicationsVO > serviceApplicationsEntity = serviceApplicationsDao . selectByRecordNoNotMy ( userId , addForm . getRecordNo ( ) ) ;
if ( ! serviceApplicationsEntity . isEmpty ( ) ) {
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + serviceApplicationsEntity . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
}
// 检查当前用户角色是否为CEO
/ * RequestUser requestUser = AdminRequestUtil . getRequestUser ( ) ;
List < RoleVO > roles = roleEmployeeService . getRoleIdList ( requestUser . getUserId ( ) ) ;
if ( ! roles . isEmpty ( ) ) {
String roleCode = roles . get ( 0 ) . getRoleCode ( ) ;
// 如果是CEO角色提交申报,默认通过律所审核和协会审核
if ( UserTypeEnum . CEO . getDesc ( ) . equals ( roleCode ) ) {
serviceApplicationsEntity . setFirmAuditStatus ( ReviewEnum . PASS . getValue ( ) ) ;
serviceApplicationsEntity . setFirmAuditUser ( requestUser . getUserId ( ) ) ;
serviceApplicationsEntity . setFirmAuditTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsEntity . setAssociationAuditStatus ( ReviewEnum . PASS . getValue ( ) ) ;
serviceApplicationsEntity . setAssociationAuditUser ( requestUser . getUserId ( ) ) ;
serviceApplicationsEntity . setAssociationAuditTime ( LocalDateTime . now ( ) ) ;
}
} else { * /
//}
if ( null = = addForm . getApplicationId ( ) ) {
if ( null = = addForm . getApplicationId ( ) ) {
// 新增提交
ServiceApplicationsEntity serviceApplications = new ServiceApplicationsEntity ( ) ;
ServiceApplicationsEntity serviceApplications = new ServiceApplicationsEntity ( ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplications . setReportTime ( LocalDateTime . now ( ) ) ;
serviceApplications . setReportTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsDao . insert ( serviceApplications ) ;
serviceApplicationsDao . insert ( serviceApplications ) ;
} else {
} else {
// 编辑提交
ServiceApplicationsEntity serviceApplications = serviceApplicationsDao . selectById ( addForm . getApplicationId ( ) ) ;
ServiceApplicationsEntity serviceApplications = serviceApplicationsDao . selectById ( addForm . getApplicationId ( ) ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplications . setReportTime ( LocalDateTime . now ( ) ) ;
serviceApplications . setReportTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsDao . updateById ( serviceApplications ) ;
serviceApplicationsDao . updateById ( serviceApplications ) ;
}
}
//serviceApplicationsDao.updateById(serviceApplications);
return ResponseDTO . ok ( ) ;
return ResponseDTO . ok ( ) ;
}
}
/ * *
/ * *
@ -564,13 +597,7 @@ public class ServiceApplicationsService {
}
}
public ResponseDTO < String > addSubmit ( @Valid ServiceApplicationsAddForm addForm ) {
public ResponseDTO < String > addSubmit ( @Valid ServiceApplicationsAddForm addForm ) {
//判断活动类型查询案号有没有存在
if ( "TIME" . equals ( addForm . getServiceType ( ) ) ) {
List < ServiceApplicationsVO > serviceApplicationsEntity = serviceApplicationsDao . selectByRecordNo ( addForm . getRecordNo ( ) ) ;
if ( ! serviceApplicationsEntity . isEmpty ( ) ) {
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + serviceApplicationsEntity . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
}
//ServiceApplicationsEntity serviceApplicationsEntity = SmartBeanUtil.copy(addForm, ServiceApplicationsEntity.class);
//ServiceApplicationsEntity serviceApplicationsEntity = SmartBeanUtil.copy(addForm, ServiceApplicationsEntity.class);
//serviceApplicationsEntity.setFirmAuditStatus(ReviewEnum.APPROVAL.getValue());
//serviceApplicationsEntity.setFirmAuditStatus(ReviewEnum.APPROVAL.getValue());
//serviceApplicationsEntity.setReportTime(LocalDateTime.now());
//serviceApplicationsEntity.setReportTime(LocalDateTime.now());
@ -592,12 +619,35 @@ public class ServiceApplicationsService {
} * /
} * /
if ( null = = addForm . getApplicationId ( ) ) {
if ( null = = addForm . getApplicationId ( ) ) {
//判断活动类型查询案号有没有存在
if ( "TIME" . equals ( addForm . getServiceType ( ) ) ) {
List < ServiceApplicationsVO > serviceApplicationsEntity = serviceApplicationsDao . selectByRecordNo ( addForm . getRecordNo ( ) ) ;
if ( ! serviceApplicationsEntity . isEmpty ( ) ) {
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + serviceApplicationsEntity . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
}
ServiceApplicationsEntity serviceApplications = new ServiceApplicationsEntity ( ) ;
ServiceApplicationsEntity serviceApplications = new ServiceApplicationsEntity ( ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplications . setReportTime ( LocalDateTime . now ( ) ) ;
serviceApplications . setReportTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsDao . insert ( serviceApplications ) ;
serviceApplicationsDao . insert ( serviceApplications ) ;
} else {
} else {
//判断活动类型查询案号有没有存在
if ( "TIME" . equals ( addForm . getServiceType ( ) ) ) {
Long userId = AdminRequestUtil . getRequestUser ( ) . getEmployeeId ( ) ;
// 编辑操作:检查案号是否被其他用户使用并且本人也不能使用
List < ServiceApplicationsVO > existingRecords = serviceApplicationsDao . selectByRecordNo ( addForm . getRecordNo ( ) ) ;
if ( ! existingRecords . isEmpty ( ) ) {
// 检查是否是当前用户的记录
boolean isCurrentUserRecord = existingRecords . stream ( )
. anyMatch ( record - > record . getUserId ( ) . equals ( userId ) ) ;
if ( ! isCurrentUserRecord | | existingRecords . size ( ) > 1 ) {
// 如果不是当前用户的记录,或者有多条记录(包括当前用户),则不允许
throw new BusinessException ( UserErrorCode . HAS_EXIST . getMsg ( ) + existingRecords . get ( 0 ) . getUserName ( ) + UserErrorCode . HAS_EXIST1 . getMsg ( ) ) ;
}
}
}
ServiceApplicationsEntity serviceApplications = serviceApplicationsDao . selectById ( addForm . getApplicationId ( ) ) ;
ServiceApplicationsEntity serviceApplications = serviceApplicationsDao . selectById ( addForm . getApplicationId ( ) ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
SmartBeanUtil . copyProperties ( addForm , serviceApplications ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplications . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;