| | |
| | | import com.kidgrow.oprationcenter.feign.RoleOrganizationService; |
| | | import com.kidgrow.oprationcenter.mapper.ProductOrderRecordMapper; |
| | | import com.kidgrow.oprationcenter.model.ProductOrderRecord; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderDetailService; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderRecordService; |
| | | import com.kidgrow.oprationcenter.vo.DiagnosisRecord; |
| | | import com.kidgrow.oprationcenter.vo.GroupProductDetail; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @version 1.0 |
| | | * @Description: 产品/明显的充值记录<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-04-01 09:37:05 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ProductOrderRecordServiceImpl extends SuperServiceImpl<ProductOrderRecordMapper, ProductOrderRecord> implements IProductOrderRecordService { |
| | | @Autowired |
| | | @Autowired |
| | | DiagnosticService diagnosticService; |
| | | @Autowired |
| | | private RoleOrganizationService roleOrganizationService; |
| | |
| | | private SysDoctorService sysDoctorService; |
| | | @Autowired |
| | | private SysHospitalService sysHospitalService; |
| | | @Autowired |
| | | private IProductOrderDetailService productOrderDetailService; |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<ProductOrderRecord> findList(Map<String, Object> params){ |
| | | public PageResult<ProductOrderRecord> findList(Map<String, Object> params) { |
| | | Page<ProductOrderRecord> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<ProductOrderRecord> list = baseMapper.findList(page, params); |
| | | List<ProductOrderRecord> list = baseMapper.findList(page, params); |
| | | return PageResult.<ProductOrderRecord>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 获取诊断列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<DiagnosisRecord> findAllDataList(Map<String, Object> params){ |
| | | return diagnosticService.getDiagnosticItemList(params).getData(); |
| | | public PageResult<DiagnosisRecord> findAllDataList(Map<String, Object> params) { |
| | | return diagnosticService.getDiagnosticItemList(params).getData(); |
| | | } |
| | | |
| | | /** |
| | | * 查看报告 |
| | | */ |
| | | @Override |
| | | public ResultBody getPdfPathForOperation(String diagnosticId, Integer reportType, Long hospitalId, Long departId) { |
| | | ResultBody pdfPathForOperation = diagnosticService.getPdfPathForOperation(diagnosticId, reportType, hospitalId, departId); |
| | | return pdfPathForOperation; |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<ProductOrderJoinDetail> findAllList(Map<String, Object> params, SysUser sysUser) { |
| | | Page<ProductOrderJoinDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | Map<String, Object> roleOrgMap = roleOrganizationService.getRoleOrgMap(sysUser.getRoles()); |
| | | params.putAll(roleOrgMap); |
| | | List<ProductOrderJoinDetail> list = baseMapper.findAllList(page,params); |
| | | // Map<String, Object> roleOrgMap = roleOrganizationService.getRoleOrgMap(sysUser); |
| | | // params.putAll(roleOrgMap); |
| | | List<ProductOrderJoinDetail> list = baseMapper.findAllList(page, params); |
| | | for (ProductOrderJoinDetail productOrderJoinDetail : list) { |
| | | Date proBegintime = productOrderJoinDetail.getProBegintime(); |
| | | Date proEndtime = productOrderJoinDetail.getProEndtime(); |
| | | Date nowDate = new Date(); |
| | | if(nowDate.getTime()<proBegintime.getTime()){ |
| | | productOrderJoinDetail.setUseType("未使用"); |
| | | }else if (proBegintime.getTime()<=nowDate.getTime()&&nowDate.getTime()<proEndtime.getTime()){ |
| | | productOrderJoinDetail.setUseType("使用中"); |
| | | }else if(nowDate.getTime()>=proEndtime.getTime()){ |
| | | productOrderJoinDetail.setUseType("已结束"); |
| | | } |
| | | } |
| | | return PageResult.<ProductOrderJoinDetail>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 获取统计数据 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<GroupProductDetail> groupList(Map<String, Object> params) { |
| | | Page<GroupProductDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<GroupProductDetail> list = baseMapper.groupProductDetail(page,params); |
| | | List<GroupProductDetail> list = baseMapper.groupProductDetail(page, params); |
| | | return PageResult.<GroupProductDetail>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 统计用户所有套餐剩余 |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @return |
| | | * 根据ProductOrderRecord对象当做查询条件进行查询 |
| | | * |
| | | * @param productOrderRecord |
| | | * @return ProductOrderRecord |
| | | */ |
| | | @Override |
| | | public ResultBody biUserNowProduct(long hospitalId, Long departmentId) { |
| | | if (hospitalId>0&& departmentId>0) { |
| | | //查询当前医院正在使用的套餐 |
| | | Map<String,Object> selectMap=new HashMap<>(); |
| | | selectMap.put("hospitalId",hospitalId); |
| | | List<ProductOrderJoinDetail> productOrderDetailList=productOrderDetailService.findAllList(selectMap); |
| | | Long userAICount=0l; |
| | | if (productOrderDetailList.size()>0) { |
| | | //包含共享的数据 |
| | | List<ProductOrderJoinDetail> productOrderJoinDetailListShare=productOrderDetailList.stream().filter(f->f.getIsShare()).collect(Collectors.toList()); |
| | | //科室私有的数据 |
| | | List<ProductOrderJoinDetail> productOrderJoinDetailsListDep=productOrderDetailList.stream().filter((f->departmentId.equals(f.getDepartmentId())&&f.getIsShare()==false)).collect(Collectors.toList()); |
| | | //本医院可共享的读片总量 |
| | | Long shareCount=productOrderJoinDetailListShare.stream().collect(Collectors.summingLong(ProductOrderJoinDetail::getAilightCount)); |
| | | //本科室私有读片总量 |
| | | Long depCount=productOrderJoinDetailsListDep.stream().collect(Collectors.summingLong(ProductOrderJoinDetail::getAilightCount)); |
| | | //可用的总量 |
| | | userAICount=shareCount+depCount; |
| | | } |
| | | return ResultBody.ok().data(userAICount); |
| | | } |
| | | else |
| | | { |
| | | return ResultBody.failed("医院和科室数据有误!"); |
| | | } |
| | | public ProductOrderRecord findByObject(ProductOrderRecord productOrderRecord) { |
| | | return baseMapper.findByObject(productOrderRecord); |
| | | } |
| | | |
| | | /** |
| | | * 根据ProductOrderRecord对象当做查询条件进行查询 |
| | | * @param productOrderRecord |
| | | * @return ProductOrderRecord |
| | | */ |
| | | @Override |
| | | public ProductOrderRecord findByObject(ProductOrderRecord productOrderRecord){ |
| | | return baseMapper.findByObject(productOrderRecord); |
| | | } |
| | | /** |
| | | * 修改数据状态 启用 禁用 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | |
| | | @Override |
| | | public ResultBody getTypeByUser(SysUser sysUser) { |
| | | List<SysOrganization> organizations = sysUser.getOrganizations(); |
| | | if(organizations.size()>0){ |
| | | if (organizations.size() > 0) { |
| | | SysOrganization sysOrganization = organizations.get(0); |
| | | List<ProductOrderJoinDetail> list=baseMapper.getTypeByUser(sysOrganization.getId()); |
| | | if (list.size()>0) { |
| | | List<ProductOrderJoinDetail> list = baseMapper.getTypeByUser(sysOrganization.getId()); |
| | | if (list.size() > 0) { |
| | | ProductOrderJoinDetail productOrderJoinDetail = list.get(0); |
| | | //查询用户的真实姓名 |
| | | Map<String,Object> selectMap=new HashMap<>(); |
| | | selectMap.put("user_id",sysUser.getId()); |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("user_id", sysUser.getId()); |
| | | ResultBody listByMap = sysDoctorService.getListByMap(selectMap); |
| | | List<SysDoctor> sysDoctors = JSON.parseArray(JSON.toJSONString(listByMap.getData()), SysDoctor.class); |
| | | String str=""; |
| | | if(sysDoctors!=null&&sysDoctors.size()>0){ |
| | | str= sysDoctors.get(0).getDoctorName(); |
| | | String str = ""; |
| | | if (sysDoctors != null && sysDoctors.size() > 0) { |
| | | str = sysDoctors.get(0).getDoctorName(); |
| | | } |
| | | //查询医院的 logo |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("id",sysOrganization.getId()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", sysOrganization.getId()); |
| | | ResultBody allByMap = sysHospitalService.findAllByMap(map); |
| | | List<SysHospital> hospitals = JSON.parseArray(JSON.toJSONString(allByMap.getData()), SysHospital.class); |
| | | String logo=""; |
| | | if(hospitals.size()>0){ |
| | | String logo = ""; |
| | | if (hospitals.size() > 0) { |
| | | logo = hospitals.get(0).getHospitalLogo(); |
| | | } |
| | | Map<String,Object> mapVo=new HashMap<>(); |
| | | mapVo.put("type",productOrderJoinDetail.getProType()); |
| | | mapVo.put("realName",str); |
| | | Map<String, Object> mapVo = new HashMap<>(); |
| | | mapVo.put("type", productOrderJoinDetail.getProType()); |
| | | mapVo.put("realName", str); |
| | | //剩余时间 |
| | | Date proEndtime = productOrderJoinDetail.getProEndtime(); |
| | | Double surplusDay=DateUtils.getDays(proEndtime, new Date()); |
| | | Double surplusDay = DateUtils.getDays(proEndtime, new Date()); |
| | | int surplus = surplusDay.intValue(); |
| | | mapVo.put("surplus",surplus); |
| | | mapVo.put("logo",logo); |
| | | mapVo.put("surplus", surplus); |
| | | mapVo.put("logo", logo); |
| | | //获取 售后服务工程师********不能从sysOrganization获取,从department获取 |
| | | /* mapVo.put("saleUserName",sysOrganization.getSaleUserName()); |
| | | mapVo.put("saleUserTel",sysOrganization.getSaleUserTel());*/ |
| | | return ResultBody.ok().data(mapVo); |
| | | }else { |
| | | } else { |
| | | return ResultBody.failed("该用户套餐已经失效"); |
| | | } |
| | | }else { |
| | | } else { |
| | | return ResultBody.failed("该用户的组织已经失效"); |
| | | } |
| | | } |