瀏覽代碼

Merge branch 'dev' of trick9191/jw2.0 into dev

trick9191 7 年之前
父節點
當前提交
fe172d3b27

+ 80 - 1
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/controller/PatientArchivesController.java

@ -1,22 +1,38 @@
package com.yihu.jw.controller;
import com.alibaba.fastjson.JSON;
import com.yihu.jw.entity.archives.PatientArchives;
import com.yihu.jw.entity.archives.PatientArchivesInfo;
import com.yihu.jw.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.restmodel.archives.PatientArchivesInfoVO;
import com.yihu.jw.restmodel.archives.PatientArchivesVO;
import com.yihu.jw.restmodel.archives.Test;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.archives.PatientArchivesMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.service.PatientArchivesSevice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by Trick on 2018/2/7.
 */
@RestController
@RequestMapping(PatientArchivesMapping.api_archives_common)
@Api(tags = "居民建档相关操作", description = "居民建档相关操作")
public class PatientArchivesController {
public class PatientArchivesController extends EnvelopRestController {
    @Autowired
    private PatientArchivesSevice patientArchivesSevice;
    @GetMapping(value = "test")
    @ApiOperation(value = "测试")
@ -26,4 +42,67 @@ public class PatientArchivesController {
        t.setFileType("1");
        return t;
    }
    @GetMapping(value = PatientArchivesMapping.Archives.findPatientArchives)
    @ApiOperation(value = "查询健康信息列表")
    public Envelop<PatientArchivesVO> findPatientArchives(@ApiParam(name = "name", value = "姓名(模糊匹配)")
                                                          @RequestParam(value = "name", required = false)String name,
                                                          @ApiParam(name = "status", value = "档案状态")
                                                          @RequestParam(value = "status", required = false)String status,
                                                          @ApiParam(name = "cancelReseanType", value = "注销状态")
                                                          @RequestParam(value = "cancelReseanType", required = false)String cancelReseanType,
                                                          @ApiParam(name = "page", value = "分页") @RequestParam(value = "page", required = false)Integer page,
                                                          @ApiParam(name = "size", value = "每一页大小")@RequestParam(value = "size", required = false )Integer size){
        try {
            return patientArchivesSevice.queryPatientArchivesPage(page,size,status, cancelReseanType ,name);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = PatientArchivesMapping.Archives.findPatientArchivesInfos)
    @ApiOperation(value = "查询健康信息详情列表")
    public Envelop<PatientArchivesInfoVO> queryPatientArchivesInfoPage(@ApiParam(name = "code", value = "档案编号")
                                                                           @RequestParam(value = "code", required = false)String code){
        try {
            return patientArchivesSevice.queryPatientArchivesInfoPage(code);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = PatientArchivesMapping.Archives.createPatientArchives)
    @ApiOperation(value = "创建健康信息详情列表")
    public Envelop<Boolean> createPatientArchives(@ApiParam(name = "patientArchives", value = "建档基本信息Json")
                                                  @RequestParam(value = "patientArchives", required = true)String patientArchives,
                                                  @ApiParam(name = "list", value = "建档详情")
                                                  @RequestParam(value = "list", required = true)List<PatientArchivesInfoVO> list){
        try {
            PatientArchives ps = toEntity(patientArchives, PatientArchives.class);
            List<PatientArchivesInfo> infos = new ArrayList<>();
            convertToModels(list,infos,PatientArchivesInfo.class);
            return patientArchivesSevice.createPatientArchives(ps,infos);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = PatientArchivesMapping.Archives.updatePatientArchives)
    @ApiOperation(value = "更新健康信息详情列表")
    public Envelop<Boolean> updatePatientArchives(@ApiParam(name = "patientArchives", value = "建档基本信息Json")
                                                  @RequestParam(value = "patientArchives", required = true)String patientArchives,
                                                  @ApiParam(name = "list", value = "建档详情")
                                                  @RequestParam(value = "list", required = true)List<PatientArchivesInfoVO> list){
        try {
            PatientArchives ps = toEntity(patientArchives, PatientArchives.class);
            List<PatientArchivesInfo> infos = new ArrayList<>();
            convertToModels(list,infos,PatientArchivesInfo.class);
            return patientArchivesSevice.updatePatientArchives(ps,infos);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 4 - 0
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/dao/PatientArchivesInfoDao.java

@ -4,9 +4,13 @@ import com.yihu.jw.entity.archives.PatientArchivesInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/2/7.
 */
public interface PatientArchivesInfoDao extends PagingAndSortingRepository<PatientArchivesInfo, String>,
        JpaSpecificationExecutor<PatientArchivesInfo> {
    List<PatientArchivesInfo> findByCodeOrderByLevel1(String code);
    int deleteByArchivesCode(String archivesCode);
}

+ 128 - 1
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/service/PatientArchivesSevice.java

@ -1,13 +1,140 @@
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.PatientArchives;
import com.yihu.jw.entity.archives.PatientArchivesInfo;
import com.yihu.jw.iot.company.IotCompanyDO;
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.restmodel.iot.company.IotCompanyTypeVO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.rm.archives.PatientArchivesMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
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.awt.*;
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 {
public class PatientArchivesSevice extends BaseJpaService<PatientArchives,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.isBlank(cancelReseanType)){
            filters+= semicolon + "cancelReseanType="+cancelReseanType+"";
            semicolon = ";";
        }
        String sorts = "-createTime";
        //得到list数据
        List<PatientArchivesVO> 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<PatientArchivesInfo> list = patientArchivesInfoDao.findByCodeOrderByLevel1(code);
        List<PatientArchivesInfoVO> patientArchivesinfoVOs = convertToModelVOs2(list,new ArrayList<>(list.size()));
        return Envelop.getSuccessList(PatientArchivesMapping.api_success,patientArchivesinfoVOs);
    }
    public Envelop<Boolean> createPatientArchives(PatientArchives patientArchives,List<PatientArchivesInfo> list){
        patientArchivesDao.save(patientArchives);
        patientArchivesInfoDao.save(list);
        Envelop envelop = new Envelop();
        envelop.setObj(true);
        return envelop;
    }
    public  Envelop<Boolean> updatePatientArchives(PatientArchives patientArchives,List<PatientArchivesInfo> list){
        patientArchivesDao.save(patientArchives);
        patientArchivesInfoDao.deleteByArchivesCode(patientArchives.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;
    }
}