Commit ef57cbbb authored by zhangwanglin's avatar zhangwanglin

结算

parent 9adf0859
......@@ -17,12 +17,8 @@ import java.util.List;
@Repository
public interface ChDisabAccountsDetailMapper extends BaseMapper<ChDisabDetailAccounts> {
List<OrganAccountsVO> getOrganAccountsList(String taskDetailId);
List<AccountExportDetailListResp> searchSrvOrganAccountDetailExport(SrvOrganListReq req);
List<ChDisabDetailAccounts> queryAccountByCondition(@Param("taskDetailIds") List<String> taskDetailIds);
List<OrganAccountsVO> getOtherPlaceList(String programId);
......@@ -30,6 +26,8 @@ public interface ChDisabAccountsDetailMapper extends BaseMapper<ChDisabDetailAcc
Page<NursingRecordsRespVO> queryNursingRecords(Page page, NursingReqVO req);
Page<NursingRecordsRespVO> queryNursingRecordsGoDoor(Page page, NursingReqVO req);
OverallEduceDecreaseCostRespVO queryOverallCostRecords(OverallCostReqVO req);
......
......@@ -47,7 +47,6 @@ public interface AccountService extends IService<ChDisabAccounts> {
int updateChDisabAccounts(int id);
Result organAccountTaskExecute(List<AccountTaskExecuteReqVO> accountTaskExecuteReqVOS);
Result accountTaskExecute(List<AccountTaskExecuteReqVO> accountTaskExecuteReqVOS);
......
......@@ -17,7 +17,6 @@ import com.hungraim.ltc.pojo.entity.SysConfig.ChCfgCostStandard;
import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach;
import com.hungraim.ltc.pojo.entity.account.*;
import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvTaskDetail;
import com.hungraim.ltc.pojo.entity.serviceManage.ChSrvTaskFinishItem;
import com.hungraim.ltc.pojo.vo.account.*;
import com.hungraim.ltc.util.*;
import lombok.AllArgsConstructor;
......@@ -476,18 +475,14 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
@Override
public Page<NursingRecordsRespVO> queryNursingRecords(NursingReqVO nursingReqVO) {
String modeName = nursingReqVO.getModeName();
String modeId = "";
if("医疗".equals(modeName)){
modeId = "1";
}else if("养老".equals(modeName)) {
modeId = "2";
}else if ("上门".equals(modeName)){
modeId = "3";
}else if ("异地".equals(modeName)){
modeId = "4";
Page<NursingRecordsRespVO> nursingRecordsRespVOPage = null;
if("上门".equals(modeName)){
nursingRecordsRespVOPage = chDisabAccountsDetailMapper.queryNursingRecordsGoDoor(new Page<>(nursingReqVO.getPageNum(), nursingReqVO.getPageSize()), nursingReqVO);
}else {
nursingReqVO.setModeId("医疗".equals(modeName) ? "1" : "2");
nursingRecordsRespVOPage = chDisabAccountsDetailMapper.queryNursingRecords(new Page<>(nursingReqVO.getPageNum(), nursingReqVO.getPageSize()), nursingReqVO);
}
nursingReqVO.setModeId(modeId);
return chDisabAccountsDetailMapper.queryNursingRecords(new Page<>(nursingReqVO.getPageNum(), nursingReqVO.getPageSize()),nursingReqVO);
return nursingRecordsRespVOPage;
}
@Override
......@@ -528,7 +523,6 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
chDisabDetailAccounts.setDeductionAmount(deductionAmount.add(amountOfMoney));
deductionAmountTotal = deductionAmountTotal.add(amountOfMoney);
}
chDisabDetailAccounts.setRemarks(req.getRemarks());
int result = chDisabAccountsDetailMapper.updateById(chDisabDetailAccounts);
chDisabAccounts.setReissueAmountTotal(reissueAmountTotal);
chDisabAccounts.setDeductionAmountTotal(deductionAmountTotal);
......@@ -539,6 +533,7 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
chDisabFreeRdInfo.setAccountsDetailId(accountsDetailId);
chDisabFreeRdInfo.setAccountsId(accountsId);
chDisabFreeRdInfo.setCreationTime(new Date());
chDisabFreeRdInfo.setRemarks(req.getRemarks());
chDisabFreeRdInfoMapper.insert(chDisabFreeRdInfo);
return result;
}
......@@ -660,8 +655,6 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
String planId = accountsVO.getPlanId();
// 更新
chDisabAccountsDetailMapper.updateByPlanId(planId);
}else {
BigDecimal accountsAllCost = chDisabDetailAccountsDTO.getAccountsAllCost();
BigDecimal accountsOverallCost = chDisabDetailAccountsDTO.getAccountsOverallCost();
......@@ -675,119 +668,6 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result organAccountTaskExecute(List<AccountTaskExecuteReqVO> accountTaskExecuteReqVOS) {
log.info("organAccountTaskExecute.accountTaskExecuteReqVOS:{}",accountTaskExecuteReqVOS);
if (CollectionUtil.isEmpty(accountTaskExecuteReqVOS)) {
return Result.failed("参数不能为空");
}
List<String> taskDetailIds = accountTaskExecuteReqVOS.stream().map(AccountTaskExecuteReqVO::getTaskDetailId).distinct().collect(Collectors.toList());
// 根据任务id查找结算详情,还没有对应的任务数据说明还未发生过结算,进行插入详情表和结算表
List<ChDisabDetailAccounts> chDisabDetailList = chDisabAccountsDetailMapper.queryAccountByCondition(taskDetailIds);
// 根据任务id分组,一个任务下会有多个项目,任务id相同
Map<String, List<AccountTaskExecuteReqVO>> accountTaskMap = accountTaskExecuteReqVOS.stream().collect(Collectors.groupingBy(AccountTaskExecuteReqVO::getTaskDetailId));
for(Map.Entry<String, List<AccountTaskExecuteReqVO>> entry:accountTaskMap.entrySet()) {
String taskDetailId = entry.getKey();
// 已完成的任务,一个任务下有服务完成就产生结算,多个服务完成算一条服务的结算(实际上结算详情有一条记录就产生结算费用)
List<ChSrvTaskFinishItem> chSrvTaskFinishItems = chSrvTaskFinishItemMapper.selectList(new LambdaQueryWrapper<ChSrvTaskFinishItem>()
.eq(ChSrvTaskFinishItem::getTaskDetailId, taskDetailId));
List<AccountTaskExecuteReqVO> accountTaskList = entry.getValue();
// 处理具体的服务项目
try {
for (AccountTaskExecuteReqVO accountTaskExecuteReqVO : accountTaskList) {
// 已完成的任务更新ch_srv_plan状态
String planId = accountTaskExecuteReqVO.getPlanId();
Integer integer = chSrvTaskDetailMapper.updateSrvPlanById(planId);
if(integer == 0){
log.info("更新任务计划表失败");
}
if (CollectionUtil.isNotEmpty(chSrvTaskFinishItems)) {
List<ChSrvTaskFinishItem> chSrvTaskFinishItemStream = chSrvTaskFinishItems.stream()
.filter(s -> s.getItemId().equals(Long.valueOf(accountTaskExecuteReqVO.getItemId()))).collect(Collectors.toList());
// 如果存在就不插入了
if (CollectionUtil.isNotEmpty(chSrvTaskFinishItemStream)) {
log.info("chSrvTaskFinishItemStream is totEmpty:{}",chSrvTaskFinishItemStream);
return Result.success();
}
}
ChSrvTaskFinishItem chSrvTaskFinishItem = new ChSrvTaskFinishItem();
chSrvTaskFinishItem.setTaskDetailId(Long.valueOf(accountTaskExecuteReqVO.getTaskDetailId()));
chSrvTaskFinishItem.setItemId(Long.valueOf(accountTaskExecuteReqVO.getItemId()));
chSrvTaskFinishItemMapper.insert(chSrvTaskFinishItem);
ChSrvTaskDetail ca = new ChSrvTaskDetail();
ca.setStatus((short) 4);
ca.setTaskDetailId(Long.valueOf(accountTaskExecuteReqVO.getTaskDetailId()));
chSrvTaskDetailMapper.updateById(ca);
}
accountSave(taskDetailId, chDisabDetailList);
} catch (Exception e) {
log.info("=====accountSave error:{}",e);
return Result.failed("服务异常");
}
}
return Result.success();
}
private void accountSave(String taskDetailId, List<ChDisabDetailAccounts> chDisabDetailList) {
if (CollectionUtil.isEmpty(chDisabDetailList)) {
List<OrganAccountsVO> accountsList = chDisabAccountsDetailMapper.getOrganAccountsList(taskDetailId);
for (OrganAccountsVO accountsVO : accountsList) {
ChDisabDetailAccounts chDisabDetailAccounts = new ChDisabDetailAccounts();
String srvOrganId = accountsVO.getSrvOrganId();
// 结算时间为任务时间
Date accountsTime = DateUtils.strToDate(accountsVO.getSrvDate());
String disabInfoId = accountsVO.getDisabInfoId();
//要判断是养老还是医疗,因为费用不一样
BigDecimal limit = BigDecimal.valueOf(0);
BigDecimal overallPercent = BigDecimal.valueOf(0.7);
BigDecimal personalPercent = BigDecimal.valueOf(0.3);
String srvModeName = accountsVO.getSrvModeName();
// 养老机构护理,其限额为 50 元/人/天 由长期护理保险基金支付 70% 个人支付 30%
if ("养老".equals(srvModeName)) {
limit = BigDecimal.valueOf(50);
// 医疗机构护理,原则上收治医疗护理需求为主的重度失能人员一级及以下医疗机构其限额为 80 元/人/天,由长期护理保险基金支付 70%,个人支付 30%;
} else if ("医疗".equals(srvModeName) && "1".equals(accountsVO.getLevelCode())) {
limit = BigDecimal.valueOf(80);
// 二级及以上医疗机构其限额为 100 元/人/天,由长期护理保险基金支付 70%,个人支付 30%;
} else if ("医疗".equals(srvModeName) && (!"1".equals(accountsVO.getLevelCode()))) {
limit = BigDecimal.valueOf(100);
} else {
break;
}
// 根据护理机构、结算月份、失能人员id和服务方式查询表里是否有值
// ChDisabDetailAccounts chDisabDetailAccountsDTO = chDisabAccountsDetailMapper.queryDisabDetailAccounts(srvOrganId, DateUtils.dateToStrYm(accountsTime), disabInfoId, srvModeName);
chDisabDetailAccounts.setAccountsAllCost(limit);
BigDecimal overallCost = limit.multiply(overallPercent);
chDisabDetailAccounts.setAccountsOverallCost(overallCost);
BigDecimal personalCost = limit.multiply(personalPercent);
chDisabDetailAccounts.setAccountsPersonalCost(personalCost);
chDisabDetailAccounts.setModeName(accountsVO.getSrvModeName());
chDisabDetailAccounts.setSrvOrganId(srvOrganId);
chDisabDetailAccounts.setEmpId(accountsVO.getEmpId());
chDisabDetailAccounts.setCreationTime(new Date());
chDisabDetailAccounts.setAccountsTime(accountsTime);
chDisabDetailAccounts.setAccountsStartTime(DateUtils.getFirstDayOfMonth(DateUtils.strToDate(accountsVO.getSrvDate())));
chDisabDetailAccounts.setAccountsEndTime(DateUtils.getlastDayOfMonth(DateUtils.strToDate(accountsVO.getSrvDate())));
// chDisabDetailAccounts.setTaskDetailId(accountsVO.getTaskDetailId());
chDisabDetailAccounts.setMedicalArea(accountsVO.getMedicalArea());
chDisabDetailAccounts.setDisabInfoId(disabInfoId);
chDisabDetailAccounts.setStatus((short)0);
chDisabDetailAccounts.setReissueAmount(BigDecimal.valueOf(0));
chDisabDetailAccounts.setDeductionAmount(BigDecimal.valueOf(0));
ChDisabAccounts chDisabAccounts = getChDisabAccounts(accountsVO, limit, overallCost, personalCost);
chDisabDetailAccounts.setAccountsId(chDisabAccounts.getAccountsId());
chDisabAccountsDetailMapper.insert(chDisabDetailAccounts);
}
}
}
private ChDisabAccounts getChDisabAccounts1(AccountTaskExecuteReqVO accountsVO) {
// 结算表 根据机构和结算时间 服务方式
ChDisabAccounts chDisabAccounts = disabAccountsMapper.queryAccountByCondition(DateUtils.dateToStrYm(DateUtils.strToDate(accountsVO.getSrvDate())), accountsVO.getSrvModeName(), accountsVO.getSrvOrganId(),null);
......@@ -810,30 +690,9 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
}
private ChDisabAccounts getChDisabAccounts(OrganAccountsVO accountsVO, BigDecimal limit, BigDecimal overallCost, BigDecimal personalCost) {
// 结算表 根据机构和结算时间 服务方式
ChDisabAccounts chDisabAccounts = disabAccountsMapper.queryAccountByCondition(DateUtils.dateToStrYm(DateUtils.strToDate(accountsVO.getSrvDate())), accountsVO.getSrvModeName(), accountsVO.getSrvOrganId(),null);
if(chDisabAccounts == null) {
chDisabAccounts = new ChDisabAccounts();
chDisabAccounts.setModeName(accountsVO.getSrvModeName());
chDisabAccounts.setAccountsTime(DateUtils.strToTime(accountsVO.getSrvDate()));
chDisabAccounts.setSrvOrganId(Long.valueOf(accountsVO.getSrvOrganId()));
chDisabAccounts.setCreationTime(new Date());
chDisabAccounts.setAccountsStatus((short) 0);
BigDecimal zero = BigDecimal.valueOf(0);
chDisabAccounts.setAllCost(zero);
chDisabAccounts.setOverallCost(zero);
chDisabAccounts.setPersonalCost(zero);
chDisabAccounts.setReissueAmountTotal(zero);
chDisabAccounts.setDeductionAmountTotal(zero);
disabAccountsMapper.insert(chDisabAccounts);
}
return chDisabAccounts;
}
@Override
public void otherPlaceHandler(String programId){
List<OrganAccountsVO> accountsList = chDisabAccountsDetailMapper.getOtherPlaceList(programId);
/* List<OrganAccountsVO> accountsList = chDisabAccountsDetailMapper.getOtherPlaceList(programId);
for (OrganAccountsVO accountsVO : accountsList) {
ChDisabDetailAccounts chDisabDetailAccounts = new ChDisabDetailAccounts();
chDisabDetailAccounts.setSrvOrganId(accountsVO.getSrvOrganId());
......@@ -854,10 +713,10 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
chDisabDetailAccounts.setTaskDetailId(accountsVO.getTaskDetailId());
chDisabDetailAccounts.setMedicalArea(accountsVO.getMedicalArea());
chDisabDetailAccounts.setDisabInfoId(accountsVO.getDisabInfoId());
ChDisabAccounts chDisabAccounts = getChDisabAccounts(accountsVO, limit, zero, zero);
ChDisabAccounts chDisabAccounts = getChDisabAccounts1(accountsVO);
chDisabDetailAccounts.setAccountsId(chDisabAccounts.getAccountsId());
chDisabAccountsDetailMapper.insert(chDisabDetailAccounts);
}
}*/
}
@Override
......
......@@ -31,6 +31,9 @@
<if test="req.accountsId != null and req.accountsId != ''">
and d.ACCOUNTS_ID = #{req.accountsId}
</if>
<if test="req.modeId != null and req.modeId != ''">
and DECODE(d.mode_name, '医疗','1','养老', '2','上门','3', '异地', '4') = #{req.modeId}
</if>
<if test="req.accountsStatus != null and req.accountsStatus != ''">
and d.status = #{req.accountsStatus}
</if>
......@@ -54,7 +57,7 @@
<select id="queryNursingRecords" resultType="com.hungraim.ltc.pojo.entity.account.NursingRecordsRespVO">
select organ.SRV_ORGAN_NAME srvOrganName,
to_char(plan.SRV_PLAN_TIME,'yyyy-MM-dd') srvPlanTime,
DECODE(plan.MODE_ID, '1','医疗','2', '养老','3','上门', '4', '异地') modeName,
DECODE(plan.MODE_ID, '1','医疗','2', '养老','3','上门') modeName,
to_char(plan.CREATION_TIME,'yyyy-MM-dd HH24:mi:ss') executionTime,
plan.item_name itemName
from CH_SRV_PLAN plan
......@@ -65,6 +68,22 @@
and plan.IS_STATUS ='4'
</select>
<select id="queryNursingRecordsGoDoor" resultType="com.hungraim.ltc.pojo.entity.account.NursingRecordsRespVO">
select organ.SRV_ORGAN_NAME srvOrganName,
to_char(task.SRV_DATE,'yyyy-MM-dd') srvPlanTime,
detail.MODE_NAME modeName,
to_char(item.FCD,'yyyy-MM-dd HH:mm:ss') executionTime,
service.SERVICE_TYPE_DETAILED_NAME itemName
from CH_DISAB_ACCOUNTS_DETAIL detail
left join CH_SRV_TASK_DETAIL task on task.TASK_DETAIL_ID = detail.TASK_DETAIL_ID
left join CH_SRV_TASK_FINISH_ITEM item on detail.TASK_DETAIL_ID = item.TASK_DETAIL_ID
left join CH_SRV_ORGAN organ on organ.SRV_ORGAN_ID = detail.SRV_ORGAN_ID
LEFT JOIN CH_SRV_ORGAN_PROJECT CSOP ON CSOP.PROJECT_ID = item.ITEM_ID
left join CH_SERVICE_TYPE_DETAILED service on service.SERVICE_TYPE_DETAILED_ID = CSOP.ITEM_NAME
where detail.DISAB_INFO_ID = #{req.disabInfoId}
and detail.SRV_ORGAN_ID = #{req.srvOrganId} and detail.MODE_NAME = '上门'
</select>
......@@ -104,44 +123,7 @@
</where>
</select>
<select id="getOrganAccountsList" resultType="com.hungraim.ltc.pojo.vo.account.OrganAccountsVO">
select
detail.TASK_DETAIL_ID taskDetailId,
--失能人员姓名
disable.real_name realName,
disable.DISAB_INFO_ID disabInfoId,
--身份证号
disable.CERTI_CODE certiCode,
--所在省市
(select district_name from ch_fnd_district dis where apply.MEDICAL_AREA = dis.district_code) medicalArea,
program.SRV_MODE_ID modeId,
--服务方式
DECODE(program.SRV_MODE_ID, '1','医疗','2', '养老','3','上门', '4', '异地') srvModeName,
--护理机构名称
organ.srv_organ_id srvOrganId,
--护理机构名称
organ.srv_organ_name srvOrganName,
--护理服务人员 Id
emp.EMP_ID empId,
--任务时间
detail.SRV_DATE srvDate,
-- 机构等级
organ.LEVEL_CODE levelCode
from ch_srv_task_detail detail--服务计划
left join ch_srv_task task on task.srv_task_id = detail.srv_task_id--服务计划详情
left join ch_disable_info disable on task.disab_info_id = disable.disab_info_id--失能人员
left join CH_DISABLE_APPLY apply on apply.apply_id = disable.apply_id
left join ch_srv_organ_emp emp on task.srv_emp_id = emp.emp_id--护理人员
left join ch_srv_program program on task.program_id = program.program_id--服务方案
left join ch_srv_organ organ on program.srv_organ_id = organ.srv_organ_id--服务机构
LEFT JOIN CH_SRV_TASK_FINISH_ITEM CSTFI ON detail.TASK_DETAIL_ID = CSTFI.TASK_DETAIL_ID
<where>
detail.STATUS = '4'
<if test="taskDetailId != null and taskDetailId != ''">
AND detail.TASK_DETAIL_ID = #{taskDetailId}
</if>
</where>
</select>
<select id="queryPlanInfoByDetailId" resultType="com.hungraim.ltc.pojo.vo.account.OrganAccountsVO">
select
......@@ -173,16 +155,7 @@
where plan.IS_STATUS = '4' and plan.IS_BILL = 1 and plan.TASK_DETAIL_ID = #{taskDetailId}
</select>
<select id="queryAccountByCondition" resultType="com.hungraim.ltc.pojo.entity.account.ChDisabDetailAccounts">
select * from CH_DISAB_ACCOUNTS_DETAIL t where t.MODE_NAME in ('养老','医疗')
<if test="taskDetailIds != null and taskDetailIds.size() > 0">
AND t.TASK_DETAIL_ID IN
<foreach collection="taskDetailIds" separator="," open="(" close=")" item="taskDetailId">
#{taskDetailId}
</foreach>
</if>
</select>
<!--查询评估信息-->
<select id="getAssessAccountsList" resultType="com.hungraim.ltc.pojo.vo.account.AssessAccountsVO">
......
......@@ -14,6 +14,7 @@
organ.SRV_ORGAN_NAME srvOrganName,
rd.AMOUNT_OF_MONEY amountOfMoney,
rd.FREE_RD_ID freeRdId,
rd.REMARKS remarks,
d.ACCOUNTS_STATUS accountsStatus
from CH_DISAB_FREE_RD_INFO rd left join
CH_DISAB_ACCOUNTS_DETAIL detail on
......
......@@ -16,10 +16,11 @@ public class NursingReqVO extends BaseReq {
private String disabInfoId;
private String modeId;
private String modeName;
private String modeId;
private String srvOrganId;
......
......@@ -65,4 +65,6 @@ public class OverallCostListRespVO {
private String srvOrganName;
private String accountsStatus;
private String remarks;
}
......@@ -24,6 +24,8 @@ public class SrvOrganListReq extends BaseReq {
*/
private Long srvOrganId;
private String modeId;
/**
* 护理机构id
......
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