| | |
| | | package com.kidgrow.oprationcenter.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.common.utils.AesUtils; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.common.utils.StringUtils; |
| | | import com.kidgrow.oprationcenter.feign.DiagnosticService; |
| | |
| | | import com.kidgrow.oprationcenter.model.ConsumptionRecord; |
| | | import com.kidgrow.oprationcenter.model.ProductOrder; |
| | | import com.kidgrow.oprationcenter.model.ProductOrderDetail; |
| | | import com.kidgrow.oprationcenter.model.SysProduct; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderDetailService; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderService; |
| | | import com.kidgrow.oprationcenter.service.ISysProductService; |
| | | import com.kidgrow.oprationcenter.vo.*; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.usercenter.feign.SysDoctorService; |
| | |
| | | import org.springframework.cglib.beans.BeanCopier; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Autowired |
| | | private IProductOrderService iProductOrderService; |
| | | @Autowired |
| | | private ISysProductService productService; |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | /** |
| | | * 列表 |
| | |
| | | public PageResult<ProductOrderDetail> findList(Map<String, Object> params){ |
| | | Page<ProductOrderDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<ProductOrderDetail> list = baseMapper.findList(page, params); |
| | | for (ProductOrderDetail productOrderDetail : list) { |
| | | if(productOrderDetail.getOrderAilightCount()==null){ |
| | | SysProduct byId = productService.getById(productOrderDetail.getProId()); |
| | | if(byId!=null){ |
| | | productOrderDetail.setOrderAilightCount(byId.getAilightCount()); |
| | | productOrderDetail.setOrderRecordCount(byId.getRecordCount()); |
| | | } |
| | | } |
| | | } |
| | | return PageResult.<ProductOrderDetail>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | /** |
| | |
| | | public List<OrderChartVo> proCountChart() { |
| | | return baseMapper.proCountChart(); |
| | | } |
| | | @Override |
| | | public int getUserdProduct(Long hospitalId, Long departmentId) { |
| | | return baseMapper.getUserdProduct(hospitalId,departmentId); |
| | | } |
| | | /** |
| | | *获取该科室下的所有的套餐信息 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<ProductOrderDetail> departmentProductDetail(Map<String, Object> params) { |
| | | public PageResult<ProductOrderDetailVo> departmentProductDetail(Map<String, Object> params) { |
| | | Page<ProductOrderDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | Boolean enabled = MapUtils.getBoolean(params, "enabled"); |
| | | 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(); |
| | | baseMapper.departmentProductDetail(page, Long.parseLong(params.get("hospitalId").toString()),Long.parseLong(params.get("departmentId").toString()),enabled); |
| | | List<ProductOrderDetailVo> listvo = new ArrayList<>(); |
| | | for (ProductOrderDetail productOrderDetail : list) { |
| | | ProductOrderDetailVo productOrderDetailVo=new ProductOrderDetailVo(); |
| | | BeanCopier beanCopier = BeanCopier.create(ProductOrderDetail.class, ProductOrderDetailVo.class, false); |
| | | beanCopier.copy(productOrderDetail,productOrderDetailVo,null); |
| | | Date proBegintime = productOrderDetailVo.getProBegintime(); |
| | | Date proEndtime = productOrderDetailVo.getProEndtime(); |
| | | Date nowDate = new Date(); |
| | | if(productOrderDetailVo.getEnabled()){ |
| | | if(nowDate.getTime()<proBegintime.getTime()){ |
| | | productOrderDetailVo.setUseType("未使用"); |
| | | }else if (proBegintime.getTime()<=nowDate.getTime()&&nowDate.getTime()<proEndtime.getTime()){ |
| | | productOrderDetailVo.setUseType("使用中"); |
| | | }else if(nowDate.getTime()>=proEndtime.getTime()){ |
| | | productOrderDetailVo.setUseType("已结束"); |
| | | } |
| | | }else { |
| | | productOrderDetailVo.setUseType("禁用"); |
| | | } |
| | | listvo.add(productOrderDetailVo); |
| | | } |
| | | return PageResult.<ProductOrderDetailVo>builder().data(listvo).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<ProductEndVo> productEndList(Map<String, Object> params) { |
| | | Page<ProductEndVo> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<ProductEndVo> list = |
| | | baseMapper.productEndList(page,MapUtils.getIntValue(params,"monthPar"),MapUtils.getIntValue(params,"aiCountPar")); |
| | | return PageResult.<ProductEndVo>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | |
| | | List<GroupProductDetail> list = baseMapper.groupProductDetail(page,params); |
| | | return PageResult.<GroupProductDetail>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 根据ProductOrderDetail对象当做查询条件进行查询 |
| | | * @param productOrderDetail |
| | |
| | | return ResultBody.failed("医院和科室数据有误!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 私有云套餐验证 |
| | | * @param hospitalId 医院ID |
| | | * @param departmentId 科室ID |
| | | * @return com.kidgrow.common.model.ResultBody |
| | | */ |
| | | public ResultBody verificateProductOrderDetail(Long hospitalId, Long departmentId ){ |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | // 查询科室可用的合同列表【当前日期在合同开始、结束日期之间】 |
| | | List<ProductOrder> productOrderList = iProductOrderService.list( |
| | | new QueryWrapper<ProductOrder>() |
| | | .eq("hospital_id",hospitalId) |
| | | .eq("department_id",departmentId) |
| | | //.le("contract_begin_time",dateFormat.format(DateTime.now())) |
| | | //.ge("contract_end_time",dateFormat.format(DateTime.now())) |
| | | .eq("enabled",1) |
| | | .eq("is_del",0) |
| | | ); |
| | | |
| | | if ((productOrderList != null) && (productOrderList.size() > 0)) { |
| | | for (int i = 0 ; i < productOrderList.size(); i++) { |
| | | |
| | | ProductOrder productOrder = productOrderList.get(i); |
| | | // 查询合同可用的套餐【当前日期在套餐开始、结束日期之间,剩余读片量大于零】 |
| | | List<ProductOrderDetail> productOrderDetailList = baseMapper.selectList( |
| | | new QueryWrapper<ProductOrderDetail>() |
| | | .eq("order_id",productOrder.getId()) |
| | | //.le("pro_begintime",dateFormat.format(DateTime.now())) |
| | | //.ge("pro_endtime",dateFormat.format(DateTime.now())) |
| | | //.gt("order_ailight_count",0) |
| | | //.gt("order_ailight_count - ailight_count",0) |
| | | .eq("enabled",1) |
| | | .eq("is_del",0) |
| | | |
| | | ); |
| | | if ((productOrderDetailList != null) && (productOrderDetailList.size() > 0)) { |
| | | try { |
| | | for (int j = 0; j < productOrderDetailList.size(); j++) { |
| | | ProductOrderDetail productOrderDetail = productOrderDetailList.get(j); |
| | | if ((productOrderDetail.getAilightCountEncryption() == null) || (productOrderDetail.getAilightCountEncryption().isEmpty())) { |
| | | log.error("可用读片数量验证串为空"); |
| | | return ResultBody.failed("可用读片数量验证串为空"); |
| | | } |
| | | if ((productOrderDetail.getProBegintimeEncryption() == null) || (productOrderDetail.getProBegintimeEncryption().isEmpty())) { |
| | | log.error("套餐开始日期验证串为空"); |
| | | return ResultBody.failed("套餐开始日期验证串为空"); |
| | | } |
| | | if ((productOrderDetail.getProEndtimeEncryption() == null) || (productOrderDetail.getProEndtimeEncryption().isEmpty())) { |
| | | log.error("套餐结束日期验证串为空"); |
| | | return ResultBody.failed("套餐结束日期验证串为空"); |
| | | } |
| | | |
| | | String ailightCount = AesUtils.desEncrypt(productOrderDetail.getAilightCountEncryption()); |
| | | String proBeginTime = AesUtils.desEncrypt(productOrderDetail.getProBegintimeEncryption()); |
| | | String proEndTime = AesUtils.desEncrypt(productOrderDetail.getProEndtimeEncryption()); |
| | | |
| | | if ((ailightCount.isEmpty()) || (!productOrderDetail.getAilightCount().toString().equals(ailightCount))) { |
| | | log.error("可用读片数量验证失败"); |
| | | return ResultBody.failed("可用读片数量验证失败"); |
| | | } |
| | | if ((proBeginTime.isEmpty()) || (!dateFormat.format(productOrderDetail.getProBegintime()).equals(proBeginTime))) { |
| | | log.error("套餐开始日期验证失败"); |
| | | return ResultBody.failed("套餐开始日期验证失败"); |
| | | } |
| | | if ((proEndTime.isEmpty()) || (!dateFormat.format(productOrderDetail.getProEndtime()).equals(proEndTime))) { |
| | | log.error("套餐结束日期验证失败"); |
| | | return ResultBody.failed("套餐结束日期验证失败"); |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultBody.failed(e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | // } else { |
| | | // return ResultBody.failed("无有效的合同"); |
| | | } |
| | | log.error("私有云套餐验证通过"); |
| | | return ResultBody.ok().msg("私有云套餐验证通过"); |
| | | } |
| | | } |