Преглед изворни кода

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

叶仕杰 пре 3 година
родитељ
комит
0f958e7dca

+ 49 - 16
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -21,6 +21,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.sms.dao.HospitalSysDictDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
@ -73,6 +74,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    private String wxId;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private HospitalSysDictDao hospitalSysDictDao;
    /**
     * 签约记录
@ -441,21 +444,48 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        String online= imUtil.getOnlineListByType(null);
        JSONObject json = JSON.parseObject(online).getJSONObject("data");
        String limit = " limit "+(page-1)*size+","+size;
        String filter ="";
        if("1".equals(type)||StringUtil.isBlank(type)){
            List<Map<String,Object>> list = findChild(name,residentialArea,limit,json.getJSONObject("child"));
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and id not in ('"+orgCodes+"')";
            }
            List<Map<String,Object>> list = findChild(name,residentialArea,limit,filter);
            re.put("child",list);
            re.put("childTotal",findChildTotal(name,residentialArea));
            re.put("childTotal",findChildTotal(name,residentialArea,filter));
        }
        if("2".equals(type)||StringUtil.isBlank(type)){
            List<Map<String,Object>> list = findOld(name,residentialArea,limit,json);
            filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and a.id not in ('"+orgCodes+"')";
            }
            List<Map<String,Object>> list = findOld(name,residentialArea,limit,json,filter);
            re.put("old",list);
            re.put("oldTotal",findOldTotal(name,residentialArea));
            re.put("oldTotal",findOldTotal(name,residentialArea,filter));
        }
        if("3".equals(type)||StringUtil.isBlank(type)){
            List<Map<String,Object>> list = findHelper(name,limit,json.getJSONObject("helper"));
            filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_helper' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and id not in ('"+orgCodes+"')";
            }
            List<Map<String,Object>> list = findHelper(name,limit,filter);
            re.put("helper",list);
            re.put("helperTotal",findHelperTotal(name));
            re.put("helperTotal",findHelperTotal(name,filter));
        }
        return re;
    }
@ -465,10 +495,9 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @param name
     * @param residentialArea
     * @param limit
     * @param json
     * @return
     */
    public List<Map<String,Object>> findChild(String name,String residentialArea,String limit,JSONObject json){
    public List<Map<String,Object>> findChild(String name,String residentialArea,String limit,String filter1){
        String sql = "SELECT id,name,photo,idcard,CAST(IFNULL(birthday,'') AS char ) birthday,residential_area residentialArea" +
                ",sex,IFNULL(on_line,0) online  from base_patient WHERE archive_type = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
@ -477,6 +506,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        sql += filter1;
        sql += " order by online desc";
        sql+=limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
@ -485,7 +516,6 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            String paientId = map.get("id").toString();
            String filter = " and patient = '"+paientId+"'";
            Integer count = jdbcTemplate.queryForObject(sqlCount+filter,Integer.class);
//            map.put("online",json.containsKey(paientId));
            map.put("doorCoach",count);
            String idcardNo = map.get("idcard") + "";
            Date birthday = DateUtil.strToDate(map.get("birthday").toString());
@ -495,7 +525,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return list;
    }
    public Integer findChildTotal(String name,String residentialArea){
    public Integer findChildTotal(String name,String residentialArea,String filter){
        String sql = "SELECT count(id) from base_patient WHERE archive_type = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
@ -503,6 +533,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        sql += filter;
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
@ -514,7 +545,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @param json
     * @return
     */
    public List<Map<String,Object>> findOld(String name,String residentialArea,String limit,JSONObject json){
    public List<Map<String,Object>> findOld(String name,String residentialArea,String limit,JSONObject json,String filter1){
        String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
                ", GROUP_CONCAT(DISTINCT d.category_code) deviceFlag,IFNULL(on_line,0) online,IFNULL(sign_status,0) signStatus from base_patient a " +
                " LEFT JOIN wlyy_patient_device d on d.`user`=a.id  WHERE a.archive_type = 1 and a.del = '1' ";
@ -524,6 +555,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        sql += filter1;
        sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex,online,signStatus ";
        sql += " ORDER BY online,signStatus desc";
        sql += limit;
@ -550,7 +582,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return list;
    }
    public Integer findOldTotal(String name,String residentialArea){
    public Integer findOldTotal(String name,String residentialArea,String filter){
        String sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
@ -558,6 +590,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        sql += filter;
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
@ -565,14 +598,14 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * 查找助老员
     * @param name
     * @param limit
     * @param json
     * @return
     */
    public List<Map<String,Object>> findHelper(String name,String limit,JSONObject json){
    public List<Map<String,Object>> findHelper(String name,String limit,String fileter){
        String sql = "SELECT id,name,photo,sex,IFNULL(on_line,0) online from base_doctor WHERE doctor_level = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        sql += fileter;
        sql += " ORDER BY online desc";
        sql+=limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
@ -594,7 +627,6 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
            Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
//            map.put("online",json.containsKey(doctorId));
            map.put("lifeCare",lifeCare);
            map.put("emergency",emergency);
            map.put("security",security);
@ -602,11 +634,12 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return list;
    }
    public Integer findHelperTotal(String name){
    public Integer findHelperTotal(String name,String filter){
        String sql = "SELECT count(id) from base_doctor WHERE doctor_level = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        sql += filter;
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }