|
|
|
@ -45,6 +45,7 @@ import net.lab1024.sa.base.common.util.SmartPageUtil; |
|
|
|
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 net.sf.jsqlparser.expression.LongValue; |
|
|
|
import org.apache.catalina.util.RequestUtil; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
|
@ -58,6 +59,8 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.Arrays; |
|
|
|
@ -581,6 +584,42 @@ public class ServiceApplicationsService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<LawyerStatisticsVO> getLawyerStatisticsByDepartment(@Valid LawyerStatisticsQueryFormList queryForms) { |
|
|
|
LawyerStatisticsQueryForm queryForm = getQueryForm(queryForms); |
|
|
|
DictEntity dictItem = dictService.getOne("FILECOST"); |
|
|
|
//根据统计出律所的年度服务时长
|
|
|
|
List<LawyerStatisticsVO> lawyerStatisticsWithParamYear = serviceApplicationsDao.getdepartmentStatistics(queryForm); |
|
|
|
if (!lawyerStatisticsWithParamYear.isEmpty() && lawyerStatisticsWithParamYear.get(0).getFirmId() != null) { |
|
|
|
//律所季度服务时长和服务成本
|
|
|
|
monthStatisticsDepartment(queryForm, lawyerStatisticsWithParamYear,null); |
|
|
|
//查询这个部门下面律师的统计信息
|
|
|
|
lawyerStatisticsWithParamYear.forEach(lawyerStatisticsVO -> { |
|
|
|
ServiceLawyerQueryForm serviceLawyerQueryForm = new ServiceLawyerQueryForm(); |
|
|
|
serviceLawyerQueryForm.setFirmId(lawyerStatisticsVO.getFirmId()); |
|
|
|
//每个人的年度
|
|
|
|
List<ServiceLawyerImportForm> lawyerServiceVOList = serviceApplicationsDao.getLawyerStatisticsWithParam(serviceLawyerQueryForm); |
|
|
|
//每个人的季度
|
|
|
|
if (!lawyerServiceVOList.isEmpty() && queryForm.getQuarter() != null) { |
|
|
|
lawyerServiceVOList.forEach(lawyerServiceVO -> { |
|
|
|
lawyerServiceVO.setAnnualServiceCost(BigDecimal.valueOf(Long.valueOf(dictItem.getRemark()) * lawyerServiceVO.getAnnualServiceDuration())); |
|
|
|
//查詢每個律師季度服務信息
|
|
|
|
serviceLawyerQueryForm.setUserId(lawyerServiceVO.getUserId()); |
|
|
|
List<ServiceLawyerImportForm> lawyerImportForms = serviceApplicationsDao.getLawyerStatisticsByMonth(serviceLawyerQueryForm); |
|
|
|
lawyerServiceVO.setQuarterlyServiceCost(BigDecimal.valueOf(Long.valueOf(dictItem.getRemark()) * lawyerImportForms.get(0).getQuarterlyServiceDuration())); |
|
|
|
lawyerServiceVO.setQuarterlyServiceDuration(lawyerImportForms.get(0).getQuarterlyServiceDuration()); |
|
|
|
}); |
|
|
|
} |
|
|
|
lawyerStatisticsVO.setLawyerServiceVOList(lawyerServiceVOList); |
|
|
|
}); |
|
|
|
} |
|
|
|
return lawyerStatisticsWithParamYear; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 律所查询条件封装 |
|
|
|
* @param queryForms |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public LawyerStatisticsQueryForm getQueryForm(LawyerStatisticsQueryFormList queryForms){ |
|
|
|
LawyerStatisticsQueryForm queryForm = new LawyerStatisticsQueryForm(); |
|
|
|
BeanUtil.copyProperties(queryForms, queryForm); |
|
|
|
// 如果没有指定季度,则使用年度范围,否则使用季度范围
|
|
|
|
@ -599,21 +638,8 @@ public class ServiceApplicationsService { |
|
|
|
queryForm.setStartTime(quarterStart.toString()); |
|
|
|
queryForm.setEndTime(quarterEnd.toString()); |
|
|
|
} |
|
|
|
//统计
|
|
|
|
List<LawyerStatisticsVO> lawyerStatisticsWithParamYear = serviceApplicationsDao.getdepartmentStatistics(queryForm); |
|
|
|
monthStatisticsDepartment(queryForm, lawyerStatisticsWithParamYear,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 lawyerStatisticsWithParamYear; |
|
|
|
return queryForm; |
|
|
|
} |
|
|
|
|
|
|
|
public void exportLawyerByDepartment(ServiceLawyerQueryForm queryForm, HttpServletResponse response) { |
|
|
|
// 如果没有指定季度,则使用年度范围,否则使用季度范围
|
|
|
|
if (queryForm.getQuarter() == null) { |
|
|
|
@ -677,7 +703,7 @@ public class ServiceApplicationsService { |
|
|
|
* @param queryForm |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Long getServiceApplicationsCost(ServiceLawyerQueryForm queryForm) { |
|
|
|
public BigDecimal getServiceApplicationsCost(ServiceLawyerQueryForm queryForm) { |
|
|
|
// 根据指定的季度设置时间范围
|
|
|
|
LocalDateTime quarterStart = DateTimeEnum.getQuarterStart(queryForm.getYear(), queryForm.getQuarter()); |
|
|
|
LocalDateTime quarterEnd = DateTimeEnum.getQuarterEnd(queryForm.getYear(), queryForm.getQuarter()); |
|
|
|
@ -686,18 +712,27 @@ public class ServiceApplicationsService { |
|
|
|
//获取多少小时
|
|
|
|
Long time = serviceApplicationsDao.getServiceApplicationsCost(queryForm); |
|
|
|
//获取字典表的设置
|
|
|
|
DictEntity dictItem = dictService.getOne(3); |
|
|
|
DictEntity dictItem = dictService.getOne("FILECOST"); |
|
|
|
if (dictItem == null){ |
|
|
|
return 0L; |
|
|
|
return BigDecimal.valueOf(0L); |
|
|
|
} |
|
|
|
|
|
|
|
//除1w
|
|
|
|
if (time != null && time != 0L) { |
|
|
|
Long timeCost = time * Long.valueOf(dictItem.getRemark()); |
|
|
|
timeCost = timeCost / 10000; |
|
|
|
return timeCost; |
|
|
|
//取两位小数
|
|
|
|
|
|
|
|
// 将long类型转换为BigDecimal
|
|
|
|
BigDecimal bigDecimalDividend = BigDecimal.valueOf(timeCost); |
|
|
|
BigDecimal bigDecimalDivisor = BigDecimal.valueOf(10000); |
|
|
|
|
|
|
|
// 执行除法运算
|
|
|
|
BigDecimal result = bigDecimalDividend.divide(bigDecimalDivisor, 2, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
return result; |
|
|
|
}else { |
|
|
|
return BigDecimal.valueOf(0L); |
|
|
|
} |
|
|
|
return 0l; |
|
|
|
} |
|
|
|
|
|
|
|
public ResponseDTO<String> batchReviewByDepartmentId(@Valid ServiceApplicationsUpdateForm updateForm) { |
|
|
|
@ -940,16 +975,29 @@ public class ServiceApplicationsService { |
|
|
|
*/ |
|
|
|
public PageResult<LawyerStatisticsVO> getLawyerStatistics(LawyerStatisticsQueryForm queryForm) { |
|
|
|
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm); |
|
|
|
DictEntity one = dictService.getOne("FILECOST"); |
|
|
|
//查询下角色
|
|
|
|
RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); |
|
|
|
RoleVO roleList = roleEmployeeService.getRoleIdList(requestUser.getEmployeeId()).get(0); |
|
|
|
TimeVo yearStartAndEnd = DateTimeUtil.getYearStartAndEnd(queryForm.getYear()); |
|
|
|
//根据year拼接年度的开始时间和结束时间
|
|
|
|
String yearStart = yearStartAndEnd.getStartTime(); |
|
|
|
String yearEnd = yearStartAndEnd.getEndTime(); |
|
|
|
queryForm.setStartTime(yearStart); |
|
|
|
queryForm.setEndTime(yearEnd); |
|
|
|
if (UserTypeEnum.USER.getDesc().equals(roleList.getRoleCode())){ |
|
|
|
queryForm.setUserId(requestUser.getEmployeeId()); |
|
|
|
}else if (UserTypeEnum.CTO.getDesc().equals(roleList.getRoleCode())){ |
|
|
|
queryForm.setUserId(null); |
|
|
|
queryForm.setFirmId(requestUser.getDepartmentId()); |
|
|
|
} |
|
|
|
//统计当前年度的
|
|
|
|
List<LawyerStatisticsVO> lawyerStatisticsWithParamYear = serviceApplicationsDao.getLawyerStatisticsWithParamYear(page, queryForm); |
|
|
|
PageResult<LawyerStatisticsVO> lawyerStatisticsVOPageResult = SmartPageUtil.convert2PageResult(page, lawyerStatisticsWithParamYear); |
|
|
|
if (!lawyerStatisticsVOPageResult.getList().isEmpty()) { |
|
|
|
for (LawyerStatisticsVO statisticsVO : lawyerStatisticsWithParamYear) { |
|
|
|
statisticsVO.setAnnualServiceCost(BigDecimal.valueOf(statisticsVO.getAnnualServiceDuration() * Long.valueOf(one.getRemark()))); |
|
|
|
} |
|
|
|
monthStatistics(queryForm, lawyerStatisticsVOPageResult.getList(),null); |
|
|
|
} |
|
|
|
return lawyerStatisticsVOPageResult; |
|
|
|
@ -960,6 +1008,7 @@ public class ServiceApplicationsService { |
|
|
|
* @param queryForm |
|
|
|
*/ |
|
|
|
public void exportLawyer(ServiceLawyerQueryForm queryForm, HttpServletResponse response) { |
|
|
|
DictEntity one = dictService.getOne("FILECOST"); |
|
|
|
// 如果没有指定季度,则使用年度范围,否则使用季度范围
|
|
|
|
if (queryForm.getQuarter() == null) { |
|
|
|
TimeVo yearStartAndEnd = DateTimeUtil.getYearStartAndEnd(queryForm.getYear()); |
|
|
|
@ -974,8 +1023,12 @@ public class ServiceApplicationsService { |
|
|
|
queryForm.setStartTime(quarterStart.toString()); |
|
|
|
queryForm.setEndTime(quarterEnd.toString()); |
|
|
|
} |
|
|
|
//律师年度
|
|
|
|
List<ServiceLawyerImportForm> lawyerStatisticsWithParamYear = serviceApplicationsDao.getLawyerStatisticsWithParam(queryForm); |
|
|
|
if (!lawyerStatisticsWithParamYear.isEmpty()) { |
|
|
|
for (ServiceLawyerImportForm serviceLawyerImportForm : lawyerStatisticsWithParamYear) { |
|
|
|
serviceLawyerImportForm.setAnnualServiceCost(BigDecimal.valueOf(serviceLawyerImportForm.getAnnualServiceDuration() * Long.valueOf(one.getRemark()))); |
|
|
|
} |
|
|
|
LawyerStatisticsQueryForm queryForm1 = SmartBeanUtil.copy(queryForm, LawyerStatisticsQueryForm.class); |
|
|
|
monthStatistics(queryForm1, null, lawyerStatisticsWithParamYear); |
|
|
|
} |
|
|
|
@ -990,6 +1043,7 @@ public class ServiceApplicationsService { |
|
|
|
* @param lawyerStatisticsVOPageResult |
|
|
|
*/ |
|
|
|
public void monthStatistics(LawyerStatisticsQueryForm originalQueryForm, List<LawyerStatisticsVO> lawyerStatisticsVOPageResult,List<ServiceLawyerImportForm> lawyerStatisticsWithParamYear) { |
|
|
|
DictEntity one = dictService.getOne("FILECOST"); |
|
|
|
if (lawyerStatisticsVOPageResult != null) { |
|
|
|
for (LawyerStatisticsVO statisticsVO : lawyerStatisticsVOPageResult) { |
|
|
|
// 创建新的查询表单对象以避免修改原始对象
|
|
|
|
@ -1014,6 +1068,7 @@ public class ServiceApplicationsService { |
|
|
|
LawyerStatisticsVO quarterStatisticsVO = serviceApplicationsDao.getLawyerStatistic(queryForm); |
|
|
|
if (quarterStatisticsVO != null && quarterStatisticsVO.getQuarterlyServiceDuration() != null) { |
|
|
|
statisticsVO.setQuarterlyServiceDuration(quarterStatisticsVO.getQuarterlyServiceDuration()); |
|
|
|
statisticsVO.setQuarterlyServiceCost(BigDecimal.valueOf(quarterStatisticsVO.getQuarterlyServiceDuration() * Long.valueOf(one.getRemark()))); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if (lawyerStatisticsWithParamYear != null) { |
|
|
|
@ -1040,12 +1095,15 @@ public class ServiceApplicationsService { |
|
|
|
LawyerStatisticsVO quarterStatisticsVO = serviceApplicationsDao.getLawyerStatistic(queryForm); |
|
|
|
if (quarterStatisticsVO != null && quarterStatisticsVO.getQuarterlyServiceDuration() != null) { |
|
|
|
statisticsVO.setQuarterlyServiceDuration(quarterStatisticsVO.getQuarterlyServiceDuration()); |
|
|
|
statisticsVO.setQuarterlyServiceCost(BigDecimal.valueOf(quarterStatisticsVO.getQuarterlyServiceDuration() * Long.valueOf(one.getRemark()))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void monthStatisticsDepartment(LawyerStatisticsQueryForm originalQueryForm, List<LawyerStatisticsVO> lawyerStatisticsVOPageResult,List<ServiceDepartmentImportForm> lawyerStatisticsWithParamYear) { |
|
|
|
DictEntity dictItem = dictService.getOne("FILECOST"); |
|
|
|
if (lawyerStatisticsVOPageResult != null) { |
|
|
|
for (LawyerStatisticsVO statisticsVO : lawyerStatisticsVOPageResult) { |
|
|
|
// 创建新的查询表单对象以避免修改原始对象
|
|
|
|
@ -1066,10 +1124,14 @@ public class ServiceApplicationsService { |
|
|
|
queryForm.setEndTime(quarterEnd.toString()); |
|
|
|
} |
|
|
|
queryForm.setUserId(statisticsVO.getUserId()); |
|
|
|
//计算年度累计服务成本
|
|
|
|
statisticsVO.setAnnualServiceCost(BigDecimal.valueOf(statisticsVO.getAnnualServiceDuration() * Long.valueOf(dictItem.getRemark()))); |
|
|
|
//季度服务时间范围
|
|
|
|
LawyerStatisticsVO quarterStatisticsVO = serviceApplicationsDao.getdepartmentMothStatistic(queryForm); |
|
|
|
if (quarterStatisticsVO != null && quarterStatisticsVO.getQuarterlyServiceDuration() != null) { |
|
|
|
statisticsVO.setQuarterlyServiceDuration(quarterStatisticsVO.getQuarterlyServiceDuration()); |
|
|
|
//计算季度累计服务成本
|
|
|
|
statisticsVO.setQuarterlyServiceCost(BigDecimal.valueOf(quarterStatisticsVO.getQuarterlyServiceDuration() * Long.valueOf(dictItem.getRemark()))); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if (lawyerStatisticsWithParamYear != null) { |
|
|
|
@ -1092,10 +1154,14 @@ public class ServiceApplicationsService { |
|
|
|
queryForm.setEndTime(quarterEnd.toString()); |
|
|
|
} |
|
|
|
queryForm.setFirmId(statisticsVO.getFirmId()); |
|
|
|
//计算年度累计服务成本
|
|
|
|
statisticsVO.setAnnualServiceCost(BigDecimal.valueOf(statisticsVO.getAnnualServiceDuration() * Long.valueOf(dictItem.getRemark()))); |
|
|
|
//季度服务时间范围
|
|
|
|
LawyerStatisticsVO quarterStatisticsVO = serviceApplicationsDao.getdepartmentMothStatistic(queryForm); |
|
|
|
if (quarterStatisticsVO != null && quarterStatisticsVO.getQuarterlyServiceDuration() != null) { |
|
|
|
statisticsVO.setQuarterlyServiceDuration(quarterStatisticsVO.getQuarterlyServiceDuration()); |
|
|
|
//计算季度累计服务成本
|
|
|
|
statisticsVO.setQuarterlyServiceCost(BigDecimal.valueOf(quarterStatisticsVO.getQuarterlyServiceDuration() * Long.valueOf(dictItem.getRemark()))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|