Просмотр исходного кода

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

wangzhinan 4 лет назад
Родитель
Сommit
3140dc6c41

+ 52 - 10
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -45,6 +45,7 @@ import com.yihu.jw.hospital.mapping.service.PatientMappingService;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.prescription.service.useragent.BaseUserAgent;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
@ -232,6 +233,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private WxPushLogDao wxPushLogDao;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Value("${demo.flag}")
@ -445,7 +448,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //复诊信息
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outpatientId);
        rs.put("outpatient",convertToModel(outpatientDO,WlyyOutpatientVO.class));
        rs.put("doctorCancelType",outpatientDO.getDoctorCancelType());
        rs.put("doctorCancelValue",outpatientDO.getDoctorCancelValue());
        rs.put("doctorCancelRemark",outpatientDO.getDoctorCancelRemark());
        rs.put("payStatus",outpatientDO.getPayStatus());
        //居民详情
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
        rs.put("patientName",basePatientDO.getName());
@ -3285,12 +3291,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","9");
                   msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个图文复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
//                   sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"9");
                   sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"9");
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","16");
                    msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个视频复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
//                    sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"16");
                    sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"16");
                }
                data.put("msg",msg);
                messageDO.setData(data.toString());
@ -3336,14 +3342,28 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param type
     */
    public void sendWxTemplateMsg(String wxId,WlyyOutpatientDO outpatientDO,String type){
        List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getPatient());
        if(ps.isEmpty()){
            logger.info("该用户"+outpatientDO.getPatientName()+"没有openid,无法推送模版消息,用户ID:"+outpatientDO.getPatient()+"wechatId:"+wxId);
            return;
        BaseDoctorDO doctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
        String typeMsg="";
        String first="";
        if ("9".equals(type)){
            typeMsg="通知内容:您的图文复诊订单已被医生取消,您可重新发起。由于订单取消将不做扣费处理";
            first=outpatientDO.getPatientName() + ",您好!您的图文复诊已取消";
        }
        if ("16".equals(type)){
            typeMsg="通知内容:您的视频复诊订单已被医生取消,您可重新发起。由于订单取消将不做扣费处理";
            first=outpatientDO.getPatientName() + ",您好!您的视频复诊已取消";
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getPatient());
            if(ps.isEmpty()){
                logger.info("该用户"+outpatientDO.getPatientName()+"没有openid,无法推送模版消息,用户ID:"+outpatientDO.getPatient()+"wechatId:"+wxId);
                return;
            }
            ps.stream().forEach(one->{
                BaseDoctorDO doctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_doctor_notice","ysqxjz",1);
                WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                BeanUtils.copyProperties(config,newConfig);
@ -3373,6 +3393,28 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                wxPushLogDao.save(wxPushLogDO);
            });
        }else if("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
            String MsgUrl="https://www.xmheart.com/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientDO.getPatient();
            String responseMsg = xzzxEntranceService.sendXCXMes(wxId,
                    doctorDO.getId(),
                    doctorDO.getIdcard(),
                    first,
                    "通知时间:" + DateUtil.getStringDate(),
                    typeMsg,
                    MsgUrl,
                    "wx53f6bb4ac081d840");
            logger.info("XZZX_Msg="+responseMsg);
        }else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            String MsgUrl="https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientDO.getPatient();
            String responseMsg = entranceService.ehospitalNotice(doctorDO.getName(),
                    doctorDO.getIdcard(),
                    doctorDO.getMobile(),
                    first,
                    MsgUrl,
                    "通知时间:" + DateUtil.getStringDate(),
                    typeMsg
            );
            logger.info("ZSYY_Msg="+responseMsg);
        }
    }
@ -6842,11 +6884,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public MixEnvelop findPatientOpenId(String patientCode) {
        List<BasePatientWechatDo> basePatientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId, patientCode);
        if (basePatientWechatDo.isEmpty()){
            return MixEnvelop.getError("居民不存在");
            return MixEnvelop.getSuccess("居民openID不存在");
        }
        String openid = basePatientWechatDo.get(0).getOpenid();
        if (StringUtils.isEmpty(openid)){
            return MixEnvelop.getError("居民openID不存在");
            return MixEnvelop.getSuccess("居民openID不存在");
        }
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,openid);
    }

+ 3 - 3
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -238,7 +238,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        }else {
            patientId = ykyyService.registerYkt(basePatientDO.getId());
        }
        String orderAmout = businessOrderDO.getPayPrice().toString();
        String orderAmout = businessOrderDO.getPayPrice()/100+"";
        String description = businessOrderDO.getDescription();
        String state = businessOrderDO.getStatus().toString();
        String orderType =businessOrderDO.getOrderType().toString();
@ -298,7 +298,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        BasePatientDO basePatientDO = patientDao.findById(patient);
        String orderNo = businessOrderDO.getOrderNo();
        String patientId = basePatientDO.getYktId();
        String orderAmout = businessOrderDO.getPayPrice().toString();
        String orderAmout = businessOrderDO.getPayPrice()/100+"";
        String description = businessOrderDO.getDescription();
        String state = businessOrderDO.getStatus().toString();
        String orderType =businessOrderDO.getOrderType().toString();
@ -687,7 +687,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        String patient = businessOrderDO.getPatient();
        BasePatientDO basePatientDO = patientDao.findById(patient);
        String patientId = basePatientDO.getYktId();
        String orderAmout = businessOrderDO.getPayPrice().toString();
        String orderAmout = businessOrderDO.getPayPrice()/100+"";
        String description = businessOrderDO.getDescription();
        String state = businessOrderDO.getStatus().toString();
        String orderType =businessOrderDO.getOrderType().toString();

+ 22 - 9
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -84,15 +84,28 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    public List<Map<String,Object>> queryPatientBaseInfo(String nameOrIdcard,int page,int size,String sorts)throws Exception{
        List<Map<String, Object>> result = new ArrayList<>();
        String param = null == nameOrIdcard ? "": nameOrIdcard;
        String sql = "select id                                                as id, " +
                "       idcard                                                 as idcard, " +
                "       name                                                   as name, " +
                "       case sex when 1 then '男' when 2 then '女' else '未知' end as sex, " +
                "       phone                                                  as phone, " +
                "       committee_name                                         as committeeName, " +
                "       concat(province_name, city_name, town_name, street_name)   as address " +
                " from base_patient " +
                " where name like '%" + param + "%' or idcard like '%" + param + "%' order by create_time desc";
        String sql = "SELECT\n" +
                "\tID AS \"ID\",\n" +
                "\tidcard AS \"idcard\",\n" +
                "\tNAME AS \"NAME\",\n" +
                "\tCASE\n" +
                "WHEN sex = 1 THEN\n" +
                "\t'男'\n" +
                "WHEN sex = 2 THEN\n" +
                "\t'女'\n" +
                "ELSE\n" +
                "\t'未知'\n" +
                "END AS \"sex\",\n" +
                " phone AS \"phone\",\n" +
                " committee_name AS \"committeeName\",\n" +
                " province_name || city_name || town_name || street_name AS \"address\"\n" +
                "FROM\n" +
                "\tbase_patient\n" +
                "WHERE\n" +
                "\tNAME LIKE '%%'\n" +
                "OR idcard LIKE '%%'\n" +
                "ORDER BY\n" +
                "\tcreate_time DESC";
        String countSql = "select count(id) from base_patient where name like '%" + param + "%' or idcard like '%" + param + "%'";
        Long count  = jdbcTemplate.queryForObject(countSql,Long.class);
        if(count <= 0){

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorEndpoint.java

@ -20,6 +20,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -57,6 +58,9 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseDoctorExcelDOReader doctorExcelDOReader;
    @Value("${wechat.id}")
    private String wechatId;
    @PostMapping(value = BaseRequestMapping.BaseDoctor.CREATE)
    @ApiOperation(value = "新增医生")
    public Envelop create(
@ -187,7 +191,7 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = baseDoctorService.queryDoctorListFullInfo(nameOrIdcard,orgCode, doctorStatus,page,size);
        JSONObject result = baseDoctorService.queryDoctorListFullInfo(nameOrIdcard,orgCode, doctorStatus,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/org/BaseOrgEndpoint.java

@ -14,6 +14,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@ -37,6 +38,9 @@ public class BaseOrgEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseOrgService baseOrgService;
    @Value("${wechat.id}")
    private String wechatId;
    @PostMapping(value = BaseRequestMapping.BaseOrg.CREATE )
    @ApiOperation(value = "创建")
    public Envelop create(
@ -140,7 +144,7 @@ public class BaseOrgEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = baseOrgService.queryOrgBaseInfoList(codeOrName, orgStatus,page,size);
        JSONObject result = baseOrgService.queryOrgBaseInfoList(codeOrName, orgStatus,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java

@ -186,6 +186,9 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<SaasDO> saasDOS = saasService.search(fields, filters, sorts, page, size);
        if (saasDOS.isEmpty()){
            return null;
        }
        saasDOS.forEach(saas->{
            SaasTypeDictDO saasTypeDictDO = saasTypeDictService.findById(saas.getType());
            saas.setTypeName(saasTypeDictDO.getName());

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/team/BaseTeamEndpoint.java

@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@ -39,6 +40,9 @@ public class BaseTeamEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseTeamService baseTeamService;
    @Value("${wechat.id}")
    private String wechatId;
    @PostMapping(value = BaseRequestMapping.BaseTeam.CREATE)
    @ApiOperation(value = "创建团队")
    public Envelop create(
@ -153,7 +157,7 @@ public class BaseTeamEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = baseTeamService.getTeamInfoList(teamName, orgCode, status, page, size,getUserAgent());
        JSONObject result = baseTeamService.getTeamInfoList(teamName, orgCode, status, page, size,getUserAgent(),wechatId);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/user/UserEndpoint.java

@ -16,6 +16,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@ -34,6 +35,9 @@ public class UserEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private UserService userService;
    @Value("${wechat.id}")
    private String wechatId;
    @PostMapping(value = BaseRequestMapping.User.CREATE)
    @ApiOperation(value = "创建")
    public Envelop create (
@ -192,7 +196,7 @@ public class UserEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = userService.userInfoList(realName,saasid, roleId,page,size);
        JSONObject result = userService.userInfoList(realName,saasid, roleId,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }

+ 167 - 38
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -23,9 +23,12 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -34,6 +37,7 @@ import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.*;
import java.util.logging.Logger;
/**
 * 
@ -123,48 +127,144 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
     * @param docStatus
     * @return
     */
    public JSONObject queryDoctorListFullInfo(String nameOrIdcard, String orgCode, String docStatus, int page, int size) throws Exception {
    public JSONObject queryDoctorListFullInfo(String nameOrIdcard, String orgCode, String docStatus, int page, int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        String orgCodeVale = null == orgCode ? "" : orgCode;
        String del = null == docStatus ? "" : docStatus;
        String nameOrIdcardValue = null == nameOrIdcard ? "" : "%" + nameOrIdcard + "%";
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;
        String sql = "select" +
                "  tb.id as id," +
                "  tb.name as name," +
                "  tb.idcard as idcard,  " +
                "  tb.sex as sex,  " +
                "  tb.mobile as mobile,  " +
                "  GROUP_CONCAT(tb.org SEPARATOR ',') as orgInfo,  " +
                "  tb.job_title_name as jobTitleName,  " +
                "  tb.status as status " +
                "from  " +
                "  (  " +
                "    select  " +
                "     doc.id,  " +
                "     doc.name,  " +
                "     doc.idcard,  " +
                "     case doc.sex when 1 then '男' when 2 then '女' else '未知' end as sex,  " +
                "     doc.mobile,  " +
                "     concat(hos.org_name,'/',dept.name,'/',hos.doctor_duty_name) as org,  " +
                "     doc.job_title_name,  " +
                "     case doc.del when 0 then '已失效' when 1 then '生效中' end as status,  " +
                "      doc.create_time  " +
                "   from  " +
                "     base_doctor doc,  " +
                "     base_doctor_hospital hos,  " +
                "     dict_hospital_dept dept  " +
                "  where  " +
                "    doc.id = hos.doctor_code  " +
                "    and  " +
                "    hos.org_code = dept.org_code " +
                "    and " +
                "    hos.dept_code = dept.code  " +
                "    and  " +
                "    ((doc.idcard like '{idcard}' or ''= '{idcard}' ) or (doc.name like '{name}'  or ''= '{name}' )  and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " +
                "  ) tb  " +
                "GROUP BY tb.id order by tb.create_time desc limit {start},{end} ";
//        String sql = "select" +
//                "  tb.id as id," +
//                "  tb.name as name," +
//                "  tb.idcard as idcard,  " +
//                "  tb.sex as sex,  " +
//                "  tb.mobile as mobile,  " +
//                "  GROUP_CONCAT(tb.org SEPARATOR ',') as orgInfo,  " +
//                "  tb.job_title_name as jobTitleName,  " +
//                "  tb.status as status " +
//                "from  " +
//                "  (  " +
//                "    select  " +
//                "     doc.id,  " +
//                "     doc.name,  " +
//                "     doc.idcard,  " +
//                "     case doc.sex when 1 then '男' when 2 then '女' else '未知' end as sex,  " +
//                "     doc.mobile,  " +
//                "     concat(hos.org_name,'/',dept.name,'/',hos.doctor_duty_name) as org,  " +
//                "     doc.job_title_name,  " +
//                "     case doc.del when 0 then '已失效' when 1 then '生效中' end as status,  " +
//                "      doc.create_time  " +
//                "   from  " +
//                "     base_doctor doc,  " +
//                "     base_doctor_hospital hos,  " +
//                "     dict_hospital_dept dept  " +
//                "  where  " +
//                "    doc.id = hos.doctor_code  " +
//                "    and  " +
//                "    hos.org_code = dept.org_code " +
//                "    and " +
//                "    hos.dept_code = dept.code  " +
//                "    and  " +
//                "    ((doc.idcard like '{idcard}' or ''= '{idcard}' ) or (doc.name like '{name}'  or ''= '{name}' )  and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}'))  " +
//                "  ) tb  " +
//                "GROUP BY tb.id order by tb.create_time desc limit {start},{end} ";
//        String finalSql = sql
//                .replace("{idcard}",nameOrIdcardValue)
//                .replace("{name}",nameOrIdcardValue)
//                .replace("{orgCode}",orgCodeVale)
//                .replace("{docStatus}",del)
//                .replace("{start}",String.valueOf(start))
//                .replace("{end}",String.valueOf(end));
        String sql="SELECT\n" +
                "\ttb. ID AS \"ID\",\n" +
                "\ttb.idcard AS \"idcard\",\n" +
                "\ttb. NAME AS \"NAME\",\n" +
                "\ttb.sex AS \"sex\",\n" +
                "\ttb.mobile AS \"mobile\",";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            sql+="  wm_concat (tb.org || ',') AS \"orgInfo\",";
        }else {
            sql+=" GROUP_CONCAT(tb.org SEPARATOR ',') AS orgInfo,";
        }
        sql+="tb.job_title_name AS \"jobTitleName\",\n" +
                "\ttb.status AS \"status\",\n" +
                "  tb.create_time AS \"createtime\"\n" +
                "FROM\n" +
                "\t(\n" +
                "\t\tSELECT\n" +
                "\t\t\tdoc. ID,\n" +
                "\t\t\tdoc. NAME,\n" +
                "\t\t\tdoc.idcard,\n" +
                "\t\t\tCASE\n" +
                "\t\tWHEN doc.sex = 1 THEN\n" +
                "\t\t\t'男'\n" +
                "\t\tWHEN doc.sex = 2 THEN\n" +
                "\t\t\t'女'\n" +
                "\t\tELSE\n" +
                "\t\t\t'未知'\n" +
                "\t\tEND AS sex,\n" +
                "\t\tdoc.mobile,\n" +
                "\t\thos.org_name || '/' || dept. NAME || '/' || hos.doctor_duty_name AS org,\n" +
                "\t\tdoc.job_title_name,\n" +
                "\t\tCASE\n" +
                "\tWHEN doc.del = 0 THEN\n" +
                "\t\t'已失效'\n" +
                "\tWHEN doc.del = 1 THEN\n" +
                "\t\t'生效中'\n" +
                "\tEND AS status,\n" +
                "\tdoc.create_time\n" +
                "FROM\n" +
                "\tbase_doctor doc,\n" +
                "\tbase_doctor_hospital hos,\n" +
                "\tdict_hospital_dept dept\n" +
                "WHERE\n" +
                "\tdoc. ID = hos.doctor_code\n" +
                "AND hos.org_code = dept.org_code\n" +
                "AND hos.dept_code = dept.code\n" +
                "AND (\n" +
                "\t(\n" +
                "\t\tdoc.idcard LIKE '%%'\n" +
                "\t\tOR '' = '%%'\n" +
                "\t)\n" +
                "\tOR (doc. NAME LIKE '%%' OR '' = '%%')\n" +
                "\tAND (hos.org_code = '' OR '' = '')\n" +
                "\tAND (doc.del = '' OR '' = '')\n" +
                ")\n" +
                "\t) tb" +
                "  GROUP BY\n" +
                "\ttb. ID,\n" +
                "\ttb.idcard,\n" +
                "\ttb. NAME,\n" +
                "\ttb.sex,\n" +
                "\ttb.mobile,\n" +
                "\ttb.job_title_name,\n" +
                "\ttb.status,\n" +
                "  tb.create_time\n" +
                "ORDER BY\n" +
                "\ttb.create_time DESC";
//        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
//            sql+=" GROUP BY\n" +
//                    "\ttb. ID,\n" +
//                    "\ttb.idcard,\n" +
//                    "\ttb. NAME,\n" +
//                    "\ttb.sex,\n" +
//                    "\ttb.mobile,\n" +
//                    "\ttb.job_title_name,\n" +
//                    "\ttb.status,\n" +
//                    "  tb.create_time\n" +
//                    "ORDER BY\n" +
//                    "\ttb.create_time DESC";
//        }else {
//            sql+=" GROUP BY\n" +
//                    "\ttb. ID\n" +
//                    "ORDER BY\n" +
//                    "\ttb.create_time DESC";
//        }
        String finalSql = sql
                .replace("{idcard}",nameOrIdcardValue)
                .replace("{name}",nameOrIdcardValue)
@ -173,8 +273,36 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                .replace("{start}",String.valueOf(start))
                .replace("{end}",String.valueOf(end));
        List<Map<String,Object>> list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=finalSql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            Logger.getAnonymousLogger().info("oracleSql="+oracleSql);
            list = jdbcTemplate.queryForList(oracleSql);
        }else {
            finalSql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            Logger.getAnonymousLogger().info("finalCountSql="+finalSql);
            list = jdbcTemplate.queryForList(finalSql);
        }
        String countSql = " select " +
                "     count(DISTINCT (doc.id)) as count " +
                "     COUNT(DISTINCT (doc.id)) as count " +
                "   from " +
                "     base_doctor doc, " +
                "     base_doctor_hospital hos, " +
@ -192,7 +320,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                .replace("{name}",nameOrIdcardValue)
                .replace("{orgCode}",orgCodeVale)
                .replace("{docStatus}",del);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(finalSql);
//        List<Map<String,Object>> list = jdbcTemplate.queryForList(finalSql);
        Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
        int count = jdbcTemplate.queryForObject(finalCountSql,Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));

+ 90 - 13
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java

@ -14,6 +14,8 @@ import com.yihu.jw.entity.base.org.BaseOrgSaasDO;
import com.yihu.jw.entity.base.org.BaseOrgUserDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.logging.Logger;
/**
 * 
@ -76,26 +79,100 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
     * @param orgStatus
     * @return
     */
    public JSONObject queryOrgBaseInfoList(String codeOrName,String orgStatus,int page,int size) throws Exception {
    public JSONObject queryOrgBaseInfoList(String codeOrName,String orgStatus,int page,int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;
        String codeOrNameValue = null == codeOrName ? "" : codeOrName;
        String sql = "select id as \"id\",code as \"code\",name as \"name\",case del when 1 then '有效' else '失效' end as status as \"del\",concat(province_name,city_name,town_name,address) as \"address\" " +
                " from base_org " +
                " where " +
                " ((code like '{code}' or ''='{code}')  and (del = '{orgStatus}' or ''='{orgStatus}'))" +
                " or " +
                " ((name like '{name}' or ''='{name}') and (del = '{orgStatus}' or ''='{orgStatus}'))" +
                " and" +
                " (del = '{orgStatus}' or ''='{orgStatus}')" +
                "  order by create_time desc ";
        String finalSql = sql
//        String sql = "select id as \"id\",code as \"code\",name as \"name\",case del when 1 then '有效' else '失效' end as status as \"del\",concat(province_name,city_name,town_name,address) as \"address\" " +
//                " from base_org " +
//                " where " +
//                " ((code like '{code}' or ''='{code}')  and (del = '{orgStatus}' or ''='{orgStatus}'))" +
//                " or " +
//                " ((name like '{name}' or ''='{name}') and (del = '{orgStatus}' or ''='{orgStatus}'))" +
//                " and" +
//                " (del = '{orgStatus}' or ''='{orgStatus}')" +
//                "  order by create_time desc ";
//        String finalSql = sql
//
//                .replace("{code}", "%" + codeOrNameValue + "%")
//                .replace("{name}", "%" + codeOrNameValue + "%")
//                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus);
//
//        String countSql = "SELECT count(id)" +
//                " FROM base_org " +
//                " WHERE " +
//                " ((code like '{code}' or ''='{code}')  and (del = '{orgStatus}' or ''='{orgStatus}'))" +
//                " OR " +
//                " ((name like '{name}' or ''='{name}') and (del = '{orgStatus}' or ''='{orgStatus}'))" +
//                " AND" +
//                " (del = '{orgStatus}' OR ''='{orgStatus}')";
//        String finalCountSql = countSql
//                .replace("{code}", "%" + codeOrNameValue + "%")
//                .replace("{name}", "%" + codeOrNameValue + "%")
//                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus);
//        Logger.getAnonymousLogger().info("finalSql="+finalSql);
//        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
//        Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
                String sql = "SELECT\n" +
                        "\tID AS \"id\",\n" +
                        "\tcode AS \"code\",\n" +
                        "\tNAME AS \"name\",\n" +
                        "\tCASE \n" +
                        "WHEN del=1 THEN\n" +
                        "\t'有效'\n" +
                        "ELSE\n" +
                        "\t'失效'\n" +
                        "END AS \"del\",\n" +
                        " province_name || city_name || town_name || address AS \"address\"\n" +
                        "FROM\n" +
                        "\tbase_org\n" +
                        "WHERE\n" +
                        "\t(\n" +
                        "\t\t(code LIKE '%%' OR '' = '%%')\n" +
                        "\t\tAND (del = '' OR '' = '')\n" +
                        "\t)\n" +
                        "OR (\n" +
                        "\t(NAME LIKE '%%' OR '' = '%%')\n" +
                        "\tAND (del = '' OR '' = '')\n" +
                        ")\n" +
                        "AND (del = '' OR '' = '')\n" +
                        "ORDER BY\n" +
                        "\tcreate_time DESC";
                String finalSql = sql
                .replace("{code}", "%" + codeOrNameValue + "%")
                .replace("{name}", "%" + codeOrNameValue + "%")
                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus);
        List<Map<String, Object>> list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=finalSql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            list = jdbcTemplate.queryForList(oracleSql);
        }else {
            finalSql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            list = jdbcTemplate.queryForList(finalSql);
        }
        String countSql = "SELECT count(id)" +
                " FROM base_org " +
                " WHERE " +
@ -108,7 +185,7 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
                .replace("{code}", "%" + codeOrNameValue + "%")
                .replace("{name}", "%" + codeOrNameValue + "%")
                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus);
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));

+ 79 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/service/team/BaseTeamService.java

@ -19,10 +19,13 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import org.springframework.transaction.annotation.Transactional;
@ -30,6 +33,7 @@ import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.util.*;
import java.util.logging.Logger;
/**
 * 
@ -303,7 +307,7 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
     * @return
     * @throws Exception
     */
    public JSONObject getTeamInfoList(String teamName,String orgCode,String status,int page,int size,JSONObject userAgent) throws Exception {
    public JSONObject getTeamInfoList(String teamName,String orgCode,String status,int page,int size,JSONObject userAgent,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
      /*  int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
@ -311,11 +315,51 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
        String orgCodeValue = null == orgCode ? "" : orgCode;
        String statusValue = null == status ? "" : status;
//        String sql = " " +
//                "SELECT " +
//                "  team.id as \"teamId\", " +
//                "  team.name as \"name\", " +
//                "  case team.del when 0 then '已失效' when 1 then '生效中' end  as \"del\", " +
//                "  org.name as \"orgName\" " +
//                "FROM " +
//                "  base_team team, " +
//                "  base_org org " +
//                "WHERE " +
//                "  team.org_code = org.code " +
//                "  and (team.name like '{teamName}' or '' ='{teamName}') " +
//                "  and (team.org_code = '{orgCode}' or '' = '{orgCode}') " +
//                "  and ( team.del = '{status}' or '' = '{status}') " +
//                " ORDER BY team.create_time DESC " ;
//
//        String finalSql = sql
//                .replace("{teamName}","%" + teamNameValue + "%")
//                .replace("{orgCode}",orgCodeValue)
//                .replace("{status}",statusValue);
//
//        String countSql = "SELECT " +
//                "  count(team.id) " +
//                "FROM " +
//                "  base_team team, " +
//                "  base_org org " +
//                "WHERE " +
//                "  team.org_code = org.code " +
//                "  AND (team.name LIKE '{teamName}' OR '' = '{teamName}') " +
//                "  AND (team.org_code = '{orgCode}' OR '' = '{orgCode}') " +
//                "  AND (team.del = '{status}' OR '' = '{status}')";
//        String finalCountSql = countSql
//                .replace("{teamName}","%" + teamNameValue + "%")
//                .replace("{orgCode}",orgCodeValue)
//                .replace("{status}",statusValue);
//
//        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
//        int count = jdbcTemplate.queryForObject(finalCountSql,Integer.class);
        String sql = " " +
                "SELECT " +
                "  team.id as \"teamId\", " +
                "  team.name as \"name\", " +
                "  case team.del when 0 then '已失效' when 1 then '生效中' end status as \"del\", " +
                "  case  when team.del=0 then '已失效' when team.del=1 then '生效中' end  as \"del\", " +
                "  org.name as \"orgName\" " +
                "FROM " +
                "  base_team team, " +
@ -327,12 +371,43 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
                "  and ( team.del = '{status}' or '' = '{status}') " +
                " ORDER BY team.create_time DESC " ;
        String finalSql = sql
                .replace("{teamName}","%" + teamNameValue + "%")
                .replace("{orgCode}",orgCodeValue)
                .replace("{status}",statusValue);
        String countSql = "SELECT " +
        List<Map<String,Object>>  list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=finalSql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            Logger.getAnonymousLogger().info("oracleSql="+oracleSql);
            list = jdbcTemplate.queryForList(oracleSql);
        }else {
            finalSql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            Logger.getAnonymousLogger().info("oracleSql="+finalSql);
            list = jdbcTemplate.queryForList(finalSql);
        }
                String countSql = "SELECT " +
                "  count(team.id) " +
                "FROM " +
                "  base_team team, " +
@ -346,8 +421,7 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
                .replace("{teamName}","%" + teamNameValue + "%")
                .replace("{orgCode}",orgCodeValue)
                .replace("{status}",statusValue);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
        int count = jdbcTemplate.queryForObject(finalCountSql,Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));

+ 116 - 30
svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java

@ -20,6 +20,8 @@ import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
@ -37,6 +39,7 @@ import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.*;
import java.util.logging.Logger;
/**
 * Service - 后台管理员
@ -623,7 +626,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
     * @return
     * @throws Exception
     */
    public JSONObject userInfoList(String name,String saasid,String roleId,int page,int size) throws Exception {
    public JSONObject userInfoList(String name,String saasid,String roleId,int page,int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
   /*     int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
@ -631,50 +634,133 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
        String saasidValue = null == saasid ? "" : saasid;
        String roleIdValue = null == roleId ? "" : roleId;
        String sql = "SELECT " +
                "  user.id as \"id\", " +
                "  user.name as \"realName\", " +
                "  user.username as \"username\", " +
                "  case user.enabled when 0 then '已失效' when 1 then '生效中' end status as \"enabled\", " +
                "  user.mobile as \"mobile\", " +
                "  saas.name as \"saasName\", " +
                "  role.name as \"roleName\" " +
                " FROM " +
                "  base_user user, " +
                "  base_saas saas, " +
                "  base_role role " +
                " WHERE " +
                "  user.saas_id = saas.id " +
                "  AND " +
                "  user.role_id = role.id " +
                " and (user.name like '{realName}' or '' ='{realName}') " +
                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
                "  and ( user.role_id = '{roleId}' or '' = '{roleId}') " +
                " ORDER BY user.create_time DESC";
        String finalSql = sql
//        String sql = "SELECT " +
//                "  usr.id as \"id\", " +
//                "  usr.name as \"realName\", " +
//                "  usr.username as \"username\", " +
//                "  case when usr.enabled=0 then '已失效' when usr.enabled=1 then '生效中' end  as \"enabled\", " +
//                "  usr.mobile as \"mobile\", " +
//                "  saas.name as \"saasName\", " +
//                "  role.name as \"roleName\" " +
//                " FROM " +
//                "  base_user usr, " +
//                "  base_saas saas, " +
//                "  base_role role " +
//                " WHERE " +
//                "  usr.saas_id = saas.id " +
//                "  AND " +
//                "  usr.role_id = role.id " +
//                " and (usr.name like '{realName}' or '' ='{realName}') " +
//                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
//                "  and ( usr.role_id = '{roleId}' or '' = '{roleId}') " +
//                " ORDER BY usr.create_time DESC";
//        String finalSql = sql
//                .replace("{realName}","%" + realName + "%")
//                .replace("{saasid}",saasidValue)
//                .replace("{roleId}",roleIdValue);
//
//        String countSql = "SELECT " +
//                "  count(usr.id) " +
//                "FROM " +
//                "  base_user usr, " +
//                "  base_saas saas, " +
//                "  base_role role " +
//                "WHERE " +
//                "  usr.saas_id = saas.id " +
//                "  AND " +
//                "  usr.role_id = role.id " +
//                " and (usr.name like '{realName}' or '' ='{realName}') " +
//                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
//                "  and ( usr.role_id = '{roleId}' or '' = '{roleId}') ";
//        String finalCountSql = countSql
//                .replace("{realName}", "%" + realName + "%")
//                .replace("{saasid}",  saasidValue )
//                .replace("{roleId}",  roleIdValue );
//        Logger.getAnonymousLogger().info("sql="+sql);
//        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
//        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
//        result.put("count", count);
//        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        String finalSql="SELECT\n" +
                "\t\t\tusr . ID AS \"id\",\n" +
                "\t\t\tusr . NAME AS \"realName\",\n" +
                "\t\t\tusr .username AS \"username\",\n" +
                "\t\t\tCASE \n" +
                "\t\tWHEN usr .enabled=0 THEN\n" +
                "\t\t\t'已失效'\n" +
                "\t\tWHEN usr .enabled=1 THEN\n" +
                "\t\t\t'生效中'\n" +
                "\t\tEND  AS \"enabled\",\n" +
                "\t\tusr .mobile AS \"mobile\",\n" +
                "\t\tsaas. NAME AS \"saasName\",\n" +
                "\t\tROLE . NAME AS \"roleName\"\n" +
                "\tFROM\n" +
                "\t\tbase_user usr,\n" +
                "\t\tbase_saas saas,\n" +
                "\t\tbase_role ROLE\n" +
                "\tWHERE\n" +
                "\t\tusr .saas_id = saas. ID\n" +
                "\tAND usr .role_id = ROLE . ID\n" +
                "\tAND (usr . NAME LIKE '%%' OR '' = '%%')\n" +
                "\tAND (saas. ID = '' OR '' = '')\n" +
                "\tAND (usr .role_id = '' OR '' = '')\n" +
                "\tORDER BY\n" +
                "\t\tusr .create_time DESC";
        String sql = finalSql
                .replace("{realName}","%" + realName + "%")
                .replace("{saasid}",saasidValue)
                .replace("{roleId}",roleIdValue);
        List<Map<String, Object>> list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=sql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            Logger.getAnonymousLogger().info("oracleSql="+oracleSql);
            list = jdbcTemplate.queryForList(oracleSql);
        }else {
            sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            Logger.getAnonymousLogger().info("sql="+sql);
            list = jdbcTemplate.queryForList(sql);
        }
        String countSql = "SELECT " +
                "  count(user.id) " +
                "  COUNT(usr.id) " +
                "FROM " +
                "  base_user user, " +
                "  base_user usr, " +
                "  base_saas saas, " +
                "  base_role role " +
                "WHERE " +
                "  user.saas_id = saas.id " +
                "  usr.saas_id = saas.id " +
                "  AND " +
                "  user.role_id = role.id " +
                " and (user.name like '{realName}' or '' ='{realName}') " +
                "  usr.role_id = role.id " +
                " and (usr.name like '{realName}' or '' ='{realName}') " +
                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
                "  and ( user.role_id = '{roleId}' or '' = '{roleId}') ";
                "  and ( usr.role_id = '{roleId}' or '' = '{roleId}') ";
        String finalCountSql = countSql
                .replace("{realName}", "%" + realName + "%")
                .replace("{saasid}",  saasidValue )
                .replace("{roleId}",  roleIdValue );
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));