| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.constant.ConsumptionConstant; |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.common.utils.StringUtils; |
| | | import com.kidgrow.oprationcenter.feign.DiagnosticService; |
| | | import com.kidgrow.oprationcenter.mapper.ConsumptionRecordMapper; |
| | | import com.kidgrow.oprationcenter.mapper.ProductOrderDetailMapper; |
| | | import com.kidgrow.oprationcenter.mapper.ProductOrderMapper; |
| | | import com.kidgrow.oprationcenter.model.ConsumptionRecord; |
| | | import com.kidgrow.oprationcenter.model.ProductOrder; |
| | | import com.kidgrow.oprationcenter.model.ProductOrderDetail; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderDetailService; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderService; |
| | | import com.kidgrow.oprationcenter.vo.*; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.usercenter.feign.SysDoctorService; |
| | | import com.kidgrow.usercenter.feign.SysHospitalService; |
| | | import com.kidgrow.usercenter.model.SysHospital; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cglib.beans.BeanCopier; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private ConsumptionRecordMapper consumptionRecordMapper; |
| | | @Autowired |
| | | private IProductOrderService iProductOrderService; |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | /** |
| | | * 列表 |
| | | * @param params |
| | |
| | | * 判定医院科室的套餐是否到期 以及到期时间 |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @param diagnosticId |
| | | * @return |
| | | */ |
| | | public ResultBody UserProductDetailData(Long hospitalId,Long departmentId) |
| | | public ResultBody<UserProductData> UserProductDetailData(Long hospitalId,Long departmentId,String diagnosticId) |
| | | { |
| | | UserProductData userProductData=new UserProductData(); |
| | | userProductData.setEnd(true); |
| | |
| | | userProductData.setMaxEndTime(productOrderJoinDetailsNewList.get(0).getProEndtime()); |
| | | } |
| | | } |
| | | //是否已经结束 |
| | | if (userProductData.isEnd()&& StringUtils.isNotBlank(diagnosticId)) { |
| | | //写入redis中,防止扣非后不能生成报告 |
| | | redisUtils.lSet(CommonConstant.SAAS_LAST_SERVER+diagnosticId,diagnosticId); |
| | | } |
| | | return ResultBody.ok().data(userProductData); |
| | | } |
| | | |
| | | /** |
| | | * 获取需要审核的套餐 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult all(Map<String, Object> params) { |
| | | Page<ProductOrderDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | |
| | | } |
| | | } |
| | | return PageResult.<ProductOrderDetailVo>builder().data(volist).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 获取科室试用次数 |
| | | * @param departmentId 科室ID |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int getEnabledCount(Long departmentId) { |
| | | int counts=baseMapper.getEnabledCount(departmentId); |
| | | return counts; |
| | | } |
| | | /** |
| | | * 统计获取数据量 |
| | | * @param datatype |
| | | * 0 试用审核量 |
| | | * 1 套餐总量 |
| | | * 2 未处理用户反馈 |
| | | * 3 未处理数据需求 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int oprationChart(int datatype) { |
| | | return baseMapper.oprationChart(datatype); |
| | | } |
| | | /** |
| | | * 按指定类型统计合同数量 |
| | | * @param params |
| | | * datatype 1 按年 |
| | | * 2 按月 |
| | | * 3 按天 |
| | | * 4 按周 |
| | | * beginTime 查询时间段的开始时间 |
| | | * endTime 结束时间 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<OrderChartVo> productOrderChart(Map<String, Object> params) { |
| | | return baseMapper.productOrderChart(params); |
| | | } |
| | | /** |
| | | * 统计产品的使用数量 |
| | | * @return ccount 是数量 |
| | | * units 是产品名称 |
| | | */ |
| | | @Override |
| | | public List<OrderChartVo> proCountChart() { |
| | | return baseMapper.proCountChart(); |
| | | } |
| | | /** |
| | | *获取该科室下的所有的套餐信息 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<ProductOrderDetail> departmentProductDetail(Map<String, Object> params) { |
| | | Page<ProductOrderDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<ProductOrderDetail> list = |
| | | baseMapper.departmentProductDetail(page, Long.parseLong(params.get("hospitalId").toString()),Long.parseLong(params.get("departmentId").toString())); |
| | | return PageResult.<ProductOrderDetail>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | |
| | | //包含共享的数据 |
| | | userProductDetail.setProductOrderJoinDetailListShare(productOrderDetailList.stream().filter(f -> f.getIsShare()).collect(Collectors.toList())); |
| | | //科室私有的数据 |
| | | userProductDetail.setProductOrderJoinDetailsListDep(productOrderDetailList.stream().filter((f -> departmentId.equals(f.getDepartmentId()) && f.getIsShare() == false)).collect(Collectors.toList())); |
| | | userProductDetail.setProductOrderJoinDetailsListDep(productOrderDetailList.stream().filter((f -> departmentId.equals(f.getDepartmentId()) && !f.getIsShare())).collect(Collectors.toList())); |
| | | return userProductDetail; |
| | | } |
| | | return null; |
| | |
| | | //科室私有的数据 |
| | | List<ProductOrderJoinDetail> productOrderJoinDetailsListDep = userProductDetail.getProductOrderJoinDetailsListDep(); |
| | | //本医院可共享的读片总量 |
| | | int shareCount = productOrderJoinDetailListShare.stream().collect(Collectors.summingInt(ProductOrderJoinDetail::getAilightCount)); |
| | | int shareCount = (productOrderJoinDetailListShare.size()>0)? |
| | | productOrderJoinDetailListShare.stream().collect(Collectors.summingInt(ProductOrderJoinDetail::getAilightCount)) |
| | | :0; |
| | | //本科室私有读片总量 |
| | | int depCount = productOrderJoinDetailsListDep.stream().collect(Collectors.summingInt(ProductOrderJoinDetail::getAilightCount)); |
| | | int depCount = (productOrderJoinDetailsListDep.size()>0)? |
| | | productOrderJoinDetailsListDep.stream().collect(Collectors.summingInt(ProductOrderJoinDetail::getAilightCount)) |
| | | :0; |
| | | //可用的总量 |
| | | userAICount = shareCount + depCount; |
| | | |
| | | //共享套餐里面的detailid |
| | | List<Long> shareDetailId = (productOrderJoinDetailListShare.size()>0) |
| | | ?productOrderJoinDetailListShare.stream().map(m -> m.getId()).collect(Collectors.toList()) |
| | | :new ArrayList<>(); |
| | | //私有套餐里面的detailid |
| | | List<Long> depDetailId = (productOrderJoinDetailsListDep.size()>0) |
| | | ?productOrderJoinDetailsListDep.stream().map(m -> m.getId()).collect(Collectors.toList()) |
| | | :new ArrayList<>(); |
| | | //获取所有有效的套餐id |
| | | List<Long> nowDetailList=new ArrayList<>(); |
| | | BeanUtils.copyProperties(shareDetailId,nowDetailList); |
| | | nowDetailList.addAll(depDetailId); |
| | | //查询已预扣 未退还 未扣费的数据 |
| | | List<ConsumptionRecord> consumptionRecordList = consumptionRecordMapper.findDetailList(nowDetailList); |
| | | //计算预扣费的总量 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("recordType", ConsumptionConstant.BEFORE_DEDUCTION); |
| | | List<ConsumptionRecord> consumptionRecordList = consumptionRecordMapper.findList(selectMap);; |
| | | if (consumptionRecordList.size() > 0) { |
| | | //共享套餐里面的detailid |
| | | List<Long> shareDetailId = productOrderJoinDetailListShare.stream().map(m -> m.getId()).collect(Collectors.toList()); |
| | | //私有套餐里面的detailid |
| | | List<Long> depDetailId = productOrderJoinDetailsListDep.stream().map(m -> m.getId()).collect(Collectors.toList()); |
| | | //共享套餐里面预扣费总数 |
| | | int shareConCount = consumptionRecordList.stream().filter(f -> shareDetailId.contains(f.getProOrderDetailId())).collect(Collectors.summingInt(ConsumptionRecord::getConsumptionCount)); |
| | | //共享套餐里面预扣费总数 |
| | | int depConCount = consumptionRecordList.stream().filter(f -> depDetailId.contains(f.getProOrderDetailId())).collect(Collectors.summingInt(ConsumptionRecord::getConsumptionCount)); |
| | | int shareConCount = (shareDetailId.size()>0)?consumptionRecordList.stream() |
| | | .filter(f -> shareDetailId.contains(f.getProOrderDetailId())) |
| | | .collect(Collectors.summingInt(ConsumptionRecord::getConsumptionCount)):0; |
| | | //私有套餐里面预扣费总数 |
| | | int depConCount = (depDetailId.size()>0)?consumptionRecordList.stream() |
| | | .filter(f -> depDetailId.contains(f.getProOrderDetailId())) |
| | | .collect(Collectors.summingInt(ConsumptionRecord::getConsumptionCount)):0; |
| | | userAICount -= (shareConCount + depConCount); |
| | | } |
| | | } |