123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- package com.yihu.jw.service;
- import com.yihu.base.mysql.query.BaseJpaService;
- import com.yihu.jw.dao.PatientArchivesDao;
- import com.yihu.jw.dao.PatientArchivesInfoDao;
- import com.yihu.jw.entity.archives.PatientArchivesDO;
- import com.yihu.jw.entity.archives.PatientArchivesInfoDO;
- import com.yihu.jw.restmodel.archives.PatientArchivesInfoVO;
- import com.yihu.jw.restmodel.archives.PatientArchivesVO;
- import com.yihu.jw.restmodel.common.Envelop;
- import com.yihu.jw.rm.archives.PatientArchivesMapping;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.text.ParseException;
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.List;
- /**
- * Created by Trick on 2018/2/7.
- */
- @Service
- @Transactional
- public class PatientArchivesSevice extends BaseJpaService<PatientArchivesDO,PatientArchivesDao> {
- @Autowired
- private PatientArchivesInfoDao patientArchivesInfoDao;
- @Autowired
- private PatientArchivesDao patientArchivesDao;
- /**
- * 分页查找健康档案
- * @param page
- * @param size
- * @param status
- * @param name
- * @return
- * @throws ParseException
- */
- public Envelop<PatientArchivesVO> queryPatientArchivesPage(Integer page, Integer size, String status,String cancelReseanType ,String name) throws ParseException {
- String filters = "";
- String semicolon = "";
- if(StringUtils.isNotBlank(name)){
- filters = "patientName?"+name+"";
- semicolon = ";";
- }
- if(StringUtils.isNotBlank(status)){
- filters += semicolon +"status="+status;
- semicolon = ";";
- }
- if(StringUtils.isNotBlank(cancelReseanType)){
- filters+= semicolon + "cancelReseanType="+cancelReseanType+"";
- semicolon = ";";
- }
- String sorts = "-createTime";
- //得到list数据
- List<PatientArchivesDO> list = search(null, filters, sorts, page, size);
- //获取总数
- long count = getCount(filters);
- //DO转VO
- List<PatientArchivesVO> patientArchivesVOs = convertToModelVOs(list,new ArrayList<>(list.size()));
- return Envelop.getSuccessListWithPage(PatientArchivesMapping.api_success,patientArchivesVOs, page, size,count);
- }
- /**
- * 获取档案详情
- * @return
- * @throws ParseException
- */
- public Envelop<PatientArchivesInfoVO> queryPatientArchivesInfoPage(String code) throws ParseException {
- List<PatientArchivesInfoDO> list = patientArchivesInfoDao.findByArchivesCodeOrderByLevel1(code);
- List<PatientArchivesInfoVO> patientArchivesinfoVOs = convertToModelVOs2(list,new ArrayList<>(list.size()));
- return Envelop.getSuccessList(PatientArchivesMapping.api_success,patientArchivesinfoVOs);
- }
- public Envelop<Boolean> createPatientArchives(PatientArchivesDO patientArchivesDO, List<PatientArchivesInfoDO> list){
- patientArchivesDao.save(patientArchivesDO);
- patientArchivesInfoDao.save(list);
- Envelop envelop = new Envelop();
- envelop.setObj(true);
- return envelop;
- }
- public Envelop<Boolean> updatePatientArchives(PatientArchivesDO patientArchivesDO, List<PatientArchivesInfoDO> list){
- patientArchivesDao.save(patientArchivesDO);
- patientArchivesInfoDao.deleteByArchivesCode(patientArchivesDO.getId());
- patientArchivesInfoDao.save(list);
- Envelop envelop = new Envelop();
- envelop.setObj(true);
- return envelop;
- }
- /**
- * 转换
- * @param sources
- * @param targets
- * @return
- */
- public List<PatientArchivesVO> convertToModelVOs(Collection sources, List<PatientArchivesVO> targets){
- sources.forEach(one -> {
- PatientArchivesVO target = new PatientArchivesVO();
- BeanUtils.copyProperties(one, target);
- targets.add(target);
- });
- return targets;
- }
- /**
- * 转换
- * @param sources
- * @param targets
- * @return
- */
- public List<PatientArchivesInfoVO> convertToModelVOs2(Collection sources, List<PatientArchivesInfoVO> targets){
- sources.forEach(one -> {
- PatientArchivesInfoVO target = new PatientArchivesInfoVO();
- BeanUtils.copyProperties(one, target);
- targets.add(target);
- });
- return targets;
- }
- }
|