Quellcode durchsuchen

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

liubing vor 3 Jahren
Ursprung
Commit
04d120701d

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/DoctorConsultEndpoint.java

@ -163,7 +163,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
            if(permissionService.noPermission(1,param)){
                return Envelop.getError("该操作没有权限");
            }
            consultService.sendWeTempMesMiniProgram(sender_id,reciver_id,session_id,token,channelName);
            consultService.sendWeTempMesMiniProgram(sender_id,reciver_id,"2",session_id,token,channelName);
            return success("操作成功");
        }catch (Exception e){
            return failedException2(e);

+ 25 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java

@ -115,6 +115,31 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Autowired
	private MessageUtil messageUtil;
	@PostMapping(value = "videoInviteMiniProgram")
	@ApiOperation(value = "医生端:发起/断开 会话小程序视频邀请", notes = "医生端:发起/断开 会话小程序视频邀请")
	public Envelop videoInviteMiniProgram(@ApiParam(name = "sender_id", value = "发起人")
										  @RequestParam(value = "sender_id",required = true) String sender_id,
										  @ApiParam(name = "reciver_id", value = "接收人")
										  @RequestParam(value = "reciver_id",required = true) String reciver_id,
										  @ApiParam(name = "reciver_type", value = "接收人类型1居民 2医生")
										  @RequestParam(value = "reciver_type",required = false) String reciver_type,
										  @ApiParam(name = "token", value = "token")
										  @RequestParam(value = "token",required = false) String token,
										  @ApiParam(name = "channelName", value = "房间号")
										  @RequestParam(value = "channelName",required = false) String channelName,
										  @ApiParam(name = "session_id", value = "会话ID",required = false)
										  @RequestParam(value = "session_id",required = false) String session_id
	){
		try{
			consultService.sendWeTempMesMiniProgram(sender_id,reciver_id,"1",session_id,token,channelName);
			return success("操作成功");
		}catch (Exception e){
			return failedException2(e);
		}
	}
	@PostMapping(value = "sendGetuiMessage")
	@ApiOperation(value = "im推送个推消息")
	public Envelop sendGetuiMessage(String sessionId,String type,String contentType,String senderName,String senderId,String targetId){

+ 125 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wlyygc/WlyygcDataEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.wlyygc;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.WlyygcStatisticsService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -129,4 +130,128 @@ public class WlyygcDataEndpoint extends EnvelopRestEndpoint {
            return failedPageEnvelopException2(e);
        }
    }
    /********************************************全社区*******************************************************/
    @GetMapping(value = "emeAndsecinfos")
    @ApiOperation(value = "获取紧急安防工单信息")
    public PageEnvelop emeAndsecinfo(@ApiParam(name = "page", value = "分页大小", required = true)
                                     @RequestParam(value = "page") Integer page,
                                     @ApiParam(name = "size", value = "页码", required = true)
                                     @RequestParam(value = "size") Integer size){
        try {
            return wlyygcStatisticsService.emeAndsecinfo(page, size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceLists")
    @ApiOperation(value = "设备信息")
    public PageEnvelop deviceLists(@ApiParam(name = "page", value = "分页大小", required = true)
                                   @RequestParam(value = "page") Integer page,
                                   @ApiParam(name = "size", value = "页码", required = true)
                                   @RequestParam(value = "size") Integer size) {
        try {
            return wlyygcStatisticsService.deviceLists(page, size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "doorServiceOrder")
    @ApiOperation(value = "获取上门辅导")
    public PageEnvelop doorServiceOrder(@ApiParam(name = "page", value = "分页大小", required = true)
                                        @RequestParam(value = "page") Integer page,
                                        @ApiParam(name = "size", value = "页码", required = true)
                                        @RequestParam(value = "size") Integer size){
        try {
            return wlyygcStatisticsService.doorServiceOrder(page, size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "infantInfo")
    @ApiOperation(value = "幼儿信息")
    public PageEnvelop infantInfo(@ApiParam(name = "page", value = "分页大小", required = true)
                                   @RequestParam(value = "page") Integer page,
                                   @ApiParam(name = "size", value = "页码", required = true)
                                   @RequestParam(value = "size") Integer size){
        try {
            return wlyygcStatisticsService.infantInfo(page,size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "lifeCareList")
    @ApiOperation(value = "生活照料")
    public PageEnvelop lifeCareList(@ApiParam(name = "page", value = "分页大小", required = true)
                                    @RequestParam(value = "page") Integer page,
                                    @ApiParam(name = "size", value = "页码", required = true)
                                    @RequestParam(value = "size") Integer size) {
        try {
           return wlyygcStatisticsService.lifeCareList(page,size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceCollectInfo")
    @ApiOperation(value = "设备采集信息")
    public ListEnvelop deviceCollectInfo(@ApiParam(name = "deviceSN",value = "设备SN",required = true)
                                         @RequestParam(value = "deviceSN")String deviceSn,
                                         @ApiParam(name = "code",value = "设备code",required = true)
                                         @RequestParam(value = "code")String code,
                                         @ApiParam(name = "startDate",value = "开始时间",required = false)
                                         @RequestParam(value = "startDate",required = false)String startDate,
                                         @ApiParam(name = "endDate",value = "结束时间",required = false)
                                         @RequestParam(value = "endDate",required = false)String endDate){
        try {
            return success(wlyygcStatisticsService.deviceCollectInfo(deviceSn,code,startDate,endDate));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "signOldInfo")
    @ApiOperation(value = "老人签约信息 签约团队")
    public PageEnvelop signOldInfo(@ApiParam(name = "patient",value = "居民code",required = true)
                                   @RequestParam(value = "patient")String patient,
                                   @ApiParam(name = "page", value = "分页大小", required = true)
                                   @RequestParam(value = "page") Integer page,
                                   @ApiParam(name = "size", value = "页码", required = true)
                                   @RequestParam(value = "size") Integer size){
        try {
            return wlyygcStatisticsService.signOldInfo(patient,page,size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "oldInfo")
    @ApiOperation(value = "老人基本信息")
    public PageEnvelop oldInfo(@ApiParam(name = "page", value = "分页大小", required = true)
                               @RequestParam(value = "page") Integer page,
                               @ApiParam(name = "size", value = "页码", required = true)
                               @RequestParam(value = "size") Integer size){
        try {
            return wlyygcStatisticsService.oldInfo(page,size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
}

+ 11 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java

@ -98,10 +98,18 @@ public class ConsultService {
     * @param reciver_id 接收者ID
     * @param session_id 会话ID
     */
    public String sendWeTempMesMiniProgram(String sender_id, String reciver_id, String session_id,String token,String channelName)throws Exception {
    public String sendWeTempMesMiniProgram(String sender_id, String reciver_id,String sender_type, String session_id,String token,String channelName)throws Exception {
        BasePatientDO patient = basePatientDao.findById(reciver_id);
        if(patient!=null){
            BaseDoctorDO doctorDO = baseDoctorDao.findById(sender_id);
            String key2 = "";
            if("1".equals(sender_type)){
                BasePatientDO tmp = basePatientDao.findById(reciver_id);
                key2 = tmp.getName();
            }else{
                BaseDoctorDO doctorDO = baseDoctorDao.findById(sender_id);
                key2 = doctorDO.getName();
            }
            JSONObject json = new JSONObject();
            json.put("nickName", patient.getName());
            json.put("token", token);
@ -111,7 +119,7 @@ public class ConsultService {
            json.put("sessionId", session_id);
            String first = "【key1】您好!【key2】向您发起了视频请求";
            first = first.replace("key1",patient.getName());
            first = first.replace("key2", doctorDO.getName());
            first = first.replace("key2", key2);
            List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patient.getId());
            if (basePatientWechatDos.size()>0){
                String openId = basePatientWechatDos.get(0).getOpenid();

+ 1 - 55
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/role/RoleService.java

@ -92,64 +92,10 @@ public class RoleService extends BaseJpaService<DoctorRole, DoctorRoleDao> {
        if (roleList != null && roleList.size() > 0) {
            //遍历角色
            for (DoctorRole role : roleList) {
                if(role.getCode().length()!=6&&role.getCode().length()!=10){
                    continue;
                }
                Map<String, String> map = new HashMap<>();
                map.put("code", role.getCode());
                map.put("name", role.getName());
                //获取区域权限
                String areaString = "";
                List<DoctorRoleRealm> areaList = doctorRoleRealmDao.findByRoleCode(role.getCode());
                if (areaList != null && areaList.size() > 0) {
                    //获取最大权限区域
                    List<String> areas = new ArrayList<>();
                    List<String> orgs = new ArrayList<>();
                    for (DoctorRoleRealm areaItem : areaList) {
                        String currentArea = areaItem.getAreaCode();
                        int currentLength = currentArea.length();
                        if (currentLength == 6) //区域
                        {
                            areas.add(currentArea);
                        } else {               //机构
                            orgs.add(currentArea);
                        }
                    }
                    //区域权限重复校验
                    for (int i = areas.size() - 1; i >= 0; i--) {
                        String currentArea = areas.get(i);
                        for (int j = 0; j < areas.size() - i - 1; j++) {
                            String shortArea = getShortArea(areas.get(j));
                            if (currentArea.startsWith(shortArea))   //包含则移除
                            {
                                areas.remove(i);
                            }
                        }
                    }
                    //机构权限重复校验
                    for (int m = orgs.size() - 1; m >= 0; m--) {
                        String currentOrg = orgs.get(m);
                        for (int n = 0; n < areas.size() - m - 1; n++) {
                            String shortArea = getShortArea(areas.get(n));
                            if (currentOrg.startsWith(shortArea))   //包含则移除
                            {
                                orgs.remove(m);
                            }
                        }
                    }
                    for (String item : areas) {
                        areaString += item + ",";
                    }
                    for (String item : orgs) {
                        areaString += item + ",";
                    }
                    areaString = areaString.substring(0, areaString.length() - 1);
                }
                map.put("areas", areaString);
                map.put("areas", "");
                map.put("level",roleConverse(role.getCode())+"");
                map.put("isManage", "1");
                if(resultLevel==roleConverse(role.getCode())){

+ 331 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/WlyygcStatisticsService.java

@ -6,13 +6,16 @@ import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by yeshijie on 2022/1/18.
@ -25,6 +28,8 @@ public class WlyygcStatisticsService {
    @Autowired
    private BaseEmergencyWarnLogDao logDao;
    /***************************************************华联社区******************************************************/
    /**
     * 社区签约老人数量
     * @return
@ -349,7 +354,6 @@ public class WlyygcStatisticsService {
        return PageEnvelop.getSuccessListWithPage("查询成功",res,page,size,total);
    }
    public PageEnvelop deviceList(String code,Integer page,Integer size){
        if (page == null) {
            page = 1;
@ -404,4 +408,330 @@ public class WlyygcStatisticsService {
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,total);
    }
    /***************************************************所有社区******************************************************/
    /**
     *老人基本信息 居民标签
     */
    public PageEnvelop oldInfo(Integer page, Integer size){
        if (page == null) {
            page = 1;
        }
        if (size == null) {
            size = 10;
        }
        String patientInfoSql="SELECT DISTINCT" +
                " a.`name` AS `name`," +
                " TIMESTAMPDIFF(YEAR, a.birthday, CURDATE()) AS age," +
                " a.address AS address," +
                " a.residential_area AS residential_area," +
                " '老人' AS type," +
                " a.sign_status * 1 AS signStatus," +
                " a.archive_status * 1 AS archiveStatus," +
                " l.label_name AS labelName," +
                " a.id as id" +
                " FROM" +
                " base_patient a LEFT JOIN " +
                " wlyy_patient_label l ON a.id = l.patient" +
                " WHERE" +
                " a.archive_type = 1" +
                " AND a.del = '1' and  l.label_type = 1 limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(patientInfoSql);
        //删除测试老人数据
        Iterator<Map<String, Object>> iterator = maps.iterator();
        Map<String, String> signOlderMap = removeTestOld();
        while (iterator.hasNext()) {
            Map<String, Object> next = iterator.next();
            if (!signOlderMap.containsValue(next.get("id").toString())) {
                iterator.remove();
            }
        }
        return  PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+""));
    }
    /**
     * 老人签约信息 签约团队
     */
    public PageEnvelop signOldInfo(String patient,Integer page, Integer size){
        String signOld = "SELECT" +
                " DATE_FORMAT(pr.create_time,'%Y-%m-%d') AS createTime," +
                " p.`name` AS serName," +
                " p.type AS serType," +
                " p.org_name AS serOrgName," +
                " sr.sign_doctor_name AS signDoctorName," +
                " t.name AS teamName" +
                " FROM" +
                " base_service_package_sign_record sr " +
                " LEFT JOIN base_service_package_record pr ON sr.id = pr.sign_id" +
                " LEFT JOIN base_service_package p ON pr.service_package_id = p.id" +
                " LEFT JOIN base_team t ON t.id = pr.team_code" +
                " WHERE" +
                "  sr.status=1" +
                " AND p.del = '1'" +
                " AND t.del = '1'" +
                " AND sr.patient = '"+patient+"' limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(signOld);
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+""));
    }
    /**
     * 紧急预警信息
     */
    public PageEnvelop emeAndsecinfo(Integer page,Integer size){
        String emeSql = "SELECT DISTINCT " +
                " eao.patient AS patient, " +
                " eao.patient_name AS patientName, " +
                " eao.org_name AS orgName, " +
                " eao.serve_address AS serveAddress, " +
                " eao.doctor_name AS doctorName, " +
                " DATE_FORMAT(eao.create_time,'%Y-%m-%d')  AS createTime," +
                " eao.type AS type," +
                " '紧急呼叫' serve_desc," +
                " eao.`status` AS `status`," +
                " DATE_FORMAT(eao.complete_time,'%Y-%m-%d') as completeTime," +
                " DATE_FORMAT(wdr.response_time,'%Y-%m-%d')  AS responseTime" +
                " FROM" +
                " base_emergency_assistance_order eao LEFT JOIN base_emergency_warn_doctor_response wdr ON eao.id = wdr.order_id limit " + (page - 1)*size + "," + size;
        String secSql = "SELECT DISTINCT" +
                " mo.patient AS patient," +
                " mo.patient_name AS patientName," +
                " mo.doctor_name AS doctorName," +
                " mo.serve_desc AS serveDesc," +
                " mo.serve_address AS serveAddress," +
                " DATE_FORMAT(mo.create_time,'%Y-%m-%d')  AS createTime," +
                " DATE_FORMAT(mo.complete_time,'%Y-%m-%d')  AS completeTime," +
                " DATE_FORMAT(mo.service_response_time,'%Y-%m-%d')  AS responseTime," +
                " mo.order_source AS orderSource," +
                " mo.type AS type," +
                " mo.`status` AS `status`" +
                " FROM" +
                " base_security_monitoring_order mo limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> emeList = jdbcTemplate.queryForList(emeSql);
        List<Map<String, Object>> secList = jdbcTemplate.queryForList(secSql);
        emeList.addAll(secList);
        Map<String, String> jkzlUserMap = removeTestUser();
        Iterator<Map<String, Object>> iterator = emeList.iterator();
        while (iterator.hasNext()) {
            Map<String, Object> next = iterator.next();
            if (jkzlUserMap.containsValue(next.get("patient"))) {
                iterator.remove();
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",emeList,page,size,Long.parseLong(emeList.size()+""));
    }
    /**
     * 设备信息
     */
    public PageEnvelop deviceLists(Integer page,Integer size){
        String deviceSql = "SELECT DISTINCT" +
                " p.`name`," +
                " p.id," +
                " pd.device_sn AS deviceSn," +
                " pd.device_name AS deviceName," +
                " wd.device_type as deviceType," +
                " pd.category_code as categoryCode  " +
                " FROM" +
                " wlyy_patient_device pd," +
                " wlyy_devices wd," +
                " base_patient p" +
                " WHERE" +
                " p.id = pd.`user` AND" +
                " wd.device_code = pd.device_sn limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(deviceSql);
        Map<String, String> jkzlUserMap = removeTestUser();
        Iterator<Map<String, Object>> iterator = maps.iterator();
        while (iterator.hasNext()) {
            Map<String, Object> next = iterator.next();
            if (jkzlUserMap.containsValue(next.get("patient"))) {
                iterator.remove();
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+""));
    }
    //1血糖仪,2.血压计,3药盒,4智能手表,7 = 居家报警器,12 监控器 13 睡眠带 14气感报警器 15烟感报警器 16拐杖 17随身wifi
    public List<Map<String, Object>> deviceCollectInfo(String deviceSN,String code,String startDate,String endDate){
        String sql = "";
        switch (code){
            case "14":
                //烟感气感实时数据
                sql = "SELECT device_sn,device_type,value,unit,DATE_FORMAT(create_time,'%Y-%m-%d') as create_time,temperature_value,power_value FROM base_device_health_index WHERE device_sn = '"+deviceSN+"'";
                break;
            case "16": //拐杖
                sql = "SELECT lat,lon,DATE_FORMAT(create_time,'%Y-%m-%d') as create_time FROM base_yxdevice_index WHERE sn = '"+deviceSN+"'";
                break;
            case "13": //睡眠带
                sql = "SELECT * FROM base_sleep_device WHERE device_sn = '"+deviceSN+"'";
                break;
            case "4": //智能手表
                sql = "SELECT sleep_time,deep_sleep,light_sleep,awake_time,interval_time,total,del,DATE_FORMAT(create_time,'%Y-%m-%d') as create_time FROM base_sleep_x1device WHERE device_sn = '"+deviceSN+"' ";
                break;
        }
        if (StringUtils.isNotBlank(startDate)&&StringUtils.isNotBlank(endDate)){
            sql += " AND create_time >= '"+startDate+"' AND create_time <='"+endDate+"' ";
        }
        sql += " ORDER BY create_time";
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 生活照料
     */
    public PageEnvelop lifeCareList(Integer page,Integer size){
        if (null==page||0==page){
            page = 1;
        }
        if (null==size||0==size) {
            size = 10;
        }
        String sql ="SELECT DISTINCT" +
                " co.proxy_patient_name," +
                " co.patient_name AS patientName," +
                " co.serve_address AS serveAddress," +
                " DATE_FORMAT(co.create_time,'%Y-%m-%d') AS createTime," +
                " DATE_FORMAT(co.complete_time,'%Y-%m-%d') AS completeTime," +
                " co.doctor_name AS doctorName," +
                " fd.`name` AS lifeCareName," +
                " co.`status` AS `status`," +
                " co.conclusion_remark AS remark" +
                " FROM" +
                " base_life_care_order co" +
                " LEFT JOIN base_life_care_fee_detail fd ON co.id = fd.order_id ORDER BY co.create_time DESC LIMIT "+(page-1)*size+","+size+"";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        Map<String, String> jkzlUserMap = removeTestUser();
        Iterator<Map<String, Object>> iterator = maps.iterator();
        while (iterator.hasNext()) {
            Map<String, Object> next = iterator.next();
            if (jkzlUserMap.containsValue(next.get("patientName"))) {
                iterator.remove();
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+""));
    }
    /**
     * 幼儿信息
     */
    public PageEnvelop infantInfo(Integer page,Integer size){
        String infantSql = "SELECT DISTINCT" +
                " p.id AS id," +
                " o.address AS address," +
                " p. NAME AS `name`," +
                " t. STATUS AS `status`," +
                " o. NAME AS `orgName`" +
                " FROM" +
                " base_patient p" +
                " LEFT JOIN base_doctor_patient_tmp t ON t.patient = p.id" +
                " LEFT JOIN base_org o ON t.org_code = o. CODE" +
                " WHERE" +
                " p.archive_type = 2" +
                " AND t.del = 1" +
                " AND p.del = 1" +
                " and o.type = 4 ORDER BY p.create_time DESC LIMIT "+(page-1)*size+","+page+"";
        List<Map<String, Object>> infantList = jdbcTemplate.queryForList(infantSql);
        Map<String, String> jkzlUserRem = removeTestUser();
        Iterator<Map<String, Object>> iterator = infantList.iterator();
        while (iterator.hasNext()) {
            Map<String, Object> next = iterator.next();
            if (jkzlUserRem.containsValue(next.get("id"))) {
                iterator.remove();
            }else {
                next.put("age",IdCardUtil.getAgeForIdcard(next.get("idcard").toString()));
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",infantList,page,size,Long.parseLong(infantList.size()+""));
    }
    /**
     * 上门辅导
     */
    public PageEnvelop doorServiceOrder(Integer page,Integer size){
        String serviceSql ="SELECT DISTINCT " +
                " so.serve_address AS serveAddress, " +
                " so.proxy_patient_name AS ppName, " +
                " so.patient_name AS pName, " +
                " so.patient AS patient," +
                " DATE_FORMAT(so.create_time,'%Y-%m-%d')  AS createTime, " +
                " DATE_FORMAT(so.service_response_time,'%Y-%m-%d')  AS serviceTime, " +
                " so.doctor_name AS  doctorName, " +
                " dc.`name` AS serveName, " +
                " DATE_FORMAT(so.complete_time,'%Y-%m-%d')  AS completeTime, " +
                " so.`status` AS `status`, " +
                " fd.conclusion AS conclusion " +
                " FROM " +
                " base_door_coach_order so " +
                " LEFT JOIN base_door_coach_fee_detail dc ON so.id = dc.order_id " +
                " LEFT JOIN base_door_coach_conclusion fd ON so.id = fd.order_id ";
        List<Map<String, Object>> lists = jdbcTemplate.queryForList(serviceSql);
        Map<String, String> jkzlUserRm = removeTestUser();
        Iterator<Map<String, Object>> iterator = lists.iterator();
        while (iterator.hasNext()) {
            Map<String, Object> next = iterator.next();
            if (jkzlUserRm.containsValue(next.get("patient"))) {
                iterator.remove();
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",lists,page,size,Long.parseLong(lists.size()+""));
    }
    /**
     * 排除测试数据
     */
    public Map<String,String>  removeTestOrg(){
        String filterOrg = "";//排除的测试机构
        String sqlOgr = "SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' and dict_code is not null ";
        List<String> Orglist =  jdbcTemplate.queryForList(sqlOgr,String.class);
        Map<String,String> jkzlOrgMap = new HashMap<>();
        if(Orglist.size()>0){
            jkzlOrgMap = Orglist.stream().collect(Collectors.toMap(String::toString,String::toString));
            filterOrg = " '" +String.join("','",Orglist)+ "' ";
        }
        return jkzlOrgMap;
    }
    //排除的测试用户
    public Map<String, String> removeTestUser() {
        String filterUser = " ";
        String sqltmp = "SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' " +
                "  or dict_name = 'jkzl_user' or dict_name = 'jkzl_helper'  or dict_name = 'jkzl_teacher' ) and dict_code is not null";
        List<String> listtmp = jdbcTemplate.queryForList(sqltmp, String.class);
        Map<String, String> jkzlUserMap = new HashMap<>();
        if (listtmp.size() > 0) {
            jkzlUserMap = listtmp.stream().collect(Collectors.toMap(String::toString, String::toString));
            filterUser = " '" + String.join("','", listtmp) + "' ";
        }
        return jkzlUserMap;
    }
    //测试 签约老人id
    public Map<String,String> removeTestOld(){
        String signOlderSql="SELECT " +
                " DISTINCT p.id " +
                " FROM  " +
                " base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 and  " +
                " p.id not in ( SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' or dict_name = 'jkzl_user' or dict_name = 'jkzl_helper'  or dict_name = 'jkzl_teacher' ) and dict_code is not null ) " +
                " WHERE p.del = 1 and p.archive_type =1  " ;
        List<String> signOlderList = jdbcTemplate.queryForList(signOlderSql,String.class);
        Map<String,String> signOlderMap = signOlderList.stream().collect(Collectors.toMap(String::toString,String::toString));
        return signOlderMap;
    }
}