Browse Source

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 4 years ago
parent
commit
d057efa326

+ 52 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/common/OrgUserService.java

@ -0,0 +1,52 @@
package com.yihu.iot.service.common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by yeshijie on 2020/7/29.
 */
@Service
public class OrgUserService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取当前登录者的机构权限
     * @param userId
     * @return
     */
    public List<String> getUserOrgNameById(String userId){
        String sql = "SELECT h.name from `iot-base`.base_org_user o,iot_hospital h WHERE o.org_code = h.saas_id and o.user_id = '"+userId+"' ";
        return jdbcTemplate.queryForList(sql,String.class);
    }
    /**
     * 获取当前登录者的机构权限
     * @param userId
     * @return
     */
    public List<String> getUserOrgById(String userId){
        String sql = "SELECT org_code from `iot-base`.base_org_user WHERE user_id = '"+userId+"' ";
        return jdbcTemplate.queryForList(sql,String.class);
    }
    /**
     *
     * @param list
     * @return
     */
    public String getUserOrg(List<String> list){
        String res = "'";
        for (String s:list){
            res +=s+"'";
        }
        if(res.length()==1){
            res +="'";
        }
        return res;
    }
}

+ 11 - 8
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -9,6 +9,7 @@ import com.yihu.iot.dao.device.IotDeviceSimDao;
import com.yihu.iot.dao.device.IotPatientDeviceDao;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.util.excel.HibenateUtils;
@ -31,7 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.provider.HibernateUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -69,6 +69,9 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
    private IotCompanyDao iotCompanyDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private OrgUserService orgUserService;
    /**
     * 新增
@ -296,18 +299,12 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
                String snCoed = locationDataVO.getDeviceSn();
                List<Map<String,Object>> nameList = new ArrayList<>();
                List<Map<String,Object>> deviceList = new ArrayList<>();
                System.out.println("idCard:="+idCard);
                System.out.println("snCode:="+snCoed);
                if (StringUtils.isNotEmpty(idCard)){
                    sql = sql +" and t.idcard = '"+idCard+"'";
                    System.out.println("查询患者name和code开始");
                    nameList = jdbcTempalte.queryForList(sql);
                    System.out.println("查询患者name和code结束:"+nameList);
                }if (StringUtils.isNotEmpty(snCoed)){
                    sqlEqt = sqlEqt +" and t.device_code = '"+snCoed+"'";
                    System.out.println("查询设备名称开始");
                    deviceList = jdbcTempalte.queryForList(sqlEqt);
                    System.out.println("查询设备名称结束:"+deviceList);
                }
                if(nameList.size()>0){
                    String code = null==nameList.get(0).get("code")?"":nameList.get(0).get("code").toString();
@ -530,7 +527,8 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        }
    }
    public MixEnvelop<IotPatientDeviceVO,IotPatientDeviceVO> getPatientDeviceList(String deviceSn, String deviceName, String categoryCode, String patientName, String hospitalName, Integer isDel, Integer page, Integer pageSize) {
    public MixEnvelop<IotPatientDeviceVO,IotPatientDeviceVO> getPatientDeviceList(String deviceSn, String deviceName,
        String categoryCode, String patientName, String hospitalName, Integer isDel, Integer page, Integer pageSize) {
        String sql = "SELECT DISTINCT d.* FROM `iot_patient_device` d  where 1=1  ";
        if(isDel != null &&isDel == 1){
            sql += "and d.del != 1 ";
@ -550,6 +548,11 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        if(StringUtils.isNotBlank(hospitalName)){
            sql += "and d.hospital_name like '%" + hospitalName + "%' ";
        }
        //数据权限过滤
        List<String> list = orgUserService.getUserOrgById(userAgent.getUID());
        if(!list.contains(userAgent.commonHospital)){
            sql += " and d.hospital in ("+orgUserService.getUserOrg(list)+") ";
        }
        sql += "order by d.update_time desc ";
        //判断是否需要分页
        if (page != null && pageSize != null) {

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/useragent/UserAgent.java

@ -16,6 +16,9 @@ import javax.servlet.http.HttpServletRequest;
@Component
public class UserAgent {
    public String commonHospital = "iot-hospital";
    public String commonHospitalName = "物联网通用机构";
    /**
     * 获取当前登录人ID
     * @return

+ 3 - 3
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -610,13 +610,13 @@ public class SpecialistService{
                " r.team_code,r.sign_date , " +
                " t.`name` AS name," +
                " d.photo," +
                " d.code AS doctor," +
                " d.name AS doctorName,d.hospital,d.hospital_name " +
                " md.code AS doctor," +
                " md.name AS doctorName,d.hospital,d.hospital_name " +
                " FROM " +
                " wlyy_specialist_patient_relation r  " +
                " JOIN "+basedb+".wlyy_admin_team t ON t.id = r.team_code " +
                " JOIN "+basedb+".wlyy_doctor d ON t.leader_code = d.`code` " +
//                " JOIN "+basedb+".wlyy_doctor md ON md.code = r.doctor " +
                " JOIN "+basedb+".wlyy_doctor md ON md.code = r.doctor " +
                " WHERE " +
                " r.patient = '"+patient+"' " +
                " AND r.`status` >=0  " +