Commit 43599d4f authored by 蔡镇泽's avatar 蔡镇泽

费用结算

parent 22ef61f1
...@@ -28,6 +28,7 @@ public interface SrvTaskMapper extends BaseMapper<ChSrvTask> { ...@@ -28,6 +28,7 @@ public interface SrvTaskMapper extends BaseMapper<ChSrvTask> {
" t7.item_id " +//服务项目id " t7.item_id " +//服务项目id
" t7.item_times " +//服务频次 " t7.item_times " +//服务频次
" t7.planning_frequency " +//计划频次 " t7.planning_frequency " +//计划频次
" t7.planning_frequency_type " +//计划频次类型
" t8.srv_level_id " +//服务等级id " t8.srv_level_id " +//服务等级id
"FROM " + "FROM " +
" ch_srv_task t1 " + " ch_srv_task t1 " +
......
...@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.hungraim.ltc.pojo.entity.account.ChDisabAccounts; import com.hungraim.ltc.pojo.entity.account.ChDisabAccounts;
import com.hungraim.ltc.pojo.vo.account.*; import com.hungraim.ltc.pojo.vo.account.*;
import java.util.List;
public interface AccountService extends IService<ChDisabAccounts> { public interface AccountService extends IService<ChDisabAccounts> {
/** /**
...@@ -18,5 +16,5 @@ public interface AccountService extends IService<ChDisabAccounts> { ...@@ -18,5 +16,5 @@ public interface AccountService extends IService<ChDisabAccounts> {
AccountOperVo getSrvOrganDetail(Long accountsId); AccountOperVo getSrvOrganDetail(Long accountsId);
List<ExpenseSettlementVo> expenseSettlement(ExpenseSettlementReq req); ExpenseVo expenseSettlement(ExpenseSettlementReq req);
} }
...@@ -10,7 +10,6 @@ import com.hungraim.ltc.account.service.BaseAccountService; ...@@ -10,7 +10,6 @@ import com.hungraim.ltc.account.service.BaseAccountService;
import com.hungraim.ltc.api.AttachFeignService; import com.hungraim.ltc.api.AttachFeignService;
import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach; import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach;
import com.hungraim.ltc.pojo.entity.account.ChDisabAccounts; import com.hungraim.ltc.pojo.entity.account.ChDisabAccounts;
import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvProgramSet;
import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvTaskDetail; import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvTaskDetail;
import com.hungraim.ltc.pojo.vo.account.*; import com.hungraim.ltc.pojo.vo.account.*;
import com.hungraim.ltc.util.*; import com.hungraim.ltc.util.*;
...@@ -76,7 +75,7 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -76,7 +75,7 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
} }
@Override @Override
public List<ExpenseSettlementVo> expenseSettlement(ExpenseSettlementReq req) { public ExpenseVo expenseSettlement(ExpenseSettlementReq req) {
Page<ExpenseSettlementInfoBo> page = new Page<>(req.getPageNum(), req.getPageSize()); Page<ExpenseSettlementInfoBo> page = new Page<>(req.getPageNum(), req.getPageSize());
Page<ExpenseSettlementInfoBo> expenseSettlementInfo = srvTaskMapper.getExpenseSettlementInfo(page, req); Page<ExpenseSettlementInfoBo> expenseSettlementInfo = srvTaskMapper.getExpenseSettlementInfo(page, req);
List<ExpenseSettlementVo> vos = new ArrayList<>(); List<ExpenseSettlementVo> vos = new ArrayList<>();
...@@ -114,16 +113,26 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -114,16 +113,26 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
Integer srvTaskId = bo.getSrvTaskId(); Integer srvTaskId = bo.getSrvTaskId();
int taskDetailsCount = taskDetailMapper.selectCount(new LambdaQueryWrapper<ChSrvTaskDetail>()//计划次数 int taskDetailsCount = taskDetailMapper.selectCount(new LambdaQueryWrapper<ChSrvTaskDetail>()//计划次数
.eq(ChSrvTaskDetail::getSrvTaskId, srvTaskId) .eq(ChSrvTaskDetail::getSrvTaskId, srvTaskId)
.in(ChSrvTaskDetail::getIllegalType, 0, 1)
.ne(ChSrvTaskDetail::getStatus, 3)); .ne(ChSrvTaskDetail::getStatus, 3));
List<ChSrvTaskDetail> taskDetails = taskDetailMapper.selectList(new LambdaQueryWrapper<ChSrvTaskDetail>() List<ChSrvTaskDetail> taskDetails = taskDetailMapper.selectList(new LambdaQueryWrapper<ChSrvTaskDetail>()
.eq(ChSrvTaskDetail::getSrvTaskId, srvTaskId) .eq(ChSrvTaskDetail::getSrvTaskId, srvTaskId)
.in(ChSrvTaskDetail::getIllegalType, 0, 1)
.eq(ChSrvTaskDetail::getStatus, 4)); .eq(ChSrvTaskDetail::getStatus, 4));
int taskDetailsFinishCount = taskDetails.size();//完成次数 int taskDetailsFinishCount = 0;//完成次数
ChSrvProgramSet chSrvProgramSet = programSetMapper.selectOne(new LambdaQueryWrapper<ChSrvProgramSet>() if (taskDetails != null && taskDetails.size() > 0) {
.eq(ChSrvProgramSet::getProgramId, bo.getProgramId()) taskDetailsFinishCount = taskDetails.size();
.eq(ChSrvProgramSet::getIsConf, '1')); }
int monPlanningFrequency = bo.getPlanningFrequency();//每月计划次数
if (bo.getPlanningFrequencyType() == 1) {
monPlanningFrequency = bo.getPlanningFrequency();
} else if (bo.getPlanningFrequencyType() == 2) {
monPlanningFrequency = bo.getPlanningFrequency() * 30;
} else if (bo.getPlanningFrequencyType() == 3) {
monPlanningFrequency = bo.getPlanningFrequency() * 4;
}
BigDecimal divide = BigDecimal.valueOf(taskDetailsFinishCount).divide(BigDecimal.valueOf(taskDetailsCount), 2, BigDecimal.ROUND_DOWN); BigDecimal divide = BigDecimal.valueOf(taskDetailsFinishCount).divide(BigDecimal.valueOf(taskDetailsCount), 2, BigDecimal.ROUND_DOWN);
BigDecimal divide1 = BigDecimal.valueOf(bo.getItemTimes()).divide(BigDecimal.valueOf(bo.getPlanningFrequency()), 2, BigDecimal.ROUND_DOWN); BigDecimal divide1 = BigDecimal.valueOf(bo.getItemTimes()).divide(BigDecimal.valueOf(monPlanningFrequency), 2, BigDecimal.ROUND_DOWN);
if (divide.doubleValue() > 1) { if (divide.doubleValue() > 1) {
divide = BigDecimal.valueOf(1); divide = BigDecimal.valueOf(1);
} }
...@@ -133,10 +142,11 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -133,10 +142,11 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
BigDecimal comp = divide.multiply(divide1).setScale(4, BigDecimal.ROUND_DOWN);//基护完成率 BigDecimal comp = divide.multiply(divide1).setScale(4, BigDecimal.ROUND_DOWN);//基护完成率
vo.setCompletionRateFoundationProtection(comp.multiply(BigDecimal.valueOf(100)).doubleValue() + "%"); vo.setCompletionRateFoundationProtection(comp.multiply(BigDecimal.valueOf(100)).doubleValue() + "%");
//巡护基护完成考核 //巡护基护完成考核
BigDecimal patrolAndBasicProtectionCompletedAssessment = null;//巡护基护完成考核 BigDecimal patrolAndBasicProtectionCompletedAssessment = BigDecimal.valueOf(0.8);//巡护基护完成考核
if (FndSrvMode.PATROL.getCode().equals(bo.getSrvModeId())) { if (FndSrvMode.PATROL.getCode().equals(bo.getSrvModeId())) {//巡护
long serviceTime = 0;//服务时长/毫秒 long serviceTime = 0;//服务时长/毫秒
int serviceCount = 0;//服务次数 int serviceCount = 0;//服务次数
if (taskDetails != null && taskDetails.size() > 0) {
for (ChSrvTaskDetail taskDetail : taskDetails) { for (ChSrvTaskDetail taskDetail : taskDetails) {
long l = taskDetail.getSrvEndTime().getTime() - taskDetail.getSrvStartTime().getTime(); long l = taskDetail.getSrvEndTime().getTime() - taskDetail.getSrvStartTime().getTime();
serviceTime += l; serviceTime += l;
...@@ -144,7 +154,11 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -144,7 +154,11 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
serviceCount++; serviceCount++;
} }
} }
long serviceTimeM = serviceTime / (1000 * 60 * 60);//服务时长/小时 }
long serviceTimeM = 0;
if (serviceTime != 0) {
serviceTimeM = serviceTime / (1000 * 60 * 60);//服务时长/小时
}
boolean serviceCountK = false;//服务次数考核 boolean serviceCountK = false;//服务次数考核
boolean serviceTimeK = false;//服务时长考核 boolean serviceTimeK = false;//服务时长考核
if (serviceCount >= 6) { if (serviceCount >= 6) {
...@@ -170,7 +184,6 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -170,7 +184,6 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
patrolAndBasicProtectionCompletedAssessment = BigDecimal.valueOf(0.9); patrolAndBasicProtectionCompletedAssessment = BigDecimal.valueOf(0.9);
vo.setPatrolAndBasicProtectionCompletedAssessment("90%"); vo.setPatrolAndBasicProtectionCompletedAssessment("90%");
} else { } else {
patrolAndBasicProtectionCompletedAssessment = BigDecimal.valueOf(0.8);
vo.setPatrolAndBasicProtectionCompletedAssessment("80%"); vo.setPatrolAndBasicProtectionCompletedAssessment("80%");
} }
} }
...@@ -197,7 +210,16 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -197,7 +210,16 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
vo.setStandardCareCost("45元/人/天"); vo.setStandardCareCost("45元/人/天");
} }
//照护费用 //照护费用
BigDecimal careCosts = BigDecimal.valueOf(standardCareCost).multiply(BigDecimal.valueOf(effectiveSettlementDate)); List<ChSrvTaskDetail> taskDetails2 = taskDetailMapper.selectList(new LambdaQueryWrapper<ChSrvTaskDetail>()
.eq(ChSrvTaskDetail::getSrvTaskId, srvTaskId)
.in(ChSrvTaskDetail::getIllegalType, 0, 2)
.eq(ChSrvTaskDetail::getStatus, 4));
BigDecimal careCosts = BigDecimal.valueOf(0);
int taskDetailsFinishCount2 = 0;
if (taskDetails2 != null && taskDetails2.size() > 0) {
taskDetailsFinishCount2 = taskDetails2.size();
careCosts = BigDecimal.valueOf(standardCareCost).multiply(BigDecimal.valueOf(taskDetails2.size()));
}
if (FndSrvMode.PATROL.getCode().equals(bo.getSrvModeId())) {//巡护 if (FndSrvMode.PATROL.getCode().equals(bo.getSrvModeId())) {//巡护
if (CfgSrvLevel.ONE.getCode().equals(bo.getSrvLevelId())) {//服务等级 if (CfgSrvLevel.ONE.getCode().equals(bo.getSrvLevelId())) {//服务等级
if (careCosts.intValue() > 600) { if (careCosts.intValue() > 600) {
...@@ -215,11 +237,75 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -215,11 +237,75 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
} }
vo.setCareCosts(careCosts.doubleValue()); vo.setCareCosts(careCosts.doubleValue());
//照护完成率 //照护完成率
int taskDetailsCount2 = taskDetailMapper.selectCount(new LambdaQueryWrapper<ChSrvTaskDetail>()//计划次数
.eq(ChSrvTaskDetail::getSrvTaskId, srvTaskId)
.in(ChSrvTaskDetail::getIllegalType, 0, 2)
.ne(ChSrvTaskDetail::getStatus, 3));
BigDecimal divide2 = BigDecimal.valueOf(taskDetailsFinishCount2).divide(BigDecimal.valueOf(taskDetailsCount2), 2, BigDecimal.ROUND_DOWN);
BigDecimal divide3 = BigDecimal.valueOf(bo.getItemTimes()).divide(BigDecimal.valueOf(monPlanningFrequency), 2, BigDecimal.ROUND_DOWN);
if (divide2.doubleValue() > 1) {
divide2 = BigDecimal.valueOf(1);
}
if (divide3.doubleValue() > 1) {
divide3 = BigDecimal.valueOf(1);
}
BigDecimal comp2 = divide2.multiply(divide3).setScale(4, BigDecimal.ROUND_DOWN);//照护完成率
vo.setCareCompletionRate(comp2.multiply(BigDecimal.valueOf(100)).doubleValue() + "%");
//巡护照护完成考核 //巡护照护完成考核
BigDecimal patrolCareCompletionAssessment = BigDecimal.valueOf(0.8);//巡护照护完成考核
if (FndSrvMode.PATROL.getCode().equals(bo.getSrvModeId())) {//巡护 if (FndSrvMode.PATROL.getCode().equals(bo.getSrvModeId())) {//巡护
long serviceTime = 0;//服务时长/毫秒
int serviceCount = 0;//服务次数
if (taskDetails2 != null && taskDetails2.size() > 0) {
for (ChSrvTaskDetail taskDetail : taskDetails2) {
long l = taskDetail.getSrvEndTime().getTime() - taskDetail.getSrvStartTime().getTime();
serviceTime += l;
if (l > 30 * 60 * 1000) {
serviceCount++;
}
}
}
long serviceTimeM = 0;
if (serviceTime != 0) {
serviceTimeM = serviceTime / (1000 * 60 * 60);//服务时长/小时
}
boolean serviceCountK = false;//服务次数考核
boolean serviceTimeK = false;//服务时长考核
if (serviceCount >= 6) {
serviceCountK = true;
}
if (DisableLevel.ONE.getCode().equals(bo.getDisableLevelId())) {
if (serviceTimeM >= 8) {
serviceTimeK = true;
}
} else if (DisableLevel.TWO.getCode().equals(bo.getDisableLevelId())) {
if (serviceTimeM >= 10) {
serviceTimeK = true;
}
} else if (DisableLevel.THREE.getCode().equals(bo.getDisableLevelId())) {
if (serviceTimeM >= 12) {
serviceTimeK = true;
}
}
if (serviceCountK && serviceTimeK) {
patrolCareCompletionAssessment = BigDecimal.valueOf(1);
vo.setPatrolCareCompletionAssessment("100%");
} else if (serviceCountK || serviceTimeK) {
patrolCareCompletionAssessment = BigDecimal.valueOf(0.9);
vo.setPatrolCareCompletionAssessment("90%");
} else {
vo.setPatrolCareCompletionAssessment("80%");
}
} }
//照护应拨费用 //照护应拨费用
if (FndSrvMode.PATROL.getCode().equals(bo.getSrvModeId())) {//巡护
BigDecimal multiply = careCosts.multiply(comp2).multiply(patrolCareCompletionAssessment).multiply(BigDecimal.valueOf(0.9)).setScale(2, BigDecimal.ROUND_DOWN);
vo.setCarePayable(multiply.doubleValue());
} else if (FndSrvMode.HOME_CARE.getCode().equals(bo.getSrvModeId())
|| FndSrvMode.HOSPITAL_NURSING.getCode().equals(bo.getSrvModeId())) {//家护/院护
BigDecimal multiply = careCosts.multiply(comp2).multiply(BigDecimal.valueOf(0.9)).setScale(2, BigDecimal.ROUND_DOWN);
vo.setCarePayable(multiply.doubleValue());
}
//应拨付总金额 //应拨付总金额
vo.setTotalAmountDue(BigDecimal.valueOf(vo.getExpensesPayableFoundationProtection()).add(BigDecimal.valueOf(vo.getCarePayable())).doubleValue()); vo.setTotalAmountDue(BigDecimal.valueOf(vo.getExpensesPayableFoundationProtection()).add(BigDecimal.valueOf(vo.getCarePayable())).doubleValue());
vos.add(vo); vos.add(vo);
...@@ -248,8 +334,12 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -248,8 +334,12 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
//应拨付总金额 //应拨付总金额
totalAmountDue = totalAmountDue.add(BigDecimal.valueOf(vo.getTotalAmountDue())); totalAmountDue = totalAmountDue.add(BigDecimal.valueOf(vo.getTotalAmountDue()));
} }
ExpenseVo expenseVo = new ExpenseVo();
expenseVo.setExpenseSettlements(vos);
expenseVo.setTotal(totalVo);
return expenseVo;
} }
return null; return new ExpenseVo();
} }
//求当月最后一天 //求当月最后一天
......
...@@ -68,6 +68,10 @@ public class ExpenseSettlementInfoBo { ...@@ -68,6 +68,10 @@ public class ExpenseSettlementInfoBo {
* 计划频次 * 计划频次
*/ */
private Integer planningFrequency; private Integer planningFrequency;
/**
* 计划频次类型
*/
private Integer planningFrequencyType;
/** /**
* 服务等级id * 服务等级id
......
...@@ -100,6 +100,6 @@ public class ExpenseSettlementVo { ...@@ -100,6 +100,6 @@ public class ExpenseSettlementVo {
/** /**
* 合计 * 合计
*/ */
private String total; private ExpenseSettlementTotalVo total;
} }
package com.hungraim.ltc.pojo.vo.account;
import lombok.Data;
import java.util.List;
@Data
public class ExpenseVo {
/**
* 费用结算
*/
private List<ExpenseSettlementVo> expenseSettlements;
/**
* 合计
*/
private ExpenseSettlementTotalVo total;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment