@ -1,5 +1,6 @@
package net.lab1024.sa.admin.module.service.service ;
package net.lab1024.sa.admin.module.service.service ;
import cn.hutool.core.bean.BeanUtil ;
import com.alibaba.excel.EasyExcel ;
import com.alibaba.excel.EasyExcel ;
import com.alibaba.excel.write.handler.SheetWriteHandler ;
import com.alibaba.excel.write.handler.SheetWriteHandler ;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder ;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder ;
@ -42,6 +43,8 @@ import net.lab1024.sa.base.common.exception.BusinessException;
import net.lab1024.sa.base.common.util.SmartBeanUtil ;
import net.lab1024.sa.base.common.util.SmartBeanUtil ;
import net.lab1024.sa.base.common.util.SmartPageUtil ;
import net.lab1024.sa.base.common.util.SmartPageUtil ;
import net.lab1024.sa.base.common.util.SmartResponseUtil ;
import net.lab1024.sa.base.common.util.SmartResponseUtil ;
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity ;
import net.lab1024.sa.base.module.support.dict.service.DictService ;
import org.apache.catalina.util.RequestUtil ;
import org.apache.catalina.util.RequestUtil ;
import org.apache.commons.collections4.CollectionUtils ;
import org.apache.commons.collections4.CollectionUtils ;
import org.apache.poi.ss.usermodel.* ;
import org.apache.poi.ss.usermodel.* ;
@ -92,6 +95,8 @@ public class ServiceApplicationsService {
private RoleEmployeeService roleEmployeeService ;
private RoleEmployeeService roleEmployeeService ;
@Resource
@Resource
PositionService positionService ;
PositionService positionService ;
@Resource
private DictService dictService ;
//查看详情
//查看详情
public ServiceApplicationsVO queryDetail ( Long applicationId ) {
public ServiceApplicationsVO queryDetail ( Long applicationId ) {
@ -138,25 +143,7 @@ public class ServiceApplicationsService {
if ( isAssociationRole ) {
if ( isAssociationRole ) {
// 协会用户(CEO):可以看到所有律所提交的数据,但只显示associationAuditStatus为待审核(1)、通过(3)和拒绝(4)的数据和自己创建的数据
// 协会用户(CEO):可以看到所有律所提交的数据,但只显示associationAuditStatus为待审核(1)、通过(3)和拒绝(4)的数据和自己创建的数据
Integer oneByRoleId = dataScopeViewService . getOneByRoleId ( roleIdList . get ( 0 ) . getRoleId ( ) ) ;
// CEO作为最高权限用户,不需要限制在特定部门范围内,直接设置includeAssociationReviewed即可
// 获取自己部门范围内的数据
List < Long > departmentEmployees = new ArrayList < > ( ) ;
if ( DataScopeViewTypeEnum . ME . getValue ( ) . equals ( oneByRoleId ) ) {
departmentEmployees = dataScopeViewService . getCanViewEmployeeId ( DataScopeViewTypeEnum . ME , requestUser . getUserId ( ) ) ;
} else if ( DataScopeViewTypeEnum . DEPARTMENT . getValue ( ) . equals ( oneByRoleId ) ) {
departmentEmployees = dataScopeViewService . getCanViewEmployeeId ( DataScopeViewTypeEnum . DEPARTMENT , requestUser . getUserId ( ) ) ;
}
// 确保包含当前用户ID,以便能看到自己创建的数据
if ( departmentEmployees = = null ) {
departmentEmployees = new ArrayList < > ( ) ;
}
if ( ! departmentEmployees . contains ( requestUser . getUserId ( ) ) ) {
departmentEmployees . add ( requestUser . getUserId ( ) ) ;
}
queryForm . setEmployeeIdList ( departmentEmployees ) ;
// 设置只显示associationAuditStatus为待审核、通过、拒绝的数据
queryForm . setIncludeAssociationReviewed ( true ) ;
queryForm . setIncludeAssociationReviewed ( true ) ;
} else if ( isFirmAdminRole ) {
} else if ( isFirmAdminRole ) {
// 律所管理员(cto):能看到自己部门范围内的数据,但只显示firmAuditStatus为待审核、通过和拒绝的数据和自己创建的数据
// 律所管理员(cto):能看到自己部门范围内的数据,但只显示firmAuditStatus为待审核、通过和拒绝的数据和自己创建的数据
@ -193,7 +180,7 @@ public class ServiceApplicationsService {
longs = new ArrayList < > ( ) ;
longs = new ArrayList < > ( ) ;
}
}
if ( ! longs . contains ( requestUser . getUserId ( ) ) ) {
if ( ! longs . contains ( requestUser . getUserId ( ) ) ) {
longs . remove ( requestUser . getUserId ( ) ) ;
longs . add ( requestUser . getUserId ( ) ) ;
}
}
queryForm . setEmployeeIdList ( longs ) ;
queryForm . setEmployeeIdList ( longs ) ;
// 普通用户不需要审核状态过滤,可以看到自己所有状态的数据
// 普通用户不需要审核状态过滤,可以看到自己所有状态的数据
@ -264,7 +251,7 @@ public class ServiceApplicationsService {
ServiceApplicationsEntity serviceApplicationsEntity = serviceApplicationsDao . selectById ( applicationId ) ;
ServiceApplicationsEntity serviceApplicationsEntity = serviceApplicationsDao . selectById ( applicationId ) ;
// 检查当前用户角色是否为CEO
// 检查当前用户角色是否为CEO
RequestUser requestUser = AdminRequestUtil . getRequestUser ( ) ;
/ * RequestUser requestUser = AdminRequestUtil . getRequestUser ( ) ;
List < RoleVO > roles = roleEmployeeService . getRoleIdList ( requestUser . getUserId ( ) ) ;
List < RoleVO > roles = roleEmployeeService . getRoleIdList ( requestUser . getUserId ( ) ) ;
if ( ! roles . isEmpty ( ) ) {
if ( ! roles . isEmpty ( ) ) {
String roleCode = roles . get ( 0 ) . getRoleCode ( ) ;
String roleCode = roles . get ( 0 ) . getRoleCode ( ) ;
@ -277,10 +264,10 @@ public class ServiceApplicationsService {
serviceApplicationsEntity . setAssociationAuditUser ( requestUser . getUserId ( ) ) ;
serviceApplicationsEntity . setAssociationAuditUser ( requestUser . getUserId ( ) ) ;
serviceApplicationsEntity . setAssociationAuditTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsEntity . setAssociationAuditTime ( LocalDateTime . now ( ) ) ;
}
}
} else {
} else { * /
serviceApplicationsEntity . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplicationsEntity . setFirmAuditStatus ( ReviewEnum . APPROVAL . getValue ( ) ) ;
serviceApplicationsEntity . setReportTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsEntity . setReportTime ( LocalDateTime . now ( ) ) ;
}
//}
serviceApplicationsDao . updateById ( serviceApplicationsEntity ) ;
serviceApplicationsDao . updateById ( serviceApplicationsEntity ) ;
return ResponseDTO . ok ( ) ;
return ResponseDTO . ok ( ) ;
}
}
@ -503,27 +490,27 @@ public class ServiceApplicationsService {
return ResponseDTO . ok ( ) ;
return ResponseDTO . ok ( ) ;
}
}
RequestUser requestUser = AdminRequestUtil . getRequestUser ( ) ;
// RequestUser requestUser = AdminRequestUtil.getRequestUser();
// 查询用户角色是律所管理员,则修改律所的审核状态
// 查询用户角色是律所管理员,则修改律所的审核状态
// 如果是ceo则修改协会审核状态
// 如果是ceo则修改协会审核状态
List < RoleVO > roles = roleEmployeeService . getRoleIdList ( requestUser . getUserId ( ) ) ;
// List<RoleVO> roles = roleEmployeeService.getRoleIdList(requestUser.getUserId());
if ( roles . isEmpty ( ) ) {
// if (roles.isEmpty()) {
return ResponseDTO . error ( UserErrorCode . NO_PERMISSION ) ;
// return ResponseDTO.error(UserErrorCode.NO_PERMISSION);
}
// }
String roleCode = roles . get ( 0 ) . getRoleCode ( ) ;
// String roleCode = roles.get(0).getRoleCode();
// 设置审核时间
// 设置审核时间
String reviewTime = LocalDateTime . now ( ) . toString ( ) ;
// String reviewTime = LocalDateTime.now().toString();
// 根据不同角色执行不同的提交操作
// 根据不同角色执行不同的提交操作
if ( UserTypeEnum . CEO . getDesc ( ) . equals ( roleCode ) ) {
// if (UserTypeEnum.CEO.getDesc().equals(roleCode)) {
// CEO角色:修改协会审核状态
// CEO角色:修改协会审核状态
serviceApplicationsDao . batchSubmitAsAssociation ( idList , ReviewEnum . PASS . getValue ( ) , requestUser . getUserId ( ) , reviewTime ) ;
//serviceApplicationsDao.batchSubmitAsAssociation(idList, ReviewEnum.PASS.getValue());
} else {
// } else {
// 其他角色(如律所管理员):修改律所审核状态
// 其他角色(如律所管理员):修改律所审核状态
serviceApplicationsDao . batchSubmitAsFirm ( idList , ReviewEnum . REVIEW . getValue ( ) ) ;
serviceApplicationsDao . batchSubmitAsAssociation ( idList , ReviewEnum . APPROVAL . getValue ( ) ) ;
}
// }
return ResponseDTO . ok ( ) ;
return ResponseDTO . ok ( ) ;
}
}
@ -572,23 +559,11 @@ public class ServiceApplicationsService {
// 根据不同角色执行不同的审核操作
// 根据不同角色执行不同的审核操作
if ( UserTypeEnum . CEO . getDesc ( ) . equals ( roleCode ) ) {
if ( UserTypeEnum . CEO . getDesc ( ) . equals ( roleCode ) ) {
//如果是CEO自己创建的数据
if ( serviceApplicationsEntity . getUserId ( ) . equals ( requestUser . getEmployeeId ( ) ) ) {
// 修改所有状态审核状态
serviceApplicationsEntity . setAssociationAuditStatus ( updateForm . getAssociationAuditStatus ( ) ) ;
serviceApplicationsEntity . setAssociationAuditUser ( requestUser . getEmployeeId ( ) ) ;
serviceApplicationsEntity . setAssociationAuditTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsEntity . setAssociationAuditOpinion ( updateForm . getAssociationAuditOpinion ( ) ) ;
serviceApplicationsEntity . setFirmAuditStatus ( updateForm . getAssociationAuditStatus ( ) ) ;
serviceApplicationsEntity . setFirmAuditUser ( requestUser . getEmployeeId ( ) ) ;
serviceApplicationsEntity . setFirmAuditTime ( LocalDateTime . now ( ) ) ;
} else {
// CEO角色:修改协会审核状态
// CEO角色:修改协会审核状态
serviceApplicationsEntity . setAssociationAuditStatus ( updateForm . getAssociationAuditStatus ( ) ) ;
serviceApplicationsEntity . setAssociationAuditStatus ( updateForm . getAssociationAuditStatus ( ) ) ;
serviceApplicationsEntity . setAssociationAuditUser ( requestUser . getEmployeeId ( ) ) ;
serviceApplicationsEntity . setAssociationAuditUser ( requestUser . getEmployeeId ( ) ) ;
serviceApplicationsEntity . setAssociationAuditTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsEntity . setAssociationAuditTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsEntity . setAssociationAuditOpinion ( updateForm . getAssociationAuditOpinion ( ) ) ;
serviceApplicationsEntity . setAssociationAuditOpinion ( updateForm . getAssociationAuditOpinion ( ) ) ;
}
} else {
} else {
// 其他角色(如律所管理员):修改律所审核状态
// 其他角色(如律所管理员):修改律所审核状态
serviceApplicationsEntity . setFirmAuditStatus ( updateForm . getFirmAuditStatus ( ) ) ;
serviceApplicationsEntity . setFirmAuditStatus ( updateForm . getFirmAuditStatus ( ) ) ;
@ -602,12 +577,12 @@ public class ServiceApplicationsService {
/ * *
/ * *
* 律所统计
* 律所统计
* @param queryForm
* @param queryForms
* @return
* @return
* /
* /
public PageResul t< LawyerStatisticsVO > getLawyerStatisticsByDepartment ( @Valid LawyerStatisticsQueryForm queryForm ) {
public Lis t< LawyerStatisticsVO > getLawyerStatisticsByDepartment ( @Valid LawyerStatisticsQueryFormList queryForms ) {
Page < ? > page = SmartPageUtil . convert2PageQuery ( queryForm ) ;
LawyerStatisticsQueryForm queryForm = new LawyerStatisticsQueryForm ( ) ;
BeanUtil . copyProperties ( queryForms , queryForm ) ;
// 如果没有指定季度,则使用年度范围,否则使用季度范围
// 如果没有指定季度,则使用年度范围,否则使用季度范围
if ( queryForm . getQuarter ( ) = = null ) {
if ( queryForm . getQuarter ( ) = = null ) {
// 如果用户指定了年份,则使用指定年份,否则使用当前年份
// 如果用户指定了年份,则使用指定年份,否则使用当前年份
@ -625,18 +600,24 @@ public class ServiceApplicationsService {
queryForm . setEndTime ( quarterEnd . toString ( ) ) ;
queryForm . setEndTime ( quarterEnd . toString ( ) ) ;
}
}
//统计
//统计
List < LawyerStatisticsVO > lawyerStatisticsWithParamYear = serviceApplicationsDao . getdepartmentStatistics ( page , queryForm ) ;
List < LawyerStatisticsVO > lawyerStatisticsWithParamYear = serviceApplicationsDao . getdepartmentStatistics ( queryForm ) ;
PageResult < LawyerStatisticsVO > lawyerStatisticsVOPageResult = SmartPageUtil . convert2PageResult ( page , lawyerStatisticsWithParamYear ) ;
monthStatisticsDepartment ( queryForm , lawyerStatisticsWithParamYear , null ) ;
if ( ! lawyerStatisticsVOPageResult . getList ( ) . isEmpty ( ) ) {
//查询这个部门下面律师的统计信息
monthStatisticsDepartment ( queryForm , lawyerStatisticsVOPageResult . getList ( ) , null ) ;
if ( ! lawyerStatisticsWithParamYear . isEmpty ( ) ) {
lawyerStatisticsWithParamYear . forEach ( lawyerStatisticsVO - > {
ServiceLawyerQueryForm serviceLawyerQueryForm = new ServiceLawyerQueryForm ( ) ;
serviceLawyerQueryForm . setFirmId ( lawyerStatisticsVO . getFirmId ( ) ) ;
List < ServiceLawyerImportForm > lawyerServiceVOList = serviceApplicationsDao . getLawyerStatisticsWithParam ( serviceLawyerQueryForm ) ;
lawyerStatisticsVO . setLawyerServiceVOList ( lawyerServiceVOList ) ;
} ) ;
}
}
return lawyerStatisticsVOPageResult ;
return lawyerStatisticsWithParamYear ;
}
}
public void exportLawyerByDepartment ( ServiceLawyerQueryForm queryForm , HttpServletResponse response ) {
public void exportLawyerByDepartment ( ServiceLawyerQueryForm queryForm , HttpServletResponse response ) {
// 如果没有指定季度,则使用年度范围,否则使用季度范围
// 如果没有指定季度,则使用年度范围,否则使用季度范围
if ( queryForm . getQuarter ( ) = = null ) {
if ( queryForm . getQuarter ( ) = = null ) {
TimeVo yearStartAndEnd = DateTimeUtil . getYearStartAndEnd ( ) ;
TimeVo yearStartAndEnd = DateTimeUtil . getYearStartAndEnd ( queryForm . getYear ( ) ) ;
String yearStart = yearStartAndEnd . getStartTime ( ) ;
String yearStart = yearStartAndEnd . getStartTime ( ) ;
String yearEnd = yearStartAndEnd . getEndTime ( ) ;
String yearEnd = yearStartAndEnd . getEndTime ( ) ;
queryForm . setStartTime ( yearStart ) ;
queryForm . setStartTime ( yearStart ) ;
@ -691,6 +672,43 @@ public class ServiceApplicationsService {
return ResponseDTO . ok ( ) ;
return ResponseDTO . ok ( ) ;
}
}
/ * *
* 获取服务上报费用
* @param queryForm
* @return
* /
public Long getServiceApplicationsCost ( ServiceLawyerQueryForm queryForm ) {
// 根据指定的季度设置时间范围
LocalDateTime quarterStart = DateTimeEnum . getQuarterStart ( queryForm . getYear ( ) , queryForm . getQuarter ( ) ) ;
LocalDateTime quarterEnd = DateTimeEnum . getQuarterEnd ( queryForm . getYear ( ) , queryForm . getQuarter ( ) ) ;
queryForm . setStartTime ( quarterStart . toString ( ) ) ;
queryForm . setEndTime ( quarterEnd . toString ( ) ) ;
//获取多少小时
Long time = serviceApplicationsDao . getServiceApplicationsCost ( queryForm ) ;
//获取字典表的设置
DictEntity dictItem = dictService . getOne ( 3 ) ;
if ( dictItem = = null ) {
return 0L ;
}
//除1w
if ( time ! = null & & time ! = 0L ) {
Long timeCost = time * Long . valueOf ( dictItem . getRemark ( ) ) ;
timeCost = timeCost / 10000 ;
return timeCost ;
}
return 0l ;
}
public ResponseDTO < String > batchReviewByDepartmentId ( @Valid ServiceApplicationsUpdateForm updateForm ) {
//根据部门id批量审核
RequestEmployee requestUser = AdminRequestUtil . getRequestUser ( ) ;
updateForm . setAssociationAuditUser ( requestUser . getEmployeeId ( ) ) ;
updateForm . setAssociationAuditTime ( LocalDateTime . now ( ) ) ;
serviceApplicationsDao . batchReviewByDepartmentId ( updateForm ) ;
return ResponseDTO . ok ( ) ;
}
/ * *
/ * *
* Excel下拉列表处理器
* Excel下拉列表处理器
* /
* /
@ -922,7 +940,7 @@ public class ServiceApplicationsService {
* /
* /
public PageResult < LawyerStatisticsVO > getLawyerStatistics ( LawyerStatisticsQueryForm queryForm ) {
public PageResult < LawyerStatisticsVO > getLawyerStatistics ( LawyerStatisticsQueryForm queryForm ) {
Page < ? > page = SmartPageUtil . convert2PageQuery ( queryForm ) ;
Page < ? > page = SmartPageUtil . convert2PageQuery ( queryForm ) ;
TimeVo yearStartAndEnd = DateTimeUtil . getYearStartAndEnd ( ) ;
TimeVo yearStartAndEnd = DateTimeUtil . getYearStartAndEnd ( queryForm . getYear ( ) ) ;
//根据year拼接年度的开始时间和结束时间
//根据year拼接年度的开始时间和结束时间
String yearStart = yearStartAndEnd . getStartTime ( ) ;
String yearStart = yearStartAndEnd . getStartTime ( ) ;
String yearEnd = yearStartAndEnd . getEndTime ( ) ;
String yearEnd = yearStartAndEnd . getEndTime ( ) ;
@ -944,7 +962,7 @@ public class ServiceApplicationsService {
public void exportLawyer ( ServiceLawyerQueryForm queryForm , HttpServletResponse response ) {
public void exportLawyer ( ServiceLawyerQueryForm queryForm , HttpServletResponse response ) {
// 如果没有指定季度,则使用年度范围,否则使用季度范围
// 如果没有指定季度,则使用年度范围,否则使用季度范围
if ( queryForm . getQuarter ( ) = = null ) {
if ( queryForm . getQuarter ( ) = = null ) {
TimeVo yearStartAndEnd = DateTimeUtil . getYearStartAndEnd ( ) ;
TimeVo yearStartAndEnd = DateTimeUtil . getYearStartAndEnd ( queryForm . getYear ( ) ) ;
String yearStart = yearStartAndEnd . getStartTime ( ) ;
String yearStart = yearStartAndEnd . getStartTime ( ) ;
String yearEnd = yearStartAndEnd . getEndTime ( ) ;
String yearEnd = yearStartAndEnd . getEndTime ( ) ;
queryForm . setStartTime ( yearStart ) ;
queryForm . setStartTime ( yearStart ) ;
@ -1118,6 +1136,22 @@ public class ServiceApplicationsService {
* /
* /
public PageResult < ServiceReportStatisticsVO > getServiceReportStatistics ( ServiceApplicationsQueryForm queryForm ) {
public PageResult < ServiceReportStatisticsVO > getServiceReportStatistics ( ServiceApplicationsQueryForm queryForm ) {
Page < ? > page = SmartPageUtil . convert2PageQuery ( queryForm ) ;
Page < ? > page = SmartPageUtil . convert2PageQuery ( queryForm ) ;
// 如果没有指定季度,则使用年度范围,否则使用季度范围
if ( queryForm . getQuarter ( ) = = null ) {
// 如果用户指定了年份,则使用指定年份,否则使用当前年份
int targetYear = queryForm . getYear ( ) ! = null ? queryForm . getYear ( ) : DateTimeUtil . getCurrentYear ( ) ;
String yearStart = targetYear + "-01-01" ;
String yearEnd = targetYear + "-12-31" ;
queryForm . setStartTime ( yearStart ) ;
queryForm . setEndTime ( yearEnd ) ;
} else {
// 根据指定的季度设置时间范围
int targetYear = queryForm . getYear ( ) ! = null ? queryForm . getYear ( ) : DateTimeUtil . getCurrentYear ( ) ;
LocalDateTime quarterStart = DateTimeEnum . getQuarterStart ( targetYear , queryForm . getQuarter ( ) ) ;
LocalDateTime quarterEnd = DateTimeEnum . getQuarterEnd ( targetYear , queryForm . getQuarter ( ) ) ;
queryForm . setStartTime ( quarterStart . toString ( ) ) ;
queryForm . setEndTime ( quarterEnd . toString ( ) ) ;
}
List < ServiceReportStatisticsVO > list = serviceApplicationsDao . getServiceReportStatistics ( page , queryForm ) ;
List < ServiceReportStatisticsVO > list = serviceApplicationsDao . getServiceReportStatistics ( page , queryForm ) ;
return SmartPageUtil . convert2PageResult ( page , list ) ;
return SmartPageUtil . convert2PageResult ( page , list ) ;
}
}