Browse Source

修复我的处方

mengkang 4 years ago
parent
commit
3e25d4d618

+ 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);
    }

+ 156 - 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,133 @@ 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";
        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 +262,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 +309,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));