Browse Source

修复我的处方

mengkang 4 years ago
parent
commit
bf9bd690a2

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

@ -6711,11 +6711,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);
    }

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

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