瀏覽代碼

医生圈导出功能

wangzhinan 1 年之前
父節點
當前提交
0fff317b40
共有 100 個文件被更改,包括 10040 次插入14 次删除
  1. 1 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/BaseRestEndPoint.java
  2. 52 0
      common/commons-cat/pom.xml
  3. 26 0
      common/commons-cat/src/main/java/com/yihu/jw/cat/CatContext.java
  4. 16 0
      common/commons-cat/src/main/java/com/yihu/jw/cat/CatErrorConstants.java
  5. 62 0
      common/commons-cat/src/main/java/com/yihu/jw/cat/CatHeaderRequestWrapper.java
  6. 45 0
      common/commons-cat/src/main/java/com/yihu/jw/cat/CatOkHttpInterceptor.java
  7. 108 0
      common/commons-cat/src/main/java/com/yihu/jw/cat/CatServletFilter.java
  8. 26 0
      common/commons-cat/src/main/java/com/yihu/jw/cat/config/CatFilterConfig.java
  9. 34 0
      common/commons-cat/src/main/java/com/yihu/jw/cat/config/FeignOkHttpConfig.java
  10. 1 0
      common/commons-cat/src/main/resources/META-INF/app.properties
  11. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/AgAdminConstants.java
  12. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/ApiVersion.java
  13. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/Channel.java
  14. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/ErrorCode.java
  15. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/HBConstants.java
  16. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/HttpHeader.java
  17. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/LisEntry.java
  18. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/MicroServices.java
  19. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/PageArg.java
  20. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/ServiceApi.java
  21. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/SessionAttributeKeys.java
  22. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/SystemDictId.java
  23. 1 1
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/UrlScope.java
  24. 21 0
      gateway/ag-admin/.gitignore
  25. 128 0
      gateway/ag-admin/pom.xml
  26. 44 0
      gateway/ag-admin/src/main/java/com/yihu/jw/AgAdminApplication.java
  27. 282 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/AdapterDataSetController.java
  28. 296 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/AdapterDictController.java
  29. 242 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/AdapterOrgController.java
  30. 272 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgAdapterPlanController.java
  31. 204 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgDataSetController.java
  32. 187 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgDictController.java
  33. 196 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgDictEntryController.java
  34. 200 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgMetaDataController.java
  35. 116 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/AdapterDataSetClient.java
  36. 99 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/AdapterDictClient.java
  37. 80 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/AdapterOrgClient.java
  38. 77 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgDataSetClient.java
  39. 80 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgDictClient.java
  40. 90 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgDictEntryClient.java
  41. 82 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgMetaDataClient.java
  42. 110 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/PlanClient.java
  43. 110 0
      gateway/ag-admin/src/main/java/com/yihu/jw/adapter/utils/ExtendController.java
  44. 346 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppApiController.java
  45. 156 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppApiParameterController.java
  46. 133 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppApiResponseController.java
  47. 471 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppController.java
  48. 285 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppFeatureController.java
  49. 86 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppApiClient.java
  50. 59 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppApiParameterClient.java
  51. 59 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppApiResponseClient.java
  52. 126 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppClient.java
  53. 89 0
      gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppFeatureClient.java
  54. 29 0
      gateway/ag-admin/src/main/java/com/yihu/jw/config/FeignMultipartSupportConfig.java
  55. 27 0
      gateway/ag-admin/src/main/java/com/yihu/jw/config/TenantConfiguration.java
  56. 68 0
      gateway/ag-admin/src/main/java/com/yihu/jw/device/client/DeviceClient.java
  57. 86 0
      gateway/ag-admin/src/main/java/com/yihu/jw/device/controller/DeviceController.java
  58. 75 0
      gateway/ag-admin/src/main/java/com/yihu/jw/dfs/client/ElasticSearchClient.java
  59. 98 0
      gateway/ag-admin/src/main/java/com/yihu/jw/dfs/client/FastDFSClient.java
  60. 136 0
      gateway/ag-admin/src/main/java/com/yihu/jw/dfs/controller/ElasticSearchController.java
  61. 225 0
      gateway/ag-admin/src/main/java/com/yihu/jw/dfs/controller/FastDFSController.java
  62. 82 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/AmbulanceClient.java
  63. 77 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/AttendanceClient.java
  64. 54 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/LocationClient.java
  65. 67 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/ScheduleClient.java
  66. 131 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/AmbulanceController.java
  67. 106 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/AttendanceController.java
  68. 66 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/LocationController.java
  69. 100 0
      gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/ScheduleController.java
  70. 47 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosAcqTaskClient.java
  71. 31 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosEsbMiniInstallLogClient.java
  72. 42 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosLogClient.java
  73. 49 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosReleaseClient.java
  74. 49 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosSqlTaskClient.java
  75. 150 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosAcqTaskController.java
  76. 73 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosEsbMiniInstallLogController.java
  77. 93 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosLogController.java
  78. 130 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosReleaseController.java
  79. 137 0
      gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosSqlTaskController.java
  80. 132 0
      gateway/ag-admin/src/main/java/com/yihu/jw/fileresource/controller/FileResourceController.java
  81. 78 0
      gateway/ag-admin/src/main/java/com/yihu/jw/fileresource/service/FileResourceClient.java
  82. 35 0
      gateway/ag-admin/src/main/java/com/yihu/jw/filter/TenantFilter.java
  83. 34 0
      gateway/ag-admin/src/main/java/com/yihu/jw/filter/WritableHttpServletRequest.java
  84. 271 0
      gateway/ag-admin/src/main/java/com/yihu/jw/geography/controller/AddressController.java
  85. 126 0
      gateway/ag-admin/src/main/java/com/yihu/jw/geography/service/AddressClient.java
  86. 53 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/GovernmentBrowseLogController.java
  87. 272 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/GovernmentMenuController.java
  88. 61 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/GovernmentMenuReportMonitorTypeController.java
  89. 61 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/OutpatientsBoardController.java
  90. 37 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/service/GovernmentBrowseLogClient.java
  91. 52 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/service/GovernmentMenuClient.java
  92. 49 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/service/GovernmentMenuReportMonitorTypeClient.java
  93. 44 0
      gateway/ag-admin/src/main/java/com/yihu/jw/government/service/OutpatientsBoardClient.java
  94. 192 0
      gateway/ag-admin/src/main/java/com/yihu/jw/msg/controller/TelVerificationController.java
  95. 42 0
      gateway/ag-admin/src/main/java/com/yihu/jw/msg/service/TelVerificationClient.java
  96. 749 0
      gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgDeptController.java
  97. 89 0
      gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgDeptImportController.java
  98. 94 0
      gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgHealthCategoryController.java
  99. 231 0
      gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgSaasController.java
  100. 0 0
      gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrganizationController.java

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/BaseRestEndPoint.java

@ -2,7 +2,7 @@ package com.yihu.jw.restmodel.web.endpoint;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.PageArg;
import com.yihu.jw.constants.PageArg;
import com.yihu.jw.util.date.DateTimeUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;

+ 52 - 0
common/commons-cat/pom.xml

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>commons</artifactId>
        <groupId>com.yihu.ehr</groupId>
        <version>2.4.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>commons-cat</artifactId>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>com.dianping.cat</groupId>
            <artifactId>cat-client</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-okhttp</artifactId>
            <version>9.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
      	<dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
        </dependency>
    </dependencies>
</project>

+ 26 - 0
common/commons-cat/src/main/java/com/yihu/jw/cat/CatContext.java

@ -0,0 +1,26 @@
package com.yihu.jw.cat;
import com.dianping.cat.Cat;
import java.util.HashMap;
import java.util.Map;
/**
 * Context - CAT上下文
 * Created by progr1mmer on 2018/9/4.
 */
public class CatContext implements Cat.Context {
    private Map<String, String> properties = new HashMap<>();
    @Override
    public void addProperty(String key, String value) {
        properties.put(key, value);
    }
    @Override
    public String getProperty(String key) {
        return properties.get(key);
    }
}

+ 16 - 0
common/commons-cat/src/main/java/com/yihu/jw/cat/CatErrorConstants.java

@ -0,0 +1,16 @@
package com.yihu.jw.cat;
/**
 * Constants - 常量
 * Created by progr1mmer on 2018/9/5.
 */
public class CatErrorConstants {
    /*
     * 异常在过滤链中被捕获的时候可以通过
     * request.setAttribute(ERROR_FOR_CAT, e)
     * 将异常传递给 Transaction
     */
    public static final String ERROR_FOR_CAT = "EFC";
}

+ 62 - 0
common/commons-cat/src/main/java/com/yihu/jw/cat/CatHeaderRequestWrapper.java

@ -0,0 +1,62 @@
package com.yihu.jw.cat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.*;
/**
 * Wrapper - 添加请求头
 * Created by progr1mmer on 2018/9/4.
 */
public class CatHeaderRequestWrapper extends HttpServletRequestWrapper {
    private final Map<String, String> customHeaders;
    CatHeaderRequestWrapper(HttpServletRequest request) {
        super(request);
        this.customHeaders = new HashMap<>();
    }
    void putHeader(String name, String value) {
        this.customHeaders.put(name, value);
    }
    @Override
    public String getHeader(String name) {
        // check the custom headers first
        String headerValue = customHeaders.get(name);
        if (headerValue != null){
            return headerValue;
        }
        // else return from into the original wrapped object
        return ((HttpServletRequest) getRequest()).getHeader(name);
    }
    @Override
    public Enumeration<String> getHeaders(String name) {
        if (customHeaders.containsKey(name)) {
            Set<String> set = new HashSet<>();
            set.add(getHeader(name));
            return Collections.enumeration(set);
        }
        return super.getHeaders(name);
    }
    @Override
    public Enumeration<String> getHeaderNames() {
        // create a set of the custom header names
        Set<String> set = new HashSet<>(customHeaders.keySet());
        // now add the headers from the wrapped request object
        Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaderNames();
        while (e.hasMoreElements()) {
            // add the names of the request headers into the list
            String n = e.nextElement();
            set.add(n);
        }
        // create an enumeration from the set and return
        return Collections.enumeration(set);
    }
}

+ 45 - 0
common/commons-cat/src/main/java/com/yihu/jw/cat/CatOkHttpInterceptor.java

@ -0,0 +1,45 @@
package com.yihu.jw.cat;
import com.dianping.cat.Cat;
import com.dianping.cat.CatConstants;
import com.dianping.cat.message.Transaction;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
/**
 * Interceptor - 拦截http调用过程
 * Created by progr1mmer on 2018/9/5.
 */
public class CatOkHttpInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Transaction t = Cat.newTransaction(CatConstants.TYPE_REMOTE_CALL, request.url().toString());
        try {
            //保存和传递CAT调用链上下文
            CatContext ctx = new CatContext();
            Cat.logRemoteCallClient(ctx);
            Request.Builder builder = request.newBuilder();
            builder.header(Cat.Context.ROOT, ctx.getProperty(Cat.Context.ROOT));
            builder.header(Cat.Context.PARENT, ctx.getProperty(Cat.Context.PARENT));
            builder.header(Cat.Context.CHILD, ctx.getProperty(Cat.Context.CHILD));
            request = builder.build();
            //执行请求
            Response response = chain.proceed(request);
            t.setStatus(Transaction.SUCCESS);
            return response;
        } catch (Exception e) {
            //记录异常
            t.setStatus(e);
            Cat.getProducer().logError(e);
            throw e;
        } finally {
            //当前Transaction须完成
            t.complete();
        }
    }
}

+ 108 - 0
common/commons-cat/src/main/java/com/yihu/jw/cat/CatServletFilter.java

@ -0,0 +1,108 @@
package com.yihu.jw.cat;
import com.dianping.cat.Cat;
import com.dianping.cat.CatConstants;
import com.dianping.cat.message.Transaction;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
 * http://tx.cat.weimob.com/cat/doc.html - 部分说明文档
 * Filter - Cat基础过滤器
 * Created by progr1mmer on 2018/9/4.
 */
public class CatServletFilter implements Filter {
    private final ObjectMapper objectMapper = new ObjectMapper();
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        CatHeaderRequestWrapper headerRequestWrapper = new CatHeaderRequestWrapper(request);
        if (isRoot(request)) {
            Transaction t = Cat.newTransaction(CatConstants.TYPE_REMOTE_CALL, request.getRequestURL().toString());
            try {
                Cat.logEvent("Request.remoteHost", request.getRemoteHost());
                Cat.logEvent("Request.params", objectMapper.writeValueAsString(request.getParameterMap()));
                CatContext catContext = new CatContext();
                Cat.logRemoteCallClient(catContext);
                headerRequestWrapper.putHeader(Cat.Context.ROOT, catContext.getProperty(Cat.Context.ROOT));
                headerRequestWrapper.putHeader(Cat.Context.PARENT, catContext.getProperty(Cat.Context.PARENT));
                headerRequestWrapper.putHeader(Cat.Context.CHILD, catContext.getProperty(Cat.Context.CHILD));
                filterChain.doFilter(headerRequestWrapper, servletResponse);
                if (null == request.getAttribute(CatErrorConstants.ERROR_FOR_CAT)) {
                    Integer status = ((HttpServletResponse) servletResponse).getStatus();
                    if (status != 500) {
                        t.setStatus(Transaction.SUCCESS);
                    } else {
                        Cat.logError(new IllegalStateException(status.toString()));
                        t.setStatus(new IllegalStateException(status.toString()));
                    }
                } else {
                    Cat.logError((Exception)request.getAttribute(CatErrorConstants.ERROR_FOR_CAT));
                    t.setStatus((Exception)request.getAttribute(CatErrorConstants.ERROR_FOR_CAT));
                }
            } catch (Exception e) {
                Cat.logError(e);
                t.setStatus(e);
                throw e;
            } finally {
                t.complete();
            }
        } else {
            CatContext catContext = new CatContext();
            catContext.addProperty(Cat.Context.ROOT, request.getHeader(Cat.Context.ROOT));
            catContext.addProperty(Cat.Context.PARENT, request.getHeader(Cat.Context.PARENT));
            catContext.addProperty(Cat.Context.CHILD, request.getHeader(Cat.Context.CHILD));
            Cat.logRemoteCallServer(catContext);
            Transaction t = Cat.newTransaction(CatConstants.TYPE_SERVICE, request.getRequestURL().toString());
            try {
                Cat.logEvent("Request.params", objectMapper.writeValueAsString(request.getParameterMap()));
                filterChain.doFilter(headerRequestWrapper, servletResponse);
                if (null == request.getAttribute(CatErrorConstants.ERROR_FOR_CAT)) {
                    Integer status = ((HttpServletResponse) servletResponse).getStatus();
                    if (status != 500) {
                        t.setStatus(Transaction.SUCCESS);
                    } else {
                        Cat.logError(new IllegalStateException(status.toString()));
                        t.setStatus(new IllegalStateException(status.toString()));
                    }
                } else {
                    Cat.logError((Exception)request.getAttribute(CatErrorConstants.ERROR_FOR_CAT));
                    t.setStatus((Exception)request.getAttribute(CatErrorConstants.ERROR_FOR_CAT));
                }
            } catch (Exception e) {
                Cat.logError(e);
                t.setStatus(e);
                throw e;
            } finally {
                t.complete();
            }
        }
    }
    @Override
    public void destroy() {
    }
    private boolean isRoot(HttpServletRequest request) {
        /*return request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_ROOT_MESSAGE_ID) != null &&
                request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_PARENT_MESSAGE_ID) != null &&
                request.getHeader(CatHttpConstants.CAT_HTTP_HEADER_CHILD_MESSAGE_ID) != null;*/
        return request.getHeader(Cat.Context.ROOT) == null &&
                request.getHeader(Cat.Context.PARENT) == null &&
                request.getHeader(Cat.Context.CHILD) == null;
    }
}

+ 26 - 0
common/commons-cat/src/main/java/com/yihu/jw/cat/config/CatFilterConfig.java

@ -0,0 +1,26 @@
package com.yihu.jw.cat.config;
import com.yihu.jw.cat.CatServletFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * Config - 配置CAT过滤路径
 * Created by progr1mmer on 2018/9/4.
 */
@Configuration
public class CatFilterConfig {
    @Bean
    public FilterRegistrationBean catFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        CatServletFilter filter = new CatServletFilter();
        registration.setFilter(filter);
        registration.addUrlPatterns("/*");
        registration.setName("catFilter");
        registration.setOrder(1);
        return registration;
    }
}

+ 34 - 0
common/commons-cat/src/main/java/com/yihu/jw/cat/config/FeignOkHttpConfig.java

@ -0,0 +1,34 @@
package com.yihu.jw.cat.config;
import com.yihu.jw.cat.CatOkHttpInterceptor;
import feign.Feign;
import okhttp3.ConnectionPool;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.netflix.feign.FeignAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
/**
 * Config - 自定义OkHttpClient,添加拦截器
 * Created by progr1mmer on 2018/9/5.
 */
@Configuration
@ConditionalOnClass(Feign.class)
@AutoConfigureBefore(FeignAutoConfiguration.class)
public class FeignOkHttpConfig {
    @Bean
    public okhttp3.OkHttpClient okHttpClient(){
        return new okhttp3.OkHttpClient.Builder()
                .readTimeout(10000, TimeUnit.SECONDS)
                .connectTimeout(10000, TimeUnit.SECONDS)
                .writeTimeout(10000, TimeUnit.SECONDS)
                .connectionPool(new ConnectionPool())
                .addInterceptor(new CatOkHttpInterceptor())
                .build();
    }
}

+ 1 - 0
common/commons-cat/src/main/resources/META-INF/app.properties

@ -0,0 +1 @@
app.name=commons-cat

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/AgAdminConstants.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * Created by AndyCai on 2016/2/22.

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/ApiVersion.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * API版本前缀。用于适配Rest控制器的版本。定义好适用的版本之后,可以方便API版本编写。

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/Channel.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * @author Sand

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/ErrorCode.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 *

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/HBConstants.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
public class HBConstants {
	final static public String T_HFILES = "H_Files";

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/HttpHeader.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * Created by Sand Wen on 2016.2.27.

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/LisEntry.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * 检验名称枚举列表(用于赛诺菲接口)

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/MicroServices.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * 全局微服务名称枚举。用于Feign及Thrift客户端。

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/PageArg.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * @author Sand

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/ServiceApi.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * 微服务REST API. 此处定义的URL可用于服务对外提供的地址及HTTP客户端请求地址.

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/SessionAttributeKeys.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * Spring MVC 的Web会话常用会话属性常量。

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/SystemDictId.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * 通用字典ID。

+ 1 - 1
common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/UrlScope.java

@ -1,4 +1,4 @@
package com.yihu.ehr.constants;
package com.yihu.jw.constants;
/**
 * @author linaz

+ 21 - 0
gateway/ag-admin/.gitignore

@ -0,0 +1,21 @@
#project files
*.iml
.idea/*
target/*
# ---> Java
*/target
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*#
# thrift generate code

+ 128 - 0
gateway/ag-admin/pom.xml

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>wlyy-parent-pom</artifactId>
        <version>2.4.0</version>
        <relativePath>../../wlyy-parent-pom/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>ag-admin</artifactId>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-ehr-constants</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-ui-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-admin-gateway-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-cat</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign.form</groupId>
            <artifactId>feign-form</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign.form</groupId>
            <artifactId>feign-form-spring</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.hos</groupId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

+ 44 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/AgAdminApplication.java

@ -0,0 +1,44 @@
package com.yihu.jw;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
 * Created by AndyCai on 2016/1/19.
 */
@Configuration
@EnableAutoConfiguration(exclude = {
        SecurityAutoConfiguration.class,
        ManagementWebSecurityAutoConfiguration.class,
        DataSourceAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,
        DataSourceTransactionManagerAutoConfiguration.class})
@ComponentScan
@EnableEurekaClient
@EnableDiscoveryClient
@EnableFeignClients
@EnableZuulProxy
public class AgAdminApplication extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(AgAdminApplication.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(AgAdminApplication.class);
    }
}

+ 282 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/AdapterDataSetController.java

@ -0,0 +1,282 @@
package com.yihu.jw.adapter.controller;
import com.yihu.jw.adapter.service.AdapterDataSetClient;
import com.yihu.jw.adapter.service.OrgMetaDataClient;
import com.yihu.jw.adapter.service.PlanClient;
import com.yihu.jw.agModel.adapter.AdapterDataSetDetailModel;
import com.yihu.jw.agModel.adapter.AdapterDataSetModel;
import com.yihu.jw.agModel.adapter.AdapterRelationshipModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.adapter.service.OrgDataSetClient;
import com.yihu.jw.adapter.utils.ExtendController;
import com.yihu.jw.std.service.DataSetClient;
import com.yihu.jw.model.adaption.*;
import com.yihu.hos.model.standard.MStdDataSet;
import com.yihu.hos.model.standard.MStdMetaData;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.util.validate.ValidateResult;
import io.swagger.annotations.Api;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * @author lincl
 * @version 1.0
 * @created 2016.3.1
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapter")
@RestController
@Api(protocols = "https", value = "adapter", description = "数据集适配", tags = {"适配管理-数据集适配"})
public class AdapterDataSetController extends ExtendController<AdapterDataSetModel> {
    @Autowired
    AdapterDataSetClient adapterDataSetClient;
    @Autowired
    DataSetClient dataSetClient;
    @Autowired
    OrgDataSetClient orgDataSetClient;
    @Autowired
    OrgMetaDataClient orgMetaDataClient;
    @Autowired
    PlanClient planClient;
    @RequestMapping(value = "/metadata/{id}", method = RequestMethod.GET)
    public Envelop getAdapterMetaDataById(
            @ApiParam(name = "id", value = "适配关系ID")
            @PathVariable(value = "id") Long id) {
        try {
            MAdapterDataSet dataSet = adapterDataSetClient.getAdapterMetaData(id);
            if (dataSet == null) {
                return failed("数据获取失败!");
            }
            return success(convertAdapterDataSetModel(dataSet));
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem() ;
        }
    }
    @RequestMapping(value = "/plan/data_set/{plan_id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据方案ID及查询条件查询数据集适配关系")
    public Envelop searchAdapterDataSet(
            @ApiParam(name = "plan_id", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "plan_id") long planId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ResponseEntity<Collection<MAdapterRelationship>> responseEntity = adapterDataSetClient.searchAdapterDataSet(planId, code, name, sorts, size, page);
        List<MAdapterRelationship> mAdapterRelationships = (List<MAdapterRelationship>) responseEntity.getBody();
        List<AdapterRelationshipModel> adapterRelationshipModels = (List<AdapterRelationshipModel>) convertToModels(
                mAdapterRelationships,
                new ArrayList<AdapterRelationshipModel>(mAdapterRelationships.size()),
                AdapterRelationshipModel.class, null);
        return getResult(adapterRelationshipModels, getTotalCount(responseEntity), page, size);
    }
    @RequestMapping(value = "/plan/meta_data/{plan_id}/{set_id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据dataSetId搜索数据元适配关系")
    public Envelop searchAdapterMetaData(
            @ApiParam(name = "plan_id", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "plan_id") Long planId,
            @ApiParam(name = "set_id", value = "数据集id", defaultValue = "")
            @PathVariable(value = "set_id") Long dataSetId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ResponseEntity<Collection<MAdapterDataVo>> responseEntity = adapterDataSetClient.searchAdapterMetaData(planId, dataSetId, code, name, sorts, size, page);
        List<MAdapterDataVo> mAdapterDataSets = (List<MAdapterDataVo>) responseEntity.getBody();
        List<AdapterDataSetModel> adapterDataSetModels = (List<AdapterDataSetModel>) convertToModels(
                mAdapterDataSets,
                new ArrayList<>(), AdapterDataSetModel.class, null);
        return getResult(adapterDataSetModels, getTotalCount(responseEntity), page, size);
    }
    @RequestMapping(value = "/metadata", method = RequestMethod.PUT)
    public Envelop updateAdapterMetaData(
            @ApiParam(name = "model", value = "说明")
            @RequestParam(value = "model") String model) {
        try {
            AdapterDataSetModel dataModel = jsonToObj(model);
            ValidateResult validateResult = validate(dataModel);
            if (!validateResult.isRs()) {
                return failed(validateResult.getMsg());
            }
            AdapterDataSetDetailModel detailModel = convertToModel(dataModel,AdapterDataSetDetailModel.class);
            MAdapterDataSet mAdapterDataSet = adapterDataSetClient.
                    updateAdapterMetaData(detailModel.getId(), toEncodeJson(detailModel));
            if (mAdapterDataSet == null) {
                return failed("保存失败!");
            }
            AdapterDataSetModel adapterDataSetModel = convertAdapterDataSetModel(mAdapterDataSet);
            return success(adapterDataSetModel);
        } catch (ApiException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/metadata", method = RequestMethod.POST)
    public Envelop addAdapterMetaData(
            @ApiParam(name = "model", value = "说明")
            @RequestParam(value = "model") String model) throws Exception {
        try {
            AdapterDataSetModel dataModel = jsonToObj(model);
            ValidateResult validateResult = validate(dataModel);
            if (!validateResult.isRs()) {
                return failed(validateResult.getMsg());
            }
            AdapterDataSetDetailModel detailModel = convertToModel(dataModel,AdapterDataSetDetailModel.class);
            MAdapterDataSet mAdapterDataSet = adapterDataSetClient.createAdapterMetaData(toEncodeJson(detailModel));
            if (mAdapterDataSet == null) {
                return failed("保存失败!");
            }
            AdapterDataSetModel adapterDataSetModel = convertAdapterDataSetModel(mAdapterDataSet);
            return success(adapterDataSetModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/meta_data", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除适配关系", notes = "根据适配关系ID删除适配关系,批量删除时ID以逗号隔开")
    public Envelop deleteAdapterMetaData(
            @ApiParam(name = "plan_id", value = "数据集id")
            @RequestParam(value = "plan_id") long planId,
            @ApiParam(name = "data_set_id", value = "数据集id")
            @RequestParam(value = "data_set_id") long dataSetId,
            @ApiParam(name = "ids", value = "适配关系ID")
            @RequestParam(value = "ids") String ids) {
        try {
            if(!adapterDataSetClient.isLeftMeta(planId, dataSetId, ids)){
                return failed("至少保留一条适配数据!");
            }
            ids = trimEnd(ids, ",");
            if (StringUtils.isEmpty(ids)) {
                return failed("请选择需要删除的数据!");
            }
            boolean result = adapterDataSetClient.delMetaData(ids);
            if (!result) {
                return failed("删除失败!");
            }
            return success(null);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    /**
     * 标准字典项的下拉
     * @return
     */
    @RequestMapping("/std_meta_data/combo")
    @ResponseBody
    public Envelop getStdDictEntry(
            @ApiParam(name = "plan_id", value = "方案编号")
            @RequestParam(value = "plan_id") Long planId,
            @ApiParam(name = "data_set_id", value = "字典编号")
            @RequestParam(value = "data_set_id") Long dataSetId,
            @ApiParam(name = "mode", value = "编辑模式: modify、new")
            @RequestParam(value = "mode") String mode,
            @ApiParam(name = "search_name", value = "查询字符串")
            @RequestParam(value = "search_name") String searchName,
            @ApiParam(name = "page", value = "当前页")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "大小")
            @RequestParam(value = "size") int size){
        try {
            ResponseEntity<Collection<MAdapterRelationship>> responseEntity = adapterDataSetClient.searchStdMeta(planId, dataSetId, searchName, mode, "", size, page);
            List<MAdapterRelationship> stdMeta = (List<MAdapterRelationship>) responseEntity.getBody();
            return getResult(stdMeta, getTotalCount(responseEntity), page, size);
        }
        catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    public AdapterDataSetModel convertAdapterDataSetModel(MAdapterDataSet mAdapterDataSet){
        AdapterDataSetModel adapterDataSetModel = convertToModel(mAdapterDataSet,AdapterDataSetModel.class);
        long planId = adapterDataSetModel.getAdapterPlanId();
        MAdapterPlan mAdapterPlan = planClient.getAdapterPlanById(planId);
        String versionCode = mAdapterPlan.getVersion();
        long dataSetId = adapterDataSetModel.getDataSetId()==null?0:adapterDataSetModel.getDataSetId();
        if (dataSetId != 0) {
            MStdDataSet mStdDataSet = dataSetClient.getDataSet(dataSetId, versionCode);
            adapterDataSetModel.setDataSetCode(mStdDataSet == null ? "" : mStdDataSet.getCode());
            adapterDataSetModel.setDataSetName(mStdDataSet == null ? "" : mStdDataSet.getName());
        }
        long metaDataId = adapterDataSetModel.getMetaDataId()==null?0:adapterDataSetModel.getMetaDataId();
        if (metaDataId != 0) {
            MStdMetaData mStdMetaData = dataSetClient.getMetaData(metaDataId, versionCode);
            adapterDataSetModel.setMetaDataCode(mStdMetaData == null ? "" : mStdMetaData.getCode());
            adapterDataSetModel.setMetaDataName(mStdMetaData == null ? "" : mStdMetaData.getName());
        }
        long orgDataSetSeq = adapterDataSetModel.getOrgDataSetSeq()==null?0:adapterDataSetModel.getOrgDataSetSeq();
        if (orgDataSetSeq != 0) {
            MOrgDataSet mOrgDataSet = orgDataSetClient.getDataSetBySequence(mAdapterPlan.getOrg(), orgDataSetSeq);
            adapterDataSetModel.setOrgDataSetCode(mOrgDataSet == null ? "" : mOrgDataSet.getCode());
            adapterDataSetModel.setOrgDataSetName(mOrgDataSet == null ? "" : mOrgDataSet.getName());
        }
        long orgMateDataSeq =  adapterDataSetModel.getOrgMetaDataSeq()==null?0:adapterDataSetModel.getOrgMetaDataSeq();
        if(orgMateDataSeq!=0)
        {
            MOrgMetaData mOrgMetaData = orgMetaDataClient.getMetaDataBySequence(mAdapterPlan.getOrg(),Integer.parseInt(String.valueOf(orgMateDataSeq)));
            adapterDataSetModel.setOrgMetaDataCode(mOrgMetaData==null?"":mOrgMetaData.getCode());
            adapterDataSetModel.setOrgMetaDataName(mOrgMetaData==null?"":mOrgMetaData.getName());
        }
        return adapterDataSetModel;
    }
}

+ 296 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/AdapterDictController.java

@ -0,0 +1,296 @@
package com.yihu.jw.adapter.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.adapter.service.AdapterDictClient;
import com.yihu.jw.adapter.service.OrgDictClient;
import com.yihu.jw.adapter.service.OrgDictEntryClient;
import com.yihu.jw.adapter.service.PlanClient;
import com.yihu.jw.adapter.utils.ExtendController;
import com.yihu.jw.agModel.adapter.AdapterDictDetailModel;
import com.yihu.jw.agModel.adapter.AdapterDictModel;
import com.yihu.jw.agModel.adapter.AdapterRelationshipModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.std.service.DictClient;
import com.yihu.jw.model.adaption.*;
import com.yihu.hos.model.standard.MStdDict;
import com.yihu.hos.model.standard.MStdDictEntry;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.util.validate.ValidateResult;
import io.swagger.annotations.Api;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
 * @author lincl
 * @version 1.0
 * @created 2016.3.1
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapter")
@RestController
@Api(protocols = "https", value = "adapter", description = "字典适配", tags = {"适配管理-字典适配"})
public class AdapterDictController extends ExtendController<AdapterDictModel> {
    @Autowired
    AdapterDictClient adapterDictClient;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    OrgDictClient orgDictClient;
    @Autowired
    OrgDictEntryClient orgDictEntryClient;
    @Autowired
    DictClient dictClient;
    @Autowired
    PlanClient planClient;
    @RequestMapping(value = "/plan/{plan_id}/dicts", method = RequestMethod.GET)
    public Envelop searchDicts(
            @ApiParam(name = "plan_id", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "plan_id") Long planId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        try {
            ResponseEntity<Collection<MAdapterRelationship>> responseEntity = adapterDictClient.searchAdapterDict(planId, code, name, sorts, size, page);
            List<MAdapterRelationship> mAdapterRelationships = (List<MAdapterRelationship>) responseEntity.getBody();
            List<AdapterRelationshipModel> relationshipModels = (List<AdapterRelationshipModel>) convertToModels(mAdapterRelationships,
                    new ArrayList<AdapterRelationshipModel>(mAdapterRelationships.size()),
                    AdapterRelationshipModel.class, null);
            return getResult(relationshipModels, getTotalCount(responseEntity), page, size);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/plan/dict/entrys/{plan_id}/{dict_id}", method = RequestMethod.GET)
    public Envelop getAdapterDictEntryByDictId(
            @ApiParam(name = "plan_id", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "plan_id") Long planId,
            @ApiParam(name = "dict_id", value = "字典编号", defaultValue = "")
            @PathVariable(value = "dict_id") Long dictId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        try {
            ResponseEntity<Collection<MAdapterDictVo>> responseEntity = adapterDictClient.searchAdapterDictEntry(planId, dictId, code, name, sorts, size, page);
            List<MAdapterDictVo> mAdapterDicts = (List<MAdapterDictVo>) responseEntity.getBody();
            List<AdapterDictModel> adapterDictModels = (List<AdapterDictModel>) convertToModels(mAdapterDicts, new ArrayList<AdapterDictModel>(mAdapterDicts.size())
                    , AdapterDictModel.class, null);
            return getResult(adapterDictModels, getTotalCount(responseEntity), page, size);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/dict/entry/{id}", method = RequestMethod.GET)
    public Envelop getAdapterDictEntry(
            @ApiParam(name = "id", value = "适配关系ID")
            @PathVariable(value = "id") long id) {
        try {
            MAdapterDict mAdapterDict = adapterDictClient.getAdapterDictEntry(id);
            AdapterDictModel adapterDictModel = convertAdapterDictModel(mAdapterDict);
            if (adapterDictModel == null) {
                return failed("数据获取失败!");
            }
            return success(adapterDictModel);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/dict/entry", method = RequestMethod.POST)
    @ApiOperation(value = "保存字典项映射关系")
    public Envelop createAdapterDictEntry(
            @ApiParam(name = "model", value = "数据模型")
            @RequestParam(value = "model") String model) {
        try {
            AdapterDictModel adapterDictModel = jsonToObj(model);
            ValidateResult validateResult = validate(adapterDictModel);
            if(!validateResult.isRs()){
                return failed(validateResult.getMsg());
            }
            AdapterDictDetailModel detailModel = convertToModel(adapterDictModel,AdapterDictDetailModel.class);
            MAdapterDict mAdapterDict = adapterDictClient.createAdapterDictEntry(toEncodeJson(detailModel));
            if(mAdapterDict==null)
            {
                return failed("保存失败!");
            }
            adapterDictModel = convertAdapterDictModel(mAdapterDict);
            return success(adapterDictModel);
        } catch (ApiException e){
            e.printStackTrace();
            return failed(e.getMessage());
        } catch (Exception e){
            e.printStackTrace();
            return failedSystem();
        }
    };
    @RequestMapping(value = "/dict/entry", method = RequestMethod.PUT)
    public Envelop updateAdapterDictEntry(
            @ApiParam(name = "model", value = "数据模型")
            @RequestParam(value = "model") String model) {
        try {
            AdapterDictModel adapterDictModel = jsonToObj(model);
            ValidateResult validateResult = validate(adapterDictModel);
            if(!validateResult.isRs()){
                return failed(validateResult.getMsg());
            }
            AdapterDictDetailModel detailModel = convertToModel(adapterDictModel,AdapterDictDetailModel.class);
            MAdapterDict mAdapterDict =adapterDictClient.updateAdapterDictEntry(detailModel.getId(), toEncodeJson(detailModel));
            if(mAdapterDict==null)
            {
                return  failed("保存失败!");
            }
            adapterDictModel = convertAdapterDictModel(mAdapterDict);
            return success(adapterDictModel);
        } catch (ApiException e){
            e.printStackTrace();
            return failed(e.getMessage());
        } catch (Exception e){
            e.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/dict/entrys", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除适配关系", notes = "根据适配关系ID删除适配关系,批量删除时ID以逗号隔开")
    public Envelop delAdapterDictEntry(
            @ApiParam(name = "ids", value = "适配关系ID")
            @RequestParam(value = "ids") String ids){
        try {
            ids = trimEnd(ids, ",");
            if (StringUtils.isEmpty(ids)) {
                return failed("请选择需要删除的数据!");
            }
            boolean result = adapterDictClient.delDictEntry(ids);
            if (!result) {
                return failed("删除失败!");
            }
            return success(null);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    /**
     * 标准字典项的下拉
     * @return
     */
    @RequestMapping("/std_dict_entries/combo")
    @ResponseBody
    public Envelop getStdDictEntry(
            @ApiParam(name = "plan_id", value = "方案编号")
            @RequestParam(value = "plan_id") Long planId,
            @ApiParam(name = "dict_id", value = "字典编号")
            @RequestParam(value = "dict_id") Long dictId,
            @ApiParam(name = "mode", value = "编辑模式: modify、new")
            @RequestParam(value = "mode") String mode,
            @ApiParam(name = "search_name", value = "查询字符串")
            @RequestParam(value = "search_name") String searchName,
            @ApiParam(name = "page", value = "当前页")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "大小")
            @RequestParam(value = "size") int size){
        try {
            ResponseEntity<Collection<MAdapterRelationship>> responseEntity = adapterDictClient.searchStdDictEntry(planId, dictId, searchName, mode, "", size, page);
            List<MAdapterRelationship> stdDictEntries = (List<MAdapterRelationship>) responseEntity.getBody();
            return getResult(stdDictEntries, getTotalCount(responseEntity), page, size);
        }
        catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    public AdapterDictModel convertAdapterDictModel(MAdapterDict mAdapterDict)
    {
        AdapterDictModel dictModel = convertToModel(mAdapterDict,AdapterDictModel.class);
        MAdapterPlan mAdapterPlan = planClient.getAdapterPlanById(dictModel.getAdapterPlanId());
        String versionCode = mAdapterPlan.getVersion();
        long dictId = dictModel.getDictId()==null?0:dictModel.getDictId();
        if(dictId!=0)
        {
            MStdDict mStdDict = dictClient.getCdaDictInfo(dictId, versionCode);
            dictModel.setDictCode(mStdDict == null ? "" : mStdDict.getCode());
            dictModel.setDictName(mStdDict==null?"":mStdDict.getName());
        }
        long dictEntry = dictModel.getDictEntryId()==null?0:dictModel.getDictEntryId();
        if(dictEntry!=0)
        {
            MStdDictEntry dictEntry1 = dictClient.getDictEntry(dictEntry,versionCode);
            dictModel.setDictEntryCode(dictEntry1==null?"":dictEntry1.getCode());
            dictModel.setDictEntryName(dictEntry1 == null ? "" : dictEntry1.getValue());
        }
       long orgDictSeq = dictModel.getOrgDictSeq()==null?0:dictModel.getOrgDictSeq();
        if(orgDictSeq!=0)
        {
            MOrgDict mOrgDict = orgDictClient.getOrgDictBySequence(mAdapterPlan.getOrg(),Integer.parseInt(String.valueOf(orgDictSeq)));
            dictModel.setOrgDictCode(mOrgDict==null?"":mOrgDict.getCode());
            dictModel.setOrgDictName(mOrgDict == null ? "" : mOrgDict.getName());
        }
        long orgDictEntrySeq = dictModel.getOrgDictEntrySeq()==null?0:dictModel.getOrgDictEntrySeq();
        if(orgDictEntrySeq!=0)
        {
            MOrgDictItem mOrgDictItem = orgDictEntryClient.getOrgDicEntryBySequence(mAdapterPlan.getOrg(),Integer.parseInt(String.valueOf(orgDictEntrySeq)));
            dictModel.setOrgDictEntryCode(mOrgDictItem==null?"":mOrgDictItem.getCode());
            dictModel.setOrgDictEntryName(mOrgDictItem == null ? "" : mOrgDictItem.getName());
        }
        return dictModel;
    }
}

+ 242 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/AdapterOrgController.java

@ -0,0 +1,242 @@
package com.yihu.jw.adapter.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.agModel.thirdpartystandard.AdapterOrgDetailModel;
import com.yihu.jw.agModel.thirdpartystandard.AdapterOrgModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.model.resource.MRsAdapterSchema;
import com.yihu.jw.resource.client.RsAdapterSchemaClient;
import com.yihu.jw.systemdict.service.ConventionalDictEntryClient;
import com.yihu.jw.adapter.service.AdapterOrgClient;
import com.yihu.jw.organization.service.OrganizationClient;
import com.yihu.jw.model.adaption.MAdapterOrg;
import com.yihu.jw.model.dict.MConventionalDict;
import com.yihu.jw.model.org.MOrganization;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/1/26.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapterOrg")
@RestController
@Api(protocols = "https", value = "adapter", description = "适配机构管理", tags = {"适配管理-适配机构管理"})
public class AdapterOrgController extends BaseController {
    @Autowired
    private AdapterOrgClient adapterOrgClient;
    @Autowired
    private ConventionalDictEntryClient dictEntryClient;
    @Autowired
    private OrganizationClient organizationClient;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private RsAdapterSchemaClient adapterSchemaClient;
    @RequestMapping(value = "/orgs", method = RequestMethod.GET)
    @ApiOperation(value = "适配采集标准")
    public Envelop searchAdapterOrg(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        try {
            ResponseEntity<Collection<MAdapterOrg>> responseEntity = adapterOrgClient.searchAdapterOrg(fields, filters, sorts, size, page);
            List<MAdapterOrg> mAdapterOrgs = (List<MAdapterOrg>) responseEntity.getBody();
            List<AdapterOrgModel> adapterOrgModels = new ArrayList<>();
            for (MAdapterOrg mAdapterOrg : mAdapterOrgs) {
                AdapterOrgModel adapterOrgModel = convertToModel(mAdapterOrg, AdapterOrgModel.class);
                String type = adapterOrgModel.getType();
                if (StringUtils.isNotEmpty(type)) {
                    MConventionalDict dict = dictEntryClient.getAdapterType(type);
                    adapterOrgModel.setTypeValue(dict == null ? "" : dict.getValue());
                }
                String orgCode = adapterOrgModel.getOrg();
                if (StringUtils.isNotEmpty(orgCode)) {
                    MOrganization mOrganization = organizationClient.getOrg(orgCode);
                    adapterOrgModel.setOrgValue(mOrganization == null ? "" : mOrganization.getFullName());
                }
                String parentId = adapterOrgModel.getParent();
                if (StringUtils.isNotEmpty(parentId)) {
                    MAdapterOrg adapterOrg = adapterOrgClient.getAdapterOrg(parentId);
                    adapterOrgModel.setParentValue(adapterOrg == null ? "" : adapterOrg.getName());
                }
                adapterOrgModels.add(adapterOrgModel);
            }
            return getResult(adapterOrgModels, getTotalCount(responseEntity), page, size);
        } catch (Exception ex) {
            return failedSystem();
        }
    }
    @RequestMapping(value = "/org/{code}", method = RequestMethod.GET)
    @ApiOperation(value = "获取适配采集标准")
    public Envelop getAdapterOrg(
            @ApiParam(name = "code", value = "代码", defaultValue = "")
            @PathVariable(value = "code") String code) throws Exception {
        MAdapterOrg mAdapterOrg = adapterOrgClient.getAdapterOrg(code);
        AdapterOrgDetailModel adapterOrgModel = convertAdapterOrgDetailModel(mAdapterOrg);
        if (adapterOrgModel == null) {
            return failed("适配机构信息获取失败!");
        }
        return success(adapterOrgModel);
    }
    @RequestMapping(value = "/org", method = RequestMethod.POST)
    @ApiOperation(value = "新增采集标准")
    public Envelop addAdapterOrg(
            @ApiParam(name = "adapterOrg", value = "采集机构模型", defaultValue = "")
            @RequestParam(value = "adapterOrg", required = false) String adapterOrg) {
        MAdapterOrg mAdapterOrg = null;
        try {
            AdapterOrgDetailModel detailModel = objectMapper.readValue(adapterOrg, AdapterOrgDetailModel.class);
            String errorMsg = "";
            if (StringUtils.isEmpty(detailModel.getName())) {
                errorMsg += "名称不能为空!";
            }
            if (StringUtils.isEmpty(detailModel.getOrg())) {
                errorMsg += "机构代码不能为空!";
            }
            if (StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            if (adapterOrgClient.isExistAdapterOrg(detailModel.getCode())) {
                return failed("该机构已存在采集标准!");
            }
            mAdapterOrg = convertToModel(detailModel, MAdapterOrg.class);
            mAdapterOrg = adapterOrgClient.addAdapterOrg(objectMapper.writeValueAsString(mAdapterOrg));
            if (mAdapterOrg == null) {
                return failed("新增失败!");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
        return success(convertAdapterOrgDetailModel(mAdapterOrg));
    }
    @RequestMapping(value = "/org/{code}", method = RequestMethod.PUT)
    @ApiOperation(value = "更新采集标准")
    public Envelop updateAdapterOrg(
            @ApiParam(name = "code", value = "代码", defaultValue = "")
            @PathVariable(value = "code") String code,
            @ApiParam(name = "name", value = "名称", defaultValue = "")
            @RequestParam(value = "name") String name,
            @ApiParam(name = "description", value = "描述", defaultValue = "")
            @RequestParam(value = "description", required = false) String description) throws Exception {
        String errorMsg = "";
        if (StringUtils.isEmpty(code)) {
            errorMsg += "代码不能为空!";
        }
        if (StringUtils.isEmpty(name)) {
            errorMsg += "名称不能为空!";
        }
        if (StringUtils.isNotEmpty(errorMsg)) {
            return failed(errorMsg);
        }
        MAdapterOrg mAdapterOrg = adapterOrgClient.updateAdapterOrg(code, name, description);
        if (mAdapterOrg == null) {
            return failed("修改失败!");
        }
        return success(convertAdapterOrgDetailModel(mAdapterOrg));
    }
    @RequestMapping(value = "/orgs", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除采集标准")
    public Envelop delAdapterOrg(
            @ApiParam(name = "codes", value = "代码", defaultValue = "")
            @RequestParam(value = "codes") String codes) {
        try {
            codes = trimEnd(codes, ",");
            ResponseEntity<List<MRsAdapterSchema>> responseEntity = adapterSchemaClient.getSchema("", "adapterVersion=" + codes + ";type=2", "", 1, 1);
            List<MRsAdapterSchema> mRsAdapterSchemas =  responseEntity.getBody();
            if(mRsAdapterSchemas!=null&&mRsAdapterSchemas.size()>0){
                return failed("删除失败,第三方标准已经被资源适配!");
            }
            if (StringUtils.isEmpty(codes)) {
                return failed("请选择需要删除的内容!");
            }
            boolean result = adapterOrgClient.delAdapterOrg(codes);
            if (!result) {
                return failed("删除失败!");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
        return success(null);
    }
    @RequestMapping(value = "/{org}/isExistAdapterData", method = RequestMethod.GET)
    @ApiOperation(value = "判断采集机构是否存在采集数据")
    public boolean orgIsExistData(
            @ApiParam(name = "org_code", value = "机构", defaultValue = "")
            @PathVariable(value = "org_code") String orgCode) throws Exception {
        return adapterOrgClient.orgIsExistData(orgCode);
    }
    public AdapterOrgDetailModel convertAdapterOrgDetailModel(MAdapterOrg mAdapterOrg) {
        AdapterOrgDetailModel detailModel = convertToModel(mAdapterOrg, AdapterOrgDetailModel.class);
        String type = detailModel.getType();
        if (StringUtils.isNotEmpty(type)) {
            MConventionalDict dict = dictEntryClient.getAdapterType(type);
            detailModel.setTypeValue(dict == null ? "" : dict.getValue());
        }
        String orgCode = detailModel.getOrg();
        if (StringUtils.isNotEmpty(orgCode)) {
            MOrganization mOrganization = organizationClient.getOrg(orgCode);
            detailModel.setOrgValue(mAdapterOrg == null ? "" : mOrganization.getFullName());
        }
        String parentId = detailModel.getParent();
        if (StringUtils.isNotEmpty(parentId)) {
            MAdapterOrg adapterOrg = adapterOrgClient.getAdapterOrg(parentId);
            detailModel.setParentValue(adapterOrg == null ? "" : adapterOrg.getName());
        }
        return detailModel;
    }
}

+ 272 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgAdapterPlanController.java

@ -0,0 +1,272 @@
package com.yihu.jw.adapter.controller;
import com.yihu.jw.systemdict.service.ConventionalDictEntryClient;
import com.yihu.jw.adapter.service.AdapterOrgClient;
import com.yihu.jw.adapter.service.PlanClient;
import com.yihu.jw.adapter.utils.ExtendController;
import com.yihu.jw.agModel.adapter.AdapterPlanDetailModel;
import com.yihu.jw.agModel.adapter.AdapterPlanModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.model.adaption.MAdapterOrg;
import com.yihu.jw.model.adaption.MAdapterPlan;
import com.yihu.jw.model.dict.MConventionalDict;
import com.yihu.hos.model.standard.MSTDVersion;
import com.yihu.jw.std.service.CDAVersionClient;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.util.validate.ValidateResult;
import io.swagger.annotations.Api;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
 * @author lincl
 * @version 1.0
 * @created 2016.3.1
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapter")
@RestController
@Api(protocols = "https", value = "adapter", description = "适配方案", tags = {"适配管理-适配方案"})
public class OrgAdapterPlanController extends ExtendController<AdapterPlanModel> {
    @Autowired
    PlanClient planClient;
    @Autowired
    ConventionalDictEntryClient dictEntryClient;
    @Autowired
    AdapterOrgClient adapterOrgClient;
    @Autowired
    CDAVersionClient cdaVersionClient;
    @RequestMapping(value = "/plan", method = RequestMethod.POST)
    @ApiOperation(value = "新增适配方案信息")
    public Envelop addAdapterPlan(
            @ApiParam(name = "model", value = "数据模型")
            @RequestParam(value = "model") String model,
            @ApiParam(name = "isCover", value = "是否覆盖")
            @RequestParam(value = "isCover") String isCover) {
        try {
            AdapterPlanModel dataModel = jsonToObj(model);
            ValidateResult validateResult = validate(dataModel);
            if (!validateResult.isRs()) {
                return failed(validateResult.getMsg());
            }
            AdapterPlanDetailModel detailModel = convertToModel(dataModel, AdapterPlanDetailModel.class);
            MAdapterPlan mAdapterPlan = planClient.saveAdapterPlan(toEncodeJson(detailModel), isCover);
            if (mAdapterPlan == null) {
                return failed("保存失败!");
            }
            AdapterPlanModel adapterPlanModel = ConvertAdapterPlanModel(convertToModel(mAdapterPlan, AdapterPlanModel.class));
            return success(adapterPlanModel);
        } catch (Exception e) {
            e.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/plan", method = RequestMethod.PUT)
    @ApiOperation(value = "修改适配方案信息")
    public Envelop updateAdapterPlan(
            @ApiParam(name = "model", value = "数据模型")
            @RequestParam(value = "model") String model) {
        try {
            AdapterPlanModel dataModel = jsonToObj(model);
            ValidateResult validateResult = validate(dataModel);
            if (!validateResult.isRs()) {
                return failed(validateResult.getMsg());
            }
            AdapterPlanDetailModel detailModel = convertToModel(dataModel, AdapterPlanDetailModel.class);
            MAdapterPlan mAdapterPlan = planClient.updateAdapterPlan(detailModel.getId(), toEncodeJson(detailModel));
            if (mAdapterPlan == null) {
                return failed("保存失败!");
            }
            AdapterPlanModel adapterPlanModel = ConvertAdapterPlanModel(convertToModel(mAdapterPlan, AdapterPlanModel.class));
            return success(adapterPlanModel);
        } catch (ApiException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/plans", method = RequestMethod.GET)
    @ApiOperation(value = "适配方案搜索")
    public Envelop searchAdapterPlan(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        try {
            ResponseEntity<Collection<MAdapterPlan>> responseEntity = planClient.searchAdapterPlan(fields, filters, sorts, size, page);
            List<MAdapterPlan> mAdapterPlans = (List<MAdapterPlan>) responseEntity.getBody();
            List<AdapterPlanModel> adapterPlanModels = (List<AdapterPlanModel>) convertToModels(
                    mAdapterPlans,
                    new ArrayList<AdapterPlanModel>(mAdapterPlans.size()), AdapterPlanModel.class, null);
            if (adapterPlanModels != null) {
                for (int i = 0; i < adapterPlanModels.size(); i++) {
                    ConvertAdapterPlanModel(adapterPlanModels.get(i));
                }
            }
            return getResult(adapterPlanModels, getTotalCount(responseEntity), page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/plan/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "获取适配方案信息")
    public Envelop getAdapterPlanById(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") Long id) {
        try {
            AdapterPlanModel adapterPlanModel = getModel(planClient.getAdapterPlanById(id));
            if (adapterPlanModel == null) {
                return failed("数据获取失败!");
            }
            adapterPlanModel = ConvertAdapterPlanModel(adapterPlanModel);
            return success(adapterPlanModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/plans", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除适配方案", notes = "删除适配方案信息,批量删除时,Id以逗号隔开")
    public Envelop delAdapterPlan(
            @ApiParam(name = "ids", value = "方案ID")
            @RequestParam("ids") String ids) throws Exception {
        ids = trimEnd(ids, ",");
        if (StringUtils.isEmpty(ids)) {
            return failed("请选择需要删除的方案!");
        }
        boolean result = planClient.delAdapterPlan(ids);
        if (!result) {
            return failed("删除失败!");
        }
        return success(null);
    }
    @RequestMapping(value = "/plans/list", method = RequestMethod.GET)
    @ApiOperation(value = "适配方案信息下拉")
    public List<Map<String, String>> getAdapterPlanList(
            @ApiParam(name = "type", value = "类型")
            @RequestParam(value = "type") String type,
            @ApiParam(name = "versionCode", value = "版本号")
            @RequestParam(value = "versionCode") String versionCode) throws Exception {
        return planClient.getAdapterPlanList(type, versionCode);
    }
    @RequestMapping(value = "/plan/adapterCustomizes/{plan_id}", method = RequestMethod.GET)
    @ApiOperation(value = "获取定制信息")
    public Map getAdapterCustomize(
            @ApiParam(name = "plan_id", value = "方案ID")
            @PathVariable(value = "plan_id") long planId,
            @ApiParam(name = "version", value = "版本", defaultValue = "")
            @RequestParam("version") String version) throws Exception {
        Map map = planClient.getAdapterCustomize(planId, version);
        return map;
    }
//    @RequestMapping(value = "/plan/adapterDataSet/{plan_id}", method = RequestMethod.POST)
//    @ApiOperation(value = "定制数据集")
//    public boolean adapterDataSet(
//            @ApiParam(name = "plan_id", value = "编号", defaultValue = "")
//            @PathVariable("plan_id") Long planId,
//            @ApiParam(name = "customizeData", value = "customizeData", allowMultiple = true, defaultValue = "")
//            @RequestParam("customizeData") String customizeData) throws Exception {
//
//        return planClient.adapterDataSet(planId, customizeData);
//    }
    @RequestMapping(value = "/plan/{plan_id}/public", method = RequestMethod.PUT)
    @ApiOperation(value = "发布方案")
    public boolean adapterDispatch(
            @ApiParam(name = "plan_id", value = "方案ID")
            @PathVariable(value = "plan_id") long planId) throws Exception {
        boolean b = planClient.adapterDispatch(planId);
        return b;
    }
    public AdapterPlanModel ConvertAdapterPlanModel(AdapterPlanModel adapterPlanModel)
    {
        if (adapterPlanModel == null) {
            return null;
        }
        Long parentId = adapterPlanModel.getParentId();
        if(parentId!=null && parentId!=0) {
            AdapterPlanModel parent = getModel(planClient.getAdapterPlanById(parentId));
            if(parent!=null)
                adapterPlanModel.setParentName(parent.getName());
        }
        String type = adapterPlanModel.getType();
        if(StringUtils.isNotEmpty(type))
        {
            MConventionalDict dict =dictEntryClient.getAdapterType(type);
            if(dict!=null)
            {
                adapterPlanModel.setTypeValue(dict.getValue());
            }
        }
        String orgCode = adapterPlanModel.getOrg();
        if(StringUtils.isNotEmpty(orgCode))
        {
            MAdapterOrg org = adapterOrgClient.getAdapterOrg(orgCode);
            if(org!=null)
            {
                adapterPlanModel.setOrgValue(org.getName());
            }
        }
        String versionId = adapterPlanModel.getVersion();
        if(StringUtils.isNotEmpty(versionId))
        {
            MSTDVersion version = cdaVersionClient.getVersion(versionId);
            if(version!=null)
            {
                adapterPlanModel.setVersionName(version.getVersionName());
            }
        }
        return adapterPlanModel;
    }
}

+ 204 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgDataSetController.java

@ -0,0 +1,204 @@
package com.yihu.jw.adapter.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.agModel.thirdpartystandard.OrgDataSetDetailModel;
import com.yihu.jw.constants.AgAdminConstants;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.adapter.service.OrgDataSetClient;
import com.yihu.jw.model.adaption.MOrgDataSet;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/1/27.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapter/org")
@RestController
@Api(protocols = "https", value = "adapter", description = "数据集", tags = {"第三方标准-数据集"})
public class OrgDataSetController extends BaseController {
    @Autowired
    private OrgDataSetClient orgDataSetClient;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "/data_set/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询实体")
    public Envelop getOrgDataSet(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id) {
        try {
            MOrgDataSet mOrgDataSet = orgDataSetClient.getOrgDataSet(id);
            OrgDataSetDetailModel dataSetModel = convertToOrgDataSetDetailModel(mOrgDataSet);
            if (dataSetModel == null) {
                return failed("数据集信息获取失败!");
            }
            return success(dataSetModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/data_set", method = RequestMethod.POST)
    @ApiOperation(value = "创建机构数据集")
    public Envelop saveOrgDataSet(
            @ApiParam(name = "json_data", value = "json_data", defaultValue = "")
            @RequestParam(value = "json_data") String jsonData) {
        try {
            OrgDataSetDetailModel detailModel = objectMapper.readValue(jsonData, OrgDataSetDetailModel.class);
            String errorMsg = "";
            if (StringUtils.isEmpty(detailModel.getOrganization())) {
                errorMsg += "机构代码不能为空!";
            }
            if (StringUtils.isEmpty(detailModel.getCode())) {
                errorMsg += "数据集代码不能为空!";
            }
            if (StringUtils.isEmpty(detailModel.getName())) {
                errorMsg += "数据集名称不能为空!";
            }
            if (StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            boolean isExist = orgDataSetClient.dataSetIsExist(detailModel.getOrganization(), detailModel.getCode());
            MOrgDataSet mOrgDataSet = convertToMOrgDataSet(detailModel);
            if (detailModel.getId() == 0) {
                if (isExist) {
                    return failed("数据集已存在!");
                }
                mOrgDataSet = orgDataSetClient.createOrgDataSet(objectMapper.writeValueAsString(mOrgDataSet));
            } else {
                MOrgDataSet orgDataSet = orgDataSetClient.getOrgDataSet(detailModel.getId());
                if (!orgDataSet.getCode().equals(detailModel.getCode())
                        && isExist) {
                    return failed("数据集已存在!");
                }
                BeanUtils.copyProperties(mOrgDataSet, orgDataSet, "id", "createDate", "createUser", "sequence");
                mOrgDataSet = orgDataSetClient.updateOrgDataSet(objectMapper.writeValueAsString(orgDataSet));
            }
            detailModel = convertToOrgDataSetDetailModel(mOrgDataSet);
            if (detailModel == null) {
                return failed("保存失败!");
            }
            return success(detailModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/data_set/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除机构数据集")
    public Envelop deleteOrgDataSet(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id) {
        try {
            if (id == 0) {
                return failed("请选择需要删除数据集!");
            }
            boolean result = orgDataSetClient.deleteOrgDataSet(id);
            if (!result) {
                return failed("删除失败!");
            }
            return success(null);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/data_sets", method = RequestMethod.GET)
    @ApiOperation(value = "条件查询")
    public Envelop searchAdapterOrg(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        try {
            ResponseEntity<Collection<MOrgDataSet>> responseEntity = orgDataSetClient.searchAdapterOrg(fields, filters, sorts, size, page);
            List<MOrgDataSet> mOrgDataSets = (List<MOrgDataSet>) responseEntity.getBody();
            List<OrgDataSetDetailModel> detailModels =new ArrayList<> ();
            //List<OrgDataSetDetailModel>) convertToModels(mOrgDataSets, new ArrayList<OrgDataSetDetailModel>(mOrgDataSets.size()), OrgDataSetDetailModel.class, null);
            for(MOrgDataSet mOrgDataSet : mOrgDataSets)
            {
                OrgDataSetDetailModel detailModel = convertToOrgDataSetDetailModel(mOrgDataSet);
                detailModels.add(detailModel);
            }
            return getResult(detailModels, getTotalCount(responseEntity), page, size);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/data_set", method = RequestMethod.GET)
    public Envelop getDataSetBySequence(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "sequence") long sequence) {
        try {
            MOrgDataSet mOrgDataSet = orgDataSetClient.getDataSetBySequence(orgCode, sequence);
            OrgDataSetDetailModel dataSetModel = convertToOrgDataSetDetailModel(mOrgDataSet);
            return success(dataSetModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    public MOrgDataSet convertToMOrgDataSet(OrgDataSetDetailModel detailModel)
    {
        if(detailModel==null)
        {
            return null;
        }
        MOrgDataSet mOrgDataSet = convertToModel(detailModel,MOrgDataSet.class);
        mOrgDataSet.setCreateDate(StringToDate(detailModel.getCreateDate(), AgAdminConstants.DateTimeFormat));
        mOrgDataSet.setUpdateDate(StringToDate(detailModel.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        return mOrgDataSet;
    }
    public OrgDataSetDetailModel convertToOrgDataSetDetailModel(MOrgDataSet mOrgDataSet)
    {
        if(mOrgDataSet==null)
        {
            return null;
        }
        OrgDataSetDetailModel detailModel = convertToModel(mOrgDataSet, OrgDataSetDetailModel.class);
        detailModel.setCreateDate(DateToString(mOrgDataSet.getCreateDate(),AgAdminConstants.DateTimeFormat));
        detailModel.setUpdateDate(DateToString(mOrgDataSet.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        return detailModel;
    }
}

+ 187 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgDictController.java

@ -0,0 +1,187 @@
package com.yihu.jw.adapter.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.adapter.service.OrgDictClient;
import com.yihu.jw.agModel.thirdpartystandard.OrgDictDetailModel;
import com.yihu.jw.constants.AgAdminConstants;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.model.adaption.MOrgDict;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/1/27.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapter/org")
@RestController
@Api(protocols = "https", value = "adapter", description = "机构字典", tags = {"第三方标准-机构字典"})
public class OrgDictController extends BaseController {
    @Autowired
    private OrgDictClient orgDictClient;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "/dict", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询实体")
    public Envelop getOrgDict(
            @ApiParam(name = "id", value = "查询条件", defaultValue = "")
            @RequestParam(value = "id", required = false) long id) throws Exception {
        MOrgDict mOrgDict = orgDictClient.getOrgDict(id);
        if (mOrgDict == null) {
            return failed("字典明细获取失败!");
        }
        OrgDictDetailModel detailModel = convertToModel(mOrgDict, OrgDictDetailModel.class);
        return success(detailModel);
    }
    @RequestMapping(value = "/dict", method = RequestMethod.POST)
    @ApiOperation(value = "创建机构字典")
    public Envelop saveOrgDict(
            @ApiParam(name = "json_data", value = "字典信息", defaultValue = "")
            @RequestParam(value = "json_data") String jsonData) throws Exception {
        OrgDictDetailModel detailModel = objectMapper.readValue(jsonData, OrgDictDetailModel.class);
        String errorMsg = "";
        if (StringUtils.isEmpty(detailModel.getCode())) {
            errorMsg += "代码不能为空!";
        }
        if (StringUtils.isEmpty(detailModel.getName())) {
            errorMsg += "值不能为空!";
        }
        if (StringUtils.isEmpty(detailModel.getOrganization())) {
            errorMsg += "请先选择对应的机构!";
        }
        if (StringUtils.isNotEmpty(errorMsg)) {
            return failed(errorMsg);
        }
        boolean isExist = orgDictClient.isExistDict(detailModel.getOrganization(), detailModel.getCode());
        MOrgDict mOrgDict = convertToMOrgDict(detailModel);
        if (mOrgDict.getId() == 0) {
            if (isExist) {
                return failed("字典已存在!");
            }
            mOrgDict = orgDictClient.createOrgDict(objectMapper.writeValueAsString(mOrgDict));
        } else {
            MOrgDict orgDict = orgDictClient.getOrgDict(mOrgDict.getId());
            if (!orgDict.getCode().equals(mOrgDict.getCode())
                    && isExist) {
                return failed("字典已存在");
            }
            BeanUtils.copyProperties(mOrgDict, orgDict, "id", "createDate", "createUser", "sequence");
            mOrgDict = orgDictClient.updateOrgDict(objectMapper.writeValueAsString(orgDict));
        }
        if (mOrgDict == null) {
            return failed("保存失败");
        }
        detailModel = convertToOrgDictDetailModel(mOrgDict);
        return success(detailModel);
    }
    @RequestMapping(value = "/dict/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除机构字典")
    public Envelop deleteOrgDict(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id) {
        boolean result = orgDictClient.deleteOrgDict(id);
        if (!result) {
            return failed("删除失败!");
        }
        return success(null);
    }
    @RequestMapping(value = "/dicts", method = RequestMethod.GET)
    @ApiOperation(value = "条件查询")
    public Envelop searchOrgDicts(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ResponseEntity<Collection<MOrgDict>> responseEntity = orgDictClient.searchOrgDicts(fields, filters, sorts, size, page);
        List<MOrgDict> dicts = (List<MOrgDict>) responseEntity.getBody();
        List<OrgDictDetailModel> detailModels =new ArrayList<> ();
        for(MOrgDict mOrgDict : dicts)
        {
            OrgDictDetailModel detailModel = convertToOrgDictDetailModel(mOrgDict);
            detailModels.add(detailModel);
        }
        return getResult(detailModels, getTotalCount(responseEntity), page, size);
    }
    @RequestMapping(value = "/dict/combo", method = RequestMethod.GET)
    @ApiOperation(value = "机构字典下拉")
    public List<String> getOrgDict(
            @ApiParam(name = "orgCode", value = "机构代码", defaultValue = "")
            @RequestParam(value = "orgCode", required = false) String orgCode) throws Exception {
        return orgDictClient.getOrgDict(orgCode);
    }
    @RequestMapping(value = "/dict/org_dict", method = RequestMethod.GET)
    public Envelop getOrgDictBySequence(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "sequence") int sequence) {
        try {
            MOrgDict mOrgDict = orgDictClient.getOrgDictBySequence(orgCode, sequence);
            OrgDictDetailModel detailModel = convertToOrgDictDetailModel(mOrgDict);
            return success(detailModel);
        } catch (Exception ex) {
            return failedSystem();
        }
    }
    public OrgDictDetailModel convertToOrgDictDetailModel(MOrgDict mOrgDict)
    {
        if(mOrgDict==null)
        {
            return null;
        }
        OrgDictDetailModel detailModel = convertToModel(mOrgDict,OrgDictDetailModel.class);
        detailModel.setCreateDate(DateToString(mOrgDict.getCreateDate(), AgAdminConstants.DateTimeFormat));
        detailModel.setUpdateDate(DateToString(mOrgDict.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        return detailModel;
    }
    public MOrgDict convertToMOrgDict(OrgDictDetailModel detailModel)
    {
        if(detailModel==null)
        {
            return null;
        }
        MOrgDict mOrgDict = convertToModel(detailModel,MOrgDict.class);
        mOrgDict.setCreateDate(StringToDate(detailModel.getCreateDate(),AgAdminConstants.DateTimeFormat));
        mOrgDict.setUpdateDate(StringToDate(detailModel.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        return mOrgDict;
    }
}

+ 196 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgDictEntryController.java

@ -0,0 +1,196 @@
package com.yihu.jw.adapter.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.agModel.thirdpartystandard.OrgDictEntryDetailModel;
import com.yihu.jw.agModel.thirdpartystandard.OrgDictEntryModel;
import com.yihu.jw.constants.AgAdminConstants;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.adapter.service.OrgDictEntryClient;
import com.yihu.jw.model.adaption.MOrgDictItem;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/3/2.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapter/org")
@RestController
@Api(protocols = "https", value = "adapter", description = "机构字典项", tags = {"第三方标准-机构字典项"})
public class OrgDictEntryController extends BaseController {
    @Autowired
    private OrgDictEntryClient orgDictEntryClient;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "/item/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "获取字典项信息")
    public Envelop getOrgDictItem(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id) throws Exception {
        MOrgDictItem mOrgDictItem = orgDictEntryClient.getOrgDictItem(id);
        if (mOrgDictItem == null) {
            return failed("字典明细获取失败!");
        }
        OrgDictEntryDetailModel detailModel = convertToOrgDictEntryDetailModel(mOrgDictItem);
        return success(detailModel);
    }
    @RequestMapping(value = "/item", method = RequestMethod.POST)
    @ApiOperation(value = "新增字典项")
    public Envelop saveOrgDictItem(
            @ApiParam(name = "json_data", value = "字典项信息", defaultValue = "")
            @RequestParam(value = "json_data") String jsonData) throws Exception {
        OrgDictEntryDetailModel detailModel = objectMapper.readValue(jsonData, OrgDictEntryDetailModel.class);
        String errorMsg = "";
        if (StringUtils.isEmpty(detailModel.getCode())) {
            errorMsg += "代码不能为空!";
        }
        if (StringUtils.isEmpty(detailModel.getName())) {
            errorMsg += "值不能为空!";
        }
        if (detailModel.getOrgDict() == 0) {
            errorMsg += "请先选择对应的字典!";
        }
        if (StringUtils.isEmpty(detailModel.getOrganization())) {
            errorMsg += "请先选择对应的机构!";
        }
        if (StringUtils.isNotEmpty(errorMsg)) {
            return failed(errorMsg);
        }
        boolean isExist = orgDictEntryClient.isExistDictItem(detailModel.getOrgDict(),detailModel.getOrganization(),detailModel.getCode());
        MOrgDictItem mOrgDictItem = convertToMOrgDictItem(detailModel);
        if (mOrgDictItem.getId() == 0) {
            if(isExist)
            {
                return failed("字典项已存在!");
            }
            mOrgDictItem = orgDictEntryClient.createOrgDictItem(objectMapper.writeValueAsString(mOrgDictItem));
        } else {
            MOrgDictItem dictItem = orgDictEntryClient.getOrgDictItem(detailModel.getId());
            if(!dictItem.getCode().equals(detailModel.getCode())
                    && isExist)
            {
                return failed("字典项已存在!");
            }
            BeanUtils.copyProperties(mOrgDictItem, dictItem, "id", "createDate", "createUser", "sequence");
            mOrgDictItem = orgDictEntryClient.updateDictItem(objectMapper.writeValueAsString(dictItem));
        }
        if (mOrgDictItem == null) {
            return failed("保存失败!");
        }
        detailModel = convertToOrgDictEntryDetailModel(mOrgDictItem);
        return success(detailModel);
    }
    @RequestMapping(value = "/item", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除字典项")
    public Envelop deleteOrgDictItem(
            @ApiParam(name = "ids", value = "编号", defaultValue = "")
            @RequestParam(value = "ids", required = false) String ids) throws Exception {
        ids = trimEnd(ids,",");
        boolean result = orgDictEntryClient.deleteOrgDictItemList(ids);
        if(!result)
        {
            return failed("删除失败!");
        }
        return success(null);
    }
    @RequestMapping(value = "/items", method = RequestMethod.GET)
    @ApiOperation(value = "分页查询")
    public Envelop searchOrgDictItems(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ResponseEntity<Collection<MOrgDictItem>> responseEntity = orgDictEntryClient.searchOrgDictItems(fields, filters, sorts, size, page);
        List<MOrgDictItem> dictItems = (List<MOrgDictItem>) responseEntity.getBody();
        List<OrgDictEntryModel> detailModels = (List<OrgDictEntryModel>) convertToModels(dictItems,
                                                                                                    new ArrayList<OrgDictEntryModel>(dictItems.size()),
                                                                                                    OrgDictEntryModel.class,
                                                                                                    null);
        return getResult(detailModels,getTotalCount(responseEntity),page,size);
    }
    @RequestMapping(value = "/items/combo", method = RequestMethod.GET)
    @ApiOperation(value = "机构字典项下拉")
    public List<String> getOrgDictEntry(
            @ApiParam(name = "orgDictSeq", value = "字典seq", defaultValue = "")
            @RequestParam(value = "orgDictSeq") long orgDictSeq,
            @ApiParam(name = "orgCode", value = "机构代码", defaultValue = "")
            @RequestParam(value = "orgCode") String orgCode) throws Exception {
        return (List<String>)orgDictEntryClient.getOrgDictEntry(orgDictSeq,orgCode);
    }
    @RequestMapping(value = "/dict/dict_entry", method = RequestMethod.GET)
    public Envelop getOrgDictEntryBySequence(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "sequence") int sequence) {
        try {
            MOrgDictItem mOrgDictItem = orgDictEntryClient.getOrgDicEntryBySequence(orgCode, sequence);
            OrgDictEntryDetailModel detailModel = convertToOrgDictEntryDetailModel(mOrgDictItem);
            return success(detailModel);
        } catch (Exception ex) {
            return failedSystem();
        }
    }
    public OrgDictEntryDetailModel convertToOrgDictEntryDetailModel(MOrgDictItem mOrgDictItem)
    {
        if(mOrgDictItem==null)
        {
            return null;
        }
        OrgDictEntryDetailModel detailModel = convertToModel(mOrgDictItem,OrgDictEntryDetailModel.class);
        detailModel.setCreateDate(DateToString(mOrgDictItem.getCreateDate(), AgAdminConstants.DateTimeFormat));
        detailModel.setUpdateDate(DateToString(mOrgDictItem.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        return detailModel;
    }
    public MOrgDictItem convertToMOrgDictItem(OrgDictEntryDetailModel detailModel)
    {
        if(detailModel==null)
        {
            return null;
        }
        MOrgDictItem mOrgDictItem = convertToModel(detailModel,MOrgDictItem.class);
        mOrgDictItem.setCreateDate(StringToDate(detailModel.getCreateDate(),AgAdminConstants.DateTimeFormat));
        mOrgDictItem.setUpdateDate(StringToDate(detailModel.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        return mOrgDictItem;
    }
}

+ 200 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/controller/OrgMetaDataController.java

@ -0,0 +1,200 @@
package com.yihu.jw.adapter.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.agModel.thirdpartystandard.OrgMetaDataDetailModel;
import com.yihu.jw.constants.AgAdminConstants;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.adapter.service.OrgDataSetClient;
import com.yihu.jw.adapter.service.OrgMetaDataClient;
import com.yihu.jw.model.adaption.MOrgDataSet;
import com.yihu.jw.model.adaption.MOrgMetaData;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/3/1.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/adapter/org")
@RestController
@Api(protocols = "https", value = "adapter", description = "数据元", tags = {"第三方标准-数据元"})
public class OrgMetaDataController extends BaseController {
    @Autowired
    private OrgMetaDataClient orgMetaDataClient;
    @Autowired
    private OrgDataSetClient orgDataSetClient;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "/meta_data/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取机构数据元")
    public Envelop getOrgMetaData(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id) throws Exception {
        MOrgMetaData mOrgMetaData = orgMetaDataClient.getOrgMetaData(id);
        OrgMetaDataDetailModel detailModel = convertToOrgMetaDataDetailModel(mOrgMetaData);
        if (detailModel == null) {
            return failed("数据元信息获取失败!");
        }
        return success(detailModel);
    }
    @RequestMapping(value = "/meta_data", method = RequestMethod.POST)
    @ApiOperation(value = "新增数据元")
    public Envelop saveOrgMetaData(
            @ApiParam(name = "json_data", value = "json_data", defaultValue = "")
            @RequestParam(value = "json_data") String jsonData) throws Exception {
        OrgMetaDataDetailModel detailModel = objectMapper.readValue(jsonData, OrgMetaDataDetailModel.class);
        String errorMsg = "";
        if (StringUtils.isEmpty(detailModel.getCode())) {
            errorMsg += "代码不能为空!";
        }
        if (StringUtils.isEmpty(detailModel.getName())) {
            errorMsg += "名称不能为空!";
        }
        if (StringUtils.isEmpty(detailModel.getOrganization())) {
            errorMsg += "机构不能为空!";
        }
        if (StringUtils.isNotEmpty(errorMsg)) {
            return failed(errorMsg);
        }
        boolean isExist = orgMetaDataClient.isExistMetaData(detailModel.getOrgDataSet(),detailModel.getOrganization(),detailModel.getCode());
        MOrgMetaData mOrgMetaData = convertToMOrgMetaData(detailModel);
        if (detailModel.getId() == 0) {
            if(isExist)
            {
                return failed("数据元已存在!");
            }
            mOrgMetaData = orgMetaDataClient.createOrgMetaData(objectMapper.writeValueAsString(mOrgMetaData));
        } else {
            MOrgMetaData orgMetaData = orgMetaDataClient.getOrgMetaData(detailModel.getId());
            if(!orgMetaData.getCode().equals(mOrgMetaData.getCode())
                    && isExist){
                return failed("数据元已存在!");
            }
            BeanUtils.copyProperties(mOrgMetaData, orgMetaData, "id", "createDate", "createUser", "columnType", "columnLength", "sequence");
            mOrgMetaData = orgMetaDataClient.updateOrgMetaData(objectMapper.writeValueAsString(orgMetaData));
        }
        detailModel = convertToOrgMetaDataDetailModel(mOrgMetaData);
        if (detailModel == null) {
            return failed("保存失败!");
        }
        return success(detailModel);
    }
    @RequestMapping(value = "/meta_data", method = RequestMethod.DELETE)
    @ApiOperation(value = "批量删除数据元")
    public Envelop deleteOrgMetaDataList(
            @ApiParam(name = "ids", value = "编号集", defaultValue = "")
            @RequestParam(value = "ids") String ids) throws Exception {
        ids = trimEnd(ids,",");
        if(StringUtils.isEmpty(ids))
        {
            return failed("请选择需要删除的数据元!");
        }
        boolean result = orgMetaDataClient.deleteOrgMetaDataList(ids);
        if(!result)
        {
            return failed("删除失败!");
        }
        return success(null);
    }
    @RequestMapping(value = "/meta_datas", method = RequestMethod.GET)
    @ApiOperation(value = "分页查询")
    public Envelop searchOrgMetaData(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ResponseEntity<Collection<MOrgMetaData>> responseEntity = orgMetaDataClient.searchOrgMetaDatas(fields,filters,sorts,size,page);
        List<MOrgMetaData> mOrgMetaDatas = (List<MOrgMetaData>)responseEntity.getBody();
        List<OrgMetaDataDetailModel> detailModels = new ArrayList<> ();//List<OrgMetaDataDetailModel>)convertToModels(mOrgMetaDatas,new ArrayList<OrgMetaDataDetailModel>(mOrgMetaDatas.size()),OrgMetaDataDetailModel.class,null);
        for(MOrgMetaData mOrgMetaData:mOrgMetaDatas)
        {
            OrgMetaDataDetailModel detailModel = convertToOrgMetaDataDetailModel(mOrgMetaData);
            detailModels.add(detailModel);
        }
        return getResult(detailModels,getTotalCount(responseEntity),page,size);
    }
    @RequestMapping(value = "/meta_data", method = RequestMethod.GET)
    public Envelop getMetaDataBySequence(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "sequence") int sequence) {
        try {
            MOrgMetaData mOrgMetaData = orgMetaDataClient.getMetaDataBySequence(orgCode, sequence);
            OrgMetaDataDetailModel metaDataDetailModel = convertToOrgMetaDataDetailModel(mOrgMetaData);
            return success(metaDataDetailModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    public OrgMetaDataDetailModel convertToOrgMetaDataDetailModel(MOrgMetaData mOrgMetaData)
    {
        if(mOrgMetaData==null)
        {
            return null;
        }
        OrgMetaDataDetailModel metaDataDetailModel = convertToModel(mOrgMetaData, OrgMetaDataDetailModel.class);
        metaDataDetailModel.setCreateDate(DateToString(mOrgMetaData.getCreateDate(), AgAdminConstants.DateTimeFormat));
        metaDataDetailModel.setUpdateDate(DateToString(mOrgMetaData.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        int dataSetSeq = metaDataDetailModel.getOrgDataSet();
        if (dataSetSeq!=0)
        {
            MOrgDataSet mOrgDataSet = orgDataSetClient.getDataSetBySequence(metaDataDetailModel.getOrganization(),dataSetSeq);
            metaDataDetailModel.setDataSetCode(mOrgDataSet==null?"":mOrgDataSet.getCode());
            metaDataDetailModel.setDataSetName(mOrgDataSet==null?"":mOrgDataSet.getName());
        }
        return metaDataDetailModel;
    }
    public MOrgMetaData convertToMOrgMetaData(OrgMetaDataDetailModel detailModel)
    {
        if(detailModel==null)
        {
            return null;
        }
        MOrgMetaData mOrgMetaData = convertToModel(detailModel,MOrgMetaData.class);
        mOrgMetaData.setCreateDate(StringToDate(detailModel.getCreateDate(),AgAdminConstants.DateTimeFormat));
        mOrgMetaData.setUpdateDate(StringToDate(detailModel.getUpdateDate(),AgAdminConstants.DateTimeFormat));
        return mOrgMetaData;
    }
}

+ 116 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/AdapterDataSetClient.java

@ -0,0 +1,116 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MAdapterDataSet;
import com.yihu.jw.model.adaption.MAdapterDataVo;
import com.yihu.jw.model.adaption.MAdapterRelationship;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
/**
 *
 * @author lincl
 * @version 1.0
 * @created 2016.2.3
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0 + "/adapter")
@ApiIgnore
public interface AdapterDataSetClient {
    @RequestMapping(value = "/plan/{planId}/datasets", method = RequestMethod.GET)
    @ApiOperation(value = "根据方案ID及查询条件查询数据集适配关系")
    ResponseEntity<Collection<MAdapterRelationship>> searchAdapterDataSet(
            @ApiParam(name = "planId", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "planId") Long planId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/plan/{planId}/datasets/{dataSetId}/datametas", method = RequestMethod.GET)
    @ApiOperation(value = "根据dataSetId搜索数据元适配关系")
    ResponseEntity<Collection<MAdapterDataVo>> searchAdapterMetaData(
            @ApiParam(name = "planId", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "planId") Long planId,
            @ApiParam(name = "dataSetId", value = "数据集id", defaultValue = "")
            @PathVariable(value = "dataSetId") Long dataSetId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/datameta/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据数据集ID获取数据元适配关系明细")
    MAdapterDataSet getAdapterMetaData(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") Long id);
    @RequestMapping(value = "/datameta/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改数据元映射关系")
    MAdapterDataSet updateAdapterMetaData(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") Long id,
            @ApiParam(name = "jsonModel", value = "数据元模型", defaultValue = "")
            @RequestBody String jsonModel);
    @RequestMapping(value = "/datameta", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "新增数据元映射关系")
    MAdapterDataSet createAdapterMetaData(
            @ApiParam(name = "jsonModel", value = "数据元模型", defaultValue = "")
            @RequestBody String jsonModel);
    @RequestMapping(value = "/datametas", method = RequestMethod.DELETE)
    @ApiOperation(value = "批量删除数据元映射关系")
    boolean delMetaData(
            @RequestParam("ids") String ids);
    @RequestMapping(value = "/data_set/{data_set_id}/is_left/meta", method = RequestMethod.GET)
    @ApiOperation(value = "判断除了metaIds之外是否还存在其他的数据元")
    boolean isLeftMeta(
            @RequestParam("plan_id") long planId,
            @PathVariable("data_set_id") long dataSetId,
            @RequestParam("meta_ids") String metaIds);
    @RequestMapping(value = "/plan/{planId}/data_set/{data_set_id}/std_meta", method = RequestMethod.GET)
    @ApiOperation(value = "过滤后的标准字典项分页查询")
    ResponseEntity<Collection<MAdapterRelationship>> searchStdMeta(
            @ApiParam(name = "planId", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "planId") Long planId,
            @ApiParam(name = "data_set_id", value = "字典编号", defaultValue = "")
            @PathVariable(value = "data_set_id") Long dataSetId,
            @ApiParam(name = "seach_name", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "seach_name", required = false) String searchName,
            @ApiParam(name = "mode", value = "编辑模式(new/modify)", defaultValue = "")
            @RequestParam(value = "mode", required = false) String mode,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
}

+ 99 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/AdapterDictClient.java

@ -0,0 +1,99 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MAdapterDict;
import com.yihu.jw.model.adaption.MAdapterDictVo;
import com.yihu.jw.model.adaption.MAdapterRelationship;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
/**
 *
 * @author lincl
 * @version 1.0
 * @created 2016.2.3
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0  + "/adapter")
@ApiIgnore
public interface AdapterDictClient {
    @RequestMapping(value = "/plan/{planId}/dicts", method = RequestMethod.GET)
    @ApiOperation(value = "字典适配关系分页查询")
    ResponseEntity<Collection<MAdapterRelationship>> searchAdapterDict(
            @ApiParam(name = "planId", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "planId") Long planId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) ;
    @RequestMapping(value = "/plan/{planId}/dict/{dictId}/entrys", method = RequestMethod.GET)
    @ApiOperation(value = "字典项适配关系分页查询")
    ResponseEntity<Collection<MAdapterDictVo>> searchAdapterDictEntry(
            @ApiParam(name = "planId", value = "适配方案id", defaultValue = "")
            @PathVariable(value = "planId") Long planId,
            @ApiParam(name = "dictId", value = "字典编号", defaultValue = "")
            @PathVariable(value = "dictId") Long dictId,
            @ApiParam(name = "code", value = "代码查询值", defaultValue = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "名称查询值", defaultValue = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/entry/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据字典ID获取字典项适配关系明细")
    MAdapterDict getAdapterDictEntry(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") Long id) ;
    @RequestMapping(value = "/entry", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "保存字典项映射关系")
    public MAdapterDict createAdapterDictEntry(
            @ApiParam(name = "adapterDictModel", value = "字典数据模型", defaultValue = "")
            @RequestBody String dictJsonModel) throws Exception ;
    @RequestMapping(value = "/entry/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改字典项映射关系")
    public MAdapterDict updateAdapterDictEntry(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") Long id,
            @ApiParam(name = "adapterDictModel", value = "字典数据模型", defaultValue = "")
            @RequestBody String dictJsonModel) throws Exception ;
    @RequestMapping(value = "/entrys", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除字典项映射")
    public boolean delDictEntry(
            @RequestParam("ids") String ids) throws Exception ;
    @RequestMapping(value = "/plan/{planId}/dict/{dictId}/std_entrys", method = RequestMethod.GET)
    @ApiOperation(value = "过滤后的标准字典项分页查询")
    ResponseEntity<Collection<MAdapterRelationship>> searchStdDictEntry(
            @PathVariable(value = "planId") Long planId,
            @PathVariable(value = "dictId") Long dictId,
            @RequestParam(value = "seach_name", required = false) String searchName,
            @RequestParam(value = "mode", required = false) String mode,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
}

+ 80 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/AdapterOrgClient.java

@ -0,0 +1,80 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MAdapterOrg;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
/**
 * Created by AndyCai on 2016/2/29.
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface AdapterOrgClient {
    @RequestMapping(value = "/adapter/orgs", method = RequestMethod.GET)
    @ApiOperation(value = "适配采集标准")
    ResponseEntity<Collection<MAdapterOrg>> searchAdapterOrg(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/adapter/org/{code}", method = RequestMethod.GET)
    @ApiOperation(value = "获取适配采集标准")
    MAdapterOrg getAdapterOrg(
            @ApiParam(name = "code", value = "代码", defaultValue = "")
            @PathVariable(value = "code") String code) ;
    @RequestMapping(value = "/adapter/org", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "新增采集标准")
    MAdapterOrg addAdapterOrg(
            @ApiParam(name = "json_data", value = "采集机构模型", defaultValue = "")
            @RequestBody String jsonData) ;
    @RequestMapping(value = "/adapter/org/{code}", method = RequestMethod.PUT)
    @ApiOperation(value = "更新采集标准")
    MAdapterOrg updateAdapterOrg(
            @ApiParam(name = "code", value = "代码", defaultValue = "")
            @PathVariable(value = "code") String code,
            @ApiParam(name = "name", value = "名称", defaultValue = "")
            @RequestParam(value = "name") String name,
            @ApiParam(name = "description", value = "描述", defaultValue = "")
            @RequestParam(value = "description", required = false) String description) ;
    @RequestMapping(value = "/adapter/orgs", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除采集标准")
    boolean delAdapterOrg(
            @ApiParam(name = "codes", value = "代码", defaultValue = "")
            @RequestParam(value = "codes") String codes);
    @RequestMapping(value = "/adapter/isExistAdapterData/{org}", method = RequestMethod.GET)
    @ApiOperation(value = "判断采集机构是否存在采集数据")
    boolean orgIsExistData(
            @ApiParam(name = "org", value = "机构", defaultValue = "")
            @PathVariable(value = "org") String org) ;
    @RequestMapping(value = "/adapter/isExistAdapterOrg/{org}", method = RequestMethod.GET)
    @ApiOperation(value = "判断采集机构是否存在采集数据")
    boolean isExistAdapterOrg(@ApiParam(name = "org", value = "机构", defaultValue = "")
                                     @PathVariable(value = "org") String org);
}

+ 77 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgDataSetClient.java

@ -0,0 +1,77 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MOrgDataSet;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
/**
 * Created by AndyCai on 2016/2/29.
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface OrgDataSetClient {
    @RequestMapping(value = "/adapter/org/data_set/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询实体")
    MOrgDataSet getOrgDataSet(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id);
    @RequestMapping(value = "/adapter/org/data_set", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建机构数据集")
    MOrgDataSet createOrgDataSet(
            @ApiParam(name = "model", value = "json_data", defaultValue = "")
            @RequestBody String jsonData);
    @RequestMapping(value = "/adapter/org/data_set/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除机构数据集")
    boolean deleteOrgDataSet(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id);
    @RequestMapping(value = "/adapter/org/data_set", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改机构数据集")
    MOrgDataSet updateOrgDataSet(
            @ApiParam(name = "model", value = "json_data", defaultValue = "")
            @RequestBody String jsonData);
    @RequestMapping(value = "/adapter/org/data_sets", method = RequestMethod.GET)
    @ApiOperation(value = "条件查询")
    ResponseEntity<Collection<MOrgDataSet>> searchAdapterOrg(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/adapter/org/is_exist", method = RequestMethod.GET)
    @ApiOperation(value = "条件查询")
    boolean dataSetIsExist(
            @ApiParam(name = "org_code",value = "机构代码",defaultValue = "")
            @RequestParam(value = "org_code")String orgCode,
            @ApiParam(name="code",value="数据集代码",defaultValue = "")
            @RequestParam(value = "code")String code);
    @RequestMapping(value = "/adapter/org/data_set",method = RequestMethod.GET)
    MOrgDataSet getDataSetBySequence(
            @RequestParam(value="org_code")String orgCode,
            @RequestParam(value = "sequence")long sequence);
}

+ 80 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgDictClient.java

@ -0,0 +1,80 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MOrgDict;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/3/2.
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface OrgDictClient {
    @RequestMapping(value = "/adapter/org/dict", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询实体")
    MOrgDict getOrgDict(
            @ApiParam(name = "id", value = "查询条件", defaultValue = "")
            @RequestParam(value = "id", required = false) long id);
    @RequestMapping(value = "/adapter/org/dict", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建机构字典")
    MOrgDict createOrgDict(
            @ApiParam(name = "model", value = "字典信息", defaultValue = "")
            @RequestBody String jsonData);
    @RequestMapping(value = "/adapter/org/dict/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除机构字典")
    boolean deleteOrgDict(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id);
    @RequestMapping(value = "/adapter/org/dict", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改机构字典")
    MOrgDict updateOrgDict(
            @ApiParam(name = "model", value = "字典信息", defaultValue = "")
            @RequestBody String jsonData);
    @RequestMapping(value = "/adapter/org/dicts", method = RequestMethod.GET)
    @ApiOperation(value = "条件查询")
    ResponseEntity<Collection<MOrgDict>> searchOrgDicts(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/adapter/org/dict/combo", method = RequestMethod.GET)
    @ApiOperation(value = "机构字典下拉")
    List<String> getOrgDict(
            @ApiParam(name = "orgCode", value = "机构代码", defaultValue = "")
            @RequestParam(value = "orgCode", required = false) String orgCode);
    @RequestMapping(value = "/adapter/org/dict/is_exist",method = RequestMethod.GET)
    boolean isExistDict(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "dict_code") String dictCode);
    @RequestMapping(value = "/adapter/org/dict/org_dict",method = RequestMethod.GET)
    MOrgDict getOrgDictBySequence(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "sequence") int sequence);
}

+ 90 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgDictEntryClient.java

@ -0,0 +1,90 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MOrgDictItem;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
/**
 * Created by AndyCai on 2016/3/2.
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface OrgDictEntryClient {
    @RequestMapping(value = "/adapter/org/item/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "获取字典项信息")
    MOrgDictItem getOrgDictItem(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id) ;
    @RequestMapping(value = "/adapter/org/item", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "新增字典项")
    MOrgDictItem createOrgDictItem(
            @ApiParam(name = "model", value = "字典项信息", defaultValue = "")
            @RequestBody String jsonData) ;
    @RequestMapping(value = "/adapter/org/item/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除字典项")
    boolean deleteOrgDictItem(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id) ;
    @RequestMapping(value = "/adapter/org/items", method = RequestMethod.DELETE)
    @ApiOperation(value = "批量删除字典项")
    boolean deleteOrgDictItemList(
            @ApiParam(name = "ids", value = "编号集", defaultValue = "")
            @RequestParam(value = "ids") String ids) ;
    @RequestMapping(value = "/adapter/org/item", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改字典项")
    MOrgDictItem updateDictItem(
            @ApiParam(name = "model", value = "字典项信息", defaultValue = "")
            @RequestBody String jsonData);
    @RequestMapping(value = "/adapter/org/items", method = RequestMethod.GET)
    @ApiOperation(value = "分页查询")
    ResponseEntity<Collection<MOrgDictItem>> searchOrgDictItems(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/adapter/org/items/combo", method = RequestMethod.GET)
    @ApiOperation(value = "机构字典项下拉")
    Collection<String> getOrgDictEntry(
            @ApiParam(name = "orgDictSeq", value = "字典seq", defaultValue = "")
            @RequestParam(value = "orgDictSeq") long orgDictSeq,
            @ApiParam(name = "orgCode", value = "机构代码", defaultValue = "")
            @RequestParam(value = "orgCode") String orgCode);
    @RequestMapping(value = "/adapter/org/item/is_exist",method = RequestMethod.GET)
    boolean isExistDictItem(
            @RequestParam(value = "dict_id")long dictId,
            @RequestParam(value = "org_code")String orgCode,
            @RequestParam(value = "item_code")String itemCode);
    @RequestMapping(value = "/adapter/org/dict/dict_entry",method = RequestMethod.GET)
    MOrgDictItem getOrgDicEntryBySequence(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "sequence") int sequence);
}

+ 82 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/OrgMetaDataClient.java

@ -0,0 +1,82 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MOrgMetaData;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
/**
 * Created by AndyCai on 2016/3/1.
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface OrgMetaDataClient {
    @RequestMapping(value = "/adapter/org/meta/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取机构数据元")
    MOrgMetaData getOrgMetaData(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id);
    @RequestMapping(value = "/adapter/org/meta", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "新增数据元")
    MOrgMetaData createOrgMetaData(
            @ApiParam(name = "model", value = "json_data", defaultValue = "")
            @RequestBody String jsonData);
    @RequestMapping(value = "/adapter/org/meta/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除数据元")
    boolean deleteOrgMetaData(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") long id);
    @RequestMapping(value = "/adapter/org/metas", method = RequestMethod.DELETE)
    @ApiOperation(value = "批量删除数据元")
    boolean deleteOrgMetaDataList(
            @ApiParam(name = "ids", value = "编号集", defaultValue = "")
            @RequestParam(value = "ids") String ids);
    @RequestMapping(value = "/adapter/org/meta", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改数据元")
    MOrgMetaData updateOrgMetaData(
            @ApiParam(name = "model", value = "json_data", defaultValue = "")
            @RequestBody String jsonData);
    @RequestMapping(value = "/adapter/org/page", method = RequestMethod.GET)
    @ApiOperation(value = "分页查询")
    ResponseEntity<Collection<MOrgMetaData>> searchOrgMetaDatas(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/adapter/org/meta/is_exist",method = RequestMethod.GET)
    boolean isExistMetaData(
            @RequestParam(value = "data_set_id") int dataSetId,
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "meta_data_code")String metaDataCode);
    @RequestMapping(value = "/adapter/org/meta_data",method = RequestMethod.GET)
    MOrgMetaData getMetaDataBySequence(
            @RequestParam(value = "org_code") String orgCode,
            @RequestParam(value = "sequence") int sequence);
}

+ 110 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/service/PlanClient.java

@ -0,0 +1,110 @@
package com.yihu.jw.adapter.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.adaption.MAdapterPlan;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
 *
 * @author lincl
 * @version 1.0
 * @created 2016.2.3
 */
@FeignClient(name=MicroServices.Adaption)
@RequestMapping(ApiVersion.Version1_0 )
@ApiIgnore
public interface PlanClient {
    @RequestMapping(value = "/adapter/plans", method = RequestMethod.GET)
    @ApiOperation(value = "适配方案搜索")
    ResponseEntity<Collection<MAdapterPlan>> searchAdapterPlan(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) ;
    @RequestMapping(value = "/adapter/plan/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "获取适配方案信息")
    MAdapterPlan getAdapterPlanById(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") Long id) ;
    @RequestMapping(value = "/adapter/plan", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "保存适配方案")
    MAdapterPlan saveAdapterPlan(
            @ApiParam(name = "parmJson", value = "数据模型", defaultValue = "")
            @RequestBody String parmJson,
            @ApiParam(name = "isCover", value = "是否覆盖", defaultValue = "")
            @RequestParam(value = "isCover") String isCover) ;
    @RequestMapping(value = "/adapter/plan/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新适配方案")
    MAdapterPlan updateAdapterPlan(
            @ApiParam(name = "id", value = "编号", defaultValue = "")
            @PathVariable(value = "id") Long id,
            @ApiParam(name = "parmJson", value = "数据模型", defaultValue = "")
            @RequestBody String parmJson) ;
    @RequestMapping(value = "/adapter/plans", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除适配方案")
    boolean delAdapterPlan(
            @ApiParam(name = "ids", value = "编号列表", defaultValue = "")
            @RequestParam("ids") String ids);
    @RequestMapping(value = "/adapter/plans/list", method = RequestMethod.GET)
    @ApiOperation(value = "根据类型跟版本号获取适配方案列表")
    List<Map<String, String>> getAdapterPlanList(
            @ApiParam(name = "type", value = "类型", defaultValue = "")
            @RequestParam("type") String type,
            @ApiParam(name = "version", value = "版本号", defaultValue = "")
            @RequestParam(value = "version") String version) ;
    @RequestMapping(value = "/adapter/plan/{planId}/adapterCustomizes", method = RequestMethod.GET)
    @ApiOperation(value = "获取定制信息")
    Map getAdapterCustomize(
            @ApiParam(name = "planId", value = "编号", defaultValue = "")
            @PathVariable("planId") Long planId,
            @ApiParam(name = "version", value = "版本", defaultValue = "")
            @RequestParam("version") String version) ;
    @RequestMapping(value = "/adapter/plan/{planId}/adapterDataSet", method = RequestMethod.POST)
    @ApiOperation(value = "定制数据集")
    boolean adapterDataSet(
            @ApiParam(name = "planId", value = "编号", defaultValue = "")
            @PathVariable("planId") Long planId,
            @ApiParam(name = "customizeData", value = "customizeData", defaultValue = "")
            @RequestParam("customizeData") String customizeData) ;
    /**
     * 适配版本发布
     * 1.生成适配版本文件并记录文件位置;2.修改适配方案状态
     */
    @RequestMapping(value = "/adapter/plan/{planId}/dispatch", method = RequestMethod.POST)
    @ApiOperation(value = "适配版本发布")
    boolean adapterDispatch(
            @ApiParam(name = "planId", value = "方案编号", defaultValue = "")
            @PathVariable("planId") Long planId) ;
}

+ 110 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/adapter/utils/ExtendController.java

@ -0,0 +1,110 @@
package com.yihu.jw.adapter.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.util.validate.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
 * @author lincl
 * @version 1.0
 * @created 2016/3/1
 */
public class ExtendController<T> extends BaseController {
    public static String ERR_SYSREM_DES = "系统错误!";
    protected String objToJson(Object obj) throws JsonProcessingException {
        return objectMapper.writeValueAsString(obj);
    }
    protected String toEncodeJson(Object obj) throws JsonProcessingException, UnsupportedEncodingException {
        return URLEncoder.encode(objectMapper.writeValueAsString(obj), "UTF-8") ;
    }
    protected <T> T jsonToObj(String json) throws IOException {
        return (T) jsonToObj(json, getModelClass());
    }
    protected <T> T jsonToObj(String json , Class<T> clz) throws IOException {
        return objectMapper.readValue(json, clz);
    }
    protected Class getModelClass() {
        Type genType = this.getClass().getGenericSuperclass();
        Type[] parameters = ((ParameterizedType) genType).getActualTypeArguments();
        return (Class) parameters[0];
    }
    protected T getModel(Object obj){
        return (T) convertToModel(obj, getModelClass());
    }
    public Envelop failed(String errMsg){
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(false);
        envelop.setErrorMsg(errMsg);
        return envelop;
    }
    protected Envelop failedSystem(){
        return failed(ERR_SYSREM_DES);
    }
    protected Envelop successList(List ls){
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList((List) convertToModels(ls, new ArrayList<>(), getModelClass(), ""));
        return envelop;
    }
    public Envelop success(Object object){
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setObj(convertToModel(object, getModelClass()));
        return envelop;
    }
    public Envelop successMsg(String msg){
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setErrorMsg(msg);
        return envelop;
    }
    public Envelop successObj(Object object){
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setObj(object);
        return envelop;
    }
    protected ValidateResult validate(T dataModel) {
        try {
            return ValidateUtil.validate(dataModel);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        ValidateResult validateResult = new ValidateResult();
        validateResult.setMsg("数据验证失败!");
        validateResult.setRs(false);
        return validateResult;
    }
}

+ 346 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppApiController.java

@ -0,0 +1,346 @@
package com.yihu.jw.apps.controller;
import com.yihu.jw.agModel.app.AppApiModel;
import com.yihu.jw.apps.service.AppApiClient;
import com.yihu.jw.apps.service.AppApiParameterClient;
import com.yihu.jw.apps.service.AppApiResponseClient;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.model.app.MAppApi;
import com.yihu.jw.model.app.MAppApiDetail;
import com.yihu.jw.model.dict.MConventionalDict;
import com.yihu.jw.model.user.MRoleApiRelation;
import com.yihu.jw.model.user.MRoleAppRelation;
import com.yihu.jw.systemdict.service.ConventionalDictEntryClient;
import com.yihu.jw.users.service.RoleApiRelationClient;
import com.yihu.jw.users.service.RoleAppRelationClient;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by linz on 2016年7月8日11:30:18.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@Api(value = "AppApiController", description = "应用开放接口维护", tags = {"应用管理-应用开放接口维护"})
public class AppApiController extends BaseController {
    private static final String DELETE = "delete";
    private static final String ADD = "add";
    private static final String UPDATE = "update";
    private static final String NEW_DATA = "0";
    private static final String DATA_STATUS = "__status";
    @Autowired
    private AppApiClient appApiClient;
    @Autowired
    private RoleApiRelationClient roleApiRelationClient;
    @Autowired
    private AppApiParameterClient appApiParameterClient;
    @Autowired
    private AppApiResponseClient appApiResponseClient;
    @Autowired
    private ConventionalDictEntryClient conDictEntryClient;
    @Autowired
    private RoleAppRelationClient roleAppRelationClient;
    @RequestMapping(value = ServiceApi.AppApi.AppApis, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApi列表")
    public Envelop getAppApis(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        ResponseEntity<List<MAppApi>> responseEntity = appApiClient.getAppApis(fields, filters, sort, size, page);
        List<MAppApi> mAppApiList = responseEntity.getBody();
        List<AppApiModel> appApiModels = new ArrayList<>();
        for (MAppApi mAppApi : mAppApiList) {
            AppApiModel appApiModel = new AppApiModel();
            BeanUtils.copyProperties(mAppApi, appApiModel);
            appApiModels.add(appApiModel);
        }
        Integer totalCount = getTotalCount(responseEntity);
        Envelop envelop = getResult(appApiModels, totalCount, page, size);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApi.AppApis, method = RequestMethod.POST)
    @ApiOperation(value = "创建AppApi")
    public Envelop createAppApi(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestParam(value = "model", required = false) String model,
            @ApiParam(name = "apiParms", value = "api请求参数集合")
            @RequestParam(value = "apiParms", required = false) String apiParms,
            @ApiParam(name = "apiResponse", value = "api响应参数集合")
            @RequestParam(value = "apiResponse", required = false) String apiResponse) {
        Envelop envelop = new Envelop();
        MAppApi mAppApi = appApiClient.createAppApi(model);
        if (mAppApi == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("保存失败!");
            return envelop;
        }
        AppApiModel appApiModel = new AppApiModel();
        BeanUtils.copyProperties(mAppApi, appApiModel);
        saveApiParmsResponse(appApiModel.getId() + "", apiParms, apiResponse);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApi.AppApi, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApi")
    public Envelop getAppApi(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        MAppApi mAppApi = appApiClient.getAppApi(id);
        AppApiModel appApiModel = new AppApiModel();
        if (mAppApi == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("获取数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppApi, appApiModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApi.AppApis, method = RequestMethod.PUT)
    @ApiOperation(value = "更新AppApi")
    public Envelop updateAppApi(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true)
            @RequestParam(value = "model", required = false) String AppApi,
            @ApiParam(name = "apiParms", value = "api请求参数集合")
            @RequestParam(value = "apiParms", required = false) String apiParms,
            @ApiParam(name = "apiResponse", value = "api响应参数集合")
            @RequestParam(value = "apiResponse", required = false) String apiResponse) {
        Envelop envelop = new Envelop();
        MAppApi mAppApi = appApiClient.createAppApi(AppApi);
        AppApiModel appApiModel = new AppApiModel();
        if (mAppApi == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("更新数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppApi, appApiModel);
        saveApiParmsResponse(appApiModel.getId() + "", apiParms, apiResponse);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApi.AppApi, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppApi")
    public Envelop deleteAppApi(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        Boolean isDelete = appApiClient.deleteAppApi(id);
        envelop.setSuccessFlg(isDelete);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApi.AppApisNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "获取过滤App列表")
    public Envelop getAppApiNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "roleId", value = "角色组ID,需要知道是否被关联才需要传入")
            @RequestParam(value = "roleId", required = false) String roleId) {
        Collection<MAppApi> mAppApis = appApiClient.getAppApiNoPage(filters);
        Envelop envelop = new Envelop();
        List<AppApiModel> appApiModels = new ArrayList<>();
        for (MAppApi mAppApi : mAppApis) {
            AppApiModel appApiModel = convertToModel(mAppApi, AppApiModel.class);
            if (StringUtils.isNotBlank(roleId)) {
                appApiModel.setRoleId(roleId);
            }
            converModelName(appApiModel);
            appApiModels.add(appApiModel);
        }
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(appApiModels);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApi.AppApiSearch, method = RequestMethod.GET)
    @ApiOperation(value = "查询Api详情")
    public Envelop searchApi(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page
    ) {
        ResponseEntity<List<MAppApiDetail>> responseEntity = appApiClient.searchApi(fields, filters, sorts, size, page);
        List<MAppApiDetail> mAppApiList = responseEntity.getBody();
        Integer totalCount = getTotalCount(responseEntity);
        return getResult(mAppApiList, totalCount, page, size);
    }
    @RequestMapping(value = "/role_app_api/no_paging", method = RequestMethod.GET)
    @ApiOperation(value = "获取角色组的AppApi列表")
    public Envelop getRoleAppFeatureNoPage(
            @ApiParam(name = "role_id", value = "角色组id")
            @RequestParam(value = "role_id") String roleId) {
        Collection<MRoleApiRelation> mRoleApiRelations = roleApiRelationClient.searchRoleApiRelationNoPaging("roleId=" + roleId);
        String apiIds = "";
        for (MRoleApiRelation m : mRoleApiRelations) {
            apiIds += m.getApiId() + ",";
        }
        if (!StringUtils.isEmpty(apiIds)) {
            apiIds = apiIds.substring(0, apiIds.length() - 1);
        }
        Collection<MAppApi> mAppApis = appApiClient.getAppApiNoPage("id=" + apiIds);
        Envelop envelop = new Envelop();
        List<AppApiModel> appApiModels = new ArrayList<>();
        for (MAppApi mAppApi : mAppApis) {
            AppApiModel appApiModel = convertToModel(mAppApi, AppApiModel.class);
            appApiModels.add(appApiModel);
        }
        envelop.setDetailModelList(appApiModels);
        return envelop;
    }
    /**
     * 格式化字典数据
     *
     * @param appApiModel
     */
    private void converModelName(AppApiModel appApiModel) {
        //是否已经被角色组适配,界面适配用
        if (!StringUtils.isEmpty(appApiModel.getRoleId())) {
            ResponseEntity<Collection<MRoleApiRelation>> responseEntity = roleApiRelationClient.searchRoleApiRelations("", "roleId=" + appApiModel.getRoleId() + ";apiId=" + appApiModel.getId(), "", 1, 1);
            Collection<MRoleApiRelation> mRoleFeatureRelations = responseEntity.getBody();
            if (mRoleFeatureRelations != null && mRoleFeatureRelations.size() > 0) {
                appApiModel.setIschecked(true);
            }
        }
        //审计等级
        if (!StringUtils.isEmpty(appApiModel.getAuditLevel())) {
            MConventionalDict catalopDict = conDictEntryClient.getAuditLevel(appApiModel.getAuditLevel());
            appApiModel.setAuditLevelName(catalopDict == null ? "" : catalopDict.getValue());
        }
        //开放等级
        if (!StringUtils.isEmpty(appApiModel.getOpenLevel())) {
            MConventionalDict catalopDict = conDictEntryClient.getOpenLevel(appApiModel.getOpenLevel());
            appApiModel.setOpenLevelName(catalopDict == null ? "" : catalopDict.getValue());
        }
    }
    /**
     * 保存apiParms及apiResponse
     *
     * @param apiId
     * @param apiParms
     * @param apiResponse
     */
    private void saveApiParmsResponse(String apiId, String apiParms, String apiResponse) {
        try {
            List<Map<String, Object>> list;
            if (!StringUtils.isEmpty(apiParms)) {
                list = objectMapper.readValue(apiParms, List.class);
                for (Map<String, Object> parmsMap : list) {
                    //删除的是新增的数据直接跳过
                    if (DELETE.equals(parmsMap.get(DATA_STATUS)) && NEW_DATA.equals(parmsMap.get("id") + "")) {
                        continue;
                    } else {
                        parmsMap.put("appApiId", apiId);
                        String json = toJson(parmsMap);
                        if (NEW_DATA.equals(parmsMap.get("id") + "")) {
                            appApiParameterClient.createAppApiParameter(json);
                        } else if (UPDATE.equals(parmsMap.get(DATA_STATUS))) {
                            appApiParameterClient.updateAppApiParameter(json);
                        } else if (DELETE.equals(parmsMap.get(DATA_STATUS))) {
                            appApiParameterClient.deleteAppApiParameter(parmsMap.get("id") + "");
                        }
                    }
                }
            }
            if (!StringUtils.isEmpty(apiResponse)) {
                list = objectMapper.readValue(apiResponse, List.class);
                for (Map<String, Object> parmsMap : list) {
                    //删除的是新增的数据直接跳过
                    if (DELETE.equals(parmsMap.get(DATA_STATUS)) && NEW_DATA.equals(parmsMap.get("id") + "")) {
                        continue;
                    } else {
                        parmsMap.put("appApiId", apiId);
                        String json = toJson(parmsMap);
                        if (ADD.equals(parmsMap.get(DATA_STATUS))) {
                            appApiResponseClient.createAppApiResponse(json);
                        } else if (UPDATE.equals(parmsMap.get(DATA_STATUS))) {
                            appApiResponseClient.updateAppApiResponse(json);
                        } else if (DELETE.equals(parmsMap.get(DATA_STATUS))) {
                            appApiResponseClient.deleteAppApiResponse(parmsMap.get("id") + "");
                        }
                    }
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }
    
    @RequestMapping(value = ServiceApi.AppApi.AppApiAuth, method = RequestMethod.GET)
    @ApiOperation(value = "验证应用的api调用权限")
    public Envelop checkAppApi(
            @ApiParam(name = "appId", value = "应用ID")
            @RequestParam(value = "appId") String appId,
            @ApiParam(name = "apiName", value = "api名称")
            @RequestParam(value = "apiName") String apiName) {
        Envelop envelop = new Envelop();
        try {
            //获取应用和api关系
            Collection<MRoleAppRelation> mRoleAppRelations = roleAppRelationClient.searchRoleAppNoPaging("appId=" + appId);
            String roleIds = mRoleAppRelations.stream().map(MRoleAppRelation::getRoleId).collect(Collectors.toList()).stream().map(roleId -> roleId.toString()).collect(Collectors.joining(","));
            if("".equals(roleIds)){
                return failed("应用无该API的访问权限");
            }
            //获取角色和api关系
            Collection<MRoleApiRelation> mRoleApiRelations = roleApiRelationClient.searchRoleApiRelationNoPaging("roleId=" + roleIds);
            String apiIds = mRoleApiRelations.stream().map(MRoleApiRelation::getApiId).collect(Collectors.toList()).stream().map(apiId -> apiId.toString()).collect(Collectors.joining(","));
            //获取角色相关的所有api
            Collection<MAppApi> mAppApis = appApiClient.getAppApiNoPage("id=" + apiIds + ";methodName=" + apiName);
            List<MAppApi> appApiList = mAppApis.stream().collect(Collectors.toList());
            if (appApiList!=null && appApiList.size()>0){
                return success("");
            }else {
                return failed("无该应用API的访问权限");
            }
//            envelop.setDetailModelList(appApiList);
//            return envelop;
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }
}

+ 156 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppApiParameterController.java

@ -0,0 +1,156 @@
package com.yihu.jw.apps.controller;
import com.yihu.jw.agModel.app.AppApiParameterModel;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.apps.service.AppApiParameterClient;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.model.app.MAppApiParameter;
import com.yihu.jw.model.dict.MConventionalDict;
import com.yihu.jw.systemdict.service.ConventionalDictEntryClient;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by linz on 2016年7月8日11:30:18.
 */
@RequestMapping(ApiVersion.Version1_0+"/admin" )
@RestController
@Api(value = "AppApiParameter", description = "应用开放接口参数管理", tags = {"应用管理-应用开放接口参数管理"})
public class AppApiParameterController extends BaseController {
    @Autowired
    AppApiParameterClient appApiParameterClient;
    @Autowired
    private ConventionalDictEntryClient conDictEntryClient;
    @RequestMapping(value = ServiceApi.AppApiParameter.AppApiParameters, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiParameter列表")
    public Envelop getAppApiParameters(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page){
        ResponseEntity<List<MAppApiParameter>> responseEntity =  appApiParameterClient.getAppApiParameters(fields, filters, sort, size, page);
        List<MAppApiParameter> mAppApiParameterList = responseEntity.getBody();
        List<AppApiParameterModel> AppApiParameterModels = new ArrayList<>();
        for(MAppApiParameter mAppApiParameter: mAppApiParameterList){
            AppApiParameterModel appApiParameterModel  = new AppApiParameterModel();
            BeanUtils.copyProperties(mAppApiParameter,appApiParameterModel);
            converModelName(appApiParameterModel);
            AppApiParameterModels.add(appApiParameterModel);
        }
        Integer totalCount = getTotalCount(responseEntity);
        Envelop envelop = getResult(AppApiParameterModels,totalCount,page,size);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiParameter.AppApiParameters, method = RequestMethod.POST)
    @ApiOperation(value = "创建AppApiParameter")
    public Envelop createAppApiParameter(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestParam(value = "model", required = false) String model){
        Envelop envelop = new Envelop();
        MAppApiParameter mAppApiParameter =  appApiParameterClient.createAppApiParameter(model);
        if(mAppApiParameter==null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("保存失败!");
            return envelop;
        }
        AppApiParameterModel appApiParameterModel = new AppApiParameterModel();
        BeanUtils.copyProperties(mAppApiParameter,appApiParameterModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiParameterModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiParameter.AppApiParameter, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiParameter")
    public Envelop getAppApiParameter(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id){
        Envelop envelop = new Envelop();
        MAppApiParameter mAppApiParameter =  appApiParameterClient.getAppApiParameter(id);
        AppApiParameterModel appApiParameterModel = new AppApiParameterModel();
        if(mAppApiParameter==null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("获取数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppApiParameter,appApiParameterModel);
        converModelName(appApiParameterModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiParameterModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiParameter.AppApiParameters, method = RequestMethod.PUT)
    @ApiOperation(value = "更新AppApiParameter")
    public Envelop updateAppApiParameter(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true)
            @RequestParam(value = "model", required = false) String AppApiParameter){
        Envelop envelop = new Envelop();
        MAppApiParameter mAppApiParameter =  appApiParameterClient.createAppApiParameter(AppApiParameter);
        AppApiParameterModel appApiParameterModel = new AppApiParameterModel();
        if(mAppApiParameter==null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("更新数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppApiParameter,appApiParameterModel);
        converModelName(appApiParameterModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiParameterModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiParameter.AppApiParameter, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppApiParameter")
    Envelop deleteAppApiParameter(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id){
        Envelop envelop = new Envelop();
        Boolean isDelete  = appApiParameterClient.deleteAppApiParameter(id);
        envelop.setSuccessFlg(isDelete);
        return envelop;
    }
    /**
     * 格式化字典数据
     * @param appApiParameterModel
     */
    private void converModelName(AppApiParameterModel appApiParameterModel){
        //参数类型
        if(!StringUtils.isEmpty(appApiParameterModel.getType())){
            MConventionalDict catalopDict = conDictEntryClient.getApiParameterType(appApiParameterModel.getType());
            appApiParameterModel.setTypeName(catalopDict == null ? "" : catalopDict.getValue());
        }
        //参数数据类型
        if(!StringUtils.isEmpty(appApiParameterModel.getDataType())){
            MConventionalDict catalopDict = conDictEntryClient.getApiParameterDataType(appApiParameterModel.getDataType());
            appApiParameterModel.setDataTypeName(catalopDict == null ? "" : catalopDict.getValue());
        }
        //参数必输
        if(!StringUtils.isEmpty(appApiParameterModel.getRequired())){
            MConventionalDict catalopDict = conDictEntryClient.getApiParameterDataRequired(appApiParameterModel.getRequired());
            appApiParameterModel.setRequiredName(catalopDict == null ? "" : catalopDict.getValue());
        }
    }
}

+ 133 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppApiResponseController.java

@ -0,0 +1,133 @@
package com.yihu.jw.apps.controller;
import com.yihu.jw.agModel.app.AppApiResponseModel;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.apps.service.AppApiResponseClient;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.model.app.MAppApiResponse;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by linz on 2016年7月8日11:30:18.
 */
@RequestMapping(ApiVersion.Version1_0+"/admin" )
@RestController
@Api(value = "AppApiResponse", description = "应用开放接口返回值管理", tags = {"应用管理-应用开放接口返回值管理"})
public class AppApiResponseController extends BaseController {
    @Autowired
    AppApiResponseClient appApiResponseClient;
    @RequestMapping(value = ServiceApi.AppApiResponse.AppApiResponses, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiResponse列表")
    public Envelop getAppApiResponses(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page){
        ResponseEntity<List<MAppApiResponse>> responseEntity =  appApiResponseClient.getAppApiResponses(fields, filters, sort, size, page);
        List<MAppApiResponse> mAppApiResponseList = responseEntity.getBody();
        List<AppApiResponseModel> appApiResponseModels = new ArrayList<>();
        for(MAppApiResponse mAppApiResponse: mAppApiResponseList){
            AppApiResponseModel appApiResponseModel  = new AppApiResponseModel();
            BeanUtils.copyProperties(mAppApiResponse,appApiResponseModel);
            appApiResponseModels.add(appApiResponseModel);
        }
        Integer totalCount = getTotalCount(responseEntity);
        Envelop envelop = getResult(appApiResponseModels,totalCount,page,size);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiResponse.AppApiResponses, method = RequestMethod.POST)
    @ApiOperation(value = "创建AppApiResponse")
    public Envelop createAppApiResponse(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestParam(value = "model", required = false) String model){
        Envelop envelop = new Envelop();
        MAppApiResponse mAppApiResponse =  appApiResponseClient.createAppApiResponse(model);
        if(mAppApiResponse==null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("保存失败!");
            return envelop;
        }
        AppApiResponseModel appApiResponseModel = new AppApiResponseModel();
        BeanUtils.copyProperties(mAppApiResponse,appApiResponseModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiResponseModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiResponse.AppApiResponse, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiResponse")
    public Envelop getAppApiResponse(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id){
        Envelop envelop = new Envelop();
        MAppApiResponse mAppApiResponse =  appApiResponseClient.getAppApiResponse(id);
        AppApiResponseModel appApiResponseModel = new AppApiResponseModel();
        if(mAppApiResponse==null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("获取数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppApiResponse,appApiResponseModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiResponseModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiResponse.AppApiResponses, method = RequestMethod.PUT)
    @ApiOperation(value = "更新AppApiResponse")
    public Envelop updateAppApiResponse(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true)
            @RequestParam(value = "model", required = false) String AppApiResponse){
        Envelop envelop = new Envelop();
        MAppApiResponse mAppApiResponse =  appApiResponseClient.createAppApiResponse(AppApiResponse);
        AppApiResponseModel appApiResponseModel = new AppApiResponseModel();
        if(mAppApiResponse==null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("更新数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppApiResponse,appApiResponseModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appApiResponseModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppApiResponse.AppApiResponse, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppApiResponse")
    Envelop deleteAppApiResponse(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id){
        Envelop envelop = new Envelop();
        Boolean isDelete  = appApiResponseClient.deleteAppApiResponse(id);
        envelop.setSuccessFlg(isDelete);
        return envelop;
    }
    /**
     * 格式化字典数据
     * @param appApiResponseModel
     */
    private void converModelName(AppApiResponseModel appApiResponseModel){
    }
}

+ 471 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppController.java

@ -0,0 +1,471 @@
package com.yihu.jw.apps.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.agModel.dict.SystemDictEntryModel;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.apps.service.AppApiClient;
import com.yihu.jw.model.app.MAppApi;
import com.yihu.jw.model.dict.MDictionaryEntry;
import com.yihu.jw.model.org.MOrganization;
import com.yihu.jw.model.resource.MRsAppResource;
import com.yihu.jw.model.resource.MRsResources;
import com.yihu.jw.model.user.MRoleAppRelation;
import com.yihu.jw.model.user.MRoles;
import com.yihu.jw.organization.service.OrganizationClient;
import com.yihu.jw.resource.client.RsResourceClient;
import com.yihu.jw.resource.client.RsResourceGrantClient;
import com.yihu.jw.systemdict.service.ConventionalDictEntryClient;
import com.yihu.jw.constants.AgAdminConstants;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.apps.service.AppClient;
import com.yihu.jw.agModel.app.AppDetailModel;
import com.yihu.jw.agModel.app.AppModel;
import com.yihu.jw.model.app.MApp;
import com.yihu.jw.model.dict.MConventionalDict;
import com.yihu.jw.systemdict.service.SystemDictClient;
import com.yihu.jw.users.service.RoleAppRelationClient;
import com.yihu.jw.users.service.RolesClient;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
 * Created by AndyCai on 2016/1/19.
 */
@RequestMapping(ApiVersion.Version1_0+"/admin" )
@RestController
@Api(value = "app", description = "应用管理接口", tags = {"应用管理接口"})
public class AppController extends BaseController {
    @Autowired
    private AppClient appClient;
    @Autowired
    private ConventionalDictEntryClient conDictEntryClient;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private OrganizationClient organizationClient;
    @Autowired
    private RsResourceGrantClient resourcesGrantClient;
    @Autowired
    private RsResourceClient resourcesClient;
    @Autowired
    private RoleAppRelationClient roleAppRelationClient;
    @Autowired
    private RolesClient rolesClient;
    @Autowired
    private AppApiClient appApiClient;
    @Autowired
    private SystemDictClient systemDictClient;
    @RequestMapping(value = "test", method = RequestMethod.GET)
    @ApiOperation(value = "获取app列表,不分页")
    public Envelop test() throws Exception {
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        return envelop;
    }
    
    @RequestMapping(value = "/apps", method = RequestMethod.GET)
    @ApiOperation(value = "获取App列表")
    public Envelop getApps(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "-createTime")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        List<AppModel> appModelList = new ArrayList<>();
        ResponseEntity<List<MApp>> responseEntity = appClient.getApps(fields,filters,sort,size,page);
        List<MApp> mAppList = responseEntity.getBody();
        for(MApp app :mAppList){
            appModelList.add(convertToAppModel(app));
        }
        Integer totalCount = getTotalCount(responseEntity);
        Envelop envelop = getResult(appModelList,totalCount,page,size);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.Apps.AppsNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "获取app列表,不分页")
    public Envelop getAppsNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件",defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        Envelop envelop = new Envelop();
        Collection<MApp> mAppList = appClient.getAppsNoPage(filters);
        List<AppModel> appModelList = new ArrayList<>();
        for(MApp app :mAppList){
            appModelList.add(convertToAppModel(app));
        }
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(appModelList);
        return envelop;
    }
    /**
     * @param appJson
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/apps", method = RequestMethod.POST)
    @ApiOperation(value = "创建App")
    public Envelop createApp(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true, defaultValue = "{\"name\": \"\", \"url\": \"\", \"catalog\": \"\", \"description\": \"\", \"creator\":\"\",\"icon\": \"\",\"releaseFlag\": \"\"}")
            @RequestParam(value = "app", required = false) String appJson) throws Exception {
        Envelop envelop = new Envelop();
        //传入的appJson里包含userId
        AppDetailModel appDetailModel = objectMapper.readValue(appJson,AppDetailModel.class);
        MApp app = convertToMApp(appDetailModel);
        MApp mApp = appClient.createApp(objectMapper.writeValueAsString(app));
        if(mApp == null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("app创建失败!");
        }else{
            String role =  appDetailModel.getRole();
            if(StringUtils.isNotBlank(role)){
                //role 为角色组ids,以逗号隔开
                roleAppRelationClient.batchCreateRoleAppRelation(mApp.getId(), role);
            }
            envelop.setSuccessFlg(true);
            envelop.setObj(convertToAppDetailModel(mApp));
        }
        return envelop;
    }
    @RequestMapping(value = "/apps/{app_id}", method = RequestMethod.GET)
    @ApiOperation(value = "获取App")
    public Envelop getApp(
            @ApiParam(name = "app_id", value = "id", defaultValue = "")
            @PathVariable(value = "app_id") String appId) throws Exception {
        Envelop envelop = new Envelop();
        MApp mApp = appClient.getApp(appId);
        if (mApp == null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("app获取失败");
        }else{
            //格式化角色
            if("0".equals(mApp.getSourceType()+"")){
                Collection<MRoleAppRelation> mRoleAppRelations =  roleAppRelationClient.searchRoleAppNoPaging("appId=" + appId);
                Map<String,Object> roleMap = new HashMap<>();
                for(MRoleAppRelation mRoleAppRelation:mRoleAppRelations){
                    MRoles mRoles =  rolesClient.getRolesById(mRoleAppRelation.getRoleId());
                    if(mRoles!=null){
                        roleMap.put(mRoles.getId()+"",mRoles.getName());
                    }
                }
               AppDetailModel appDetailModel =  convertToAppDetailModel(mApp);
                if(roleMap.keySet().size()>0){
                    appDetailModel.setRoleJson(toJson(roleMap));
                }
                envelop.setSuccessFlg(true);
                envelop.setObj(appDetailModel);
            }else{
                envelop.setSuccessFlg(true);
                envelop.setObj(convertToAppDetailModel(mApp));
            }
        }
        return envelop;
    }
    @RequestMapping(value = "/apps", method = RequestMethod.PUT)
    @ApiOperation(value = "更新App")
    public Envelop updateApp(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true)
            @RequestParam(value = "app", required = false) String appJson) throws Exception {
        Envelop envelop = new Envelop();
        AppDetailModel appDetailModel = objectMapper.readValue(appJson,AppDetailModel.class);
        MApp app = convertToMApp(appDetailModel);
        MApp mApp = appClient.updateApp(objectMapper.writeValueAsString(app));
        if(mApp==null){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("app更新失败!");
        }else{
            String role =  appDetailModel.getRole();
            if(StringUtils.isNotBlank(role)){
                //role 为角色组ids,以逗号隔开
                roleAppRelationClient.batchUpdateRoleAppRelation(mApp.getId(),role);
            }
            envelop.setSuccessFlg(true);
            envelop.setObj(convertToAppDetailModel(mApp));
        }
        return envelop;
    }
    @RequestMapping(value = "/apps/{app_id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除app")
    public Envelop deleteApp(
            @ApiParam(name = "app_id", value = "id", defaultValue = "")
            @PathVariable(value = "app_id") String app_id){
        try {
            boolean result = appClient.deleteApp(app_id);
            if(!result)
            {
                return failed("删除失败!");
            }
            return success(null);
        }
        catch (Exception ex)
        {
            return failedSystem();
        }
    }
    @RequestMapping(value = "/apps/status",method = RequestMethod.PUT)
    @ApiOperation(value = "修改状态")
    public boolean updateStatus(
            @ApiParam(name= "app_id",value = "app_id",defaultValue = "")
            @RequestParam(value = "app_id") String appId,
            @ApiParam(name = "app_status",value = "状态",defaultValue = "")
            @RequestParam(value = "app_status") String appStatus)throws Exception{
        return appClient.updateStatus(appId, appStatus);
    }
    @RequestMapping(value = "apps/existence/app_id/{app_id}",method = RequestMethod.GET)
    @ApiOperation(value = "验证app")
    public boolean isAppExistence(
            @ApiParam(name= "app_id",value = "app_id",defaultValue = "")
            @PathVariable(value = "app_id") String appId,
            @ApiParam(name = "secret",value = "密钥",defaultValue = "")
            @RequestParam(value = "secret") String secret)throws Exception{
        return appClient.isAppExists(appId, secret);
    }
    @RequestMapping(value = "apps/existence/app_name/{app_name}",method = RequestMethod.GET)
    @ApiOperation(value = "验证app名字是否存在")
    public boolean isAppNameExists(
            @ApiParam(value = "app_name")
            @PathVariable(value = "app_name") String appName){
        return appClient.isAppNameExists(appName);
    }
    /**
     *  将微服务返回的MApp转化为前端AppModel
     * @param mApp
     * @return AppModel
     */
    private AppModel convertToAppModel(MApp mApp) {
        if(mApp==null) {
            return null;
        }
        AppModel appModel = convertToModel(mApp, AppModel.class);
        //获取app类别字典值
        if(!StringUtils.isEmpty(mApp.getCatalog())){
            MConventionalDict catalogDict = conDictEntryClient.getAppCatalog(mApp.getCatalog());
            appModel.setCatalogName(catalogDict == null ? "" : catalogDict.getValue());
        }
        //获取状态字典值
        if(!StringUtils.isEmpty(mApp.getStatus())){
            MConventionalDict statusDict = conDictEntryClient.getAppStatus(mApp.getStatus());
            appModel.setStatusName(statusDict == null ? "" : statusDict.getValue());
        }
        //获取机构名称
        if(!StringUtils.isEmpty(mApp.getOrg())){
            MOrganization organization = organizationClient.getOrg(mApp.getOrg());
            appModel.setOrgName(organization == null ? "" : organization.getFullName());
        }
/*       update by zdm 20180505 此处根据应用已授权的资源rsIds获取资源,filters会出现过长,导致app查询失败。此处也不需要查看资源名称。所以注释。
        //获取已授权资源名称
        //根据appId获取授权资源rsIds
        //TODO 提供根据appId获取RsAppResourceModel集合接口来替代
        ResponseEntity<List<MRsAppResource>> responseEntity = resourcesGrantClient.queryAppResourceGrant("", "appId=" + mApp.getId(), "", 1, 999);
        List<MRsAppResource> rsAppResources = responseEntity.getBody();
        if(rsAppResources.size()==0){
            return appModel;
        }
        String rsIds = "";
        for (MRsAppResource m:rsAppResources){
            rsIds += m.getResourceId()+",";
        }
        rsIds = rsIds.substring(0,rsIds.length()-1);
        //根据rsIds获取资源对象集合-再获取资源名字字符串
        //TODO 提供查询资源不分页方法替代
        ResponseEntity<List<MRsResources>> entity = resourcesClient.queryResources("", "id=" + rsIds, "", 1, 999, null, null);
        List<MRsResources> mRsResources = entity.getBody();
        if(mRsResources.size() == 0){
            return appModel;
        }
        String rsNames = "";
        for(MRsResources m:mRsResources){
            rsNames += m.getName()+",";
        }
        rsNames = rsNames.substring(0,rsNames.length()-1);
        appModel.setResourceNames(rsNames);*/
        return appModel;
    }
    /**
     * 将微服务返回的MApp转化为前端显示的appDetailModel
     * @param mApp
     * @return
     */
    private AppDetailModel convertToAppDetailModel(MApp mApp){
        if(mApp==null)
        {
            return null;
        }
        AppDetailModel app = convertToModel(mApp, AppDetailModel.class);
        app.setCreateTime(DateToString(mApp.getCreateTime(), AgAdminConstants.DateTimeFormat));
        app.setAuditTime(DateToString(mApp.getAuditTime(),AgAdminConstants.DateTimeFormat));
        //获取app类别字典值
        if(!StringUtils.isEmpty(mApp.getCatalog())){
            MConventionalDict catalopDict = conDictEntryClient.getAppCatalog(mApp.getCatalog());
            app.setCatalogName(catalopDict == null ? "" : catalopDict.getValue());
        }
        //获取app状态字典值
        if(!StringUtils.isEmpty(mApp.getStatus())){
            MConventionalDict statusDict = conDictEntryClient.getAppStatus(mApp.getStatus());
            app.setStatusName(statusDict == null ? "" : statusDict.getValue());
        }
        //获取机构名称
        if(!StringUtils.isEmpty(mApp.getOrg())){
            MOrganization organization = organizationClient.getOrg(mApp.getOrg());
            app.setOrgName(organization == null ? "" : organization.getFullName());
        }
     /*   MConventionalDict sourceType = conDictEntryClient.getApplicationSource(mApp.getSourceType()+"");
        app.setSourceTypeName(sourceType == null ? "" : sourceType.getValue());*/
        return app;
    }
    private MApp convertToMApp(AppDetailModel detailModel) {
        if(detailModel==null) {
            return null;
        }
        MApp mApp = convertToModel(detailModel,MApp.class);
        mApp.setCreateTime(StringToDate(detailModel.getCreateTime(),AgAdminConstants.DateTimeFormat));
        mApp.setAuditTime(StringToDate(detailModel.getAuditTime(),AgAdminConstants.DateTimeFormat));
        return mApp;
    }
    @RequestMapping(value = "/apps/filterList", method = RequestMethod.GET)
    @ApiOperation(value = "存在性校验")
    Envelop isExitAppFeature(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters){
        Envelop envelop = new Envelop();
        try{
            Boolean isExit  = appClient.isExitApp(filters);
            envelop.setSuccessFlg(true);
            envelop.setObj(isExit);
        }catch (Exception e){
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = "/appsExitApi", method = RequestMethod.GET)
    @ApiOperation(value = "获取App列表")
    public Envelop getAppsExitApi(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        List<AppModel> appModelList = new ArrayList<>();
        Collection<MAppApi> mAppApis =  appApiClient.getAppApiNoPage("type=2");
        if(mAppApis!=null&&mAppApis.size()>0){
            StringBuffer buffer = new StringBuffer();
            for(MAppApi mAppApi: mAppApis){
                buffer.append(mAppApi.getAppId()).append(",");
            }
            String queryInfo = buffer.toString();
            queryInfo = queryInfo.substring(0,queryInfo.lastIndexOf(","));
            if(StringUtils.isNotBlank(filters)){
                filters+=";appId<>"+queryInfo;
            }else{
                filters="appId<>"+queryInfo;
            }
        }
        ResponseEntity<List<MApp>> responseEntity = appClient.getApps(fields,filters,sort,size,page);
        List<MApp> mAppList = responseEntity.getBody();
        for(MApp app :mAppList){
            appModelList.add(convertToAppModel(app));
        }
        Integer totalCount = getTotalCount(responseEntity);
        Envelop envelop = getResult(appModelList,totalCount,page,size);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.Apps.getAppTypeAndApps, method = RequestMethod.GET)
    @ApiOperation(value = "根据条件,获取APP类型及其所拥有的应用")
    public Envelop getAppTypeAndApps(
            @ApiParam(name = "userId", value = "用户ID", required = true)
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "manageType", value = "APP管理类型,backStage:后台管理,client:客户端。")
            @RequestParam(value = "manageType", required = false) String manageType) {
        Envelop envelop = new Envelop();
        //获取系统字典项(App类型)
        String filters="dictId="+1;
        String fields="";
        String sort="+sort";
        int size=999;
        int page=1;
        ResponseEntity<List<MDictionaryEntry>> responseEntity = systemDictClient.getDictEntries(fields, filters, sort, size, page);
        List<MDictionaryEntry> dictionaryEntries = responseEntity.getBody();
        List<SystemDictEntryModel> systemDictEntryModelList = (List<SystemDictEntryModel>) convertToModels(dictionaryEntries, new ArrayList<SystemDictEntryModel>(dictionaryEntries.size()), SystemDictEntryModel.class, null);
        List<SystemDictEntryModel> DictEntryModelList=new ArrayList<>();
        List<AppModel> appModelList=new ArrayList<>();
        Map<String,String> map=new HashedMap();
        if(null!=systemDictEntryModelList&&systemDictEntryModelList.size()>0){
            for(SystemDictEntryModel dict:systemDictEntryModelList){
                Collection<MApp> mAppList = appClient.getApps(userId, dict.getCode(), manageType);
                appModelList = (List<AppModel>) convertToModels(mAppList, new ArrayList<AppModel>(mAppList.size()), AppModel.class, null);
                dict.setChildren(appModelList);
                DictEntryModelList.add(dict);
            }
        }
        //应用列表
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(DictEntryModelList);
        return envelop;
    }
    @RequestMapping(value =  ServiceApi.Apps.CheckField, method = RequestMethod.POST)
    @ApiOperation(value = "根据条件判断应用ID或者名称是否存在")
    public Envelop isFieldExist(
            @ApiParam(name = "field", value = "字段", required = true)
            @RequestParam(value = "field") String field,
            @ApiParam(name = "value", value = "值", required = true)
            @RequestParam(value = "value") String value) {
        return appClient.isFieldExist(field, value);
    }
    @RequestMapping(value =  ServiceApi.Apps.AppAuthClient, method = RequestMethod.POST)
    @ApiOperation(value = "开放平台审核结果处理接口,包含App初始化和应用角色分配")
    public Envelop authClient(
            @ApiParam(name = "appJson", value = "App")
            @RequestParam(value = "appJson") String appJson,
            @ApiParam(name = "roleId", value = "角色ID")
            @RequestParam(value = "roleId") Integer roleId) throws Exception{
        return appClient.authClient(appJson, roleId);
    }
}

+ 285 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/controller/AppFeatureController.java

@ -0,0 +1,285 @@
package com.yihu.jw.apps.controller;
import com.yihu.jw.agModel.app.AppFeatureModel;
import com.yihu.jw.apps.service.AppFeatureClient;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.model.app.MAppFeature;
import com.yihu.jw.model.dict.MConventionalDict;
import com.yihu.jw.model.user.MRoleFeatureRelation;
import com.yihu.jw.systemdict.service.ConventionalDictEntryClient;
import com.yihu.jw.users.service.RoleFeatureRelationClient;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
 * Created by linz on 2016年7月8日11:30:18.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "AppFeature", description = "应用功能列表维护", tags = {"应用管理-应用功能列表维护"})
public class AppFeatureController extends BaseController {
    @Autowired
    AppFeatureClient appFeatureClient;
    @Autowired
    private ConventionalDictEntryClient conDictEntryClient;
    @Autowired
    private RoleFeatureRelationClient roleFeatureRelationClient;
    @RequestMapping(value = ServiceApi.AppFeature.AppFeatures, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppFeature列表")
    public Envelop getAppFeatures(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page, @RequestParam(value = "roleId", required = false) String roleId) {
        ResponseEntity<List<MAppFeature>> responseEntity = appFeatureClient.getAppFeatures(fields, filters, sort, size, page);
        List<MAppFeature> mAppFeatureList = responseEntity.getBody();
        List<AppFeatureModel> appFeatureModels = new ArrayList<>();
        for (MAppFeature mAppFeature : mAppFeatureList) {
            AppFeatureModel appFeatureModel = new AppFeatureModel();
            BeanUtils.copyProperties(mAppFeature, appFeatureModel);
            appFeatureModel.setRoleId(roleId);
            converModelName(appFeatureModel);
            appFeatureModels.add(appFeatureModel);
        }
        Integer totalCount = getTotalCount(responseEntity);
        Envelop envelop = getResult(appFeatureModels, totalCount, page, size);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppFeature.AppFeatures, method = RequestMethod.POST)
    @ApiOperation(value = "创建AppFeature")
    public Envelop createAppFeature(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestParam(value = "model", required = false) String model) {
        Envelop envelop = new Envelop();
        MAppFeature mAppFeature = appFeatureClient.createAppFeature(model);
        if (mAppFeature == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("保存失败!");
            return envelop;
        }
        AppFeatureModel appFeatureModel = new AppFeatureModel();
        BeanUtils.copyProperties(mAppFeature, appFeatureModel);
        converModelName(appFeatureModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appFeatureModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppFeature.AppFeature, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppFeature")
    public Envelop getAppFeature(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        MAppFeature mAppFeature = appFeatureClient.getAppFeature(id);
        AppFeatureModel appFeatureModel = new AppFeatureModel();
        if (mAppFeature == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("获取数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppFeature, appFeatureModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appFeatureModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppFeature.AppFeatures, method = RequestMethod.PUT)
    @ApiOperation(value = "更新AppFeature")
    public Envelop updateAppFeature(
            @ApiParam(name = "model", value = "对象JSON结构体", allowMultiple = true)
            @RequestParam(value = "model", required = false) String appFeature) {
        Envelop envelop = new Envelop();
        MAppFeature mAppFeature = appFeatureClient.updateAppFeature(appFeature);
        AppFeatureModel appFeatureModel = new AppFeatureModel();
        if (mAppFeature == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("更新数据失败!");
            return envelop;
        }
        BeanUtils.copyProperties(mAppFeature, appFeatureModel);
        converModelName(appFeatureModel);
        envelop.setSuccessFlg(true);
        envelop.setObj(appFeatureModel);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppFeature.AppFeature, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppFeature")
    Envelop deleteAppFeature(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        Boolean isDelete = appFeatureClient.deleteAppFeature(id);
        envelop.setSuccessFlg(isDelete);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppFeature.FilterFeatureList, method = RequestMethod.GET)
    @ApiOperation(value = "存在性校验")
    Envelop isExitAppFeature(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) {
        Envelop envelop = new Envelop();
        try {
            Boolean isExit = appFeatureClient.isExitAppFeature(filters);
            envelop.setSuccessFlg(true);
            envelop.setObj(isExit);
        } catch (Exception e) {
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppFeature.FilterFeatureNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppFeature排序后的列表(不分页)")
    public Envelop getAppFeatureNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "roleId", value = "角色ID")
            @RequestParam(value = "roleId", required = false) String roleId) {
        Collection<MAppFeature> mAppFeatures = appFeatureClient.getAppFeatureNoPageSorts(filters, sorts);
        Envelop envelop = new Envelop();
        List<AppFeatureModel> appFeatureModels = new ArrayList<>();
        for (MAppFeature mAppFeature : mAppFeatures) {
            AppFeatureModel appFeatureModel = convertToModel(mAppFeature, AppFeatureModel.class);
            if (StringUtils.isNotBlank(roleId)) {
                appFeatureModel.setRoleId(roleId);
            }
            converModelName(appFeatureModel);
            appFeatureModels.add(appFeatureModel);
        }
        envelop.setDetailModelList(appFeatureModels);
        return envelop;
    }
    @RequestMapping(value = "/role_app_feature/no_paging", method = RequestMethod.GET)
    @ApiOperation(value = "获取角色组的AppFeature列表")
    public Envelop getRoleAppFeatureNoPage(
            @ApiParam(name = "role_id", value = "角色组id")
            @RequestParam(value = "role_id") String roleId) {
        Collection<MRoleFeatureRelation> mRoleFeatureRelations = roleFeatureRelationClient.searchRoleFeatureNoPaging("roleId=" + roleId);
        String featureIds = "";
        String filters = "";
        for (MRoleFeatureRelation m : mRoleFeatureRelations) {
            featureIds += m.getFeatureId() + ",";
        }
        if (!StringUtils.isEmpty(featureIds)) {
            featureIds = featureIds.substring(0, featureIds.length() - 1);
        }
        if(StringUtils.isNotEmpty(featureIds)){
            filters = "id=" + featureIds;
        }
        Collection<MAppFeature> mAppFeatures = appFeatureClient.getAppFeatureNoPageSorts(filters, "+sort");
        Envelop envelop = new Envelop();
        List<AppFeatureModel> appFeatureModels = new ArrayList<>();
        for (MAppFeature mAppFeature : mAppFeatures) {
            AppFeatureModel appFeatureModel = convertToModel(mAppFeature, AppFeatureModel.class);
            appFeatureModels.add(appFeatureModel);
        }
        if (appFeatureModels.size() > 0) {
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(appFeatureModels);
            return envelop;
        }
        return failed("");
    }
    /**
     * 格式化字典数据
     *
     * @param appFeatureModel
     */
    private void converModelName(AppFeatureModel appFeatureModel) {
        //应用菜单类型
        if (!StringUtils.isEmpty(appFeatureModel.getType())) {
            MConventionalDict catalopDict = conDictEntryClient.getApplicationMenuType(appFeatureModel.getType());
            appFeatureModel.setTypeName(catalopDict == null ? "" : catalopDict.getValue());
        }
        //审计等级
        if (!StringUtils.isEmpty(appFeatureModel.getAuditLevel())) {
            MConventionalDict catalopDict = conDictEntryClient.getAuditLevel(appFeatureModel.getAuditLevel());
            appFeatureModel.setAuditLevelName(catalopDict == null ? "" : catalopDict.getValue());
        }
        //开放等级
        if (!StringUtils.isEmpty(appFeatureModel.getOpenLevel())) {
            MConventionalDict catalopDict = conDictEntryClient.getOpenLevel(appFeatureModel.getOpenLevel());
            appFeatureModel.setOpenLevelName(catalopDict == null ? "" : catalopDict.getValue());
        }
        //是否已经被角色组适配,界面适配用
        if (!StringUtils.isEmpty(appFeatureModel.getRoleId())) {
            ResponseEntity<Collection<MRoleFeatureRelation>> responseEntity = roleFeatureRelationClient.searchRoleFeature("", "roleId=" + appFeatureModel.getRoleId() + ";featureId=" + appFeatureModel.getId(), "", 1, 1);
            Collection<MRoleFeatureRelation> mRoleFeatureRelations = responseEntity.getBody();
            if (mRoleFeatureRelations != null && mRoleFeatureRelations.size() > 0) {
                appFeatureModel.setIschecked(true);
            } else {
                appFeatureModel.setIschecked(false);
            }
        }
    }
    @RequestMapping(value = "/AppFeatureFindUrl", method = RequestMethod.GET)
    @ApiOperation(value = "根据url获取对象")
    public Envelop AppFeatureFindUrl(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters) {
        Collection<MAppFeature> mAppFeatures = appFeatureClient.getAppFeatureNoPage(filters);
        Envelop envelop = new Envelop();
        List<AppFeatureModel> appFeatureModels = new ArrayList<>();
        if (mAppFeatures != null && mAppFeatures.size() > 0) {
            for (MAppFeature mAppFeature : mAppFeatures) {
                AppFeatureModel appFeatureModel = convertToModel(mAppFeature, AppFeatureModel.class);
                converModelName(appFeatureModel);
                appFeatureModels.add(appFeatureModel);
            }
            envelop.setSuccessFlg(true);
        }
        envelop.setDetailModelList(appFeatureModels);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.AppFeature.FindAppMenus, method = RequestMethod.GET)
    @ApiOperation(value = "根据权限,获取应用菜单")
    public Envelop findAppMenus(
            @ApiParam(name = "appId", value = "应用ID", required = true)
            @RequestParam(value = "appId", required = true) String appId,
            @ApiParam(name = "userId", value = "用户ID", required = true)
            @RequestParam(value = "userId", required = true) String userId) {
        try {
            Envelop envelop = new Envelop();
            List<Map<String, Object>> menuList = appFeatureClient.findAppMenus(appId, userId);
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(menuList);
            return envelop;
        } catch (Exception e) {
            return failed("获取应用菜单发生异常。");
        }
    }
}

+ 86 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppApiClient.java

@ -0,0 +1,86 @@
package com.yihu.jw.apps.service;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.app.MAppApi;
import com.yihu.jw.model.app.MAppApiDetail;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
import java.util.List;
/**
 * Created by linz on 2016年7月8日11:30:03.
 */
@ApiIgnore
@FeignClient(name=MicroServices.Application)
public interface AppApiClient {
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApi.AppApis, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApi列表")
    ResponseEntity<List<MAppApi>> getAppApis(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApi.AppApis, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建AppApi")
    MAppApi createAppApi(
            @ApiParam(name = "AppApi", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestBody String AppApiJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApi.AppApi, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApi")
    MAppApi getAppApi(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApi.AppApis, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新AppApi")
    MAppApi updateAppApi(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String appJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApi.AppApi, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppFeature")
    boolean deleteAppApi(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
    @RequestMapping(value =  ApiVersion.Version1_0 +ServiceApi.AppApi.AppApisNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "获取过滤App列表")
    public Collection<MAppApi> getAppApiNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApi.AppApiSearch, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApi列表")
    ResponseEntity<List<MAppApiDetail>> searchApi(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
}

+ 59 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppApiParameterClient.java

@ -0,0 +1,59 @@
package com.yihu.jw.apps.service;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.app.MAppApiParameter;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by linz on 2016年7月8日11:30:03.
 */
@FeignClient(name=MicroServices.Application)
public interface AppApiParameterClient {
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiParameter.AppApiParameters, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiParameter列表")
    ResponseEntity<List<MAppApiParameter>> getAppApiParameters(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiParameter.AppApiParameters, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建AppApiParameter")
    MAppApiParameter createAppApiParameter(
            @ApiParam(name = "AppApiParameter", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestBody String AppApiParameterJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiParameter.AppApiParameter, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiParameter")
    MAppApiParameter getAppApiParameter(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiParameter.AppApiParameters, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新AppApiParameter")
    MAppApiParameter updateAppApiParameter(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String appJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiParameter.AppApiParameter, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppFeature")
    boolean deleteAppApiParameter(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
}

+ 59 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppApiResponseClient.java

@ -0,0 +1,59 @@
package com.yihu.jw.apps.service;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.app.MAppApiResponse;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by linz on 2016年7月8日11:30:03.
 */
@FeignClient(name=MicroServices.Application)
public interface AppApiResponseClient {
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiResponse.AppApiResponses, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiResponse列表")
    ResponseEntity<List<MAppApiResponse>> getAppApiResponses(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiResponse.AppApiResponses, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建AppApiResponse")
    MAppApiResponse createAppApiResponse(
            @ApiParam(name = "AppApiResponse", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestBody String AppApiResponseJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiResponse.AppApiResponse, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppApiResponse")
    MAppApiResponse getAppApiResponse(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiResponse.AppApiResponses, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新AppApiResponse")
    MAppApiResponse updateAppApiResponse(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String appJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppApiResponse.AppApiResponse, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppFeature")
    boolean deleteAppApiResponse(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
}

+ 126 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppClient.java

@ -0,0 +1,126 @@
package com.yihu.jw.apps.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.model.app.MApp;
import com.yihu.jw.model.app.MUserApp;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/1/19.
 */
@FeignClient(name=MicroServices.Application)
public interface AppClient {
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.Apps, method = RequestMethod.GET)
    @ApiOperation(value = "获取App列表")
    ResponseEntity<List<MApp>> getApps(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.AppsNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "获取app列表,不分页")
    Collection<MApp> getAppsNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件",defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.Apps, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建App")
    MApp createApp(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true, defaultValue = "{\"name\": \"\", \"url\": \"\", \"catalog\": \"\", \"description\": \"\", \"creator\":\"\",\"icon\": \"\",\"releaseFlag\": \"\"}")
            @RequestBody String appJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.getApp, method = RequestMethod.GET)
    @ApiOperation(value = "获取App")
    MApp getApp(
            @ApiParam(name = "app_id", value = "id", defaultValue = "")
            @RequestParam(value = "app_id") String appId);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.Apps, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新App")
    MApp updateApp(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String appJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.App, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除app")
    boolean deleteApp(
            @ApiParam(name = "app_id", value = "id", defaultValue = "")
            @PathVariable(value = "app_id") String app_id);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.AppStatus, method = RequestMethod.PUT)
    @ApiOperation(value = "修改状态")
    boolean updateStatus(
            @ApiParam(name = "app_id", value = "id", defaultValue = "")
            @PathVariable(value = "app_id") String appId,
            @ApiParam(name = "app_status", value = "状态", defaultValue = "")
            @RequestParam(value = "app_status") String appStatus);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.AppExistence, method = RequestMethod.GET)
    boolean isAppExists(
            @ApiParam(name = "app_id", value = "id", defaultValue = "")
            @PathVariable(value = "app_id") String appId,
            @ApiParam(name = "secret", value = "", defaultValue = "")
            @RequestParam(value = "secret") String secret);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.AppNameExistence, method = RequestMethod.GET)
    boolean isAppNameExists(
            @ApiParam(value = "app_name")
            @PathVariable(value = "app_name") String appName);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.FilterList, method = RequestMethod.GET)
    @ApiOperation(value = "存在性校验")
    boolean isExitApp(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters") String filters);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.Apps.getApps, method = RequestMethod.GET)
    @ApiOperation(value = "根据条件,获取App列表")
    Collection<MApp>  getApps(
            @ApiParam(name = "userId", value = "userId", required = true)
            @RequestParam(value = "userId") String userId ,
            @ApiParam(name = "catalog", value = "catalog", required = true)
            @RequestParam(value = "catalog") String catalog,
            @ApiParam(name = "manageType", value = "APP管理类型,backStage:后台管理,client:客户端。")
            @RequestParam(value = "manageType", required = false) String manageType);
    @RequestMapping(value =  ApiVersion.Version1_0 + ServiceApi.Apps.CheckField, method = RequestMethod.POST)
    @ApiOperation(value = "根据条件判断应用ID或者名称是否存在")
    Envelop isFieldExist(
            @ApiParam(name = "field", value = "字段", required = true)
            @RequestParam(value = "field") String field,
            @ApiParam(name = "value", value = "值", required = true)
            @RequestParam(value = "value") String value);
    @RequestMapping(value =  ApiVersion.Version1_0 + ServiceApi.Apps.AppAuthClient, method = RequestMethod.POST)
    @ApiOperation(value = "开放平台审核结果处理接口,包含App初始化和应用角色分配")
    Envelop authClient(
            @ApiParam(name = "appJson", value = "App")
            @RequestParam(value = "appJson") String appJson,
            @ApiParam(name = "roleId", value = "角色ID")
            @RequestParam(value = "roleId") Integer roleId);
    @RequestMapping(value = ApiVersion.Version1_0 +  ServiceApi.UserApp.CreateUserApp, method = RequestMethod.GET)
    @ApiOperation(value = "创建用户与app关联")
    MUserApp createUserApp(
            @ApiParam(name = "userAppJson", value = "用户APP对象json")
            @RequestParam(value = "userAppJson", required = true) String userAppJson);
}

+ 89 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/apps/service/AppFeatureClient.java

@ -0,0 +1,89 @@
package com.yihu.jw.apps.service;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.app.MAppFeature;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
 * Created by linz on 2016年7月8日11:30:03.
 */
@FeignClient(name = MicroServices.Application)
public interface AppFeatureClient {
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.AppFeatures, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppFeature列表")
    ResponseEntity<List<MAppFeature>> getAppFeatures(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sort", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.AppFeatures, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建AppFeature")
    MAppFeature createAppFeature(
            @ApiParam(name = "appFeature", value = "对象JSON结构体", allowMultiple = true, defaultValue = "")
            @RequestBody String appFeatureJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.AppFeature, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppFeature")
    MAppFeature getAppFeature(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.AppFeatures, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新AppFeature")
    MAppFeature updateAppFeature(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String appJson);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.AppFeature, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppFeature")
    boolean deleteAppFeature(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.FilterFeatureList, method = RequestMethod.GET)
    @ApiOperation(value = "存在性校验")
    boolean isExitAppFeature(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters") String filters);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.FilterFeatureNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppFeature列表(不分页)")
    public Collection<MAppFeature> getAppFeatureNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.FilterFeatureNoPageSorts, method = RequestMethod.GET)
    @ApiOperation(value = "获取AppFeature排序后的列表(不分页)")
    public Collection<MAppFeature> getAppFeatureNoPageSorts(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序")
            @RequestParam(value = "sorts", required = false) String sorts);
    @RequestMapping(value = ApiVersion.Version1_0 + ServiceApi.AppFeature.FindAppMenus, method = RequestMethod.GET)
    @ApiOperation(value = "根据权限,获取应用菜单")
    public List<Map<String, Object>> findAppMenus(
            @ApiParam(name = "appId", value = "应用ID", required = true)
            @RequestParam(value = "appId", required = true) String appId,
            @ApiParam(name = "userId", value = "用户ID", required = true)
            @RequestParam(value = "userId", required = true) String userId);
}

+ 29 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/config/FeignMultipartSupportConfig.java

@ -0,0 +1,29 @@
package com.yihu.jw.config;
import feign.codec.Encoder;
//import feign.form.spring.SpringFormEncoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
/**
 * Created by progr1mmer on 2017/12/16.
 */
//@Configuration
public class FeignMultipartSupportConfig {
    @Bean
    @Primary
    @Scope("prototype")
    public Encoder multipartFormEncoder() {
        return new SpringFormEncoder();
    }
    @Bean
    public feign.Logger.Level multipartLoggerLevel() {
        return feign.Logger.Level.FULL;
    }
}

+ 27 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/config/TenantConfiguration.java

@ -0,0 +1,27 @@
package com.yihu.jw.config;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 *   ehr使用 feginClient 调用eip(涉及到app应用,标准等) 时,需要此类,增加请求头信息
 */
@Configuration
public class TenantConfiguration {
    @Value("${eip.tenant}")
    private String tenant;
    @Bean
    public RequestInterceptor tenantInterceptor() {
        return new RequestInterceptor() {
            @Override
            public void apply(RequestTemplate requestTemplate) {
                requestTemplate.header("tenant_name", tenant);
            }
        };
    }
}

+ 68 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/device/client/DeviceClient.java

@ -0,0 +1,68 @@
package com.yihu.jw.device.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.entity.device.Device;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * @Author: zhengwei
 * @Date: 2018/5/4 15:47
 * @Description: 设备管理
 */
@ApiIgnore
@FeignClient(name = MicroServices.Basic)
@RequestMapping(ApiVersion.Version1_0)
public interface DeviceClient {
    @RequestMapping(value = ServiceApi.Device.DeviceList, method = RequestMethod.GET)
    @ApiOperation(value = "获取所有列表")
    Envelop list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size);
    @RequestMapping(value = ServiceApi.Device.DeviceSave, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("保存")
    Envelop save(
            @ApiParam(name = "device", value = "实体类Json")
            @RequestParam(value = "device") String device);
    @RequestMapping(value = ServiceApi.Device.DeviceDelete, method = RequestMethod.POST)
    @ApiOperation("删除记录")
    Envelop delete(
            @ApiParam(name = "ids", value = "id列表", required = true)
            @RequestParam(value = "ids") String ids);
    @RequestMapping(value = ServiceApi.Device.FindById, method = RequestMethod.GET)
    @ApiOperation("获取单条记录")
    Envelop findById(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id") String id);
    @RequestMapping(value = ServiceApi.Device.DeviceBatch, method = RequestMethod.POST)
    @ApiOperation("批量导入")
    boolean addBatch(
            @ApiParam(name = "devices", value = "实体类列表Json")
            @RequestParam(value = "devices") String devices);
}

+ 86 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/device/controller/DeviceController.java

@ -0,0 +1,86 @@
package com.yihu.jw.device.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.device.client.DeviceClient;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.*;
/**
 * @Author: zhengwei
 * @Date: 2018/5/4 15:47
 * @Description: 设备管理
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + ServiceApi.GateWay.admin)
@Api(value = "DeviceController", description = "设备管理", tags = {"基础信息-设备管理"})
public class DeviceController extends BaseController {
    @Autowired
    private DeviceClient deviceClient;
    @RequestMapping(value = ServiceApi.Device.DeviceList, method = RequestMethod.GET)
    @ApiOperation(value = "获取所有列表")
    public Envelop list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        return deviceClient.list(fields, filters, sorts, page, size);
    }
    @RequestMapping(value = ServiceApi.Device.DeviceSave, method = RequestMethod.POST)
    @ApiOperation("保存")
    public Envelop save(
            @ApiParam(name = "device", value = "实体类Json")
            @RequestParam(value = "device") String device) throws Exception {
       return deviceClient.save(device);
    }
    @RequestMapping(value = ServiceApi.Device.DeviceDelete, method = RequestMethod.POST)
    @ApiOperation("删除记录")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id列表", required = true)
            @RequestParam(value = "ids") String ids) throws Exception {
        return deviceClient.delete(ids);
    }
    @RequestMapping(value = ServiceApi.Device.FindById, method = RequestMethod.GET)
    @ApiOperation("获取单条记录")
    public Envelop findById(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id") String id){
        return deviceClient.findById(id);
    }
    @RequestMapping(value = ServiceApi.Device.DeviceBatch, method = RequestMethod.POST)
    @ApiOperation("批量导入")
    public Envelop addBatch(
            @ApiParam(name = "devices", value = "实体类列表Json")
            @RequestParam(value = "devices") String devices) throws Exception{
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        try{
            deviceClient.addBatch(devices);
        }catch (Exception e){
            e.printStackTrace();
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("导入失败!"+e.getMessage());
        }
        return envelop;
    }
}

+ 75 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/dfs/client/ElasticSearchClient.java

@ -0,0 +1,75 @@
package com.yihu.jw.dfs.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Client - Es搜索服务
 * Created by progr1mmer on 2017/12/2.
 */
@ApiIgnore
@FeignClient(name = MicroServices.Dfs)
@RequestMapping(ApiVersion.Version1_0)
public interface ElasticSearchClient {
    @RequestMapping(value = ServiceApi.ElasticSearch.Mapping, method = RequestMethod.POST)
    @ApiOperation(value = "建立索引")
    Envelop mapping(
            @RequestParam(value = "index") String index,
            @RequestParam(value = "type") String type,
            @RequestParam(value = "source") String source);
    @RequestMapping(value = ServiceApi.ElasticSearch.Index, method = RequestMethod.POST)
    @ApiOperation(value = "添加数据")
    Envelop index(
            @RequestParam(value = "index") String index,
            @RequestParam(value = "type") String type,
            @RequestParam(value = "source") String source);
    @RequestMapping(value = ServiceApi.ElasticSearch.Delete, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除数据")
    Envelop delete(
            @RequestParam(value = "index") String index,
            @RequestParam(value = "type") String type,
            @RequestParam(value = "id") String id);
    @RequestMapping(value = ServiceApi.ElasticSearch.Update, method = RequestMethod.PUT)
    @ApiOperation(value = "更新数据")
    Envelop update(
            @RequestParam(value = "index") String index,
            @RequestParam(value = "type") String type,
            @RequestParam(value = "id") String id,
            @RequestParam(value = "source") String source);
    @RequestMapping(value = ServiceApi.ElasticSearch.FindById, method = RequestMethod.GET)
    @ApiOperation(value = "获取单条数据")
    Envelop findById(
            @RequestParam(value = "index") String index,
            @RequestParam(value = "type") String type,
            @PathVariable(value = "id") String id);
    @RequestMapping(value = ServiceApi.ElasticSearch.FindByField, method = RequestMethod.GET)
    @ApiOperation(value = "获取结果集")
    Envelop findByField(
            @RequestParam(value = "index") String index,
            @RequestParam(value = "type") String type,
            @RequestParam(value = "field") String field,
            @RequestParam(value = "value") String value);
    @RequestMapping(value = ServiceApi.ElasticSearch.Page, method = RequestMethod.GET)
    @ApiOperation(value = "获取结果集")
    Envelop page(
            @RequestParam(value = "index") String index,
            @RequestParam(value = "type") String type,
            @RequestParam(value = "filter", required = false) String filter,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
}

+ 98 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/dfs/client/FastDFSClient.java

@ -0,0 +1,98 @@
package com.yihu.jw.dfs.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Client - 文件服务
 * Created by progr1mmer on 2017/12/1.
 */
@ApiIgnore
@FeignClient(name = MicroServices.Dfs)
@RequestMapping(ApiVersion.Version1_0)
public interface FastDFSClient {
    @RequestMapping(value = ServiceApi.FastDFS.Upload, method = RequestMethod.POST)
    @ApiOperation(value = "文件上传", notes = "返回相关索引信息,以及HttpUrl下载连接")
    Envelop upload(
            @RequestPart(value = "file") MultipartFile file,
            @RequestParam(value = "creator") String creator,
            @RequestParam(value = "objectId") String objectId);
    @RequestMapping(value = ServiceApi.FastDFS.OldUpload, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "文件上传", notes = "返回相关索引信息,以及HttpUrl下载连接(兼容旧接口)")
    Envelop upload(
            @RequestBody String jsonData);
    @RequestMapping(value = ServiceApi.FastDFS.DeleteById, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastDfs相对应文件")
    Envelop deleteById(
            @RequestParam(value = "id") String id);
    @RequestMapping(value = ServiceApi.FastDFS.DeleteByPath, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastDfs相对应文件")
    Envelop deleteByPath(
            @RequestParam(value = "path") String path);
    @RequestMapping(value = ServiceApi.FastDFS.DeleteByObjectId, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastDfs相对应文件")
    Envelop deleteByObjectId(
            @RequestParam(value = "objectId") String objectId);
    @RequestMapping(value = ServiceApi.FastDFS.FileInfo, method = RequestMethod.GET)
    @ApiOperation(value = "获取文件信息")
    Envelop getFileInfo(
            @RequestParam(value = "path") String path);
    @RequestMapping(value = ServiceApi.FastDFS.DownloadById, method = RequestMethod.GET)
    @ApiOperation(value = "下载文件(byId)")
    Envelop downloadById (
            @RequestParam(value = "id") String id);
    @RequestMapping(value = ServiceApi.FastDFS.DeleteByPath, method = RequestMethod.GET)
    @ApiOperation(value = "下载文件(byPath)")
    Envelop downloadByPath(
            @RequestParam(value = "path") String path);
    @RequestMapping(value = ServiceApi.FastDFS.DownloadByObjectId, method = RequestMethod.GET)
    @ApiOperation(value = "下载文件(byObjectId)")
    Envelop downloadByObjectId(
            @RequestParam(value = "objectId") String objectId);
    @RequestMapping(value = ServiceApi.FastDFS.GetFilePath, method = RequestMethod.GET)
    @ApiOperation(value = "获取文件路径(byObjectId)")
    Envelop getFilePath(
            @RequestParam(value = "objectId") String objectId);
    @RequestMapping(value = ServiceApi.FastDFS.Page, method = RequestMethod.GET)
    @ApiOperation(value = "获取结果集")
    Envelop page(
            @RequestParam(value = "filter", required = false) String filter,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
    @RequestMapping(value = "/fastDfs/status", method = RequestMethod.GET)
    @ApiOperation(value = "获取服务器状态信息")
    Envelop status();
    @RequestMapping(value = ServiceApi.FastDFS.GetPublicUrl, method = RequestMethod.GET)
    @ApiOperation(value = "获取外链地址")
    Envelop getPublicUrl();
    @RequestMapping(value = ServiceApi.FastDFS.SetPublicUrl, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "设置外链地址")
    Envelop setPublicUrl(
            @RequestBody String jsonData);
}

+ 136 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/dfs/controller/ElasticSearchController.java

@ -0,0 +1,136 @@
package com.yihu.jw.dfs.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.EnvelopRestEndPoint;
import com.yihu.jw.dfs.client.ElasticSearchClient;
import com.yihu.jw.quota.service.TjQuotaJobClient;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.*;
/**
 * EndPoint - Es搜索服务
 * Created by progr1mmer on 2017/12/2.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + ServiceApi.GateWay.admin)
@Api(value = "ElasticSearchController", description = "Es搜索服务", tags = {"分布式综合服务-Es搜索服务"})
public class ElasticSearchController extends EnvelopRestEndPoint {
    @Autowired
    private ElasticSearchClient elasticSearchClient;
    @Autowired
    private TjQuotaJobClient tjQuotaJobClient;
    @RequestMapping(value = ServiceApi.ElasticSearch.Mapping, method = RequestMethod.POST)
    @ApiOperation(value = "建立索引")
    public Envelop mapper(
            @ApiParam(name = "index", value = "索引名称", required = true)
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "source", value = "Json串值", required = true)
            @RequestParam(value = "source") String source) {
        return elasticSearchClient.mapping(index, type, source);
    }
    @RequestMapping(value = ServiceApi.ElasticSearch.Index, method = RequestMethod.POST)
    @ApiOperation(value = "添加数据")
    public Envelop index(
            @ApiParam(name = "index", value = "索引名称", required = true)
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "source", value = "值", required = true)
            @RequestParam(value = "source") String source) {
        return elasticSearchClient.index(index, type, source);
    }
    @RequestMapping(value = ServiceApi.ElasticSearch.Delete, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除数据")
    public Envelop delete(
            @ApiParam(name = "index", value = "索引名称", required = true)
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "id", value = "id(多个id值以,分隔)", required = true)
            @RequestParam(value = "id") String id) {
        return elasticSearchClient.delete(index, type, id);
    }
    @RequestMapping(value = ServiceApi.ElasticSearch.Update, method = RequestMethod.PUT)
    @ApiOperation(value = "更新数据")
    public Envelop update(
            @ApiParam(name = "index", value = "索引名称", required = true)
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id,
            @ApiParam(name = "source", value = "值", required = true)
            @RequestParam(value = "source") String source) {
        return elasticSearchClient.update(index, type, id, source);
    }
    @RequestMapping(value = ServiceApi.ElasticSearch.FindById, method = RequestMethod.GET)
    @ApiOperation(value = "获取单条数据")
    public Envelop findById(
            @ApiParam(name = "index", value = "索引名称", required = true)
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "id", value = "id", required = true)
            @PathVariable(value = "id") String id) {
        return elasticSearchClient.findById(index, type, id);
    }
    @RequestMapping(value = ServiceApi.ElasticSearch.FindByField, method = RequestMethod.GET)
    @ApiOperation(value = "获取结果集")
    public Envelop findByField(
            @ApiParam(name = "index", value = "索引名称", required = true)
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "field", value = "字段", required = true)
            @RequestParam(value = "field") String field,
            @ApiParam(name = "value", value = "字段值", required = true)
            @RequestParam(value = "value") String value) {
        return elasticSearchClient.findByField(index, type, field, value);
    }
    @RequestMapping(value = ServiceApi.ElasticSearch.Page, method = RequestMethod.GET)
    @ApiOperation(value = "获取结果集")
    public Envelop page(
            @ApiParam(name = "index", value = "索引名称", required = true)
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "filter", value = "过滤条件")
            @RequestParam(value = "filter", required = false) String filter,
            @ApiParam(name = "page", value = "页码", required = true)
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "分页大小", required = true)
            @RequestParam(value = "size") int size) {
        return elasticSearchClient.page(index, type, filter, page, size);
    }
    @RequestMapping(value = "/elasticSearch/addElasticSearch", method = RequestMethod.POST)
    @ApiOperation("elasticsearch文档数据")
    public Envelop addElasticSearch(
            @ApiParam(name = "index", value = "索引名称")
            @RequestParam(value = "index") String index,
            @ApiParam(name = "type", value = "索引类型")
            @RequestParam(value = "type") String type,
            @ApiParam(name = "sourceList", value = "值")
            @RequestParam(value = "sourceList") String sourceList) throws Exception {
        Envelop envelop = new Envelop();
        boolean flag = tjQuotaJobClient.addElasticSearch(index, type, sourceList);
        envelop.setSuccessFlg(flag);
        return envelop;
    }
}

+ 225 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/dfs/controller/FastDFSController.java

@ -0,0 +1,225 @@
package com.yihu.jw.dfs.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.EnvelopRestEndPoint;
import com.yihu.jw.dfs.client.FastDFSClient;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
 * EndPoint - 文件服务
 * Created by progr1mmer on 2017/12/1.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + ServiceApi.GateWay.admin)
@Api(value = "FastDFSController", description = "FastDFS服务", tags = {"分布式综合服务-FastDfs服务"})
public class FastDFSController extends EnvelopRestEndPoint {
    @Autowired
    private FastDFSClient fastDFSClient;
    /**
     * 文件上传 - 返回相关索引信息,以及HttpUrl下载连接
     * @param file
     * @param creator
     * @param objectId
     * @return
     */
    @RequestMapping(value = ServiceApi.FastDFS.Upload, method = RequestMethod.POST)
    @ApiOperation(value = "文件上传", notes = "返回相关索引信息,以及HttpUrl下载连接")
    public Envelop upload(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            @ApiParam(name = "creator", value = "创建者", required = true)
            @RequestParam(value = "creator") String creator,
            @ApiParam(name = "objectId", value = "创建者标识", required = true, defaultValue = "EHR")
            @RequestParam(value = "objectId") String objectId) {
        return fastDFSClient.upload(file, creator, objectId);
    }
    /**
     * 文件上传 - 返回相关索引信息,以及HttpUrl下载连接(兼容旧接口)
     * @param jsonData
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.OldUpload, method = RequestMethod.POST)
    @ApiOperation(value = "上传文件", notes = "返回相关索引信息,以及HttpUrl下载连接(兼容旧接口)")
    public Envelop upload(
            @ApiParam(name = "jsonData", value = "文件资源", required = true)
            @RequestParam(value = "jsonData") String jsonData) {
        return fastDFSClient.upload(jsonData);
    }
    /**
     * 删除资源表对应关系,并且删除fastDfs相对应当文件
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.DeleteById, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastDfs相对应文件")
    public Envelop deleteById(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) {
        return fastDFSClient.deleteById(id);
    }
    /**
     * 删除资源表对应关系,并且删除fastDfs相对应当文件
     * @param path
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.DeleteByPath, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastDfs相对应文件")
    public Envelop deleteByPath(
            @ApiParam(name = "path", value = "文件路径", required = true)
            @RequestParam(value = "path") String path) {
        return fastDFSClient.deleteByPath(path);
    }
    /**
     * 删除资源表对应关系,并且删除fastDfs相对应当文件
     * @param objectId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.DeleteByObjectId, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastDfs相对应文件")
    public Envelop deleteByObjectId(
            @ApiParam(name = "objectId", value = "对象ID", required = true)
            @RequestParam(value = "objectId") String objectId) {
        return fastDFSClient.deleteByObjectId(objectId);
    }
    /**
     * 获取文件信息
     * @param path
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.FileInfo, method = RequestMethod.GET)
    @ApiOperation(value = "获取文件信息")
    public Envelop getFileInfo(
            @ApiParam(name = "path", value = "路径", required = true)
            @RequestParam(value = "path") String path) {
        return fastDFSClient.getFileInfo(path);
    }
    /**
     * 下载文件
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.DownloadById, method = RequestMethod.GET)
    @ApiOperation(value = "下载文件(byId)")
    public Envelop downloadById (
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) {
        return fastDFSClient.downloadById(id);
    }
    /**
     * 下载文件
     * @param path
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.DownloadByPath, method = RequestMethod.GET)
    @ApiOperation(value = "下载文件(byPath)")
    public Envelop downloadByPath(
            @ApiParam(name = "path", value = "文件路径", required = true)
            @RequestParam(value = "path") String path) {
       return fastDFSClient.downloadByPath(path);
    }
    /**
     * 下载文件
     * @param objectId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.DownloadByObjectId, method = RequestMethod.GET)
    @ApiOperation(value = "下载文件(byObjectId)")
    public Envelop downloadByObjectId(
            @ApiParam(name = "objectId", value = "对象ID", required = true)
            @RequestParam(value = "objectId") String objectId) {
        return fastDFSClient.downloadByObjectId(objectId);
    }
    /**
     * 获取文件下载路径
     * @param objectId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.GetFilePath, method = RequestMethod.GET)
    @ApiOperation(value = "获取文件路径(byObjectId)")
    public Envelop getFilePath(
            @ApiParam(name = "objectId", value = "对象ID", required = true)
            @RequestParam(value = "objectId") String objectId) {
       return fastDFSClient.getFilePath(objectId);
    }
    /**
     * 获取分页
     * @param filter
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.FastDFS.Page, method = RequestMethod.GET)
    @ApiOperation(value = "获取结果集")
    public Envelop page(
            @ApiParam(name = "filter", value = "过滤条件")
            @RequestParam(value = "filter", required = false) String filter,
            @ApiParam(name = "page", value = "页码", required = true)
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "分页大小", required = true)
            @RequestParam(value = "size") int size) {
        return fastDFSClient.page(filter, page, size);
    }
    /**
     * 获取服务器状态信息
     * @return
     */
    @RequestMapping(value = ServiceApi.FastDFS.Status, method = RequestMethod.GET)
    @ApiOperation(value = "获取服务器状态信息")
    public Envelop status() {
        return fastDFSClient.status();
    }
    /**
     * 获取外链地址
     * @return
     */
    @RequestMapping(value = ServiceApi.FastDFS.GetPublicUrl, method = RequestMethod.GET)
    @ApiOperation(value = "获取外链地址")
    public Envelop getPublicUrl() {
        return fastDFSClient.getPublicUrl();
    }
    /**
     * 设置外链地址
     * @return
     */
    @RequestMapping(value = ServiceApi.FastDFS.SetPublicUrl, method = RequestMethod.POST)
    @ApiOperation(value = "设置外链地址")
    public Envelop setPublicUrl(
            @ApiParam(name = "jsonData", value = "字典项JSON结构")
            @RequestParam(value = "jsonData") String jsonData) {
        return fastDFSClient.setPublicUrl(jsonData);
    }
}

+ 82 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/AmbulanceClient.java

@ -0,0 +1,82 @@
package com.yihu.jw.emergency.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * Client - 救护车信息
 * Created by progr1mmer on 2017/11/8.
 */
@ApiIgnore
@FeignClient(name = MicroServices.Basic)
@RequestMapping(ApiVersion.Version1_0)
public interface AmbulanceClient{
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceList, method = RequestMethod.GET)
    @ApiOperation(value = "获取所有救护车列表")
    Envelop list(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceSearch, method = RequestMethod.GET)
    @ApiOperation(value = "查询救护车信息,包括执勤人员信息")
    Envelop search(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceUpdateStatus, method = RequestMethod.PUT)
    @ApiOperation(value = "更新救护车状态信息")
    Envelop updateStatus(
            @RequestParam(value = "carId") String carId,
            @RequestParam(value = "status") String status);
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceSave, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("保存单条记录")
    Envelop save(
            @RequestBody String ambulance);
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceUpdate, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新单条记录")
    Envelop update(
            @RequestBody String ambulance);
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceDelete, method = RequestMethod.DELETE)
    @ApiOperation("删除记录")
    Envelop delete(
            @RequestParam(value = "ids") String ids);
    @RequestMapping(value = ServiceApi.Emergency.Ambulance, method = RequestMethod.GET)
    @ApiOperation("获取单条记录")
    Envelop findById(
            @RequestParam(value = "id") String id);
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceIdOrPhoneExistence, method = RequestMethod.POST)
    @ApiOperation("获取已存在车牌号、电话号码")
    List idExistence(
            @ApiParam(name = "type", value = "字段名")
            @RequestParam(value = "type") String type,
            @ApiParam(name = "values", value = "值")
            @RequestParam(value = "values") String values);
    @RequestMapping(value = ServiceApi.Emergency.AmbulancesBatch, method = RequestMethod.POST)
    @ApiOperation("批量导入救护车")
    boolean createAmbulancesBatch(
            @RequestBody String ambulances);
}

+ 77 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/AttendanceClient.java

@ -0,0 +1,77 @@
package com.yihu.jw.emergency.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Client - 出勤记录
 * Created by progr1mmer on 2017/11/8.
 */
@ApiIgnore
@FeignClient(name = MicroServices.Basic)
@RequestMapping(ApiVersion.Version1_0)
public interface AttendanceClient {
    @RequestMapping(value = ServiceApi.Emergency.AttendanceSave, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "保存出勤记录")
    Envelop save(
            @RequestBody String attendance);
    @RequestMapping(value = ServiceApi.Emergency.AttendanceUpdate, method = RequestMethod.PUT)
    @ApiOperation(value = "更新出勤记录")
    Envelop update(
            @RequestParam(value = "carId") String carId,
            @RequestParam(value = "status") String status);
    @RequestMapping(value = ServiceApi.Emergency.AttendanceEdit, method = RequestMethod.PUT)
    @ApiOperation("编辑出勤记录")
    Envelop edit(
            @RequestBody String attendance);
    @RequestMapping(value = ServiceApi.Emergency.AttendanceList, method = RequestMethod.GET)
    @ApiOperation("获取出勤列表")
    Envelop list(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
    @RequestMapping(value = ServiceApi.Emergency.AttendanceDelete, method = RequestMethod.DELETE)
    @ApiOperation("删除出勤记录")
    Envelop delete(
            @ApiParam(name = "ids", value = "id列表[1,2,3...] int")
            @RequestParam(value = "ids") String ids);
    @RequestMapping(value = ServiceApi.Emergency.AttendanceDetail, method = RequestMethod.GET)
    @ApiOperation("出勤记录详情")
    Envelop detail(
            @ApiParam(name = "id", value = "出勤记录id")
            @RequestParam(value = "id") String id);
    @RequestMapping(value = ServiceApi.Emergency.AttendanceAnalysis, method = RequestMethod.GET)
    @ApiOperation("出勤记录分析")
    Envelop analysis();
    @RequestMapping(value = "/attendance/queryChart1", method = RequestMethod.GET)
    @ApiOperation("出车次数分析")
    Envelop queryChart1(
            @ApiParam(name = "flag", value = "查询类型月、季、年(1,2,3)")
            @RequestParam(value = "flag") String flag);
    @RequestMapping(value = "/attendance/queryChart3", method = RequestMethod.GET)
    @ApiOperation("出勤地点热力图")
    Envelop queryChart3();
}

+ 54 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/LocationClient.java

@ -0,0 +1,54 @@
package com.yihu.jw.emergency.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Client - 待命地点
 * Created by progr1mmer on 2017/11/22.
 */
@ApiIgnore
@FeignClient(name = MicroServices.Basic)
@RequestMapping(ApiVersion.Version1_0)
public interface LocationClient {
    @RequestMapping(value = ServiceApi.Emergency.LocationList, method = RequestMethod.GET)
    @ApiOperation("获取待命地点列表")
    Envelop list(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
    @RequestMapping(value = ServiceApi.Emergency.LocationSave, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("保存单条记录")
    Envelop save(
            @ApiParam(name = "location", value = "待命地点")
            @RequestBody String location);
    @RequestMapping(value = ServiceApi.Emergency.LocationUpdate, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新单条记录")
    Envelop update(
            @ApiParam(name = "location", value = "排班")
            @RequestBody String location);
    @RequestMapping(value = ServiceApi.Emergency.LocationDelete, method = RequestMethod.DELETE)
    @ApiOperation("删除待命地点")
    Envelop delete(
            @ApiParam(name = "ids", value = "id列表[1,2,3...] int")
            @RequestParam(value = "ids") String ids);
}

+ 67 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/client/ScheduleClient.java

@ -0,0 +1,67 @@
package com.yihu.jw.emergency.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Client - 排班历史
 * Created by progr1mmer on 2017/11/8.
 */
@ApiIgnore
@FeignClient(name = MicroServices.Basic)
@RequestMapping(ApiVersion.Version1_0)
public interface ScheduleClient {
    @RequestMapping(value = ServiceApi.Emergency.ScheduleList, method = RequestMethod.GET)
    @ApiOperation("获取排班列表")
    Envelop list(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
    @RequestMapping(value = ServiceApi.Emergency.ScheduleLevel, method = RequestMethod.GET)
    @ApiOperation("获取排班层级列表(年-月-日)")
    Envelop level(
            @RequestParam(value = "date", required = false) String date,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "size") int size);
    @RequestMapping(value = ServiceApi.Emergency.ScheduleSave, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("保存单条记录")
    Envelop save(
            @ApiParam(name = "schedule", value = "排班")
            @RequestBody String schedule);
    @RequestMapping(value = ServiceApi.Emergency.ScheduleUpdate, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新单条记录")
    Envelop update(
            @ApiParam(name = "schedule", value = "排班")
            @RequestBody String schedule);
    @RequestMapping(value = ServiceApi.Emergency.ScheduleBathUpdate, method = RequestMethod.PUT)
    @ApiOperation("更新多条数据")
    Envelop bathUpdate(
            @ApiParam(name = "schedules", value = "排班")
            @RequestParam(value = "schedules") String schedules);
    @RequestMapping(value = ServiceApi.Emergency.ScheduleBatch, method = RequestMethod.POST)
    @ApiOperation("批量导入排班信息")
    boolean createSchedulesBatch(
            @ApiParam(name = "schedules", value = "排班")
            @RequestParam(value = "schedules") String schedules);
}

+ 131 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/AmbulanceController.java

@ -0,0 +1,131 @@
package com.yihu.jw.emergency.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.emergency.client.AmbulanceClient;
import com.yihu.jw.util.rest.Envelop;
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.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Controller - 救护车信息
 * Created by progr1mmer on 2017/11/8.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + ServiceApi.GateWay.admin)
@Api(value = "AmbulanceController", description = "救护车信息", tags = {"应急指挥-救护车信息"})
public class AmbulanceController extends BaseController {
    @Autowired
    private AmbulanceClient ambulanceClient;
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceList, method = RequestMethod.GET)
    @ApiOperation(value = "获取所有救护车列表")
    public Envelop list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) {
        return ambulanceClient.list(fields, filters, sorts, page, size);
    }
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceSearch , method = RequestMethod.GET)
    @ApiOperation(value = "查询救护车信息以及包括执勤人员信息,检索条件只针对车辆")
    public Envelop search(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) {
        return ambulanceClient.search(fields, filters, sorts, page, size);
    }
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceUpdateStatus, method = RequestMethod.PUT)
    @ApiOperation(value = "更新救护车状态信息")
    public Envelop update(
            @ApiParam(name = "carId", value = "车牌号码")
            @RequestParam(value = "carId") String carId,
            @ApiParam(name = "status", value = "车辆状态码(0为统一可用状态码,1为统一不可用状态码)")
            @RequestParam(value = "status") String status) {
        return ambulanceClient.updateStatus(carId, status);
    }
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceSave, method = RequestMethod.POST)
    @ApiOperation("保存单条记录")
    public Envelop save(
            @ApiParam(name = "ambulance", value = "救护车")
            @RequestParam(value = "ambulance") String ambulance){
        return ambulanceClient.save(ambulance);
    }
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceUpdate, method = RequestMethod.PUT)
    @ApiOperation("更新单条记录")
    public Envelop update(
            @ApiParam(name = "ambulance", value = "救护车")
            @RequestParam(value = "ambulance") String ambulance){
        return ambulanceClient.update(ambulance);
    }
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceDelete, method = RequestMethod.DELETE)
    @ApiOperation("删除记录")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id列表xxxx,xxxx,xxxx,...")
            @RequestParam(value = "ids") String ids){
        return ambulanceClient.delete(ids);
    }
    @RequestMapping(value = ServiceApi.Emergency.Ambulance, method = RequestMethod.GET)
    @ApiOperation("获取单条记录")
    public Envelop findById(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id") String id){
        return ambulanceClient.findById(id);
    }
    @RequestMapping(value = ServiceApi.Emergency.AmbulanceIdOrPhoneExistence, method = RequestMethod.POST)
    @ApiOperation("获取已存在车牌号、电话号码")
    public List idExistence(
            @ApiParam(name = "type", value = "字段名")
            @RequestParam(value ="type") String type,
            @ApiParam(name = "values", value = "值")
            @RequestParam(value ="values") String values) throws Exception {
        List vals = ambulanceClient.idExistence(type, values);
        return vals;
    }
    @RequestMapping(value = ServiceApi.Emergency.AmbulancesBatch, method = RequestMethod.POST)
    @ApiOperation("批量导入救护车")
    public Envelop createAmbulancesBatch(
            @ApiParam(name = "ambulances", value = "救护车", defaultValue = "")
            @RequestParam(value = "ambulances") String ambulances) throws Exception {
        Envelop envelop = new Envelop();
        try{
            ambulanceClient.createAmbulancesBatch(ambulances);
            envelop.setSuccessFlg(true);
        }catch (Exception e){
            e.printStackTrace();
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("导入失败!" + e.getMessage());
        }
        return envelop;
    }
}

+ 106 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/AttendanceController.java

@ -0,0 +1,106 @@
package com.yihu.jw.emergency.controller;
import com.netflix.eureka.V1AwareInstanceInfoConverter;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.emergency.client.AttendanceClient;
import com.yihu.jw.util.rest.Envelop;
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.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Controller - 出勤记录
 * Created by progr1mmer on 2017/11/8.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + ServiceApi.GateWay.admin)
@Api(value = "AttendanceController", description = "出勤记录", tags = {"应急指挥-出勤记录"})
public class AttendanceController extends BaseController {
    @Autowired
    private AttendanceClient attendanceClient;
    @RequestMapping(value = ServiceApi.Emergency.AttendanceSave, method = RequestMethod.POST)
    @ApiOperation(value = "保存出勤记录")
    public Envelop save(
            @ApiParam(name = "attendance", value = "出勤记录")
            @RequestParam(value = "attendance") String attendance) {
        return attendanceClient.save(attendance);
    }
    @RequestMapping(value = ServiceApi.Emergency.AttendanceUpdate, method = RequestMethod.PUT)
    @ApiOperation(value = "更新出勤记录")
    public Envelop update(
            @ApiParam(name = "carId", value = "车牌号码")
            @RequestParam(value = "carId") String carId,
            @ApiParam(name = "status", value = "任务状态")
            @RequestParam(value = "status") String status) {
        return attendanceClient.update(carId, status);
    }
    @RequestMapping(value = ServiceApi.Emergency.AttendanceEdit, method = RequestMethod.PUT)
    @ApiOperation("编辑出勤记录")
    public Envelop edit(
            @ApiParam(name = "attendance", value = "出勤记录")
            @RequestParam(value = "attendance") String attendance) {
        return attendanceClient.edit(attendance);
    }
    @RequestMapping(value = ServiceApi.Emergency.AttendanceList, method = RequestMethod.GET)
    @ApiOperation("获取出勤列表")
    public Envelop list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) {
        return attendanceClient.list(fields, filters, sorts, page, size);
    }
    @RequestMapping(value = ServiceApi.Emergency.AttendanceDelete, method = RequestMethod.DELETE)
    @ApiOperation("删除出勤记录")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id列表(int)1,2,3,...")
            @RequestParam(value = "ids") String ids){
        return attendanceClient.delete(ids);
    }
    @RequestMapping(value = ServiceApi.Emergency.AttendanceDetail, method = RequestMethod.GET)
    @ApiOperation("出勤记录详情")
    public Envelop detail(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id") String id){
        return attendanceClient.detail(id);
    }
    @RequestMapping(value = ServiceApi.Emergency.AttendanceAnalysis, method = RequestMethod.GET)
    @ApiOperation("出勤记录分析")
    public Envelop analysis(){
        return attendanceClient.analysis();
    }
    @RequestMapping(value = "/attendance/queryChart1", method = RequestMethod.GET)
    @ApiOperation("出车次数分析")
    public Envelop queryChart1(
            @ApiParam(name = "flag", value = "查询类型月、季、年(1,2,3)")
            @RequestParam(value = "flag") String flag){
        return attendanceClient.queryChart1(flag);
    }
    @RequestMapping(value = "/attendance/queryChart3", method = RequestMethod.GET)
    @ApiOperation("出勤地点热力图")
    public Envelop queryChart3(){
        return attendanceClient.queryChart3();
    }
}

+ 66 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/LocationController.java

@ -0,0 +1,66 @@
package com.yihu.jw.emergency.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseRestEndPoint;
import com.yihu.jw.emergency.client.LocationClient;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.*;
/**
 * Controller - 待命地点
 * Created by progr1mmer on 2017/11/22.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + ServiceApi.GateWay.admin)
@Api(value = "LocationController", description = "待命地点", tags = {"应急指挥-待命地点"})
public class LocationController extends BaseRestEndPoint {
    @Autowired
    private LocationClient locationClient;
    @RequestMapping(value = ServiceApi.Emergency.LocationList, method = RequestMethod.GET)
    @ApiOperation("获取待命地点列表")
    public Envelop list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) {
        return locationClient.list(fields, filters, sorts, page, size);
    }
    @RequestMapping(value = ServiceApi.Emergency.LocationSave, method = RequestMethod.POST)
    @ApiOperation("保存单条记录")
    public Envelop save(
            @ApiParam(name = "location", value = "待命地点")
            @RequestParam(value = "location") String location){
        return locationClient.save(location);
    }
    @RequestMapping(value = ServiceApi.Emergency.LocationUpdate, method = RequestMethod.PUT)
    @ApiOperation("更新单条记录")
    public Envelop update(
            @ApiParam(name = "location", value = "排班")
            @RequestParam(value = "location") String location){
        return locationClient.update(location);
    }
    @RequestMapping(value = ServiceApi.Emergency.LocationDelete, method = RequestMethod.DELETE)
    @ApiOperation("删除待命地点")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id列表(int)1,2,3,...")
            @RequestParam(value = "ids") String ids){
        return locationClient.delete(ids);
    }
}

+ 100 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/emergency/controller/ScheduleController.java

@ -0,0 +1,100 @@
package com.yihu.jw.emergency.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.emergency.client.ScheduleClient;
import com.yihu.jw.util.rest.Envelop;
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.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Controller - 排班历史
 * Created by progr1mmer on 2017/11/8.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0 + ServiceApi.GateWay.admin)
@Api(value = "ScheduleController", description = "排班历史", tags = {"应急指挥-排班历史"})
public class ScheduleController extends BaseController {
    @Autowired
    private ScheduleClient scheduleClient;
    @RequestMapping(value = ServiceApi.Emergency.ScheduleList, method = RequestMethod.GET)
    @ApiOperation("获取排班列表")
    public Envelop list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required =  true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required =  true, defaultValue = "15")
            @RequestParam(value = "size") int size) {
        return scheduleClient.list(fields, filters, sorts, page, size);
    }
    @RequestMapping(value = ServiceApi.Emergency.ScheduleLevel, method = RequestMethod.GET)
    @ApiOperation("获取排班层级列表(年-月-日)")
    public Envelop level(
            @ApiParam(name = "date", value = "年-月")
            @RequestParam(value = "date", required = false) String date,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) {
        return scheduleClient.level(date, page, size);
    }
    @RequestMapping(value = ServiceApi.Emergency.ScheduleSave, method = RequestMethod.POST)
    @ApiOperation("保存单条记录")
    public Envelop save(
            @ApiParam(name = "schedule", value = "排班")
            @RequestParam(value = "schedule") String schedule){
        return scheduleClient.save(schedule);
    }
    @RequestMapping(value = ServiceApi.Emergency.ScheduleUpdate, method = RequestMethod.PUT)
    @ApiOperation("更新单条记录")
    public Envelop update(
            @ApiParam(name = "schedule", value = "排班")
            @RequestParam(value = "schedule") String schedule){
        return scheduleClient.update(schedule);
    }
    @RequestMapping(value = ServiceApi.Emergency.ScheduleBathUpdate, method = RequestMethod.PUT)
    @ApiOperation("更新多条记录")
    public Envelop bathUpdate(
            @ApiParam(name = "schedules", value = "排班")
            @RequestParam(value = "schedules") String schedules){
        return scheduleClient.bathUpdate(schedules);
    }
    @RequestMapping(value = ServiceApi.Emergency.ScheduleBatch, method = RequestMethod.POST)
    @ApiOperation("批量导入排班信息")
    public Envelop createSchedulesBatch(
            @ApiParam(name = "schedules", value = "排班信息", defaultValue = "")
            @RequestParam(value = "schedules") String schedules) throws Exception {
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        try{
            scheduleClient.createSchedulesBatch(schedules);
        }catch (Exception e){
            e.printStackTrace();
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("导入失败!"+e.getMessage());
        }
        return envelop;
    }
}

+ 47 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosAcqTaskClient.java

@ -0,0 +1,47 @@
package com.yihu.jw.esb.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.esb.MHosAcqTask;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.13 14:15
 */
@FeignClient(name=MicroServices.ESB)
@RequestMapping(value = ApiVersion.Version1_0 + "/esb")
@ApiIgnore
public interface HosAcqTaskClient {
    @RequestMapping(value = "/searchHosAcqTasks", method = RequestMethod.GET)
    ResponseEntity<List<MHosAcqTask>> searchHosAcqTasks(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/hosAcqTask/{id}",method = RequestMethod.GET)
    MHosAcqTask getHosAcqTask(
            @PathVariable(value = "id") String id);
    @RequestMapping(value = "/createHosAcqTask", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    MHosAcqTask createHosAcqTask(
            @RequestBody String jsonData);
    @RequestMapping(value = "/updateHosAcqTask", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    MHosAcqTask updateHosAcqTask(
            @RequestBody String jsonData);
    @RequestMapping(value = "/deleteHosAcqTask/{id}", method = RequestMethod.DELETE)
    boolean deleteHosAcqTask(
            @PathVariable(value = "id") String id);
}

+ 31 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosEsbMiniInstallLogClient.java

@ -0,0 +1,31 @@
package com.yihu.jw.esb.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.esb.MHosEsbMiniInstallLog;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.13 14:15
 */
@FeignClient(name=MicroServices.ESB)
@RequestMapping(value = ApiVersion.Version1_0 + "/esb")
@ApiIgnore
public interface HosEsbMiniInstallLogClient {
    @RequestMapping(value = "/searchInstallLogs", method = RequestMethod.GET)
    ResponseEntity<List<MHosEsbMiniInstallLog>> searchHosEsbMiniInstallLogs(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
}

+ 42 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosLogClient.java

@ -0,0 +1,42 @@
package com.yihu.jw.esb.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.esb.MHosLog;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.13 14:15
 */
@FeignClient(name=MicroServices.ESB)
@RequestMapping(value = ApiVersion.Version1_0 + "/esb")
@ApiIgnore
public interface HosLogClient {
    @RequestMapping(value = "/searchHosLogs", method = RequestMethod.GET)
    ResponseEntity<List<MHosLog>> searchHosLogs(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/deleteHosLog/{id}", method = RequestMethod.DELETE)
    boolean deleteHosLog(
            @PathVariable(value = "id") String id);
    @RequestMapping(value = "/deleteHosLogs", method = RequestMethod.DELETE)
    boolean deleteHosLogs(@RequestParam(value = "filters", required = false) String filters);
}

+ 49 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosReleaseClient.java

@ -0,0 +1,49 @@
package com.yihu.jw.esb.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.esb.MHosEsbMiniRelease;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.13 14:15
 */
@FeignClient(name=MicroServices.ESB)
@RequestMapping(value = ApiVersion.Version1_0 + "/esb")
@ApiIgnore
public interface HosReleaseClient {
    @RequestMapping(value = "/searchHosEsbMiniReleases", method = RequestMethod.GET)
    ResponseEntity<List<MHosEsbMiniRelease>> searchHosEsbMiniReleases(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/deleteHosEsbMiniRelease/{id}", method = RequestMethod.DELETE)
    String deleteHosEsbMiniRelease(
            @PathVariable(value = "id") String id);
    @RequestMapping(value = "/createHosEsbMiniRelease", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "新增软件包")
    MHosEsbMiniRelease createHosEsbMiniRelease(
            @ApiParam(name = "model", value = "json数据模型", defaultValue = "")
            @RequestBody String model);
    @RequestMapping(value = "/updateHosEsbMiniRelease", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改软件包")
    MHosEsbMiniRelease updateHosEsbMiniRelease(
            @ApiParam(name = "model", value = "json数据模型", defaultValue = "")
            @RequestBody String model);
}

+ 49 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/client/HosSqlTaskClient.java

@ -0,0 +1,49 @@
package com.yihu.jw.esb.client;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.model.esb.MHosSqlTask;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.13 14:15
 */
@FeignClient(name=MicroServices.ESB)
@RequestMapping(value = ApiVersion.Version1_0 + "/esb")
@ApiIgnore
public interface HosSqlTaskClient {
    @RequestMapping(value = "/searchHosSqlTasks", method = RequestMethod.GET)
    ResponseEntity<List<MHosSqlTask>> searchHosSqlTasks(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = "/hosSqlTask/{id}",method = RequestMethod.GET)
    MHosSqlTask getHosSqlTask(
            @PathVariable(value = "id") String id);
    @RequestMapping(value = "/createHosSqlTask", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    MHosSqlTask createHosSqlTask(
            @RequestBody String jsonData);
    @RequestMapping(value = "/updateHosSqlTask", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    MHosSqlTask updateHosSqlTask(
            @RequestBody String jsonData);
    @RequestMapping(value = "/deleteHosSqlTask/{id}", method = RequestMethod.DELETE)
    boolean deleteHosSqlTask(
            @PathVariable(value = "id") String id);
}

+ 150 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosAcqTaskController.java

@ -0,0 +1,150 @@
package com.yihu.jw.esb.controller;
import com.yihu.jw.agModel.esb.HosAcqTaskModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.esb.client.HosAcqTaskClient;
import com.yihu.jw.model.esb.MHosAcqTask;
import com.yihu.jw.util.datetime.DateTimeUtil;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.12 18:00
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/esb")
@RestController
@Api(value = "补采任务管理接口", description = "补采任务管理接口" ,tags = {"ESB管理 -补采任务管理接口"})
public class HosAcqTaskController extends BaseController {
    @Autowired
    private HosAcqTaskClient hosAcqTaskClient;
    @RequestMapping(value = "/searchHosAcqTasks", method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取补采任务信息", notes = "根据查询条件获取补采任务信息")
    public Envelop searchHosAcqTasks(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page)  {
        ResponseEntity<List<MHosAcqTask>> responseEntity = hosAcqTaskClient.searchHosAcqTasks(fields,filters,sorts,size,page);
        List<MHosAcqTask> hosAcqTasks = responseEntity.getBody();
        List<HosAcqTaskModel> hosAcqTaskModels = new ArrayList<>();
        for(MHosAcqTask mHosAcqTask : hosAcqTasks) {
            HosAcqTaskModel hosAcqTaskModel = null;
            try {
                hosAcqTaskModel = convertToModelDetail(mHosAcqTask,HosAcqTaskModel.class);
                hosAcqTaskModel = utcTimeChange(hosAcqTaskModel,mHosAcqTask);
            } catch (Exception e) {
                e.printStackTrace();
            }
            hosAcqTaskModels.add(hosAcqTaskModel);
        }
        Envelop envelop = getResult(hosAcqTaskModels, getTotalCount(responseEntity), page, size);
        return envelop;
    }
    /**
     * utc时间转化成yyyy-MM-dd HH:mm:ss
     */
    public HosAcqTaskModel utcTimeChange(HosAcqTaskModel hosAcqTaskModel,MHosAcqTask mHosAcqTask){
        hosAcqTaskModel.setStartTime(DateTimeUtil.simpleDateTimeFormat(mHosAcqTask.getStartTime()));
        hosAcqTaskModel.setEndTime(DateTimeUtil.simpleDateTimeFormat(mHosAcqTask.getEndTime()));
        hosAcqTaskModel.setCreateTime(DateTimeUtil.simpleDateTimeFormat(mHosAcqTask.getCreateTime()));
        return hosAcqTaskModel;
    }
    @RequestMapping(value = "/hosAcqTask/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取补采任务信息",notes = "根据id获取补采任务信息")
    public Envelop getHosAcqTask(
            @ApiParam(name = "id",value ="",defaultValue = "")
            @PathVariable(value = "id") String id){
        Envelop envelop = new Envelop();
        MHosAcqTask mHosAcqTask = hosAcqTaskClient.getHosAcqTask(id);
        try{
            HosAcqTaskModel hosAcqTaskModel = convertToModelDetail(mHosAcqTask,HosAcqTaskModel.class);
            hosAcqTaskModel = utcTimeChange(hosAcqTaskModel,mHosAcqTask);
            envelop.setObj(hosAcqTaskModel);
            envelop.setSuccessFlg(true);
        }catch (Exception e){
            e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = "/createHosAcqTask", method = RequestMethod.POST)
    @ApiOperation(value = "创建补采任务信息", notes = "创建补采任务信息")
    public Envelop createHosAcqTask(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestParam(value = "json_data") String jsonData) throws IOException {
        Envelop envelop = new Envelop();
        HosAcqTaskModel hosAcqTaskModel = toEntity(jsonData,HosAcqTaskModel.class);
        try {
            MHosAcqTask hosAcqTask = convertToMModel(hosAcqTaskModel,MHosAcqTask.class);
            MHosAcqTask mHosAcqTaskNew = hosAcqTaskClient.createHosAcqTask(toJson(hosAcqTask));
            convertToModelDetail(mHosAcqTaskNew,HosAcqTaskModel.class);
            envelop.setSuccessFlg(true);
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = "/updateHosAcqTask", method = RequestMethod.PUT)
    @ApiOperation(value = "修改补采任务信息", notes = "修改补采任务信息")
    public Envelop updateHosAcqTask(
            @ApiParam(name = "json_data", value = "")
            @RequestParam(value = "json_data") String jsonData)  {
        Envelop envelop = new Envelop();
        try {
            HosAcqTaskModel hosAcqTaskModel = toEntity(jsonData,HosAcqTaskModel.class);
            MHosAcqTask hosAcqTask = convertToMModel(hosAcqTaskModel,MHosAcqTask.class);
            hosAcqTaskClient.updateHosAcqTask(toJson(hosAcqTask));
            convertToModelDetail(hosAcqTask,HosAcqTaskModel.class);
            envelop.setSuccessFlg(true);
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = "/deleteHosAcqTask/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除补采任务信息", notes = "删除补采任务信息")
    public Envelop deleteHosAcqTask(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        try {
            hosAcqTaskClient.deleteHosAcqTask(id);
            envelop.setSuccessFlg(true);
        }catch (Exception e){e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
}

+ 73 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosEsbMiniInstallLogController.java

@ -0,0 +1,73 @@
package com.yihu.jw.esb.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.esb.client.HosEsbMiniInstallLogClient;
import com.yihu.jw.model.esb.MHosEsbMiniInstallLog;
import com.yihu.jw.model.org.MOrganization;
import com.yihu.jw.organization.service.OrganizationClient;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * @author linaz
 * @created 2016.05.12 18:00
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/esb")
@RestController
@Api(value = "程序版本发布信息管理接口", description = "程序版本发布信息管理接口" ,tags = {"ESB管理 -程序版本发布信息管理接口"})
public class HosEsbMiniInstallLogController extends BaseController {
    @Autowired
    private HosEsbMiniInstallLogClient hosEsbMiniInstallLogClient;
    @Autowired
    private OrganizationClient organizationClient;
    @RequestMapping(value = "/searchHosEsbMiniInstallLog", method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取程序版本发布信息", notes = "根据查询条件获取程序版本发布信息")
    public Envelop searchHosEsbMiniInstallLogs(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws ParseException {
            ResponseEntity<List<MHosEsbMiniInstallLog>> responseEntity = hosEsbMiniInstallLogClient.searchHosEsbMiniInstallLogs(fields, filters, sorts, size, page);
        List<MHosEsbMiniInstallLog> mHosEsbMiniInstallLogList = responseEntity.getBody();
        if(mHosEsbMiniInstallLogList.size()>0){
            for(MHosEsbMiniInstallLog mHosEsbMiniInstallLog:mHosEsbMiniInstallLogList){
                if(StringUtils.isNotBlank(mHosEsbMiniInstallLog.getOrgCode())){
                    String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
                    Pattern p   =   Pattern.compile(regEx);
                    Matcher m   =   p.matcher(mHosEsbMiniInstallLog.getOrgCode());
                    MOrganization mOrganization =  organizationClient.getOrg(m.replaceAll("").trim());
                    if(mOrganization!=null){
                        mHosEsbMiniInstallLog.setOrgName(mOrganization.getFullName());
                    }
                }
                if(mHosEsbMiniInstallLog.getInstallTime()!=null){
                    SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    mHosEsbMiniInstallLog.setInstallDate(sm.format(mHosEsbMiniInstallLog.getInstallTime()));
                }
            }
        }
        int totalCount = getTotalCount (responseEntity);
        return getResult(mHosEsbMiniInstallLogList, totalCount, page, size);
    }
}

+ 93 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosLogController.java

@ -0,0 +1,93 @@
package com.yihu.jw.esb.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.esb.client.HosLogClient;
import com.yihu.jw.model.esb.MHosLog;
import com.yihu.jw.model.org.MOrganization;
import com.yihu.jw.organization.service.OrganizationClient;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * @author linaz
 * @created 2016.05.12 18:00
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/esb")
@RestController
@Api(value = "上传日志管理接口", description = "上传日志管理接口" ,tags = {"ESB管理 -上传日志管理接口"})
public class HosLogController extends BaseController {
    @Autowired
    private HosLogClient hosLogClient;
    @Autowired
    private OrganizationClient organizationClient;
    @RequestMapping(value = "/searchHosLogs", method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取上传日志信息", notes = "根据查询条件获取用户列表在前端表格展示")
    public Envelop searchHosLogs(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ResponseEntity<List<MHosLog>> responseEntity = hosLogClient.searchHosLogs(fields, filters,sorts,size,page);
        List<MHosLog> hosLogs = responseEntity.getBody();
        if(hosLogs.size()>0){
            for (MHosLog mHosLog :hosLogs){
                if(StringUtils.isNotBlank(mHosLog.getUploadTime())){
                    SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    mHosLog.setUploadTime(sm.format(sm.parse(mHosLog.getUploadTime())));
                }
                if(StringUtils.isNotBlank(mHosLog.getOrgCode())){
                    //过滤特殊字符,防止GET出错
                    String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
                    Pattern p   =   Pattern.compile(regEx);
                    Matcher m   =   p.matcher(mHosLog.getOrgCode());
                    MOrganization mOrganization =  organizationClient.getOrg(m.replaceAll("").trim());
                    if(mOrganization!=null){
                        mHosLog.setOrgName(mOrganization.getFullName());
                    }
                }
            }
        }
        int totalCount = getTotalCount (responseEntity);
        return getResult(hosLogs, totalCount, page, size);
    }
    @RequestMapping(value = "/deleteHosLog/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "根据id删除上传日志", notes = "根据id删除上传日志")
    public boolean deleteHosLog(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return hosLogClient.deleteHosLog(id);
    }
    @RequestMapping(value = "/deleteHosLogs", method = RequestMethod.DELETE)
    @ApiOperation(value = "根据id删除上传日志", notes = "根据id删除上传日志")
    public boolean deleteHosLogs(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters") String filters) throws Exception {
        return hosLogClient.deleteHosLogs(filters);
    }
}

+ 130 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosReleaseController.java

@ -0,0 +1,130 @@
package com.yihu.jw.esb.controller;
import com.yihu.jw.agModel.esb.HostReleaseModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.esb.client.HosReleaseClient;
import com.yihu.jw.model.esb.MHosEsbMiniRelease;
import com.yihu.jw.util.datetime.DateTimeUtil;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.12 18:00
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/esb")
@RestController
@Api(value = "程序版本发布信息管理接口", description = "程序版本发布信息管理接口" ,tags = {"ESB管理 -程序版本发布信息管理接口"})
public class HosReleaseController extends BaseController {
    @Autowired
    private HosReleaseClient hosReleaseClient;
    @RequestMapping(value = "/searchHosEsbMiniReleases", method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取程序版本发布信息", notes = "根据查询条件获取程序版本发布信息")
    public Envelop searchHosEsbMiniReleases(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws ParseException {
        ResponseEntity<List<MHosEsbMiniRelease>> responseEntity = hosReleaseClient.searchHosEsbMiniReleases(fields,filters,sorts,size,page);
        List<MHosEsbMiniRelease> mHosEsbMiniReleases = responseEntity.getBody();
        List<HostReleaseModel>  hostReleaseModels = new ArrayList<>();
        for(MHosEsbMiniRelease mHosEsbMiniRelease: mHosEsbMiniReleases){
            HostReleaseModel  hostReleaseModel = new HostReleaseModel();
            BeanUtils.copyProperties(mHosEsbMiniRelease,hostReleaseModel);
            if(mHosEsbMiniRelease.getReleaseTime()!=null) {
                hostReleaseModel.setReleaseDate(DateTimeUtil.simpleDateTimeFormat(mHosEsbMiniRelease.getReleaseTime()));
            }
            hostReleaseModels.add(hostReleaseModel);
        }
        int totalCount = getTotalCount (responseEntity);
        return getResult(hostReleaseModels, totalCount, page, size);
    }
    @RequestMapping(value = "/deleteHosEsbMiniRelease/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除程序版本发布信息", notes = "删除程序版本发布信息")
    public Envelop  deleteHosEsbMiniRelease(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
            String result =  hosReleaseClient.deleteHosEsbMiniRelease(id);
            if(result!="success"&&!"success".equals(result)){
                return failed(result);
            }else{
                return success("删除成功!");
            }
    }
    @RequestMapping(value = "/saveReleaseInfo", method = RequestMethod.POST)
    public Envelop saveDict(
            @ApiParam(name = "json_data", value = "软件版本信息")
            @RequestParam(value = "json_data") String jsonData) {
        try {
            MHosEsbMiniRelease mHosEsbMiniRelease = objectMapper.readValue(jsonData, MHosEsbMiniRelease.class);
            String errorMsg = "";
            if (StringUtils.isEmpty(mHosEsbMiniRelease.getSystemCode())) {
                errorMsg += "系统代码为空!";
            }
            if (StringUtils.isEmpty(mHosEsbMiniRelease.getFile())) {
                errorMsg += "文件路径不能为空!";
            }
            if (StringUtils.isEmpty(mHosEsbMiniRelease.getVersionName())) {
                errorMsg += "版本名称不能为空!";
            }
            if (StringUtils.isEmpty(""+mHosEsbMiniRelease.getVersionCode())) {
                errorMsg += "版本编号不能为空!";
            }
            if (StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            //系统代码唯一性校验
            if (StringUtils.isBlank(mHosEsbMiniRelease.getId())) {
                ResponseEntity<List<MHosEsbMiniRelease>> responseEntity = hosReleaseClient.searchHosEsbMiniReleases("","systemCode="+mHosEsbMiniRelease.getSystemCode(),"",1,1);
                List<MHosEsbMiniRelease> mHosEsbMiniReleases = responseEntity.getBody();
                if(mHosEsbMiniReleases.size()>0){
                    return failed("系统编码已经存在请修改!");
                }
                mHosEsbMiniRelease = hosReleaseClient.createHosEsbMiniRelease(objectMapper.writeValueAsString(mHosEsbMiniRelease));
            } else {
                ResponseEntity<List<MHosEsbMiniRelease>> responseEntity = hosReleaseClient.searchHosEsbMiniReleases("","systemCode="+mHosEsbMiniRelease.getSystemCode()+";id<>"+mHosEsbMiniRelease.getId(),"",1,1);
                List<MHosEsbMiniRelease> mHosEsbMiniReleases = responseEntity.getBody();
                if(mHosEsbMiniReleases.size()>0){
                    return failed("系统编码已经存在请修改!");
                }
                mHosEsbMiniRelease = hosReleaseClient.updateHosEsbMiniRelease(objectMapper.writeValueAsString(mHosEsbMiniRelease));
            }
             MHosEsbMiniRelease hosEsbMiniRelease = convertToModel(mHosEsbMiniRelease, MHosEsbMiniRelease.class);
            if (hosEsbMiniRelease == null) {
                return failed("保存失败!");
            }
            return success(hosEsbMiniRelease);
        } catch (Exception ex) {
            return failedSystem();
        }
    }
}

+ 137 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/esb/controller/HosSqlTaskController.java

@ -0,0 +1,137 @@
package com.yihu.jw.esb.controller;
import com.yihu.jw.agModel.esb.HosSqlTaskModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.esb.client.HosSqlTaskClient;
import com.yihu.jw.model.esb.MHosSqlTask;
import com.yihu.jw.util.datetime.DateTimeUtil;
import com.yihu.jw.util.rest.Envelop;
import com.yihu.jw.controller.BaseController;
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.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.12 18:00
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin/esb")
@RestController
@Api(value = "his穿透管理接口", description = "his穿透管理接口" ,tags = {"ESB管理 -his穿透管理接口"})
public class HosSqlTaskController extends BaseController {
    @Autowired
    private HosSqlTaskClient hosSqlTaskClient;
    @RequestMapping(value = "/searchHosSqlTasks", method = RequestMethod.GET)
    @ApiOperation(value = "根据条件进行his穿透查询", notes = "根据条件进行his穿透查询")
    public Envelop searchHosSqlTasks(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ResponseEntity<List<MHosSqlTask>> responseEntity = hosSqlTaskClient.searchHosSqlTasks(fields,filters,sorts,size,page);
        List<MHosSqlTask> hosSqlTasks = responseEntity.getBody();
        List<HosSqlTaskModel> hosSqlTaskModels = new ArrayList<>();
        for(MHosSqlTask mHosSqlTask : hosSqlTasks) {
            HosSqlTaskModel hosSqlTaskModel = null;
            try {
                hosSqlTaskModel = convertToModelDetail(mHosSqlTask,HosSqlTaskModel.class);
                hosSqlTaskModel.setCreateTime(DateTimeUtil.simpleDateTimeFormat(mHosSqlTask.getCreateTime()));
            } catch (Exception e) {
                e.printStackTrace();
            }
            hosSqlTaskModels.add(hosSqlTaskModel);
        }
        Envelop envelop = getResult(hosSqlTaskModels, getTotalCount(responseEntity), page, size);
        return envelop;
    }
    @RequestMapping(value = "/hosSqlTask/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取his穿透信息",notes = "根据id获取his穿透信息")
    public Envelop getHosSqlTask(
            @ApiParam(name = "id",value ="",defaultValue = "")
            @PathVariable(value = "id") String id) throws  Exception{
        Envelop envelop = new Envelop();
        MHosSqlTask mHosSqlTask = hosSqlTaskClient.getHosSqlTask(id);
        try{
            HosSqlTaskModel hosSqlTaskModel = convertToModelDetail(mHosSqlTask,HosSqlTaskModel.class);
            hosSqlTaskModel.setCreateTime(DateTimeUtil.simpleDateTimeFormat(mHosSqlTask.getCreateTime()));
            envelop.setObj(hosSqlTaskModel);
            envelop.setSuccessFlg(true);
        }catch (Exception e){
            e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = "/createHosSqlTask", method = RequestMethod.POST)
    @ApiOperation(value = "创建his穿透信息", notes = "创建his穿透信息")
    public Envelop createHosSqlTask(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestParam(value = "json_data", required = true) String jsonData) throws Exception {
        Envelop envelop = new Envelop();
        HosSqlTaskModel hosSqlTaskModel = toEntity(jsonData,HosSqlTaskModel.class);
        try {
            MHosSqlTask hosSqlTask = convertToMModel(hosSqlTaskModel,MHosSqlTask.class);
            hosSqlTaskClient.createHosSqlTask(toJson(hosSqlTask));
            convertToModelDetail(hosSqlTask,HosSqlTaskModel.class);
            envelop.setSuccessFlg(true);
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = "/updateHosSqlTask", method = RequestMethod.PUT)
    @ApiOperation(value = "修改his穿透信息", notes = "修改his穿透信息")
    public Envelop updateHosSqlTask(
            @ApiParam(name = "json_data", value = "")
            @RequestParam(value = "json_data") String jsonData) throws Exception {
        Envelop envelop = new Envelop();
        HosSqlTaskModel hosSqlTaskModel = toEntity(jsonData,HosSqlTaskModel.class);
        try {
            MHosSqlTask hosSqlTask = convertToMModel(hosSqlTaskModel,MHosSqlTask.class);
            hosSqlTaskClient.updateHosSqlTask(toJson(hosSqlTask));
            convertToModelDetail(hosSqlTask,HosSqlTaskModel.class);
            envelop.setSuccessFlg(true);
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;
    }
    @RequestMapping(value = "/deleteHosSqlTask/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除his穿透信息", notes = "删除his穿透信息")
    public Envelop deleteHosSqlTask(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        Envelop envelop = new Envelop();
        try {
            hosSqlTaskClient.deleteHosSqlTask(id);
            envelop.setSuccessFlg(true);
        }catch (Exception e){e.printStackTrace();
            e.printStackTrace();
            envelop.setSuccessFlg(false);
        }
        return envelop;    }
}

+ 132 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/fileresource/controller/FileResourceController.java

@ -0,0 +1,132 @@
package com.yihu.jw.fileresource.controller;
import com.netflix.eureka.V1AwareInstanceInfoConverter;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.fileresource.service.FileResourceClient;
import com.yihu.jw.util.log.LogService;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.11 11:32
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "文件管理接口", description = "文件管理接口", tags = {"文件管理接口"})
public class FileResourceController {
    @Autowired
    private FileResourceClient fileResourceClient;
    @RequestMapping(value = "/files", method = RequestMethod.POST)
    @ApiOperation(value = "上传文件")
    public String pictureUpload(
            @ApiParam(name = "file_str", value = "文件流转化后的字符串")
            @RequestParam(value = "file_str") String fileStr,
            @ApiParam(name = "file_name", value = "文件名")
            @RequestParam(value = "file_name") String fileName,
            @ApiParam(name = "json_data", value = "文件资源属性")
            @RequestParam(value = "json_data") String jsonData) {
        return fileResourceClient.fileUpload(fileStr, fileName, jsonData);
    }
    @RequestMapping(value = "/filesReturnUrl", method = RequestMethod.POST)
    @ApiOperation(value = "上传文件,并返回存储相对路径")
    public String pictureUploadReturnUrl(
            @ApiParam(name = "file_str", value = "文件流转化后的字符串")
            @RequestParam(value = "file_str") String fileStr,
            @ApiParam(name = "file_name", value = "文件名")
            @RequestParam(value = "file_name") String fileName,
            @ApiParam(name = "json_data", value = "文件资源属性")
            @RequestParam(value = "json_data") String jsonData) {
        return fileResourceClient.fileUploadReturnUrl(fileStr, fileName, jsonData);
    }
    @RequestMapping(value = "/filesReturnHttpUrl", method = RequestMethod.POST)
    @ApiOperation(value = "上传文件,并返回存储绝对路径")
    public String pictureUploadReturnHttpUrl(
            @ApiParam(name = "file_str", value = "文件流转化后的字符串")
            @RequestParam(value = "file_str") String fileStr,
            @ApiParam(name = "file_name", value = "文件名")
            @RequestParam(value = "file_name") String fileName,
            @ApiParam(name = "json_data", value = "文件资源属性")
            @RequestParam(value = "json_data") String jsonData) {
        return fileResourceClient.fileUploadReturnHttpUrl(fileStr, fileName, jsonData);
    }
    @RequestMapping(value = "/files", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastdfs相对应当文件")
    public boolean filesDelete(
            @ApiParam(name = "object_id", value = "文件字符串")
            @RequestParam(value = "object_id") String objectId) throws Exception {
        return fileResourceClient.filesDelete(objectId);
    }
    @RequestMapping(value = "/image_delete", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastdfs相对应当文件")
    public boolean delete(
            @ApiParam(name = "storagePath", value = "文件路径")
            @RequestParam(value = "storagePath") String storagePath) throws Exception {
        return fileResourceClient.filesDeleteByPath(storagePath);
    }
    @RequestMapping(value = "/files", method = RequestMethod.GET)
    @ApiOperation(value = "下载文件")
    public Envelop fileDownload(
            @ApiParam(name = "object_id", value = "文件字符串")
            @RequestParam(value = "object_id") String objectId,
            @ApiParam(name = "mime", value = "所有者")
            @RequestParam(value = "mime", required = false) String mime) throws Exception {
        List<String> filesStr = fileResourceClient.filesDownload(objectId, mime);
        Envelop envelop = new Envelop();
        envelop.setDetailModelList(filesStr);
        envelop.setSuccessFlg(true);
        return envelop;
    }
    @RequestMapping(value = "/image_view", method = RequestMethod.GET)
    @ApiOperation(value = "查看图片")
    public String imageView(
            @ApiParam(value = "查看图片")
            @RequestParam(value = "storagePath") String storagePath) throws Exception {
        String filesStr = fileResourceClient.imageView(storagePath);
        return filesStr;
    }
    @RequestMapping(value = "/files_path", method = RequestMethod.GET)
    @ApiOperation(value = "获取文件路径")
    public Envelop filePath(
            @ApiParam(name = "object_id", value = "文件字符串")
            @RequestParam(value = "object_id") String objectId) throws Exception {
        List<String> filesStr = fileResourceClient.filesPath(objectId);
        Envelop envelop = new Envelop();
        envelop.setDetailModelList(filesStr);
        envelop.setSuccessFlg(true);
        return envelop;
    }
    @ApiOperation(value = "根据文件ID,获取文件的真实访问路径")
    @RequestMapping(value = "/file/getRealPathById", method = RequestMethod.GET)
    public String getRealPathById(
            @ApiParam(value = "文件ID", required = true)
            @RequestParam(value = "fileId") String fileId) throws Exception {
        return fileResourceClient.getRealPathById(fileId);
    }
    @ApiOperation(value = "根据文件的存储路径,获取文件的真实访问路径")
    @RequestMapping(value = "/file/getRealPathByStoragePath", method = RequestMethod.GET)
    public String getRealPathByStoragePath(
            @ApiParam(value = "文件存储路径", required = true)
            @RequestParam(value = "storagePath") String storagePath) throws Exception {
        return fileResourceClient.getRealPathByStoragePath(storagePath);
    }
}

+ 78 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/fileresource/service/FileResourceClient.java

@ -0,0 +1,78 @@
package com.yihu.jw.fileresource.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.11 11:32
 */
@FeignClient(name = MicroServices.FileResource)
public interface FileResourceClient {
    @RequestMapping(value = ApiVersion.Version1_0 + "/files_upload", method = RequestMethod.POST)
    @ApiOperation(value = "上传文件")
    String fileUpload(
            @RequestBody String fileStr,
            @RequestParam(value = "file_name") String fileName,
            @RequestParam(value = "json_data") String jsonData);
    @RequestMapping(value = ApiVersion.Version1_0 + "/files_upload_returnUrl", method = RequestMethod.POST)
    @ApiOperation(value = "上传文件,并返回存储相对路径")
    String fileUploadReturnUrl(
            @RequestBody String fileStr,
            @RequestParam(value = "file_name") String fileName,
            @RequestParam(value = "json_data") String jsonData);
    @RequestMapping(value = ApiVersion.Version1_0 + "/files_upload_returnHttpUrl", method = RequestMethod.POST)
    @ApiOperation(value = "上传文件,并返回存储绝对路径")
    String fileUploadReturnHttpUrl(
            @RequestBody String fileStr,
            @RequestParam(value = "file_name") String fileName,
            @RequestParam(value = "json_data") String jsonData);
    @RequestMapping(value = ApiVersion.Version1_0 + "/files", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastdfs相对应当文件")
    boolean filesDelete(
            @RequestParam(value = "object_id") String objectId);
    @RequestMapping(value = ApiVersion.Version1_0 + "/files_download", method = RequestMethod.GET)
    @ApiOperation(value = "下载文件")
    List<String> filesDownload(
            @RequestParam(value = "object_id") String objectId,
            @RequestParam(value = "mime", required = false) String mime);
    @RequestMapping(value = ApiVersion.Version1_0 + "/image_view", method = RequestMethod.GET)
    @ApiOperation(value = "查看图片")
    String imageView(
            @RequestParam(value = "storagePath") String storagePath);
    @RequestMapping(value = ApiVersion.Version1_0 + "/files_path", method = RequestMethod.GET)
    @ApiOperation(value = "获取文件路径")
    List<String> filesPath(
            @RequestParam(value = "object_id") String objectId);
    @RequestMapping(value = ApiVersion.Version1_0 + "/image_delete", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源表对应关系,并且删除fastdfs相对应当文件")
    boolean filesDeleteByPath(
            @RequestParam(value = "storagePath") String storagePath);
    @ApiOperation(value = "根据文件的id,获取文件的真实访问路径")
    @RequestMapping(value = ApiVersion.Version1_0 + "/file/getRealPathById", method = RequestMethod.GET)
    String getRealPathById(
            @RequestParam(value = "fileId") String fileId);
    @ApiOperation(value = "根据文件的存储路径,获取文件的真实访问路径")
    @RequestMapping(value = ApiVersion.Version1_0 + "/file/getRealPathByStoragePath", method = RequestMethod.GET)
    String getRealPathByStoragePath(
            @RequestParam(value = "storagePath") String storagePath);
}

+ 35 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/filter/TenantFilter.java

@ -0,0 +1,35 @@
package com.yihu.jw.filter;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@Component
public class TenantFilter implements Filter {
    private ServletContext servletContext;
    public TenantFilter(){
        super();
    }
    public void init(FilterConfig filterConfig) throws ServletException {
        servletContext = filterConfig.getServletContext();
    }
    public void doFilter( ServletRequest req, ServletResponse res, FilterChain filterChain) throws IOException, ServletException {
        //设置请求头,调用app,标准的微服务需要该请求头
        WritableHttpServletRequest httpReq = new WritableHttpServletRequest((HttpServletRequest)req);
        httpReq.addHeader("Tenant","ehr");
        filterChain.doFilter(httpReq, res);
    }
    public void destroy(){
    }
}

+ 34 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/filter/WritableHttpServletRequest.java

@ -0,0 +1,34 @@
package com.yihu.jw.filter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.*;
public class WritableHttpServletRequest extends HttpServletRequestWrapper {
    private final Set<String> names = new HashSet<>();
    private final Map<String, String> headers = new HashMap<>();
    public WritableHttpServletRequest(HttpServletRequest request) {
        super(request);
        Enumeration<String> e = super.getHeaderNames();
        while (e.hasMoreElements()) {
            names.add(e.nextElement());
        }
    }
    public void addHeader(String name, String value) {
        headers.put(name, value);
        names.add(name);
    }
    @Override
    public String getHeader(String name) {
        if (headers.containsKey(name)) {
            return headers.get(name);
        } else {
            return super.getHeader(name);
        }
    }
    @Override
    public Enumeration<String> getHeaderNames() {
        return Collections.enumeration(names);
    }
}

+ 271 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/geography/controller/AddressController.java

@ -0,0 +1,271 @@
package com.yihu.jw.geography.controller;
import com.yihu.jw.agModel.geogrephy.GeographyDictModel;
import com.yihu.jw.agModel.geogrephy.GeographyModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.geography.service.AddressClient;
import com.yihu.jw.model.geography.MGeography;
import com.yihu.jw.model.geography.MGeographyDict;
import com.yihu.jw.util.rest.Envelop;
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.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/1/20.
 */
@EnableFeignClients
@RequestMapping(ApiVersion.Version1_0+"/admin")
@RestController
@Api(value = "address", description = "地址信息管理", tags = {"基础信息"})
public class AddressController extends BaseController{
    @Autowired
    private AddressClient addressClient;
    @RequestMapping(value = "/geography_entries/level/{level}", method = RequestMethod.GET)
    @ApiOperation(value = "根据地址等级查询地址字典")
    public Envelop getAddressByLevel(
            @ApiParam(name = "level", value = "地址级别", defaultValue = "")
            @PathVariable(value = "level") Integer level) {
        Envelop envelop = new Envelop();
        List<GeographyDictModel> geographyDictModels = new ArrayList<>();
        List<MGeographyDict> mGeographyDictList = addressClient.getAddressByLevel(level);
        for (MGeographyDict mGeographyDict : mGeographyDictList){
            GeographyDictModel geographyDictModel = convertToModel(mGeographyDict,GeographyDictModel.class);
            geographyDictModels.add(geographyDictModel);
        }
        if(geographyDictModels.size()>0){
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(geographyDictModels);
        }else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("根据地址等级查询地址字典失败");
        }
        return envelop;
    }
    @RequestMapping(value = "/geography_entries/pid/{pid}", method = RequestMethod.GET)
    @ApiOperation(value = "根据上级编号查询行政区划地址")
    public Envelop getAddressDictByPid(
            @ApiParam(name = "pid", value = "上级id", defaultValue = "")
            @PathVariable(value = "pid") Integer pid) {
        Envelop envelop = new Envelop();
        List<GeographyDictModel> geographyDictModels = new ArrayList<>();
        List<MGeographyDict> mGeographyDictList = addressClient.getAddressDictByPid(pid);
        for (MGeographyDict mGeographyDict : mGeographyDictList){
            GeographyDictModel geographyDictModel = convertToModel(mGeographyDict,GeographyDictModel.class);
            geographyDictModels.add(geographyDictModel);
        }
        if(geographyDictModels.size()>0){
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(geographyDictModels);
        }else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("根据上级编号查询行政区划地址失败");
        }
        return envelop;
    }
    @RequestMapping(value = "/geography_entries/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询行政区划地址")
    public Envelop getAddressDictById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        MGeographyDict addressDict = addressClient.getAddressDictById(id);
        if(addressDict!=null){
            envelop.setSuccessFlg(true);
            envelop.setObj(addressDict);
        }else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("根据id查询行政区划失败");
        }
        return envelop;
    }
    @RequestMapping(value = "/geographies/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询地址")
    public Envelop getAddressById(
            @ApiParam(name = "id", value = "地址编号", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        MGeography mGeography = addressClient.getAddressById(id);
        GeographyModel geographyModel = convertToModel(mGeography,GeographyModel.class);
        if(geographyModel != null){
            envelop.setSuccessFlg(true);
            envelop.setObj(geographyModel);
        }else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("地址查询失败");
        }
        return envelop;
    }
    @RequestMapping(value = "geographies/canonical/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据地址编号获取地址中文字符串全拼")
    public Envelop getCanonicalAddress(
            @ApiParam(name = "id", value = "地址代码", defaultValue = "")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        GeographyDictModel geographyDictModel = new GeographyDictModel();
        String address = addressClient.getCanonicalAddress(id);
        if(address != null){
            geographyDictModel.setName(address);
            envelop.setSuccessFlg(true);
            envelop.setObj(geographyDictModel);
        }else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("地址查询失败");
        }
        return envelop;
    }
    /**
     * 地址检查并保存
     * @return
     */
    @RequestMapping(value = "/geographies", method = RequestMethod.POST)
    @ApiOperation(value = "地址检查,如果地址在数据库中不存在,这新增这条记录,否则返回地址id")
    public Envelop saveAddress(
            @ApiParam(name = "geography_model_json_data", value = "地址json字符串")
            @RequestParam( value = "geography_model_json_data") String geographyModelJsonData) throws Exception{
        Envelop envelop = new Envelop();
        GeographyModel geographyModel = new GeographyModel();
        String id = addressClient.saveAddress(geographyModelJsonData);
        if(id != null){
            envelop.setSuccessFlg(true);
            geographyModel.setId(id);
        }else{
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("地址新增失败");
        }
        envelop.setObj(geographyModel);
        return envelop;
    }
    /**
 * 根据省市县查询地址
 * @param province
 * @param city
 * @param district
 * @return
 */
        @RequestMapping(value = "/geographies" , method = RequestMethod.GET)
        @ApiOperation(value = "根据省市县查询地址并返回地址编号列表")
        public Envelop search(
                @ApiParam(name = "province", value = "省", defaultValue = "")
                @RequestParam(value = "province",required=false) String province,
                @ApiParam(name = "city", value = "市", defaultValue = "")
                @RequestParam(value = "city",required=false) String city,
                @ApiParam(name = "district", value = "县", defaultValue = "")
                @RequestParam(value = "district",required=false) String district) {
        Envelop envelop = new Envelop();
        List<String> geographyList = addressClient.search(province,city,district);
        if(geographyList.size()>0){
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(geographyList);
        }else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("地址查询失败");
        }
        return envelop;
    }
    /**
     * 删除地址
     * @param id
     * @return
     */
    @RequestMapping(value = "geographies/{id}" , method = RequestMethod.DELETE)
    @ApiOperation(value = "根据id删除地址")
    public Envelop delete(
            @ApiParam(name = "/id" , value = "地址代码" ,defaultValue = "")
            @PathVariable (value = "id") String id) {
        Envelop envelop = new Envelop();
        Boolean bo = addressClient.delete(id);
        if(bo){
            envelop.setSuccessFlg(true);
        }else{
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("地址删除失败");
        }
        return envelop;
    }
    @RequestMapping(value = "/geographies/existence" , method = RequestMethod.GET)
    @ApiOperation(value = "判断是否是个地址")
    public Envelop isNullAddress(
            @ApiParam(name = "json_data", value = "地址json字符串")
            @RequestParam( value = "json_data") String jsonData) throws Exception{
        Envelop envelop = new Envelop();
        Boolean bo = addressClient.isNullAddress(jsonData);
        envelop.setSuccessFlg(bo);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.Geography.AddressDictByFields, method = RequestMethod.GET)
    @ApiOperation(value = "根据名称查询行政区划地址id")
    public Envelop getAddressDictByName(
            @ApiParam(name = "fields", value = "fields", defaultValue = "")
            @RequestParam(value = "fields") String[] fields ,
            @ApiParam(name = "values", value = "values", defaultValue = "")
            @RequestParam(value = "values") String[] values) {
        Envelop envelop = new Envelop();
        Collection<MGeographyDict> addressDict = addressClient.getAddressDict(fields,values);
        if(addressDict!=null){
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(new ArrayList<>(addressDict));
        }else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("根据名称查询行政区划地址id失败");
        }
        return envelop;
    }
}

+ 126 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/geography/service/AddressClient.java

@ -0,0 +1,126 @@
package com.yihu.jw.geography.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.model.common.ObjectResult;
import com.yihu.jw.model.geography.MGeography;
import com.yihu.jw.model.geography.MGeographyDict;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Collection;
import java.util.List;
/**
 * Created by AndyCai on 2016/1/20.
 */
@FeignClient(name=MicroServices.Geography)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface AddressClient {
    @RequestMapping(value = "/geography_entries/level/{level}", method = RequestMethod.GET)
    @ApiOperation(value = "根据等级查询行政区划地址")
    List<MGeographyDict> getAddressByLevel(
            @ApiParam(name = "level", value = "地址级别", defaultValue = "")
            @PathVariable(value = "level") Integer level) ;
    @RequestMapping(value = "/geography_entries/pid/{pid}", method = RequestMethod.GET)
    @ApiOperation(value = "根据上级编号查询行政区划地址")
    List<MGeographyDict> getAddressDictByPid(
            @ApiParam(name = "pid", value = "上级id", defaultValue = "")
            @PathVariable(value = "pid") Integer pid) ;
    @RequestMapping(value = "/geographies/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询地址")
    MGeography getAddressById(
            @ApiParam(name = "id", value = "地址编号", defaultValue = "")
            @PathVariable(value = "id") String id) ;
    @RequestMapping(value = "/geographies/{id}/canonical", method = RequestMethod.GET)
    @ApiOperation(value = "根据地址编号获取地址中文字符串全拼")
    String getCanonicalAddress(
            @ApiParam(name = "id", value = "地址代码", defaultValue = "")
            @PathVariable(value = "id") String id) ;
    /**
     * 地址检查并保存
     * @return
     */
    @RequestMapping(value = "/geographies", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "地址检查,如果地址在数据库中不存在,这新增这条记录,否则返回地址id")
    String saveAddress(
            @ApiParam(name = "json_data", value = "地址json字符串")
            @RequestBody String GeographyModelJsonData) ;
    /**
     * 根据省市县查询地址
     * @param province
     * @param city
     * @param district
     * @return
     */
    @RequestMapping(value = "/geographies" , method = RequestMethod.GET)
    @ApiOperation(value = "根据省市县查询地址并返回地址编号列表")
    List<String> search(
            @ApiParam(name = "province", value = "省", defaultValue = "")
            @RequestParam(value = "province") String province,
            @ApiParam(name = "city", value = "市", defaultValue = "")
            @RequestParam(value = "city") String city,
            @ApiParam(name = "district", value = "县", defaultValue = "")
            @RequestParam(value = "district") String district) ;
    /**
     * 删除地址
     * @param id
     * @return
     */
    @RequestMapping(value = "/geographies/{id}" , method = RequestMethod.DELETE)
    @ApiOperation(value = "根据id删除地址")
    boolean delete(
            @ApiParam(name = "/id" , value = "地址代码" ,defaultValue = "")
            @PathVariable (value = "id") String id) ;
    @RequestMapping(value = "/geographies/existence" , method = RequestMethod.GET)
    @ApiOperation(value = "判断是否是个地址")
    boolean isNullAddress(
            @ApiParam(name = "json_data", value = "地址json字符串")
            @RequestParam( value = "json_data") String jsonData) ;
    @RequestMapping(value = "/geography_entries/getAddressDict" , method = RequestMethod.GET)
    @ApiOperation(value = "根据地址中文名 查询地址编号")
    Collection<MGeographyDict> getAddressDict(
            @ApiParam(name = "fields", value = "fields", defaultValue = "")
            @RequestParam(value = "fields") String[] fields ,
            @ApiParam(name = "values", value = "values", defaultValue = "")
            @RequestParam(value = "values") String[] values);
    @RequestMapping(value = "/geography_entries/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询行政区划地址")
    MGeographyDict getAddressDictById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) ;
    @RequestMapping(value = ServiceApi.Geography.GetAddressNameByCode, method = RequestMethod.GET)
    @ApiOperation(value = "根据地址中文名 查询地址编号")
    ObjectResult getAddressNameByCode(
            @ApiParam(name = "name", value = "name", defaultValue = "")
            @RequestParam(value = "name") String name);
    @RequestMapping(value = "/OrgSaasAreaByname", method = RequestMethod.GET)
    @ApiOperation(value = "根据名称查询行政区划地址")
    List<MGeographyDict> getOrgSaasAreaByname(
            @ApiParam(name = "name", value = "名称", defaultValue = "")
            @RequestParam(value = "name") String name) ;
}

+ 53 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/GovernmentBrowseLogController.java

@ -0,0 +1,53 @@
package com.yihu.jw.government.controller;
import com.yihu.jw.adapter.utils.ExtendController;
import com.yihu.jw.agModel.government.GovernmentBrowseLogModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.entity.government.GovernmentBrowseLog;
import com.yihu.jw.government.service.GovernmentBrowseLogClient;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.*;
import java.util.List;
/**
 * Created by wxw on 2017/11/3.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "government_browse_log", description = "政府服务平台浏览记录", tags = {"政府服务平台"})
public class GovernmentBrowseLogController extends ExtendController<GovernmentBrowseLogModel> {
    @Autowired
    private GovernmentBrowseLogClient governmentBrowseLogClient;
    @RequestMapping(value = ServiceApi.Government.AddGovernmentBrowseLog, method = RequestMethod.POST)
    @ApiOperation(value = "新增浏览记录")
    public Envelop create(
            @ApiParam(name = "jsonData", value = " 记录信息Json", defaultValue = "")
            @RequestParam(value = "jsonData", required = false) String jsonData) {
        GovernmentBrowseLog governmentBrowseLog = governmentBrowseLogClient.saveGovernmentBrowseLog(jsonData);
        if (null == governmentBrowseLog) {
            return failed("保存失败!");
        }
        return success(governmentBrowseLog);
    }
    @RequestMapping(value = ServiceApi.Government.searchGovernmentBrowseLog, method = RequestMethod.GET)
    @ApiOperation(value = "浏览记录")
    public List<GovernmentBrowseLogModel> getBrowseName(
            @ApiParam(name = "userId", value = " 用户Id", defaultValue = "")
            @RequestParam(value = "userId", required = false) String userId) {
        return governmentBrowseLogClient.getBrowseName(userId);
    }
    @RequestMapping(value = ServiceApi.Government.searchHotBrowseLog, method = RequestMethod.GET)
    @ApiOperation(value = "热门监测报表")
    public List<GovernmentBrowseLog> getHotBrowseLog() {
        return governmentBrowseLogClient.getHotBrowseLog();
    }
}

+ 272 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/GovernmentMenuController.java

@ -0,0 +1,272 @@
package com.yihu.jw.government.controller;
import com.yihu.jw.adapter.utils.ExtendController;
import com.yihu.jw.agModel.government.GovernmentMenuModel;
import com.yihu.jw.agModel.resource.RsReportCategoryInfoModel;
import com.yihu.jw.agModel.resource.RsReportModel;
import com.yihu.jw.agModel.resource.RsReportMonitorTypeModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.government.service.GovernmentMenuClient;
import com.yihu.jw.government.service.GovernmentMenuReportMonitorTypeClient;
import com.yihu.jw.model.common.ListResult;
import com.yihu.jw.model.resource.MRsReportMonitorType;
import com.yihu.jw.model.user.MUser;
import com.yihu.jw.resource.client.RsReportCategoryClient;
import com.yihu.jw.resource.client.RsReportClient;
import com.yihu.jw.resource.client.RsReportMonitorTypeClient;
import com.yihu.jw.users.service.UserClient;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.Api;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by wxw on 2017/11/2.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "government_menu", description = "政府服务平台菜单", tags = {"政府服务平台-菜单"})
public class GovernmentMenuController extends ExtendController<GovernmentMenuModel> {
    @Autowired
    private GovernmentMenuClient governmentMenuClient;
    @Autowired
    private UserClient userClient;
    @Autowired
    private GovernmentMenuReportMonitorTypeClient reportMonitorTypeClient;
    @Autowired
    private RsReportMonitorTypeClient monitorTypeClient;
    @Autowired
    private RsReportCategoryClient rsReportCategoryClient;
    @Autowired
    private RsReportClient rsReportClient;
    @RequestMapping(value = ServiceApi.Government.SearchGovernmentMenu, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件查询政府服务平台菜单")
    public Envelop getGovernmentMenuList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        Envelop envelop = new Envelop();
        try {
            ListResult governmentMenuList = governmentMenuClient.getGovernmentMenuList(fields, filters, sorts, size, page);
            List<GovernmentMenuModel> governmentMenus = new ArrayList<>();
            if (governmentMenuList.getTotalCount() != 0) {
                List<Map<String,Object>> modelList = governmentMenuList.getDetailModelList();
                for(Map<String,Object> map : modelList) {
                    GovernmentMenuModel governmentMenuModel = objectMapper.convertValue(map,GovernmentMenuModel.class);
                    if (null != governmentMenuModel && StringUtils.isNotEmpty(governmentMenuModel.getCreateUser())) {
                        MUser user = userClient.getUser(governmentMenuModel.getCreateUser());
                        governmentMenuModel.setCreateUser((null != user) ? user.getRealName() : "" );
                    }
                    if (null != governmentMenuModel && StringUtils.isNotEmpty(governmentMenuModel.getUpdateUser())) {
                        MUser user = userClient.getUser(governmentMenuModel.getUpdateUser());
                        governmentMenuModel.setUpdateUser((null != user) ? user.getRealName() : "" );
                    }
                    governmentMenus.add(governmentMenuModel);
                }
                return getResult(governmentMenus, governmentMenuList.getTotalCount(), governmentMenuList.getCurrPage(), governmentMenuList.getPageSize());
            } else {
                envelop.setSuccessFlg(true);
                return envelop;
            }
        } catch (Exception e) {
            envelop.setErrorMsg("请求发生异常");
            return envelop;
        }
    }
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuById , method = RequestMethod.GET)
    @ApiOperation(value = "根据Id查询详情")
    public Envelop detail(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id") Integer id) {
        try {
            String errorMsg = "";
            if (id == null) {
                errorMsg += "id不能为空!";
            }
            if(StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            GovernmentMenuModel governmentMenuModel = governmentMenuClient.getGovernmentMenuById(id);
            if (governmentMenuModel == null) {
                return failed("获取详情失败!");
            }
            return success(governmentMenuModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuCheckCode, method = RequestMethod.GET)
    @ApiOperation(value = "检查编码是否唯一")
    public Envelop checkCode(
            @ApiParam(name = "code", value = "编码")
            @RequestParam(value = "code") String code) {
        try {
            Envelop envelop = new Envelop();
            if (StringUtils.isEmpty(code)) {
                envelop.setErrorMsg("编码不能为空!");
            }
            int num = governmentMenuClient.getCountByCode(code);
            if (num > 0) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("已经存在此编码!");
            }else{
                envelop.setSuccessFlg(true);
            }
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuCheckName, method = RequestMethod.GET)
    @ApiOperation(value = "检查名称是否唯一")
    public Envelop checkName(
            @ApiParam(name = "name", value = "名称")
            @RequestParam(value = "name") String name) {
        try {
            Envelop envelop = new Envelop();
            if (StringUtils.isEmpty(name)) {
                envelop.setErrorMsg("名称不能为空!");
            }
            int num = governmentMenuClient.getCountByName(name);
            if (num > 0) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("已经存在此名称!");
            } else {
                envelop.setSuccessFlg(true);
            }
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = ServiceApi.Government.AddGovernmentMenu, method = RequestMethod.POST)
    @ApiOperation(value = "新增菜单")
    public Envelop create(
            @ApiParam(name = "jsonData", value = " 菜单信息Json", defaultValue = "")
            @RequestParam(value = "jsonData", required = false) String jsonData,
            @ApiParam(name = "ids", value = "资源报表监测类型ids", defaultValue = "")
            @RequestParam(value = "ids", required = false) String ids){
        try {
            String errorMsg = "";
            GovernmentMenuModel governmentMenuModel = objectMapper.readValue(jsonData, GovernmentMenuModel.class);
            if (StringUtils.isEmpty(governmentMenuModel.getCode())) {
                errorMsg+="编码不能为空!";
            }
            if (StringUtils.isEmpty(governmentMenuModel.getName())) {
                errorMsg+="名称不能为空!";
            }
            if (StringUtils.isEmpty(governmentMenuModel.getUrl())) {
                errorMsg+="链接地址不能为空!";
            }
            if(StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            String json = objectMapper.writeValueAsString(governmentMenuModel);
            GovernmentMenuModel mQuotaCategory = governmentMenuClient.saveGovernmentMenu(json, ids);
            if (mQuotaCategory == null) {
                return failed("保存失败!");
            }
            return success(mQuotaCategory);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = ServiceApi.Government.UpdateGovernmentMenu, method = RequestMethod.POST)
    @ApiOperation(value = "修改菜单")
    public Envelop resetInfo(
            @ApiParam(name = "jsonData", value = " 菜单信息Json", defaultValue = "")
            @RequestParam(value = "jsonData", required = false) String jsonData,
            @ApiParam(name = "ids", value = "资源报表监测类型ids", defaultValue = "")
            @RequestParam(value = "ids", required = false) String ids){
        try {
            String errorMsg = "";
            GovernmentMenuModel governmentMenuModel = objectMapper.readValue(jsonData, GovernmentMenuModel.class);
            if (null == governmentMenuModel) {
                errorMsg += "内容出错!";
            }
            if (StringUtils.isEmpty(governmentMenuModel.getName())) {
                errorMsg += "名称不能为空!";
            }
            if (StringUtils.isEmpty(governmentMenuModel.getName())) {
                errorMsg+="名称不能为空!";
            }
            if (StringUtils.isEmpty(governmentMenuModel.getUrl())) {
                errorMsg+="链接地址不能为空!";
            }
            if(StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            String json = objectMapper.writeValueAsString(governmentMenuModel);
            GovernmentMenuModel mQuotaCategory = governmentMenuClient.updateGovernmentMenu(json, ids);
            if (mQuotaCategory == null) {
                return failed("修改菜单失败!");
            }
            return success(mQuotaCategory);
        } catch (Exception ex){
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = ServiceApi.Government.GetReportByMenuCode, method = RequestMethod.GET)
    @ApiOperation(value = "根据菜单id获取报表内容")
    public Envelop getReportByMenuId(
            @ApiParam(name = "code", value = "分类编码", defaultValue = "")
            @RequestParam(value = "code", required = false) String code) {
        Envelop envelop = new Envelop();
        List<RsReportCategoryInfoModel> list = new ArrayList<>();
        try {
            List<Integer> CategoryIds = rsReportCategoryClient.getCategoryIdsByCode(code);
            if (null != CategoryIds && CategoryIds.size() > 0) {
                List<RsReportCategoryInfoModel> categoryInfoModelList = rsReportCategoryClient.getCategoryByIds(CategoryIds);
                if (null != categoryInfoModelList && categoryInfoModelList.size() > 0) {
                    for (RsReportCategoryInfoModel m : categoryInfoModelList) {
                        if (null != m) {
                            // 根据categoryId获取报表信息
                            List<RsReportModel> rsReportModels = rsReportClient.getByCategoryId(m.getId());
                            m.setReportList(rsReportModels);
                        }
                        list.add(m);
                    }
                }
            }
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(list);
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setErrorMsg("请求发生异常");
        }
        return envelop;
    }
}

+ 61 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/GovernmentMenuReportMonitorTypeController.java

@ -0,0 +1,61 @@
package com.yihu.jw.government.controller;
import com.yihu.jw.agModel.government.GovernmentMenuReportMonitorTypeModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ErrorCode;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.government.service.GovernmentMenuReportMonitorTypeClient;
import com.yihu.jw.quota.service.TjQuotaJobClient;
import com.yihu.jw.users.service.UserClient;
import com.yihu.jw.util.log.LogService;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by wxw on 2017/11/2.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "governmentMenuReportMonitorType", description = "政府服务平台菜单报表监测类型接口", tags = {"政府服务平台-菜单"})
public class GovernmentMenuReportMonitorTypeController extends BaseController {
    @Autowired
    private GovernmentMenuReportMonitorTypeClient governmentMenuReportMonitorTypeClient;
    @Autowired
    private UserClient userClient;
    @Autowired
    private TjQuotaJobClient tjQuotaJobClient;
    @ApiOperation("政府服务平台菜单报表监测类型")
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuReportMonitorTypeSave, method = RequestMethod.POST)
    public Envelop add(
            @ApiParam(name = "rsReoportMonitorTypeId", value = "资源报表监测分类ID", required = true)
            @RequestParam(value = "rsReoportMonitorTypeId") String rsReoportMonitorTypeId) throws Exception {
        Envelop envelop = new Envelop();
        GovernmentMenuReportMonitorTypeModel newMGovernmentMenuReportMonitorType = governmentMenuReportMonitorTypeClient.add(rsReoportMonitorTypeId);
        envelop.setObj(newMGovernmentMenuReportMonitorType);
        envelop.setSuccessFlg(true);
        return envelop;
    }
    @ApiOperation("删除政府服务平台菜单报表监测类型")
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuReportMonitorTypeDelete, method = RequestMethod.DELETE)
    public Envelop delete(
            @ApiParam(name = "id", value = "主键", required = true)
            @RequestParam(value = "id") Integer id) throws Exception {
        Envelop envelop = new Envelop();
        governmentMenuReportMonitorTypeClient.delete(id);
        envelop.setSuccessFlg(true);
        return envelop;
    }
}

+ 61 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/controller/OutpatientsBoardController.java

@ -0,0 +1,61 @@
package com.yihu.jw.government.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.government.service.OutpatientsBoardClient;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by zdm on 2017/12/28.
 */
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "outpatientsBoard", description = "政府服务平台-门诊仪表盘", tags = {"政府服务平台-门诊仪表盘"})
public class OutpatientsBoardController extends BaseController {
        @Autowired
        private OutpatientsBoardClient outpatientsBoardClient;
        @RequestMapping(value = ServiceApi.Government.OutpatientsBoardCount, method = RequestMethod.POST)
        @ApiOperation(value = "统计门诊 当月相关数据")
        public Envelop outpatientsBoardCount(
                @ApiParam(name = "core", value = "集合", required = true)
                @RequestParam(value = "core") String core,
                @ApiParam(name = "position", value = "指标位置", required = true)
                @RequestParam(value = "position") String position) {
            Envelop envelop = new Envelop();
            envelop=outpatientsBoardClient.outpatientsBoardCount(core,position);
            return envelop;
        }
    @ApiOperation("医院门急诊人次分布")
    @RequestMapping(value = ServiceApi.Government.GetMonthDistribution, method = RequestMethod.POST)
    public Envelop getMonthDistribution(
            @ApiParam(name = "core", value = "集合", required = true)
            @RequestParam(value = "core") String core,
            @ApiParam(name = "year", value = "年份", required = true)
            @RequestParam(value = "year") String year) {
        Envelop envelop = new Envelop();
        envelop=outpatientsBoardClient.getMonthDistribution(core,year);
        return envelop;
    }
    @ApiOperation("本月各类医院门急诊人次")
    @RequestMapping(value = ServiceApi.Government.GetRescue, method = RequestMethod.POST)
    public Envelop getRescue() {
        Envelop envelop =outpatientsBoardClient.getRescue();
        return envelop;
    }
}

+ 37 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/service/GovernmentBrowseLogClient.java

@ -0,0 +1,37 @@
package com.yihu.jw.government.service;
import com.yihu.jw.agModel.government.GovernmentBrowseLogModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.entity.government.GovernmentBrowseLog;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * Created by wxw on 2017/11/3.
 */
@FeignClient(name= MicroServices.User)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface GovernmentBrowseLogClient {
    @RequestMapping(value = ServiceApi.Government.AddGovernmentBrowseLog, method = RequestMethod.POST)
    @ApiOperation(value = "新增浏览记录")
    GovernmentBrowseLog saveGovernmentBrowseLog(@RequestBody String jsonData);
    @RequestMapping(value = ServiceApi.Government.searchGovernmentBrowseLog, method = RequestMethod.GET)
    @ApiOperation(value = "浏览记录")
    List<GovernmentBrowseLogModel> getBrowseName(@RequestParam(value = "userId", required = false) String userId);
    @RequestMapping(value = ServiceApi.Government.searchHotBrowseLog, method = RequestMethod.GET)
    @ApiOperation(value = "热门监测报表")
    List<GovernmentBrowseLog> getHotBrowseLog();
}

+ 52 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/service/GovernmentMenuClient.java

@ -0,0 +1,52 @@
package com.yihu.jw.government.service;
import com.yihu.jw.agModel.government.GovernmentMenuModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.model.common.ListResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Created by wxw on 2017/11/2.
 */
@FeignClient(name= MicroServices.User)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface GovernmentMenuClient {
    @RequestMapping(value = ServiceApi.Government.SearchGovernmentMenu, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件查询政府服务平台菜单")
    ListResult getGovernmentMenuList(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuById , method = RequestMethod.GET)
    @ApiOperation(value = "根据Id查询详情")
    GovernmentMenuModel getGovernmentMenuById(@RequestParam(value = "id") Integer id);
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuCheckCode, method = RequestMethod.GET)
    @ApiOperation(value = "检查编码是否唯一")
    int getCountByCode(@RequestParam(value = "code") String code);
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuCheckName, method = RequestMethod.GET)
    @ApiOperation(value = "检查名称是否唯一")
    int getCountByName(@RequestParam(value = "name") String name);
    @RequestMapping(value = ServiceApi.Government.AddGovernmentMenu, method = RequestMethod.POST)
    @ApiOperation(value = "新增菜单")
    GovernmentMenuModel saveGovernmentMenu(@RequestBody String jsonData, @RequestParam(value = "ids") String ids);
    @RequestMapping(value = ServiceApi.Government.UpdateGovernmentMenu, method = RequestMethod.POST)
    @ApiOperation(value = "修改菜单")
    GovernmentMenuModel updateGovernmentMenu(@RequestBody String jsonData, @RequestParam(value = "ids") String ids);
}

+ 49 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/service/GovernmentMenuReportMonitorTypeClient.java

@ -0,0 +1,49 @@
package com.yihu.jw.government.service;
import com.yihu.jw.agModel.government.GovernmentMenuReportMonitorTypeModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
 * 资源报表监测监测分类 client
 *
 * @author janseny
 * @created 2017年11月7日15:05:53
 */
@FeignClient(name = MicroServices.User)
@RequestMapping(value = ApiVersion.Version1_0)
@ApiIgnore
public interface GovernmentMenuReportMonitorTypeClient {
    @ApiOperation("新增政府菜单资源报表监测分类")
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuReportMonitorTypeSave, method = RequestMethod.POST)
    GovernmentMenuReportMonitorTypeModel add(
            @ApiParam(name = "governmentMenuReportMonitorType", value = "政府菜单资源报表监测分类JSON字符串", required = true)
            @RequestBody String governmentMenuReportMonitorType);
    @ApiOperation("删除政府菜单资源报表监测分类")
    @RequestMapping(value = ServiceApi.Government.GovernmentMenuReportMonitorTypeDelete, method = RequestMethod.DELETE)
    void delete(
            @ApiParam(name = "id", value = "政府菜单资源报表监测分类ID", required = true)
            @RequestParam(value = "id") Integer id);
    @ApiOperation("获取政府菜单资源报表监测类型Id")
    @RequestMapping(value = ServiceApi.Government.MonitorTypeList, method = RequestMethod.GET)
    List<Integer> getMonitorTypeIdByGovernmentMenuId(
            @ApiParam(name = "menuId", value = "菜单ID", required = true)
            @RequestParam(value = "menuId") String menuId);
}

+ 44 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/government/service/OutpatientsBoardClient.java

@ -0,0 +1,44 @@
package com.yihu.jw.government.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Created by zdm on 2017/12/28.
 */
@FeignClient(name= MicroServices.Quota)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface OutpatientsBoardClient {
    @ApiOperation("本月门急诊人次")
    @RequestMapping(value = "/statistics/{position}", method = RequestMethod.POST)
    Envelop outpatientsBoardCount(
            @ApiParam(name = "core", value = "集合", required = true)
            @RequestParam(value = "core") String core,
            @ApiParam(name = "position", value = "指标位置", required = true)
            @RequestParam(value = "position") String position);
    @ApiOperation("医院门急诊人次分布")
    @RequestMapping(value = ServiceApi.Government.GetMonthDistribution, method = RequestMethod.POST)
    Envelop getMonthDistribution(
            @ApiParam(name = "core", value = "集合", required = true)
            @RequestParam(value = "core") String core,
            @ApiParam(name = "year", value = "年份", required = true)
            @RequestParam(value = "year") String year);
    @ApiOperation("医院门急诊人次分布")
    @RequestMapping(value = ServiceApi.Government.GetRescue, method = RequestMethod.POST)
    Envelop getRescue();
}

+ 192 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/msg/controller/TelVerificationController.java

@ -0,0 +1,192 @@
package com.yihu.jw.msg.controller;
import com.yihu.jw.apps.service.AppClient;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.model.app.MApp;
import com.yihu.jw.model.user.MUser;
import com.yihu.jw.msg.service.TelVerificationClient;
import com.yihu.jw.users.service.UserClient;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2017/2/14.
 */
@EnableFeignClients
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "TelVerification", description = "手机验证码接口管理", tags = {"基础信息 - 手机短信验证"})
public class TelVerificationController extends BaseController {
    @Autowired
    private AppClient appClient;
    @Autowired
    private UserClient userClient;
    @Autowired
    private TelVerificationClient telVerificationClient;
    @Value("${service-gateway.url}")
    private String gatewayUrl;
    @Value("${service-gateway.handlerId}")
    private String handlerId;
    @Value("${service-gateway.clientId}")
    private String clientId;
    @Value("${service-gateway.clientVersion}")
    private String clientVersion;
    /*
     * 1.1验证APPID的有效性
     * 1.2生成随机6位验证码,并存储
     * 1.3调用短信发送接口,进行短信的发送
     */
    @RequestMapping(value = "/msg/sendMsg", method = RequestMethod.GET)
    @ApiOperation(value = "验证码获取接口", notes = "根据手机号及应用的ID获取短信验证码信息")
    public Envelop sendMsg(
            @ApiParam(name = "appId", value = "应用ID")
            @RequestParam(value = "appId", required = false) String appId,
            @ApiParam(name = "tel", value = "手机号码", defaultValue = "")
            @RequestParam(value = "tel", required = false) String tel) throws Exception {
        Envelop envelop = new Envelop();
        //1.1验证APPID的有效性
        MApp mApp = appClient.getApp(appId);
        if (mApp == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("对不起,你所使用的应用尚未进行注册。");
            return envelop;
        }
        //1.2生成随机6位验证码,并存储验证信息
        Envelop result = telVerificationClient.createTelVerification(tel, appId);
        return result;
    }
    /*
     * 1.1直接验证验证码的有效性
     */
    @RequestMapping(value = "/msg/validate", method = RequestMethod.GET)
    @ApiOperation(value = "验证码有效性验证", notes = "根据手机号及应用的ID获取短信验证码信息,并校验")
    public Envelop validate(
            @ApiParam(name = "appId", value = "应用ID")
            @RequestParam(value = "appId", required = false) String appId,
            @ApiParam(name = "tel", value = "手机号码", defaultValue = "")
            @RequestParam(value = "tel", required = false) String tel,
            @ApiParam(name = "verificationCode", value = "手机验证码", defaultValue = "")
            @RequestParam(value = "verificationCode", required = false) String verificationCode) throws Exception {
        Envelop envelop = new Envelop();
        envelop = telVerificationClient.validationTelVerification(tel, appId, verificationCode);
        if (envelop == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("验证失败,请联系管理员!");
        }
        return envelop;
    }
    /*
    * 1.1直接验证验证码的有效性
    * 1.2根据手机号获取用户信息
    * 1.3修改该用户的密码信息
    * 1.4删除验证码信息
    */
    @RequestMapping(value = "/users/updatePasswordByVerificationCode", method = RequestMethod.GET)
    @ApiOperation(value = "忘记密码 - 修改密码", notes = "根据验证码修改用户密码信息")
    public Envelop updatePasswordByVerificationCode(
            @ApiParam(name = "appId", value = "应用ID")
            @RequestParam(value = "appId", required = false) String appId,
            @ApiParam(name = "tel", value = "手机号码", defaultValue = "")
            @RequestParam(value = "tel", required = false) String tel,
            @ApiParam(name = "verificationCode", value = "验证码", defaultValue = "")
            @RequestParam(value = "verificationCode", required = false) String verificationCode,
            @ApiParam(name = "password", value = "新密码", defaultValue = "")
            @RequestParam(value = "password", required = false) String password) throws Exception {
        Envelop envelop = new Envelop();
        envelop = telVerificationClient.validationTelVerification(tel, appId, verificationCode);
        if (envelop == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("验证失败,请联系管理员!");
            return envelop;
        }
        if (envelop.isSuccessFlg()) {
            //获取用户信息,根据手机号码
            MUser mUser = userClient.getUserByTel(tel);
            if (mUser == null) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("对不起,手机号码无法验证,请确认!");
                return envelop;
            }
            String userId = mUser.getId().toString();
            //在微服务中会将该密码信息进行MD5加密
            Boolean result = userClient.changePassWord(userId, password);
            if (result) {
                envelop.setSuccessFlg(true);
                envelop.setErrorMsg("密码修改成功!");
            } else {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("密码修改失败,请联系管理员!");
            }
        }
        return envelop;
    }
    /*
   * 1.1直接验证验证码的有效性
   * 1.2根据手机号获取用户信息
   * 1.3修改该用户的密码信息
   * 1.4删除验证码信息
   */
    @RequestMapping(value = "/users/updatePasswordByOldPwd", method = RequestMethod.GET)
    @ApiOperation(value = "修改密码", notes = "根据旧密码修改用户的密码信息")
    public Envelop updatePasswordByOldPwd(
            @ApiParam(name = "appId", value = "应用ID")
            @RequestParam(value = "appId", required = false) String appId,
            @ApiParam(name = "userId", value = "手机号码", defaultValue = "")
            @RequestParam(value = "userId", required = false) String userId,
            @ApiParam(name = "passwordOld", value = "验证码", defaultValue = "")
            @RequestParam(value = "passwordOld", required = false) String passwordOld,
            @ApiParam(name = "passwordNew", value = "新密码", defaultValue = "")
            @RequestParam(value = "passwordNew", required = false) String passwordNew) throws Exception {
        Envelop envelop = new Envelop();
        //获取用户信息,根据用户ID
        MUser mUser = userClient.getUser(userId);
        if (mUser == null) {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("对不起,该用户不存在,请确认!");
            return envelop;
        }
        //对旧密码进行MD5加密后,进行对比验证
        String hashPassWordOld = DigestUtils.md5Hex(passwordOld);
        if (StringUtils.equals(hashPassWordOld, mUser.getPassword().toString())) {
            //当验证通过后,进行新密码的更新在微服务中会将该密码信息进行MD5加密
            Boolean result = userClient.changePassWord(userId, passwordNew);
            if (result) {
                envelop.setSuccessFlg(true);
                envelop.setErrorMsg("密码修改成功!");
            } else {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("密码修改失败,请联系管理员!");
            }
        } else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("对不起,密码验证失败,请确认!");
        }
        return envelop;
    }
}

+ 42 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/msg/service/TelVerificationClient.java

@ -0,0 +1,42 @@
package com.yihu.jw.msg.service;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.MicroServices;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Created by AndyCai on 2016/2/1.
 */
@FeignClient(name= MicroServices.Organization)
@RequestMapping(ApiVersion.Version1_0)
@ApiIgnore
public interface TelVerificationClient {
    @RequestMapping(value = ServiceApi.TelVerification.TelVerificationMsgSendMsg, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建手机验证信息", notes = "创建手机验证信息")
    Envelop createTelVerification(
            @ApiParam(name = "telNo", value = "", defaultValue = "")
            @RequestParam(value = "telNo", required = false) String tel,
            @ApiParam(name = "appId", value = "", defaultValue = "")
            @RequestParam(value = "appId", required = false) String appId) throws Exception ;
    @RequestMapping(value = ServiceApi.TelVerification.TelVerificationMsgValidate, method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "验证手机验证信息", notes = "验证手机验证信息")
    Envelop validationTelVerification(
            @ApiParam(name = "telNo", value = "", defaultValue = "")
            @RequestParam(value = "telNo", required = false) String tel,
            @ApiParam(name = "appId", value = "", defaultValue = "")
            @RequestParam(value = "appId", required = false) String appId,
            @ApiParam(name = "verificationCode", value = "", defaultValue = "")
            @RequestParam(value = "verificationCode", required = false) String verificationCode) throws Exception ;
}

+ 749 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgDeptController.java

@ -0,0 +1,749 @@
package com.yihu.jw.organization.controller;
import com.yihu.jw.agModel.org.OrgDeptDetailModel;
import com.yihu.jw.agModel.org.OrgDeptMemberModel;
import com.yihu.jw.agModel.org.OrgDeptModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.model.dict.MConventionalDict;
import com.yihu.jw.model.org.MOrgDept;
import com.yihu.jw.model.org.MOrgDeptData;
import com.yihu.jw.model.org.MOrgDeptDetail;
import com.yihu.jw.model.org.MOrgMemberRelation;
import com.yihu.jw.model.user.MUser;
import com.yihu.jw.organization.service.OrgDeptClient;
import com.yihu.jw.organization.service.OrgDeptMemberClient;
import com.yihu.jw.organization.service.OrganizationClient;
import com.yihu.jw.systemdict.service.ConventionalDictEntryClient;
import com.yihu.jw.users.service.UserClient;
import com.yihu.jw.util.fzgateway.FzGatewayUtil;
import com.yihu.jw.util.rest.Envelop;
import io.swagger.annotations.Api;
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.cloud.netflix.feign.EnableFeignClients;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/2/20.
 */
@EnableFeignClients
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "orgDept", description = "机构信息部门管理", tags = {"机构管理 - 机构部门管理"})
public class OrgDeptController extends BaseController {
    @Autowired
    private OrgDeptClient orgDeptClient;
    @Autowired
    private OrgDeptMemberClient orgDeptMemberClient;
    @Autowired
    private UserClient userClient;
    @Autowired
    private ConventionalDictEntryClient conventionalDictClient;
    @Autowired
    private OrganizationClient orgClient;
    @Value("${service-gateway.url}")
    private String gatewayUrl;
    @Value("${service-gateway.clientId}")
    private String clientId;
    @Value("${service-gateway.clientVersion}")
    private String clientVersion;
    @ApiOperation(value = "获取所有部门列表")
    @RequestMapping(value = "/orgDept/getAllOrgDepts", method = RequestMethod.GET)
    public Envelop getAllOrgDepts() {
        try {
            Envelop envelop = new Envelop();
            envelop.setDetailModelList(orgDeptClient.getAllOrgDepts());
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @ApiOperation(value = "根据组织机构ID获取部门列表")
    @RequestMapping(value = "/orgDept/list", method = RequestMethod.GET)
    public Envelop getOrgDeptsByOrgId(
            @ApiParam(name = "orgId", value = "机构ID", defaultValue = "")
            @RequestParam(value = "orgId") String orgId) {
        try {
            Envelop envelop = new Envelop();
            envelop.setDetailModelList(orgDeptClient.searchOrgDepts(orgId));
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @ApiOperation(value = "根据父级部门ID获取子部门列表")
    @RequestMapping(value = "/orgDept/childs", method = RequestMethod.POST)
    public Envelop searchChildOrgDepts(
            @ApiParam(name = "parentDeptId", value = "父级部门ID")
            @RequestParam(value = "parentDeptId") Integer parentDeptId) {
        try {
            Envelop envelop = new Envelop();
            envelop.setDetailModelList(orgDeptClient.searchChildOrgDepts(parentDeptId));
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDept/detail", method = RequestMethod.POST)
    @ApiOperation(value = "查询部门&科室详情")
    public Envelop detail(
            @ApiParam(name = "deptId", value = "部门ID")
            @RequestParam(value = "deptId", required = true) Integer deptId
    ) {
        try {
            String errorMsg = "";
            if (deptId == null) {
                errorMsg += "部门不能为空!";
            }
            MOrgDept mOrgDeptNew = orgDeptClient.searchDeptDetail(deptId);
            if (mOrgDeptNew == null) {
                return failed("获取部门详情失败!");
            }
            return success(mOrgDeptNew);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDept/detailById", method = RequestMethod.GET)
    @ApiOperation(value = "根据id查询部门&科室详情")
    public Envelop detailById(
            @ApiParam(name = "deptId", value = "deptId")
            @RequestParam(value = "deptId", required = true) Integer deptId) {
        try {
            String errorMsg = "";
            if (deptId == null) {
                errorMsg += "部门不能为空!";
            }
            MOrgDept mOrgDeptNew = orgDeptClient.searchDeptDetail(deptId);
            if (mOrgDeptNew == null) {
                return failed("获取部门详情失败!");
            }
            if (mOrgDeptNew.getDeptDetail() != null) {
                //获取类别字典
                MConventionalDict dict = conventionalDictClient.getOrgDeptDetailDisplayStatus(String.valueOf(mOrgDeptNew.getDeptDetail().getDisplayStatus()));
                mOrgDeptNew.getDeptDetail().setDisplayStatusName(dict == null ? "" : dict.getValue());
                MConventionalDict dict2 = conventionalDictClient.getOrgDeptDetailPyCode(String.valueOf(mOrgDeptNew.getDeptDetail().getPyCode()));
                mOrgDeptNew.getDeptDetail().setPyCodeName(dict2 == null ? "" : dict2.getValue());
                String[] glory = mOrgDeptNew.getDeptDetail().getGloryId().split(",");
                String gloryName = "";
                for (int i = 0; i < glory.length; i++) {
                    MConventionalDict dict3 = conventionalDictClient.getOrgDeptDetailGloryId(glory[i]);
                    gloryName += (dict3 == null ? "" : dict3.getValue()) + ",";
                }
                mOrgDeptNew.getDeptDetail().setGloryName(gloryName.substring(0, gloryName.length() - 1));
            }
            return success(mOrgDeptNew);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDept", method = RequestMethod.POST)
    @ApiOperation(value = "新增机构部门")
    public Envelop create(
            @ApiParam(name = "orgDeptsJsonData", value = " 部门信息Json", defaultValue = "")
            @RequestParam(value = "orgDeptsJsonData", required = false) String orgDeptsJsonData) {
        try {
            String errorMsg = "";
            OrgDeptModel orgDeptModel = objectMapper.readValue(orgDeptsJsonData, OrgDeptModel.class);
//            MOrgDept mOrgDept = convertToModel(orgDeptModel, MOrgDept.class);
            if (StringUtils.isEmpty(orgDeptModel.getCode())) {
                errorMsg += "部门代码不能为空!";
            }
            if (StringUtils.isEmpty(orgDeptModel.getName())) {
                errorMsg += "部门不能为空!";
            }
            if (StringUtils.isEmpty(orgDeptModel.getOrgId())) {
                errorMsg += "机构不能为空!";
            }
            if (StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            //云门户保存
            String mOrganizationJson = objectMapper.writeValueAsString(orgDeptModel);
            MOrgDept mOrgDeptNew = orgDeptClient.saveOrgDept(mOrganizationJson);
            if (mOrgDeptNew == null) {
                return failed("保存失败!");
            }
          /*  //同步科室信息-因为在预约挂号后台追加排班信息时,会判断是否存在科室,若不存在,总部自动追加。EHR使用标准科室。
            Map<String, Object> result = saveSynDept(orgDeptModel);
            if (result.get("Code").toString().equals("10000")) {
                //同步成功
                mOrgDeptNew.setJkzlHosDeptId(Integer.parseInt(result.get("hosDeptId").toString()));
                String mOrgDeptNewJson = objectMapper.writeValueAsString(orgDeptModel);
                orgDeptClient.updateOrgDept(mOrgDeptNewJson);
            } else {
                //同步失败
                return failed("保存失败!");
            }*/
            return success(mOrgDeptNew);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    /**
     * 同步科室信息
     *
     * @param orgDeptModel
     */
    private Map<String, Object> saveSynDept(OrgDeptModel orgDeptModel) throws Exception {
        String api = "baseinfo.HosDeptApi.insertHosDept";
        String orgId = orgClient.getOrgById(orgDeptModel.getOrgId()).getJkzlOrgId();
        int parentDeptId = 0;
        if (orgDeptModel.getParentDeptId() != 0) {
            MOrgDept dept = orgDeptClient.searchDeptDetail(orgDeptModel.getParentDeptId());
            parentDeptId = dept.getJkzlHosDeptId();
        }
        Map<String, Object> apiParamMap = new HashMap<>();
        apiParamMap.put("orgId", orgId);//医院orgId
        apiParamMap.put("parentDeptID", parentDeptId);//上级科室 如果没有上级科室传0
        if(null == orgDeptModel.getDeptDetail().getTypeId()){
            apiParamMap.put("typeId", 2);//科室类型
        }else{
            apiParamMap.put("typeId", orgDeptModel.getDeptDetail().getTypeId());//科室类型
        }
        apiParamMap.put("deptName", orgDeptModel.getDeptDetail().getName());//科室名称
        apiParamMap.put("intro", orgDeptModel.getDeptDetail().getIntroduction());//科室简介
        apiParamMap.put("place", orgDeptModel.getDeptDetail().getPlace());//科室位置
        apiParamMap.put("deptCode", orgDeptModel.getDeptDetail().getDeptId());//科室代码
        apiParamMap.put("displayStatus", orgDeptModel.getDeptDetail().getDisplayStatus());//显示状态
        String resultStr = FzGatewayUtil.httpPost(gatewayUrl, clientId, clientVersion, api, apiParamMap, 1);
        logger.info(resultStr);
        return objectMapper.readValue(resultStr, Map.class);
    }
    @RequestMapping(value = "/orgDept", method = RequestMethod.PUT)
    @ApiOperation(value = "修改部门&科室详情")
    public Envelop update(
            @ApiParam(name = "orgDeptJsonData", value = " 部门信息Json", defaultValue = "")
            @RequestParam(value = "orgDeptJsonData", required = false) String orgDeptJsonData) {
        try {
            String errorMsg = "";
            OrgDeptModel orgDeptModel = objectMapper.readValue(orgDeptJsonData, OrgDeptModel.class);
            OrgDeptDetailModel deptDetailModel = orgDeptModel.getDeptDetail();
            MOrgDeptDetail mOrgDeptDetail = convertToModel(deptDetailModel, MOrgDeptDetail.class);
            MOrgDept mOrgDept = convertToModel(orgDeptModel, MOrgDept.class);
            mOrgDept.setDeptDetail(mOrgDeptDetail);
            if (StringUtils.isEmpty(mOrgDept.getCode())) {
                errorMsg += "部门代码不能为空!";
            }
            if (StringUtils.isEmpty(mOrgDept.getName())) {
                errorMsg += "部门不能为空!";
            }
            if (StringUtils.isEmpty(mOrgDept.getOrgId())) {
                errorMsg += "机构不能为空!";
            }
            if (StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
            String mOrganizationJson = objectMapper.writeValueAsString(mOrgDept);
            MOrgDept mOrgDeptNew = orgDeptClient.updateOrgDept(mOrganizationJson);
            if (mOrgDeptNew == null) {
                return failed("保存失败!");
            }
            return success(mOrgDeptNew);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDept/checkDeptName", method = RequestMethod.PUT)
    @ApiOperation(value = "检查机构下部门名称是否唯一")
    public Envelop checkDeptName(
            @ApiParam(name = "orgId", value = "机构ID")
            @RequestParam(value = "orgId", required = true) Integer orgId,
            @ApiParam(name = "name", value = "新部门名称")
            @RequestParam(value = "name", required = true) String name
    ) {
        try {
            Envelop envelop = new Envelop();
            String errorMsg = "";
            if (orgId == null) {
                envelop.setErrorMsg("机构不能为空!");
            }
            if (StringUtils.isEmpty(name)) {
                envelop.setErrorMsg("新部门名称不能为空!");
            }
            int num = orgDeptClient.getCountByDeptName(orgId, name);
            if (num > 0) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("所在机构已经存在此部门!");
            } else {
                envelop.setSuccessFlg(true);
            }
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDept/resetName", method = RequestMethod.POST)
    @ApiOperation(value = "修改机构部们名称")
    public Envelop resetDeptName(
            @ApiParam(name = "deptId", value = "部门ID")
            @RequestParam(value = "deptId", required = true) Integer deptId,
            @ApiParam(name = "name", value = "新部门名称")
            @RequestParam(value = "name", required = true) String name
    ) {
        try {
            String errorMsg = "";
            if (deptId == null) {
                errorMsg += "部门不能为空!";
            }
            if (StringUtils.isEmpty(name)) {
                errorMsg += "新部门名称不能为空!";
            }
            MOrgDept mOrgDeptNew = orgDeptClient.updateOrgDeptName(deptId, name);
            if (mOrgDeptNew == null) {
                return failed("修改部门失败!");
            }
            return success(mOrgDeptNew);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDept/delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除机构部门")
    public boolean delete(
            @ApiParam(name = "deptId", value = "部门ID")
            @RequestParam(value = "deptId", required = true) Integer deptId
    ) {
        try {
            boolean succ = orgDeptClient.deleteOrgDept(deptId);
            return succ;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
    @RequestMapping(value = "/orgDept/checkMembers", method = RequestMethod.POST)
    @ApiOperation(value = "机构部门下是否有成员存在")
    public boolean isHasMember(
            @ApiParam(name = "deptId", value = "部门ID")
            @RequestParam(value = "deptId", required = true) Integer deptId) {
        try {
            boolean succ = orgDeptClient.isHasMember(deptId);
            return succ;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
    @RequestMapping(value = "/orgDept/changeSort", method = RequestMethod.POST)
    @ApiOperation(value = "部门排序")
    public boolean changeSort(
            @ApiParam(name = "preDeptId", value = "第一个部门ID")
            @RequestParam(value = "preDeptId", required = true) Integer preDeptId,
            @ApiParam(name = "afterDeptId", value = "第二个部门ID")
            @RequestParam(value = "afterDeptId", required = true) Integer afterDeptId) {
        try {
            boolean succ = orgDeptClient.changeSort(preDeptId, afterDeptId);
            return succ;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
    /* ****************************     部门成员相关   ********************************************/
    @RequestMapping(value = "/orgDeptMember/list", method = RequestMethod.POST)
    @ApiOperation(value = "获取部门下成员列表", notes = "根据查询条件获取部门成员列表在前端表格展示")
    public Envelop searchOrgDeptMembers(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,userName,dutyName")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+deptId")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        try {
            List<OrgDeptMemberModel> orgMemberModels = new ArrayList<>();
            ResponseEntity<List<MOrgMemberRelation>> responseEntity = orgDeptMemberClient.searchOrgDeptMembers(fields, filters, sorts, size, page);
            List<MOrgMemberRelation> members = responseEntity.getBody();
            for (MOrgMemberRelation deptMember : members) {
                OrgDeptMemberModel memberModel = convertToModel(deptMember, OrgDeptMemberModel.class);
//                if (StringUtils.isNotEmpty(memberModel.getUserId()) ){
//                    MUser mUser = userClient.getUser(memberModel.getUserId());
//                    memberModel.setUserName(mUser == null ? "" : mUser.getRealName());
//                }
//                if (memberModel.getDeptId()!=null && memberModel.getDeptId()!=0 ){
//                    MOrgDept mOrgDept = orgDeptClient.searchDeptDetail(memberModel.getDeptId());
//                    memberModel.setDeptName(mOrgDept == null ? "" : mOrgDept.getName());
//                }
                orgMemberModels.add(memberModel);
            }
            int totalCount = getTotalCount(responseEntity);
            return getResult(orgMemberModels, totalCount, page, size);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDeptMember/getOrgDeptMembers", method = RequestMethod.POST)
    @ApiOperation(value = "获取部门下成员列表", notes = "根据查询条件获取机构成员去重复列表在前端表格展示")
    public Envelop getOrgDeptMembers(
            @ApiParam(name = "orgId", value = "机构ID", defaultValue = "")
            @RequestParam(value = "orgId", required = false) String orgId,
            @ApiParam(name = "searchParm", value = "关键字查询", defaultValue = "")
            @RequestParam(value = "searchParm", required = false) String searchParm,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) {
        try {
            ResponseEntity<List<MOrgMemberRelation>> responseEntity = orgDeptMemberClient.getOrgDeptMembers(orgId, searchParm, size, page);
            List<MOrgMemberRelation> members = responseEntity.getBody();
            int totalCount = getTotalCount(responseEntity);
            return getResult(members, totalCount, page, size);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @ApiOperation(value = "获取所有成员列表")
    @RequestMapping(value = "/orgDeptMember/getAllOrgDeptMember", method = RequestMethod.GET)
    public Envelop getAllOrgDeptMember(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) {
        try {
            Envelop envelop = new Envelop();
            List<MOrgMemberRelation> memberRelationList = new ArrayList<MOrgMemberRelation>();
            ResponseEntity<List<MOrgMemberRelation>> responseEntity = orgDeptMemberClient.getAllOrgDeptMember(filters);
            memberRelationList = responseEntity.getBody();
            if (memberRelationList != null && memberRelationList.size() > 0) {
                for (MOrgMemberRelation memberRelation : memberRelationList) {
                    if (StringUtils.isNotEmpty(memberRelation.getUserId()) && StringUtils.isEmpty(memberRelation.getUserName())) {
                        MUser mUser = userClient.getUser(memberRelation.getUserId());
                        memberRelation.setUserName(mUser == null ? "" : mUser.getRealName());
                    }
                }
            }
            envelop.setDetailModelList(memberRelationList);
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @ApiOperation(value = "获取所有成员列表去重复")
    @RequestMapping(value = "/orgDeptMember/getAllOrgDeptMemberDistinct", method = RequestMethod.GET)
    public Envelop getAllOrgDeptMemberDistinct(
            @ApiParam(name = "orgId", value = "机构ID", defaultValue = "")
            @RequestParam(value = "orgId", required = false) String orgId,
            @ApiParam(name = "searchNm", value = "关键字查询", defaultValue = "")
            @RequestParam(value = "searchNm", required = false) String searchNm
    ) {
        try {
            Envelop envelop = new Envelop();
            List<MOrgMemberRelation> memberRelationList = new ArrayList<MOrgMemberRelation>();
            ResponseEntity<List<MOrgMemberRelation>> responseEntity = orgDeptMemberClient.getAllOrgDeptMemberDistinct(orgId, searchNm);
            memberRelationList = responseEntity.getBody();
            if (memberRelationList != null && memberRelationList.size() > 0) {
                for (MOrgMemberRelation memberRelation : memberRelationList) {
                    if (StringUtils.isNotEmpty(memberRelation.getUserId()) && StringUtils.isEmpty(memberRelation.getUserName())) {
                        MUser mUser = userClient.getUser(memberRelation.getUserId());
                        memberRelation.setUserName(mUser == null ? "" : mUser.getRealName());
                    }
                }
            }
            envelop.setDetailModelList(memberRelationList);
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDept/checkUser", method = RequestMethod.PUT)
    @ApiOperation(value = "检查机构下用户是否唯一")
    public Envelop checkUser(
            @ApiParam(name = "orgId", value = "机构ID")
            @RequestParam(value = "orgId", required = true) Integer orgId,
            @ApiParam(name = "userId", value = "用户ID")
            @RequestParam(value = "userId", required = true) String userId,
            @ApiParam(name = "deptId", value = "部门ID")
            @RequestParam(value = "deptId", required = true) Integer deptId
    ) {
        try {
            Envelop envelop = new Envelop();
            String errorMsg = "";
            if (orgId == null) {
                errorMsg += "机构不能为空!";
                envelop.setErrorMsg(errorMsg);
            }
            if (StringUtils.isEmpty(userId)) {
                errorMsg += "用户不能为空!";
                envelop.setErrorMsg(errorMsg);
            }
            int num = orgDeptClient.getCountByUserId(orgId, userId, deptId);
            if (num > 0) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("所在机构中的部门已经存在此用户!");
            } else {
                envelop.setSuccessFlg(true);
            }
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "orgDeptMember/admin/{memRelationId}", method = RequestMethod.GET)
    @ApiOperation(value = "获取部门成员信息", notes = "部门成员信息")
    public Envelop getOrgMemberRelation(
            @ApiParam(name = "memRelationId", value = "", defaultValue = "")
            @PathVariable(value = "memRelationId") Long memRelationId) {
        try {
            MOrgMemberRelation mOrgMemberRelation = orgDeptMemberClient.getOrgMemberRelation(memRelationId);
            if (mOrgMemberRelation == null) {
                return failed("提醒消息信息获取失败!");
            }
            OrgDeptMemberModel detailModel = convertToModel(mOrgMemberRelation, OrgDeptMemberModel.class);
            if (StringUtils.isNotEmpty(detailModel.getUserId())) {
                MUser mUser = userClient.getUser(detailModel.getUserId());
                detailModel.setUserName(mUser == null ? detailModel.getUserName() : mUser.getRealName());
            }
            if (StringUtils.isNotEmpty(detailModel.getParentUserId())) {
                MUser mUser = userClient.getUser(detailModel.getParentUserId());
                detailModel.setParentUserName(mUser == null ? detailModel.getParentUserName() : mUser.getRealName());
            }
            if (detailModel.getDeptId() != null && detailModel.getDeptId() != 0) {
                MOrgDept mOrgDept = orgDeptClient.searchDeptDetail(detailModel.getDeptId());
                detailModel.setDeptName(mOrgDept == null ? detailModel.getDeptName() : mOrgDept.getName());
            }
            return success(detailModel);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    /**
     * 创建部门成员
     *
     * @param memberRelationJsonData
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/orgDeptMember", method = RequestMethod.POST)
    @ApiOperation(value = "新增部门成员")
    public Envelop createDeptMember(
            @ApiParam(name = "memberRelationJsonData", value = " 部门成员信息Json", defaultValue = "")
            @RequestParam(value = "memberRelationJsonData", required = false) String memberRelationJsonData) {
        try {
            String errorMsg = "";
            OrgDeptMemberModel deptMemberModel = objectMapper.readValue(memberRelationJsonData, OrgDeptMemberModel.class);
            MOrgMemberRelation mDeptMember = convertToModel(deptMemberModel, MOrgMemberRelation.class);
            if (StringUtils.isEmpty(mDeptMember.getOrgId())) {
                errorMsg += "机构不能为空!";
            }
            if (StringUtils.isEmpty(mDeptMember.getUserId())) {
                errorMsg += "用户不能为空!";
            }
            if (mDeptMember.getDeptId() == null) {
                errorMsg += "部门不能为空!";
            }
            if (StringUtils.isNotEmpty(errorMsg)) {
                return failed(errorMsg);
            }
         /*   MUser mUser = userClient.getUser(mDeptMember.getUserId());
            mDeptMember.setUserName(mUser == null ? "" : mUser.getRealName());
            MUser mUserp = userClient.getUser(mDeptMember.getParentUserId());
            mDeptMember.setParentUserName(mUserp == null ? "" : mUserp.getRealName());*/
            MOrgDept mOrgDept = orgDeptClient.searchDeptDetail(mDeptMember.getDeptId());
            mDeptMember.setDeptName(mOrgDept == null ? "" : mOrgDept.getName());
            String deptMemberJsonStr = objectMapper.writeValueAsString(mDeptMember);
            MOrgMemberRelation deptMember = orgDeptMemberClient.saveOrgDeptMember(deptMemberJsonStr);
            if (deptMember == null) {
                return failed("保存失败!");
            }
            return success(deptMember);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    /**
     * 修改上级成员
     *
     * @param memberRelationJsonData
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/updateOrgDeptMemberParent", method = RequestMethod.POST)
    @ApiOperation(value = "修改部门成员上级成员")
    public Envelop updateDeptMember(
            @ApiParam(name = "memberRelationJsonData", value = " 部门成员信息Json", defaultValue = "")
            @RequestParam(value = "memberRelationJsonData", required = false) String memberRelationJsonData) {
        try {
            boolean succ = orgDeptMemberClient.updateOrgDeptMemberParent(memberRelationJsonData);
            if (!succ) {
                return failed("保存失败!");
            }
            return success(null);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = "/orgDeptMember/delete", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除机构部门成员")
    public Envelop deleteDeptMember(
            @ApiParam(name = "memberRelationId", value = "部门成员关系ID")
            @RequestParam(value = "memberRelationId", required = true) Integer memberRelationId
    ) {
        try {
            boolean succ = orgDeptMemberClient.deleteOrgDeptMember(memberRelationId);
            if (!succ) {
                return failed("删除失败!");
            }
            return success(null);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    /**
     * 更新成员状态
     *
     * @param memberRelationId
     * @return
     */
    @RequestMapping(value = "/orgDeptMember/updateStatus", method = RequestMethod.PUT)
    @ApiOperation(value = "更新成员状态")
    public boolean updateDeptMemberStatus(
            @ApiParam(name = "memberRelationId", value = "memberRelationId", defaultValue = "")
            @RequestParam(value = "memberRelationId") Integer memberRelationId,
            @ApiParam(name = "status", value = "状态", defaultValue = "")
            @RequestParam(value = "status") Integer status) {
        try {
            return orgDeptMemberClient.updateStatusOrgDeptMember(memberRelationId, status);
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
    @ApiOperation(value = "根据用户ID获取部门列表")
    @RequestMapping(value = ServiceApi.Org.getUserOrglistByUserId, method = RequestMethod.GET)
    public Envelop getUserOrglistByUserId(
            @ApiParam(name = "userId", value = "用户ID", defaultValue = "")
            @RequestParam(value = "userId") String userId) {
        try {
            Envelop envelop = new Envelop();
            envelop.setDetailModelList(orgDeptClient.getUserOrglistByUserId(userId));
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @RequestMapping(value = ServiceApi.Org.GetOrgDeptsDate, method = RequestMethod.GET)
    @ApiOperation(value = "根据机构id获取机构及部门列表")
    public Envelop getOrgDeptsDate(
            @ApiParam(name = "orgId", value = "机构ID")
            @RequestParam(value = "orgId") String orgId) {
        try {
            Envelop envelop = new Envelop();
            MOrgDeptData orgDeptsDate = orgDeptClient.getOrgDeptsDate(orgId);
            List<MOrgDeptData> orgDeptDataList = new ArrayList<>();
            orgDeptDataList.add(orgDeptsDate);
            envelop.setDetailModelList(orgDeptDataList);
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedSystem();
        }
    }
    @ApiOperation(value = "根据用户ID获取机构及部门列表")
    @RequestMapping(value = ServiceApi.Users.GetOrgAndDeptRelation, method = RequestMethod.GET)
    public Envelop getOrgAndDeptRelation(
            @ApiParam(name = "userId", value = "用户ID", defaultValue = "")
            @RequestParam(value = "userId") String userId) {
        Envelop envelop = new Envelop();
        try {
            List<MOrgDeptData> orgDeptJsonList = orgDeptMemberClient.getOrgAndDeptRelation(userId);
            envelop.setDetailModelList(orgDeptJsonList);
            envelop.setSuccessFlg(true);
            return envelop;
        } catch (Exception ex) {
            ex.printStackTrace();
            envelop.setErrorMsg(ex.getMessage());
            envelop.setSuccessFlg(false);
            return envelop;
        }
    }
}

+ 89 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgDeptImportController.java

@ -0,0 +1,89 @@
package com.yihu.jw.organization.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.organization.service.OrgDeptImportClient;
import com.yihu.jw.util.rest.Envelop;
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.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by Administrator on 2017/7/14.
 */
@EnableFeignClients
@RequestMapping(ApiVersion.Version1_0 + "/admin")
@RestController
@Api(value = "orgDept", description = "机构&部门批量导入接口", tags = {"基础信息 - 机构&部门批量导入接口"})
public class OrgDeptImportController extends BaseController {
    @Autowired
    private OrgDeptImportClient orgDeptImportClient;
    @RequestMapping(value = "/orgDept/batch", method = RequestMethod.POST)
    @ApiOperation("批量导入机构&部门")
    public Envelop createOrgDeptsBatch(
            @ApiParam(name = "orgDepts", value = "JSON", defaultValue = "")
            @RequestParam(value = "orgDepts") String orgDepts) throws Exception {
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        try{
            orgDeptImportClient.createOrgDeptsBatch(orgDepts);
        }catch (Exception e){
            e.printStackTrace();
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("系统出错!");
        }
        return envelop;
    }
    @RequestMapping(value = "/code/existence",method = RequestMethod.POST)
    @ApiOperation("获取已存在部门编号")
    public List codeExistence(
            @ApiParam(name = "code", value = "", defaultValue = "")
            @RequestParam("code") String code) throws Exception {
        List existCode = orgDeptImportClient.codeExistence(code);
        return existCode;
    }
    @RequestMapping(value = "/name/existence",method = RequestMethod.POST)
    @ApiOperation("获取已存在部门名称")
    public List nameExistence(
            @ApiParam(name = "name", value = "", defaultValue = "")
            @RequestParam("name") String name) throws Exception {
        List existName = orgDeptImportClient.nameExistence(name);
        return existName;
    }
    @RequestMapping(value = "/orgCode/existence",method = RequestMethod.POST)
    @ApiOperation("获取已存在的机构代码")
    public List orgCodeExistence(
            @ApiParam(name = "orgCode", value = "", defaultValue = "")
            @RequestParam("orgCode") String orgCode) throws Exception {
        List existOrgCode = orgDeptImportClient.orgCodeExistence(orgCode);
        return existOrgCode;
    }
    @RequestMapping(value = "/orgDept/code/existence", method = RequestMethod.GET)
    @ApiOperation("根据过滤条件判断是否存在")
    public Envelop isExistence(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters") String filters) {
        try {
            return success(orgDeptImportClient.isExistence(filters));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询出错!");
        }
    }
}

+ 94 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgHealthCategoryController.java

@ -0,0 +1,94 @@
package com.yihu.jw.organization.controller;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.organization.service.OrgHealthCategoryClient;
import com.yihu.jw.util.rest.Envelop;
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.web.bind.annotation.*;
/**
 * 卫生机构类别 Controller
 *
 * @author 张进军
 * @date 2017/12/21 12:00
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0 + "/admin")
@Api(description = "卫生机构类别接口", tags = {"机构管理--卫生机构类别接口"})
public class OrgHealthCategoryController extends BaseController {
    @Autowired
    private OrgHealthCategoryClient orgHealthCategoryClient;
    @ApiOperation("根据ID获取卫生机构类别")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.GetById, method = RequestMethod.GET)
    public Envelop getById(
            @ApiParam(name = "id", value = "主键", required = true)
            @PathVariable(value = "id") Integer id) {
        return orgHealthCategoryClient.getById(id);
    }
    @ApiOperation("获取所有的卫生机构类别")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.FindAll, method = RequestMethod.GET)
    public Envelop findAll() {
        return orgHealthCategoryClient.findAll();
    }
    @ApiOperation(value = "根据条件获取卫生机构类别")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.Search, method = RequestMethod.GET)
    public Envelop search(
            @ApiParam(name = "codeName", value = "卫生机构类别编码或名称")
            @RequestParam(value = "codeName", required = false) String codeName) {
        return orgHealthCategoryClient.search(codeName);
    }
    @ApiOperation("新增卫生机构类别")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.Save, method = RequestMethod.POST)
    public Envelop add(
            @ApiParam(name = "entityJson", value = "卫生机构类别JSON", required = true)
            @RequestParam(value = "entityJson") String entityJson) {
        return orgHealthCategoryClient.add(entityJson);
    }
    @ApiOperation("更新卫生机构类别")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.Save, method = RequestMethod.PUT)
    public Envelop update(
            @ApiParam(name = "entityJson", value = "卫生机构类别JSON", required = true)
            @RequestParam(value = "entityJson") String entityJson) {
        return orgHealthCategoryClient.update(entityJson);
    }
    @ApiOperation("删除卫生机构类别")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.Delete, method = RequestMethod.DELETE)
    public Envelop delete(
            @ApiParam(name = "id", value = "卫生机构类别ID", required = true)
            @RequestParam(value = "id") Integer id) {
        return orgHealthCategoryClient.delete(id);
    }
    @ApiOperation("验证卫生机构类别编码是否唯一")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.IsUniqueCode, method = RequestMethod.GET)
    public Envelop isUniqueChannel(
            @ApiParam(name = "id", value = "卫生机构类别ID", required = true)
            @RequestParam(value = "id") Integer id,
            @ApiParam(name = "code", value = "卫生机构类别编码", required = true)
            @RequestParam(value = "code") String code) {
        return orgHealthCategoryClient.isUniqueCode(id, code);
    }
    @ApiOperation("验证卫生机构类别名称是否唯一")
    @RequestMapping(value = ServiceApi.Org.HealthCategory.IsUniqueName, method = RequestMethod.GET)
    public Envelop isUniqueChannelName(
            @ApiParam(name = "id", value = "卫生机构类别ID", required = true)
            @RequestParam(value = "id") Integer id,
            @ApiParam(name = "name", value = "卫生机构类别名称", required = true)
            @RequestParam(value = "name") String name) {
        return orgHealthCategoryClient.isUniqueName(id, name);
    }
}

+ 231 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrgSaasController.java

@ -0,0 +1,231 @@
package com.yihu.jw.saas.controller;
import com.yihu.jw.agModel.orgSaas.AreaSaasModel;
import com.yihu.jw.agModel.orgSaas.OrgSaasModel;
import com.yihu.jw.constants.ApiVersion;
import com.yihu.jw.constants.ServiceApi;
import com.yihu.jw.controller.BaseController;
import com.yihu.jw.geography.service.AddressClient;
import com.yihu.jw.model.common.ListResult;
import com.yihu.jw.model.geography.MGeographyDict;
import com.yihu.jw.organization.service.OrgSaasClient;
import com.yihu.jw.organization.service.OrganizationClient;
import com.yihu.jw.redis.client.RedisUpdateClient;
import com.yihu.jw.util.rest.Envelop;
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.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.*;
import java.net.URLDecoder;
import java.util.*;
/**
 * Created by zdm on 2017/5/26.
 */
@EnableFeignClients
@RequestMapping(ApiVersion.Version1_0+"/admin")
@RestController
@Api(value = "OrgSaas", description = "机构Saas授权", tags = {"基础信息"})
public class OrgSaasController extends BaseController{
    @Autowired
    private OrgSaasClient orgSaasClient;
    @Autowired
    private OrganizationClient orgClient;
    @Autowired
    private AddressClient addressClient;
    @Autowired
    private RedisUpdateClient redisUpdateClient;
    @RequestMapping(value = "/OrgSaasByOrg", method = RequestMethod.GET)
    @ApiOperation(value = "根据机构获取机构相关授权")
    public Envelop getOrgSaasByorgCode(
            @ApiParam(name = "orgCode", value = "机构", defaultValue = "")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "type", value = "类别", defaultValue = "")
            @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "saasName", value = "名称", defaultValue = "")
            @RequestParam(value = "saasName", required = false) String saasName)throws Exception {
        Envelop envelop = new Envelop();
        //根据机构id在asaas表中获取数据
        ListResult listResult =orgSaasClient.getOrgSaasByorgCode(orgCode,type);
        List<Map<String,Object>> saasList = listResult.getDetailModelList();
        Map<String,Object> orgSaasMap=new TreeMap();
        if(null!=saasList&&saasList.size()>0){
            for(int i=0;i<saasList.size();i++){
                Object obj=(Object)saasList.get(i);
                if(null!=((ArrayList) obj).get(3)){
                    orgSaasMap.put(((ArrayList) obj).get(3).toString(),obj);
                }
            }
        }
            //授权类型 1区域 2机构
        OrgSaasModel osm=null;
        List<OrgSaasModel> OrgSaasModelList=new ArrayList<>();
        List<OrgSaasModel> OrgSaasModelRightList=new ArrayList<>();
        if(!"".equals(type)&&type.equals("2")){
            List<Map<String,Object>> orgList =new ArrayList<>();
            //在机构表中获取所有机构数据
            if(null!=saasName&&!"".equals(saasName)){
                orgList =orgClient.getAllSaasOrgs(saasName);
            }else{
                orgList =orgClient.getAllOrgs();
            }
            if(null!=orgList&&orgList.size()>0){
                for(int i=0;i<orgList.size();i++){
                    Map<String,Object> obj=orgList.get(i);
                    osm=new OrgSaasModel();
                    if(null!=obj.get("id")){
                        osm.setId(obj.get("id").toString());
                    }
                    osm.setOrgCode(orgCode);
                    osm.setType(type);
                    if(null!=obj.get("levelId")){
                        osm.setLevel(obj.get("levelId").toString());
                    }
                    if(null!=obj.get("orgCode")){
                        osm.setSaasCode(obj.get("orgCode").toString());
                    }
                    if(null!=obj.get("fullName")){
                        osm.setSaasName(obj.get("fullName").toString());
                    }
                    if(null!=obj.get("parentHosId")){
                        osm.setParent_hos_id(obj.get("parentHosId").toString());
                    }
                    if(null!=obj.get("orgCode")&&null!=orgSaasMap.get(obj.get("orgCode").toString())){
                        osm.setIschecked(true);
                        OrgSaasModelRightList.add(osm);
                    }else{
                        osm.setIschecked(false);
                    }
                    OrgSaasModelList.add(osm);
                }
            }
            if(OrgSaasModelList.size()>0){
                envelop.setDetailModelList(OrgSaasModelList);
                envelop.setObj(OrgSaasModelRightList);
                envelop.setSuccessFlg(true);
            }else {
            }
        }else{
            //查找所有区域
            List<MGeographyDict> mGeographyDictList =new ArrayList<MGeographyDict>();
            List<AreaSaasModel> AreaSaasModelList=new ArrayList<>();
            List<AreaSaasModel> AreaSaasModelRightList=new ArrayList<>();
            AreaSaasModel asm=null;
            List<MGeographyDict> newMGeographyDictList =new ArrayList<>();
            if(null!=saasName&&!"".equals(saasName)){
                newMGeographyDictList=addressClient.getOrgSaasAreaByname(saasName);
                mGeographyDictList.addAll(newMGeographyDictList);
            }else{
                for(int i=1;i<4;i++ ){
                    newMGeographyDictList = addressClient.getAddressByLevel(i);
                    mGeographyDictList.addAll(newMGeographyDictList);
                }
            }
            if(null!=mGeographyDictList&&mGeographyDictList.size()>0){
                for(int i=0;i<mGeographyDictList.size();i++){
                    MGeographyDict obj=mGeographyDictList.get(i);
                    asm=new AreaSaasModel();
                    asm.setId(String.valueOf(obj.getId()));
                    asm.setOrgCode(orgCode);
                    asm.setType(type);
                    asm.setSaasCode(String.valueOf(obj.getId()));
                    asm.setSaasName(obj.getName());
                    asm.setParent_hos_id(String.valueOf(obj.getPid()));
                    asm.setLevel(obj.getLevel());
                    if(null!=orgSaasMap.get(String.valueOf(obj.getId()))){
                        asm.setIschecked(true);
                        AreaSaasModelRightList.add(asm);
                    }else{
                        asm.setIschecked(false);
                    }
                    AreaSaasModelList.add(asm);
                }
            }
            if(AreaSaasModelList.size()>0){
                envelop.setDetailModelList(AreaSaasModelList);
                envelop.setObj(AreaSaasModelRightList);
                envelop.setSuccessFlg(true);
            }else {
            }
        }
        return envelop;
    }
    /**
     * 机构授权检查并保存
     * @return
     */
    @RequestMapping(value = "/orgSaasSave", method = RequestMethod.POST)
    @ApiOperation(value = "机构授权检查,如果被授权的机构或者区域在指定机构总不存在,这新增这条记录,否则返回地址id")
    public Envelop saveOrgSaas(
            @ApiParam(name = "orgCode", value = "机构", defaultValue = "")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "type", value = "类别", defaultValue = "")
            @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "jsonData", value = "json数据", defaultValue = "")
            @RequestBody String jsonData) throws Exception{
        Envelop envelop = new Envelop();
        OrgSaasModel orgSaasModel = new OrgSaasModel();
        jsonData=URLDecoder.decode(jsonData);
        String[] newJsonData=jsonData.split("&");
        boolean succe = orgSaasClient.saveOrgSaas(orgCode,type,newJsonData[0]);
        if(succe){
            envelop.setSuccessFlg(true);
            //更新相关缓存数据(原则上如果更新失败不能影响实际更新结果)
            try {
                if (type.equals("1")) {
                    redisUpdateClient.updateOrgSaasArea(orgCode);
                } else {
                    redisUpdateClient.updateOrgSaasOrg(orgCode);
                }
            }catch (Exception e) {
                e.printStackTrace();
            }
            //orgSaasModel.setId(id);
        }else{
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("机构授权新增失败");
        }
        return envelop;
    }
    /**
     * 机构授权检查并保存
     * @return
     */
    @RequestMapping(value=ServiceApi.Org.getUserOrgSaasByUserOrgCode,method=RequestMethod.GET)
    @ApiOperation(value="根据用户的机构id,获取Saas化的机构或者区域id")
    public Envelop getUserOrgSaasByUserOrgCode(
            @ApiParam(name = "orgCodeStr", value = "用户所在机构")
            @RequestParam(value = "orgCodeStr", required = false) String orgCodeStr){
        Envelop envelop = new Envelop();
        List<String> orgCodeList = Arrays.asList(orgCodeStr.split(","));;
        //授权类型 1区域 2机构
        List<String> areaResult =orgSaasClient.getUserOrgSaasByUserOrgCode(orgCodeList,"1");
        List<String> orgResult =orgSaasClient.getUserOrgSaasByUserOrgCode(orgCodeList,"2");
        envelop.setSuccessFlg(true);
        envelop.setObj(areaResult);
        envelop.setDetailModelList(orgResult);
        return envelop;
    }
}

+ 0 - 0
gateway/ag-admin/src/main/java/com/yihu/jw/organization/controller/OrganizationController.java


部分文件因文件數量過多而無法顯示