| | |
| | | package com.kidgrow.oprationcenter.service.impl; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.model.PageResult; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.oprationcenter.mapper.HospitalScreeningMapper; |
| | | import com.kidgrow.oprationcenter.model.HospitalScreening; |
| | | import com.kidgrow.oprationcenter.model.ScreeningHospitalDataExcel; |
| | | import com.kidgrow.oprationcenter.service.IHospitalScreeningService; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.report.feign.ReportService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import com.kidgrow.oprationcenter.model.HospitalScreening; |
| | | import com.kidgrow.oprationcenter.mapper.HospitalScreeningMapper; |
| | | import com.kidgrow.oprationcenter.service.IHospitalScreeningService; |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © 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 HospitalScreeningServiceImpl extends SuperServiceImpl<HospitalScreeningMapper, HospitalScreening> implements IHospitalScreeningService { |
| | | |
| | | @Autowired |
| | | private ReportService reportService; |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | |
| | | private static final String CUSOTMERHOSPITAL = "CUSOTMER_HOSPITAL"; |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<HospitalScreening> findList(Map<String, Object> params){ |
| | | public PageResult<HospitalScreening> findList(Map<String, Object> params) { |
| | | Page<HospitalScreening> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<HospitalScreening> list = baseMapper.findList(page, params); |
| | | List<HospitalScreening> list = baseMapper.findList(page, params); |
| | | return PageResult.<HospitalScreening>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 根据HospitalScreening对象当做查询条件进行查询 |
| | | * @param hospitalScreening |
| | | * @return HospitalScreening |
| | | */ |
| | | * 根据HospitalScreening对象当做查询条件进行查询 |
| | | * |
| | | * @param hospitalScreening |
| | | * @return HospitalScreening |
| | | */ |
| | | @Override |
| | | public HospitalScreening findByObject(HospitalScreening hospitalScreening){ |
| | | public HospitalScreening findByObject(HospitalScreening hospitalScreening) { |
| | | return baseMapper.findByObject(hospitalScreening); |
| | | } |
| | | |
| | | /** |
| | | * 更新状态:推送装填,启停状态 |
| | | * |
| | | * @param params 包含:1、type:0推送,1启停 |
| | | * 2、ID :ID |
| | | * 3、val:对用的值 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody updateEnabled(Map<String, Object> params) { |
| | | int type = MapUtils.getInteger(params, "type"); |
| | | int val = MapUtils.getInteger(params, "objVal"); |
| | | long id = MapUtils.getLong(params, "objId"); |
| | | |
| | | HospitalScreening hospitalScreening = baseMapper.selectById(id); |
| | | |
| | | if (hospitalScreening == null) { |
| | | return ResultBody.failed("医院数据不存在!"); |
| | | } |
| | | |
| | | switch (type) { |
| | | case 0: |
| | | hospitalScreening.setIsScreeningPush(val); |
| | | break; |
| | | case 1: |
| | | hospitalScreening.setEnabled(val); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | int count = baseMapper.updateById(hospitalScreening); |
| | | |
| | | updateRedisById(hospitalScreening); |
| | | |
| | | return count > 0 ? ResultBody.ok().msg("更新成功") : ResultBody.failed("更新失败"); |
| | | } |
| | | |
| | | /** |
| | | * 根据医院名称模糊查询医院数据列表 |
| | | * |
| | | * @param hospitalName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody<HospitalScreening> findByName(String hospitalName) { |
| | | return ResultBody.ok().data(baseMapper.findByName(hospitalName)).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 医院数据导出 |
| | | * |
| | | * @param param 参数 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ScreeningHospitalDataExcel> export(Map<String, Object> param) { |
| | | List<ScreeningHospitalDataExcel> list = null; |
| | | ResultBody resultBody = reportService.exportData(param); |
| | | if (resultBody.getCode() == 0 && resultBody.getData() != null) { |
| | | list = JSONArray.parseArray(JSONArray.toJSONString(resultBody.getData()), ScreeningHospitalDataExcel.class); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 初始化,将表中的数据放入redis中 |
| | | */ |
| | | @Override |
| | | public void tableToRedis() { |
| | | List<HospitalScreening> list = baseMapper.findAll(); |
| | | if (list.size() > 0) { |
| | | if (redisUtils.hasKey(CUSOTMERHOSPITAL)) { |
| | | redisUtils.del(CUSOTMERHOSPITAL); |
| | | } |
| | | |
| | | for (HospitalScreening hs : list) { |
| | | redisUtils.hset(CUSOTMERHOSPITAL, String.valueOf(hs.getId()), hs); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新redis |
| | | * |
| | | * @param hospitalScreening |
| | | */ |
| | | @Override |
| | | public void updateRedisById(HospitalScreening hospitalScreening) { |
| | | if (redisUtils.hasKey(CUSOTMERHOSPITAL)) { |
| | | redisUtils.hset(CUSOTMERHOSPITAL, String.valueOf(hospitalScreening.getId()), hospitalScreening); |
| | | } |
| | | } |
| | | } |