bing 2 years ago
parent
commit
b026b5ee38

+ 51 - 51
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineWarrayService.java

@ -532,58 +532,58 @@ public class MedicineWarrayService extends BaseJpaService<Mediicinewarray, Medii
            String equNum, String equClass, String netStatus, String content,
            String equNum, String equClass, String netStatus, String content,
            String startTime, String endTime, String userId, int page, int size,String wechatId) throws Exception {
            String startTime, String endTime, String userId, int page, int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
//        UserDO user = userDao.findOne(userId);
//        RoleDO role = roleDao.findOne(user.getRoleId());
//        String belongCommunitys = "";
//        String tempSql = "";
//        //获取管理员所在社区code字符串
//        {
//            //市管理员
//            if ("saasAdmin".equals(role.getCode())) {
//                tempSql = "SELECT\n" +
//                        "\t`code`\tas community\n" +
//                        "FROM\n" +
//                        "\tdm_hospital\n" +
//                        "WHERE\n" +
//                        "\tdel = 1";
//            }
//            //区域管理员
//            if ("regionAdmin".equals(role.getCode())) {
//                tempSql = "SELECT\n" +
//                        "\tdh.`code` AS community\n" +
//                        "FROM\n" +
//                        "\twlyy_user_area t\n" +
//                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
//                        "WHERE\n" +
//                        "\tt.user_id = '" + userId + "'\n" +
//                        "AND t.del = 1\n" +
//                        "AND dh.del = 1";
//            }
//            //社区管理员
//            if ("communityAdmin".equals(role.getCode()) || "replenisher".equals(role.getCode())) {
//                tempSql = "SELECT\n" +
//                        "t.hospital AS community\n" +
//                        "FROM\n" +
//                        "wlyy_user_area AS t\n" +
//                        "WHERE\n" +
//                        "t.user_id = '" + userId + "'\n" +
//                        "AND t.del = 1";
//            }
//            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempSql);
//            for (Map<String, Object> stringObjectMap : list) {
//                if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
//                    if (StringUtils.isEmpty(belongCommunitys)) {
//                        belongCommunitys += stringObjectMap.get("community").toString();
//                    } else {
//                        belongCommunitys += "," +  stringObjectMap.get("community").toString();
//                    }
//                }
//            }
//        }
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        String belongCommunitys = "";
        String tempSql = "";
        //获取管理员所在社区code字符串
        {
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
                        "\tdel = 1";
            }
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "\tdh.`code` AS community\n" +
                        "FROM\n" +
                        "\twlyy_user_area t\n" +
                        "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
                        "WHERE\n" +
                        "\tt.user_id = '" + userId + "'\n" +
                        "AND t.del = 1\n" +
                        "AND dh.del = 1";
            }
            //社区管理员
            if ("communityAdmin".equals(role.getCode()) || "replenisher".equals(role.getCode())) {
                tempSql = "SELECT\n" +
                        "t.hospital AS community\n" +
                        "FROM\n" +
                        "wlyy_user_area AS t\n" +
                        "WHERE\n" +
                        "t.user_id = '" + userId + "'\n" +
                        "AND t.del = 1";
            }
            List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempSql);
            for (Map<String, Object> stringObjectMap : list) {
                if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
                    if (StringUtils.isEmpty(belongCommunitys)) {
                        belongCommunitys += stringObjectMap.get("community").toString();
                    } else {
                        belongCommunitys += "," +  stringObjectMap.get("community").toString();
                    }
                }
            }
        }
        String conditionSql = "";
        String conditionSql = "";
//        if (!StringUtils.isEmpty(belongCommunitys)) {
//            conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
//        }
        if (!StringUtils.isEmpty(belongCommunitys)) {
            conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
        }
        String sql = "SELECT\n" +
        String sql = "SELECT\n" +
                "    t.id as id,\n" +
                "    t.id as id,\n" +
                "    t.belong_community as belongCommunity,\n" +
                "    t.belong_community as belongCommunity,\n" +