Преглед изворни кода

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

wangzhinan пре 2 година
родитељ
комит
1b69fb932e
58 измењених фајлова са 3427 додато и 2414 уклоњено
  1. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/dict/SystemDictEntry.java
  2. 3 13
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDataSave.java
  3. 3 13
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDataSource.java
  4. 12 11
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDimensionMain.java
  5. 2 12
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDimensionSlave.java
  6. 14 24
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuota.java
  7. 3 13
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDataSave.java
  8. 4 13
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDataSource.java
  9. 13 12
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDimensionMain.java
  10. 3 13
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDimensionSlave.java
  11. 3 13
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaGovProvision.java
  12. 12 12
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaLog.java
  13. 3 13
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaWarn.java
  14. 41 0
      common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsResourceMetadata.java
  15. 6 0
      common/commons-ehr-constants/src/main/java/com/yihu/ehr/constants/ServiceApi.java
  16. 546 558
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/app/AppController.java
  17. 1 6
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDataSaveController.java
  18. 1 6
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDataSourceController.java
  19. 59 68
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDimensionMainController.java
  20. 15 16
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDimensionSlaveController.java
  21. 81 110
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaController.java
  22. 4 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaDimensionMainController.java
  23. 4 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaDimensionSlaveController.java
  24. 8 12
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/report/ReportController.java
  25. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/DictController.java
  26. 0 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/MetaController.java
  27. 1 6
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportCategoryController.java
  28. 726 888
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportController.java
  29. 0 3
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceBrowseController.java
  30. 40 23
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceConfigurationController.java
  31. 2 6
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceDefaultParamController.java
  32. 2 6
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceIntegratedController.java
  33. 6 15
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceManageController.java
  34. 2 5
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceMonitorTypeReportController.java
  35. 2 4
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceViewController.java
  36. 0 7
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/RsResourceCategoryController.java
  37. 148 171
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptController.java
  38. 111 107
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDataSetController.java
  39. 89 85
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDictController.java
  40. 767 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/service/ReportService.java
  41. 0 3
      svr/svr-basic/src/main/java/com/yihu/jw/basic/portal/controller/PortalSurveyQuestionAdminController.java
  42. 11 133
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/QuotaReportController.java
  43. 1 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/service/TjQuotaService.java
  44. 36 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterDataSetKeySchema.java
  45. 25 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterDictEntryKeySchema.java
  46. 25 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterDictKeySchema.java
  47. 1 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportEndPoint.java
  48. 81 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/AdapterRedisEndPoint.java
  49. 0 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/StdCdaTypeController.java
  50. 147 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/service/redis/AdapterRedisService.java
  51. 150 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/task/AdapterRedisTask.java
  52. 0 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/DatasourceController.java
  53. 0 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/DictController.java
  54. 0 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/FlowController.java
  55. 0 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/OrgController.java
  56. 0 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/ParamController.java
  57. 91 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/util/FileUploadUtil.java
  58. 109 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/util/model/FileResourceModel.java

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/dict/SystemDictEntry.java

@ -31,6 +31,8 @@ public class SystemDictEntry  implements Serializable {
    String phoneticCode;
    String phoneticCode;
    String catalog;
    String catalog;
    Boolean checked; //是否已选中
    public SystemDictEntry(){
    public SystemDictEntry(){
    }
    }
@ -85,4 +87,13 @@ public class SystemDictEntry  implements Serializable {
    public void setCatalog(String catalog) {
    public void setCatalog(String catalog) {
        this.catalog = catalog;
        this.catalog = catalog;
    }
    }
    @Transient
    public Boolean isChecked() {
        return checked;
    }
    public void setChecked(Boolean checked) {
        this.checked = checked;
    }
}
}

+ 3 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDataSave.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -12,8 +13,8 @@ import java.util.Date;
 */
 */
@Entity
@Entity
@Table(name = "tj_data_save", schema = "", catalog = "healtharchive")
@Table(name = "tj_data_save", schema = "", catalog = "healtharchive")
public class TjDataSave implements Serializable {
    private Long id;
public class TjDataSave extends IdEntity {
    private String code;
    private String code;
    private String type;
    private String type;
    private String name;
    private String name;
@ -30,17 +31,6 @@ public class TjDataSave implements Serializable {
    public static String type_solr="2";
    public static String type_solr="2";
    public static String type_mysql ="3";
    public static String type_mysql ="3";
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "code", nullable = true)
    @Column(name = "code", nullable = true)
    public String getCode() {
    public String getCode() {
        return code;
        return code;

+ 3 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDataSource.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -12,8 +13,8 @@ import java.util.Date;
@Entity
@Entity
@Table(name = "tj_data_source")
@Table(name = "tj_data_source")
@Access(value = AccessType.PROPERTY)
@Access(value = AccessType.PROPERTY)
public class TjDataSource implements Serializable {
    private Long id;
public class TjDataSource extends IdEntity {
    private String code;
    private String code;
    private String type;
    private String type;
    private String name;
    private String name;
@ -26,17 +27,6 @@ public class TjDataSource implements Serializable {
    private Integer status;
    private Integer status;
    private String remark;
    private String remark;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "code", nullable = true)
    @Column(name = "code", nullable = true)
    public String getCode() {
    public String getCode() {
        return code;
        return code;

+ 12 - 11
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDimensionMain.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -16,10 +17,9 @@ import java.util.Date;
@Entity
@Entity
@Table(name = "tj_dimension_main")
@Table(name = "tj_dimension_main")
@Access(value = AccessType.PROPERTY)
@Access(value = AccessType.PROPERTY)
public class TjDimensionMain implements Serializable{
public class TjDimensionMain extends IdEntity {
    private long id;
    private String code;  //业务代码
    private String code;  //业务代码
    private String name; //主维度名称
    private String name; //主维度名称
    private String type;//主维度 :1 行政区划
    private String type;//主维度 :1 行政区划
@ -32,15 +32,7 @@ public class TjDimensionMain implements Serializable{
    private String updateUser;//修改人
    private String updateUser;//修改人
    private String updateUserName;//修改人名
    private String updateUserName;//修改人名
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    private Boolean checked;
    @Column(name = "code",  nullable = true)
    @Column(name = "code",  nullable = true)
    public String getCode() {
    public String getCode() {
@ -140,4 +132,13 @@ public class TjDimensionMain implements Serializable{
    public void setUpdateUserName(String updateUserName) {
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
        this.updateUserName = updateUserName;
    }
    }
    @Transient
    public Boolean getChecked() {
        return checked;
    }
    public void setChecked(Boolean checked) {
        this.checked = checked;
    }
}
}

+ 2 - 12
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjDimensionSlave.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -16,10 +17,8 @@ import java.util.Date;
@Entity
@Entity
@Table(name = "tj_dimension_slave")
@Table(name = "tj_dimension_slave")
@Access(value = AccessType.PROPERTY)
@Access(value = AccessType.PROPERTY)
public class TjDimensionSlave implements Serializable{
public class TjDimensionSlave extends IdEntity {
    private long id;
    private String code;  //业务代码
    private String code;  //业务代码
    private String name; //从维度名称
    private String name; //从维度名称
    private String type;//类型:1 性别 2 年龄
    private String type;//类型:1 性别 2 年龄
@ -33,15 +32,6 @@ public class TjDimensionSlave implements Serializable{
    private String updateUserName;//修改人名
    private String updateUserName;//修改人名
    private Boolean checked;
    private Boolean checked;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    @Column(name = "code",  nullable = true)
    @Column(name = "code",  nullable = true)
    public String getCode() {
    public String getCode() {

+ 14 - 24
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuota.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -12,8 +13,8 @@ import java.util.List;
 */
 */
@Entity
@Entity
@Table(name = "tj_quota", schema = "", catalog = "healtharchive")
@Table(name = "tj_quota", schema = "", catalog = "healtharchive")
public class TjQuota implements Serializable {
    private Long id;
public class TjQuota extends IdEntity {
    private String code;
    private String code;
    private String name;
    private String name;
    private String cron;
    private String cron;
@ -36,22 +37,11 @@ public class TjQuota implements Serializable {
    //周期指标执行状态:0未开启,1执行中
    //周期指标执行状态:0未开启,1执行中
    private String jobStatus;
    private String jobStatus;
    private TjQuotaDataSource tjQuotaDataSource;
    private TjQuotaDataSave tjQuotaDataSave;
    private TjQuotaDataSource tjQuotaDataSourceModel;
    private TjQuotaDataSave tjQuotaDataSaveModel;
    private List<TjQuota> children;
    private List<TjQuota> children;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "code")
    @Column(name = "code")
    public String getCode() {
    public String getCode() {
        return code;
        return code;
@ -244,20 +234,20 @@ public class TjQuota implements Serializable {
    }
    }
    @Transient
    @Transient
    public TjQuotaDataSource getTjQuotaDataSource() {
        return tjQuotaDataSource;
    public TjQuotaDataSource getTjQuotaDataSourceModel() {
        return tjQuotaDataSourceModel;
    }
    }
    public void setTjQuotaDataSource(TjQuotaDataSource tjQuotaDataSource) {
        this.tjQuotaDataSource = tjQuotaDataSource;
    public void setTjQuotaDataSourceModel(TjQuotaDataSource tjQuotaDataSourceModel) {
        this.tjQuotaDataSourceModel = tjQuotaDataSourceModel;
    }
    }
    @Transient
    @Transient
    public TjQuotaDataSave getTjQuotaDataSave() {
        return tjQuotaDataSave;
    public TjQuotaDataSave getTjQuotaDataSaveModel() {
        return tjQuotaDataSaveModel;
    }
    }
    public void setTjQuotaDataSave(TjQuotaDataSave tjQuotaDataSave) {
        this.tjQuotaDataSave = tjQuotaDataSave;
    public void setTjQuotaDataSaveModel(TjQuotaDataSave tjQuotaDataSaveModel) {
        this.tjQuotaDataSaveModel = tjQuotaDataSaveModel;
    }
    }
}
}

+ 3 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDataSave.java

@ -1,5 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -8,8 +10,7 @@ import java.io.Serializable;
 */
 */
@Entity
@Entity
@Table(name = "tj_quota_data_save", schema = "", catalog = "healtharchive")
@Table(name = "tj_quota_data_save", schema = "", catalog = "healtharchive")
public class TjQuotaDataSave implements Serializable{
    private Long id;
public class TjQuotaDataSave extends IdEntity {
    private String quotaCode;
    private String quotaCode;
    private String saveCode;
    private String saveCode;
    private String configJson;
    private String configJson;
@ -17,17 +18,6 @@ public class TjQuotaDataSave implements Serializable{
    private String type;
    private String type;
    private String name;
    private String name;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "quota_code")
    @Column(name = "quota_code")
    public String getQuotaCode() {
    public String getQuotaCode() {
        return quotaCode;
        return quotaCode;

+ 4 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDataSource.java

@ -1,5 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -8,24 +10,13 @@ import java.io.Serializable;
 */
 */
@Entity
@Entity
@Table(name = "tj_quota_data_source", schema = "", catalog = "healtharchive")
@Table(name = "tj_quota_data_source", schema = "", catalog = "healtharchive")
public class TjQuotaDataSource implements Serializable{
    private Long id;
public class TjQuotaDataSource extends IdEntity {
    private String quotaCode;
    private String quotaCode;
    private String sourceCode;
    private String sourceCode;
    private String configJson;
    private String configJson;
    private String name;
    private String name;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "quota_code")
    @Column(name = "quota_code")
    public String getQuotaCode() {
    public String getQuotaCode() {
        return quotaCode;
        return quotaCode;

+ 13 - 12
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDimensionMain.java

@ -1,6 +1,8 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -14,24 +16,14 @@ import java.io.Serializable;
@Entity
@Entity
@Table(name = "tj_quota_dimension_main")
@Table(name = "tj_quota_dimension_main")
@Access(value = AccessType.PROPERTY)
@Access(value = AccessType.PROPERTY)
public class TjQuotaDimensionMain implements Serializable{
public class TjQuotaDimensionMain extends IdEntity {
    private Long id;
    private String quotaCode;  //关联 tj_quota code
    private String quotaCode;  //关联 tj_quota code
    private String mainCode; //关联 jt_dimension_main
    private String mainCode; //关联 jt_dimension_main
    private String dictSql;//
    private String dictSql;//
    private String keyVal;//
    private String keyVal;//
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    private String name;
    @Column(name = "quota_code",  nullable = true)
    @Column(name = "quota_code",  nullable = true)
    public String getQuotaCode() {
    public String getQuotaCode() {
@ -68,4 +60,13 @@ public class TjQuotaDimensionMain implements Serializable{
    public void setKeyVal(String keyVal) {
    public void setKeyVal(String keyVal) {
        this.keyVal = keyVal;
        this.keyVal = keyVal;
    }
    }
    @Transient
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
}

+ 3 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaDimensionSlave.java

@ -1,5 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -13,10 +15,8 @@ import java.io.Serializable;
@Entity
@Entity
@Table(name = "tj_quota_dimension_slave")
@Table(name = "tj_quota_dimension_slave")
@Access(value = AccessType.PROPERTY)
@Access(value = AccessType.PROPERTY)
public class TjQuotaDimensionSlave implements Serializable{
public class TjQuotaDimensionSlave extends IdEntity {
    private Long id;
    private String quotaCode;  //关联 tj_quota code
    private String quotaCode;  //关联 tj_quota code
    private String slaveCode; //关联 jt_dimension_slave
    private String slaveCode; //关联 jt_dimension_slave
    private String dictSql;//
    private String dictSql;//
@ -26,16 +26,6 @@ public class TjQuotaDimensionSlave implements Serializable{
    private String name;
    private String name;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "quota_code",  nullable = true)
    @Column(name = "quota_code",  nullable = true)
    public String getQuotaCode() {
    public String getQuotaCode() {
        return quotaCode;
        return quotaCode;

+ 3 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaGovProvision.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -11,8 +12,8 @@ import java.util.Date;
 */
 */
@Entity
@Entity
@Table(name = "tj_quota_gov_provision")
@Table(name = "tj_quota_gov_provision")
public class TjQuotaGovProvision implements Serializable {
    private long id;
public class TjQuotaGovProvision extends IdEntity {
    private long population;
    private long population;
    private String gender;
    private String gender;
    private String year;
    private String year;
@ -23,17 +24,6 @@ public class TjQuotaGovProvision implements Serializable {
    private Date modifyDate;
    private Date modifyDate;
    private String modifier;
    private String modifier;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    @Column(name = "population")
    @Column(name = "population")
    public long getPopulation() {
    public long getPopulation() {
        return population;
        return population;

+ 12 - 12
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaLog.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -16,10 +17,8 @@ import java.util.Date;
@Entity
@Entity
@Table(name = "tj_quota_log")
@Table(name = "tj_quota_log")
@Access(value = AccessType.PROPERTY)
@Access(value = AccessType.PROPERTY)
public class TjQuotaLog implements Serializable{
public class TjQuotaLog extends IdEntity {
    private long id;
    private String quotaCode;  //
    private String quotaCode;  //
    private String saasId; //
    private String saasId; //
    private Integer status;//1成功 0失败
    private Integer status;//1成功 0失败
@ -27,15 +26,7 @@ public class TjQuotaLog implements Serializable{
    private Date startTime;//任务开始执行时间
    private Date startTime;//任务开始执行时间
    private Date endTime;//任务结束执行时间
    private Date endTime;//任务结束执行时间
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    private String statusName;
    @Column(name = "quota_code",  nullable = true)
    @Column(name = "quota_code",  nullable = true)
    public String getQuotaCode() {
    public String getQuotaCode() {
@ -92,4 +83,13 @@ public class TjQuotaLog implements Serializable{
    public void setEndTime(Date endTime) {
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
        this.endTime = endTime;
    }
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
}
}

+ 3 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/quota/TjQuotaWarn.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.ehr.quota;
package com.yihu.jw.entity.ehr.quota;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -12,25 +13,14 @@ import java.util.Date;
 */
 */
@Entity
@Entity
@Table(name = "tj_quota_warn", schema = "", catalog = "healtharchive")
@Table(name = "tj_quota_warn", schema = "", catalog = "healtharchive")
public class TjQuotaWarn implements Serializable {
    private Long id;
public class TjQuotaWarn extends IdEntity {
    private String quotaCode;
    private String quotaCode;
    private String value;
    private String value;
    private String userId;
    private String userId;
    private Date createTime;
    private Date createTime;
    private Date updateTime;
    private Date updateTime;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "quota_code", nullable = true)
    @Column(name = "quota_code", nullable = true)
    public String getQuotaCode() {
    public String getQuotaCode() {
        return quotaCode;
        return quotaCode;

+ 41 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/ehr/resource/RsResourceMetadata.java

@ -18,6 +18,11 @@ public class RsResourceMetadata implements Serializable {
    private String groupData;
    private String groupData;
    private String description;
    private String description;
    private String dictId;
    private String stdCode;
    private String name;
    private String columnType;
    @Id
    @Id
    @GeneratedValue(generator = "Generator")
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "assigned")
    @GenericGenerator(name = "Generator", strategy = "assigned")
@ -79,4 +84,40 @@ public class RsResourceMetadata implements Serializable {
    {
    {
        this.groupData = groupData;
        this.groupData = groupData;
    }
    }
    @Transient
    public String getDictId() {
        return dictId;
    }
    public void setDictId(String dictId) {
        this.dictId = dictId;
    }
    @Transient
    public String getStdCode() {
        return stdCode;
    }
    public void setStdCode(String stdCode) {
        this.stdCode = stdCode;
    }
    @Transient
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Transient
    public String getColumnType() {
        return columnType;
    }
    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }
}
}

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

@ -1039,6 +1039,12 @@ public class ServiceApi {
        public static final String InitVersions = "/redis/init/versions";
        public static final String InitVersions = "/redis/init/versions";
        public static final String StdMetadataName = "/redis/stdMetadataName";
        public static final String StdMetadataName = "/redis/stdMetadataName";
        public static final String InitAdapterVersions = "/redis/init/adapterVersions";
        public static final String AdapterDataSetCode = "/redis/adapterDataSetCode";
        public static final String AdapterMetadataCode = "/redis/adapterMetadataCode";
        public static final String AdapterDictCode = "/redis/adapterDictCode";
        public static final String AdapterDictEntryCode = "/redis/adapterDictEntryCode";
        //更新缓存
        //更新缓存
        public static final String UpdateOrgName = "/redis/update/orgName";
        public static final String UpdateOrgName = "/redis/update/orgName";
        public static final String UpdateOrgArea = "/redis/update/orgArea";
        public static final String UpdateOrgArea = "/redis/update/orgArea";

+ 546 - 558
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/app/AppController.java

@ -1,595 +1,583 @@
//package com.yihu.jw.basic.agadmin.controller.app;
//
//
//import com.yihu.ehr.constants.ServiceApi;
//import com.yihu.ehr.constants.SessionAttributeKeys;
//
//import com.yihu.jw.basic.user.service.GetInfoService;
//import com.yihu.jw.entity.ehr.apps.App;
//import com.yihu.jw.restmodel.ehr.resource.MRsAppResource;
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.common.LogService;
//import com.yihu.jw.util.http.HttpClientUtil;
//import org.apache.commons.lang.ArrayUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.MultiValueMap;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.*;
//
///**
// * Created by yww on 2015/8/12.
// */
//@RequestMapping("/app")
//@RestController
//public class AppController extends EnvelopRestEndpoint {
//
//    @Autowired
//    private GetInfoService getInfoService;
//
////    @RequestMapping("template/appInfo")
////    public String appInfoTemplate(Model model, String appId, String mode) {
////
////        String result = "";
////        Object app = null;
////        try {
////            //mode定义:new modify view三种模式,新增,修改,查看
////            if (mode.equals("new")) {
////                app = new AppDetailModel();
////                ((AppDetailModel) app).setStatus("WaitingForApprove");
////            } else {
////                String url = "/apps/" + appId;
////                RestTemplates template = new RestTemplates();
////                result = template.doGet(comUrl + url);
////                Envelop envelop = getEnvelop(result);
////                if (envelop.isSuccessFlg()) {
////                    app = envelop.getObj();
////                }
////            }
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////        }
////
////        model.addAttribute("model", toJson(app));
////        model.addAttribute("mode", mode);
////        model.addAttribute("contentPage", "/app/appInfoDialog");
////        return "emptyView";
////    }
package com.yihu.jw.basic.agadmin.controller.app;
import com.yihu.jw.basic.apps.service.AppService;
import com.yihu.jw.basic.user.service.GetInfoService;
import com.yihu.jw.entity.ehr.apps.App;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
 * Created by yww on 2015/8/12.
 */
@RequestMapping("/app")
@RestController
@Api( tags = {"网关-应用"})
public class AppController extends EnvelopRestEndpoint {
    @Autowired
    private GetInfoService getInfoService;
    @Autowired
    private AppService appService;
//    @RequestMapping("template/appInfo")
//    public String appInfoTemplate(Model model, String appId, String mode) {
//
//
//    /**
//     * 应用列表及特定查询
//     */
//    @GetMapping("/searchApps")
//    public Envelop getAppList(String sourceType, String searchNm, String org, String catalog, String status, int page, int rows, HttpServletRequest request) {
//        StringBuilder filters = new StringBuilder();
//        if (!StringUtils.isEmpty(sourceType)) {
//            filters.append("sourceType=" + sourceType+";");
//        String result = "";
//        Object app = null;
//        try {
//            //mode定义:new modify view三种模式,新增,修改,查看
//            if (mode.equals("new")) {
//                app = new AppDetailModel();
//                ((AppDetailModel) app).setStatus("WaitingForApprove");
//            } else {
//                String url = "/apps/" + appId;
//                RestTemplates template = new RestTemplates();
//                result = template.doGet(comUrl + url);
//                Envelop envelop = getEnvelop(result);
//                if (envelop.isSuccessFlg()) {
//                    app = envelop.getObj();
//                }
//            }
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//        }
//        }
//
//
//        if (!StringUtils.isEmpty(searchNm)) {
//            filters.append("id?" + searchNm+" g1;");
//            filters.append("name?" + searchNm+" g1;");
//        model.addAttribute("model", toJson(app));
//        model.addAttribute("mode", mode);
//        model.addAttribute("contentPage", "/app/appInfoDialog");
//        return "emptyView";
//    }
    /**
     * 应用列表及特定查询
     */
    @GetMapping("/searchApps")
    public Envelop getAppList(String sourceType, String searchNm, String org, String catalog, String status, int page, int rows, HttpServletRequest request) {
        StringBuilder filters = new StringBuilder();
        if (!StringUtils.isEmpty(sourceType)) {
            filters.append("sourceType=" + sourceType+";");
        }
        if (!StringUtils.isEmpty(searchNm)) {
            filters.append("id?" + searchNm+" g1;");
            filters.append("name?" + searchNm+" g1;");
        }
        if (!StringUtils.isEmpty(org)) {
            filters.append("org?" + org+";");
        }
        if (!StringUtils.isEmpty(catalog)) {
            filters.append("catalog=" + catalog+";");
        }
        if (!StringUtils.isEmpty(status)) {
            filters.append("status=" + status+";");
        }
        String url = "/apps";
        String resultStr = "";
        try {
            List<App> appList = appService.search(null, filters.toString(), "-createTime", page, rows);
            return PageEnvelop.getSuccessListWithPage("查询成功",appList,page,rows,appService.getCount(filters.toString()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return failed("查询失败");
    }
//    @RequestMapping("/deleteApp")
//    @ResponseBody
//    public Object deleteApp(String appId) {
//        Envelop result = new Envelop();
//        String resultStr = "";
//        try {
//            String url = "/apps/" + appId;
//            RestTemplates template = new RestTemplates();
//            resultStr = template.doDelete(comUrl + url);
//            result.setSuccessFlg(getEnvelop(resultStr).isSuccessFlg());
//        } catch (Exception ex) {
//            result.setSuccessFlg(false);
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//        }
//        }
//        if (!StringUtils.isEmpty(org)) {
//            filters.append("org?" + org+";");
//        return result;
//    }
//
//    @RequestMapping("createApp")
//    @ResponseBody
//    public Object createApp(AppDetailModel appDetailModel, HttpServletRequest request) {
//
//        Envelop result = new Envelop();
//        String resultStr = "";
//        String url = "/apps";
//        MultiValueMap<String, String> conditionMap = new LinkedMultiValueMap<String, String>();
//        try {
//            if(null!=appDetailModel&&appDetailModel.getCode().length()>30){
//                return failed("应用代码长度不超过30");
//            }
//            //不能用 @ModelAttribute(SessionAttributeKeys.CurrentUser)获取,会与AppDetailModel中的id属性有冲突
//            UsersModel userDetailModel = getCurrentUserRedis(request);
//            appDetailModel.setCreator(userDetailModel.getId());
//            conditionMap.add("app", toJson(appDetailModel));
//            RestTemplates template = new RestTemplates();
//            resultStr = template.doPost(comUrl + url, conditionMap);
//            Envelop envelop = getEnvelop(resultStr);
//            if (envelop.isSuccessFlg()) {
//                result.setSuccessFlg(true);
//                result.setObj(envelop.getObj());
//            } else {
//                return failed("注册失败");
//            }
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//        }
//        }
//        if (!StringUtils.isEmpty(catalog)) {
//            filters.append("catalog=" + catalog+";");
//        return result;
//    }
//
//
//    @RequestMapping("updateApp")
//    @ResponseBody
//    public Object updateApp(AppDetailModel appDetailModel) {
////        if (appDetailModel.getDescription().equals("del")){
////            deleteApp(appDetailModel.getId());
////            return false;
////        }
//        Envelop result = new Envelop();
//        Envelop envelop = new Envelop();
//        String resultStr = "";
//        String url = "/apps";
//        try {
//            if(null!=appDetailModel&&appDetailModel.getCode().length()>30){
//                return failed("应用代码长度不超过30");
//            }
//            RestTemplates template = new RestTemplates();
//            //获取app
//            String id = appDetailModel.getId();
//            MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
//            map.add("app_id", id);
//            resultStr = template.doGet(comUrl + url + '/' + id, map);
//            envelop = getEnvelop(resultStr);
//            if (envelop.isSuccessFlg()) {
//                AppDetailModel appUpdate = getEnvelopModel(envelop.getObj(), AppDetailModel.class);
//                appUpdate.setName(appDetailModel.getName());
//                appUpdate.setOrg(appDetailModel.getOrg());
//                appUpdate.setCatalog(appDetailModel.getCatalog());
//                appUpdate.setTags(appDetailModel.getTags());
//                appUpdate.setUrl(appDetailModel.getUrl());
//                appUpdate.setOutUrl(appDetailModel.getOutUrl());
//                appUpdate.setDescription(appDetailModel.getDescription());
//                appUpdate.setCode(appDetailModel.getCode());
//                appUpdate.setRole(appDetailModel.getRole());
//                String icon = appDetailModel.getIcon();
//                if (!StringUtils.isEmpty(icon)) {
//                    icon = icon.substring(icon.indexOf("group1"), icon.length()).replace("group1/", "group1:");
//                    appUpdate.setIcon(icon);
//                }
//                appUpdate.setReleaseFlag(appDetailModel.getReleaseFlag());
//                appUpdate.setManageType(appDetailModel.getManageType());
//                appUpdate.setSourceType(appDetailModel.getSourceType());
//                appUpdate.setDoctorManageType(appDetailModel.getDoctorManageType());
//                //更新
//                MultiValueMap<String, String> conditionMap = new LinkedMultiValueMap<String, String>();
//                conditionMap.add("app", toJson(appUpdate));
//                resultStr = template.doPut(comUrl + url, conditionMap);
//                envelop = getEnvelop(resultStr);
//                if (envelop.isSuccessFlg()) {
//                    result.setSuccessFlg(true);
//                } else {
//                    result.setSuccessFlg(false);
//                    result.setErrorMsg("修改失败!");
//                }
//            }
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//            return failed("系统错误");
//        }
//        }
//        if (!StringUtils.isEmpty(status)) {
//            filters.append("status=" + status+";");
//
//        return result;
//    }
//
//    @RequestMapping("check")
//    @ResponseBody
//    public Object check(String appId, String status) {
//        Envelop result = new Envelop();
//        String urlPath = "/apps/status";
//        String resultStr = "";
//        MultiValueMap<String, String> conditionMap = new LinkedMultiValueMap<>();
//        conditionMap.add("app_id", appId);
//        conditionMap.add("app_status", status);
//        try {
//            RestTemplates template = new RestTemplates();
//            resultStr = template.doPut(comUrl + urlPath, conditionMap);
//            result.setSuccessFlg(Boolean.parseBoolean(resultStr));
//        } catch (Exception e) {
//            result.setSuccessFlg(false);
//        }
//        }
//        return result;
//    }
//
//    //-------------------------------------------------------应用---资源授权管理---开始----------------
//    @RequestMapping("/resource/initial")
//    public String resourceInitial(Model model, String backParams) {
//        model.addAttribute("backParams", backParams);
//        model.addAttribute("contentPage", "/app/resource");
//        return "emptyView";
//    }
//
//
//        builder.setPageNumber(page)
//                .setPageSize(rows);
//        builder.addSorter("createTime", false);
//    //获取app已授权资源ids集合
//    @RequestMapping("/resourceIds")
//    @ResponseBody
//    public Object getResourceIds(String appId) {
//        Envelop envelop = new Envelop();
//        List<String> list = new ArrayList<>();
//        envelop.setSuccessFlg(false);
//        envelop.setDetailModelList(list);
//        URLQueryBuilder builder = new URLQueryBuilder();
//        if (StringUtils.isEmpty(appId)) {
//            return envelop;
//        }
//        builder.addFilter("appId", "=", appId, null);
//        builder.setPageNumber(1)
//                .setPageSize(999);
//        String param = builder.toString();
//        String param = builder.toString();
//        String url = "/apps";
//        String url = "/resources/grants";
//        String resultStr = "";
//        String resultStr = "";
//        try {
//        try {
//            List<App> appList = appService.search(null, filters, null, page, rows);
//            pagedResponse(request, response, appService.getCount(filters), page, rows);
//            RestTemplates template = new RestTemplates();
//            resultStr = template.doGet(comUrl + url + "?" + param);
//            Envelop resultGet = objectMapper.readValue(resultStr, Envelop.class);
//            if (resultGet.isSuccessFlg() && resultGet.getDetailModelList().size() != 0) {
//                List<RsAppResourceModel> rsAppModels = (List<RsAppResourceModel>) getEnvelopList(resultGet.getDetailModelList(), new ArrayList<RsAppResourceModel>(), RsAppResourceModel.class);
//                for (RsAppResourceModel m : rsAppModels) {
//                    list.add(m.getResourceId());
//                }
//                envelop.setSuccessFlg(true);
//            }
//        } catch (Exception ex) {
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//        }
//        }
//        envelop.setSuccessFlg(true);
//        envelop.setDetailModelList(list);
//        return envelop;
//    }
//
//
//        return resultStr;
//    @RequestMapping("/app")
//    @ResponseBody
//    public Object getAppById(String appId) {
//        Envelop envelop = new Envelop();
//        try {
//            String url = "/apps/" + appId;
//            RestTemplates template = new RestTemplates();
//            String envelopStr = template.doGet(comUrl + url);
//            return envelopStr;
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//        }
//        envelop.setSuccessFlg(false);
//        return envelop;
//    }
//    }
//
//
////    @RequestMapping("/deleteApp")
////    @ResponseBody
////    public Object deleteApp(String appId) {
////        Envelop result = new Envelop();
////        String resultStr = "";
////        try {
////            String url = "/apps/" + appId;
////            RestTemplates template = new RestTemplates();
////            resultStr = template.doDelete(comUrl + url);
////            result.setSuccessFlg(getEnvelop(resultStr).isSuccessFlg());
////        } catch (Exception ex) {
////            result.setSuccessFlg(false);
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////        }
////        return result;
////    }
////
////    @RequestMapping("createApp")
////    @ResponseBody
////    public Object createApp(AppDetailModel appDetailModel, HttpServletRequest request) {
////
////        Envelop result = new Envelop();
////        String resultStr = "";
////        String url = "/apps";
////        MultiValueMap<String, String> conditionMap = new LinkedMultiValueMap<String, String>();
////        try {
////            if(null!=appDetailModel&&appDetailModel.getCode().length()>30){
////                return failed("应用代码长度不超过30");
////            }
////            //不能用 @ModelAttribute(SessionAttributeKeys.CurrentUser)获取,会与AppDetailModel中的id属性有冲突
////            UsersModel userDetailModel = getCurrentUserRedis(request);
////            appDetailModel.setCreator(userDetailModel.getId());
////            conditionMap.add("app", toJson(appDetailModel));
////            RestTemplates template = new RestTemplates();
////            resultStr = template.doPost(comUrl + url, conditionMap);
////            Envelop envelop = getEnvelop(resultStr);
////            if (envelop.isSuccessFlg()) {
////                result.setSuccessFlg(true);
////                result.setObj(envelop.getObj());
////            } else {
////                return failed("注册失败");
////            }
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////        }
////        return result;
////    }
////
////
////    @RequestMapping("updateApp")
//    //资源授权appId+resourceIds
//    @RequestMapping("/resource/grant")
//    @ResponseBody
//    public Object resourceGrant(String appId, String resourceIds) {
//        Envelop envelop = new Envelop();
//        try {
//            String url = "/resources/apps/" + appId + "/grant";
//            Map<String, Object> params = new HashMap<>();
//            params.put("appId", appId);
//            params.put("resourceIds", resourceIds);
//            String resultStr = HttpClientUtil.doPost(comUrl + url, params, username, password);
//            return resultStr;
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//        }
//        envelop.setSuccessFlg(false);
//        return envelop;
//    }
//
//    //批量、单个取消资源授权
//    @RequestMapping("/resource/cancel")
//    @ResponseBody
//    public Object resourceGrantCancel(String appId, String resourceIds) {
//        Envelop envelop = new Envelop();
//        envelop.setSuccessFlg(false);
//        if (StringUtils.isEmpty(appId)) {
//            envelop.setErrorMsg("应用id不能为空!");
//            return envelop;
//        }
//        if (StringUtils.isEmpty(resourceIds)) {
//            envelop.setErrorMsg("资源id不能为空!");
//            return envelop;
//        }
//        try {
//            //先获取授权关系表的ids
//            String url = "/resources/grants/no_paging";
//            Map<String, Object> params = new HashMap<>();
//            params.put("filters", "appId=" + appId + ";resourceId=" + resourceIds);
//            String envelopStrGet = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            Envelop envelopGet = objectMapper.readValue(envelopStrGet, Envelop.class);
//            String ids = "";
//            if (envelopGet.isSuccessFlg() && envelopGet.getDetailModelList().size() != 0) {
//                List<MRsAppResource> list = (List<MRsAppResource>) getEnvelopList(envelopGet.getDetailModelList(),
//                        new ArrayList<MRsAppResource>(), MRsAppResource.class);
//                for (MRsAppResource m : list) {
//                    ids += m.getId() + ",";
//                }
//                ids = ids.substring(0, ids.length() - 1);
//            }
//            //取消资源授权
//            if (!StringUtils.isEmpty(ids)) {
//                String urlCancel = "/resources/grants";
//                Map<String, Object> args = new HashMap<>();
//                args.put("ids", ids);
//                String result = HttpClientUtil.doDelete(comUrl + urlCancel, args, username, password);
//                return result;
//            }
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//            return failed("系统出错");
//
//        }
//        return envelop;
//    }
//
//
//    /**
//     * 资源文件上传
//     *
//     * @param
//     * @return
//     */
//    @RequestMapping("appIconFileUpload")
//    @ResponseBody
//    public Object orgLogoFileUpload(
//            @RequestParam("iconFile") MultipartFile file) throws IOException {
//        Envelop result = new Envelop();
//        InputStream inputStream = file.getInputStream();
//        String fileName = file.getOriginalFilename(); //获取文件名
//        if (!file.isEmpty()) {
//            return uploadFile(inputStream, fileName);
//        }
//        return "fail";
//    }
//
//    public String uploadFile(InputStream inputStream, String fileName) {
//        try {
//            //读取文件流,将文件输入流转成 byte
//            int temp = 0;
//            int bufferSize = 1024;
//            byte tempBuffer[] = new byte[bufferSize];
//            byte[] fileBuffer = new byte[0];
//            while ((temp = inputStream.read(tempBuffer)) != -1) {
//                fileBuffer = ArrayUtils.addAll(fileBuffer, ArrayUtils.subarray(tempBuffer, 0, temp));
//            }
//            inputStream.close();
//            String restStream = Base64.getEncoder().encodeToString(fileBuffer);
//            String url = "";
//            url = fileUpload(restStream, fileName);
//            if (!StringUtils.isEmpty(url)) {
//                System.out.println("上传成功");
//                return url;
//            } else {
//                System.out.println("上传失败");
//            }
//
//        } catch (Exception e) {
//            return "fail";
//        }
//        return "fail";
//    }
//
//    /**
//     * 图片上传
//     *
//     * @param inputStream
//     * @param fileName
//     * @return
//     */
//    public String fileUpload(String inputStream, String fileName) {
//
//        RestTemplates templates = new RestTemplates();
//        Map<String, Object> params = new HashMap<>();
//
//        String url = null;
//        if (!StringUtils.isEmpty(inputStream)) {
//
//            //mime  参数 doctor 需要改变  --  需要从其他地方配置
//            FileResourceModel fileResourceModel = new FileResourceModel("", "org", "");
//            String fileResourceModelJsonData = toJson(fileResourceModel);
//
//            params.put("file_str", inputStream);
//            params.put("file_name", fileName);
//            params.put("json_data", fileResourceModelJsonData);
//            try {
//                url = HttpClientUtil.doPost(comUrl + "/filesReturnUrl", params, username, password);
//                return url;
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//        return url;
//    }
//
//
//
//    //修改、查看授权资源
//    //-------------------------------------------------------应用---资源授权管理---结束----------------
//
//    //-------------------------------------------------------应用----资源----数据元--管理开始--------------
//    @RequestMapping("/resourceManage/initial")
//    public String resourceManageInitial(Model model, String appId, String resourceId, String dataModel) {
//        model.addAttribute("dataModel", dataModel);
//        model.addAttribute("appRsId", getAppResId(appId, resourceId));
//        model.addAttribute("contentPage", "/app/resourceManage");
//        return "pageView";
//    }
//
//    //获取应用资源关联关系id
//    public String getAppResId(String appId, String resourceId) {
//        URLQueryBuilder builder = new URLQueryBuilder();
//        if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(resourceId)) {
//            return "";
//        }
//        builder.addFilter("appId", "=", appId, null);
//        builder.addFilter("resourceId", "=", resourceId, null);
//        builder.setPageNumber(1)
//                .setPageSize(1);
//        String param = builder.toString();
//        String url = "/resources/grants";
//        String resultStr = "";
//        try {
//            RestTemplates template = new RestTemplates();
//            resultStr = template.doGet(comUrl + url + "?" + param);
//            Envelop resultGet = objectMapper.readValue(resultStr, Envelop.class);
//            if (resultGet.isSuccessFlg()) {
//                List<RsAppResourceModel> rsAppModels = (List<RsAppResourceModel>) getEnvelopList(resultGet.getDetailModelList(), new ArrayList<RsAppResourceModel>(), RsAppResourceModel.class);
//                RsAppResourceModel resourceModel = rsAppModels.get(0);
//                return resourceModel.getId();
//            }
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//        }
//        return "";
//    }
//
////    /**
////     * 跳转维度管理页面顶部资源信息
////     */
////    @RequestMapping("/resource")
////    @ResponseBody
////    @ResponseBody
////    public Object updateApp(AppDetailModel appDetailModel) {
//////        if (appDetailModel.getDescription().equals("del")){
//////            deleteApp(appDetailModel.getId());
//////            return false;
//////        }
////        Envelop result = new Envelop();
////    public Object getResourceById(String resourceId){
////        Envelop envelop = new Envelop();
////        Envelop envelop = new Envelop();
////        String resultStr = "";
////        String url = "/apps";
////        try {
////            if(null!=appDetailModel&&appDetailModel.getCode().length()>30){
////                return failed("应用代码长度不超过30");
////            }
////        try{
////            String url = "/resources/"+resourceId;
////            RestTemplates template = new RestTemplates();
////            RestTemplates template = new RestTemplates();
////            //获取app
////            String id = appDetailModel.getId();
////            MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
////            map.add("app_id", id);
////            resultStr = template.doGet(comUrl + url + '/' + id, map);
////            envelop = getEnvelop(resultStr);
////            if (envelop.isSuccessFlg()) {
////                AppDetailModel appUpdate = getEnvelopModel(envelop.getObj(), AppDetailModel.class);
////                appUpdate.setName(appDetailModel.getName());
////                appUpdate.setOrg(appDetailModel.getOrg());
////                appUpdate.setCatalog(appDetailModel.getCatalog());
////                appUpdate.setTags(appDetailModel.getTags());
////                appUpdate.setUrl(appDetailModel.getUrl());
////                appUpdate.setOutUrl(appDetailModel.getOutUrl());
////                appUpdate.setDescription(appDetailModel.getDescription());
////                appUpdate.setCode(appDetailModel.getCode());
////                appUpdate.setRole(appDetailModel.getRole());
////                String icon = appDetailModel.getIcon();
////                if (!StringUtils.isEmpty(icon)) {
////                    icon = icon.substring(icon.indexOf("group1"), icon.length()).replace("group1/", "group1:");
////                    appUpdate.setIcon(icon);
////                }
////                appUpdate.setReleaseFlag(appDetailModel.getReleaseFlag());
////                appUpdate.setManageType(appDetailModel.getManageType());
////                appUpdate.setSourceType(appDetailModel.getSourceType());
////                appUpdate.setDoctorManageType(appDetailModel.getDoctorManageType());
////                //更新
////                MultiValueMap<String, String> conditionMap = new LinkedMultiValueMap<String, String>();
////                conditionMap.add("app", toJson(appUpdate));
////                resultStr = template.doPut(comUrl + url, conditionMap);
////                envelop = getEnvelop(resultStr);
////                if (envelop.isSuccessFlg()) {
////                    result.setSuccessFlg(true);
////                } else {
////                    result.setSuccessFlg(false);
////                    result.setErrorMsg("修改失败!");
////                }
////            }
////        } catch (Exception ex) {
////            String envelopStr = template.doGet(comUrl+url);
////            return envelopStr;
////        }catch (Exception ex){
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////            return failed("系统错误");
////        }
////        }
////
////        return result;
////    }
////
////    @RequestMapping("check")
////    @ResponseBody
////    public Object check(String appId, String status) {
////        Envelop result = new Envelop();
////        String urlPath = "/apps/status";
////        String resultStr = "";
////        MultiValueMap<String, String> conditionMap = new LinkedMultiValueMap<>();
////        conditionMap.add("app_id", appId);
////        conditionMap.add("app_status", status);
////        try {
////            RestTemplates template = new RestTemplates();
////            resultStr = template.doPut(comUrl + urlPath, conditionMap);
////            result.setSuccessFlg(Boolean.parseBoolean(resultStr));
////        } catch (Exception e) {
////            result.setSuccessFlg(false);
////        }
////        return result;
////    }
////
////    //-------------------------------------------------------应用---资源授权管理---开始----------------
////    @RequestMapping("/resource/initial")
////    public String resourceInitial(Model model, String backParams) {
////        model.addAttribute("backParams", backParams);
////        model.addAttribute("contentPage", "/app/resource");
////        return "emptyView";
////    }
////
////    //获取app已授权资源ids集合
////    @RequestMapping("/resourceIds")
////    @ResponseBody
////    public Object getResourceIds(String appId) {
////        Envelop envelop = new Envelop();
////        List<String> list = new ArrayList<>();
////        envelop.setSuccessFlg(false);
////        envelop.setSuccessFlg(false);
////        envelop.setDetailModelList(list);
////        URLQueryBuilder builder = new URLQueryBuilder();
////        if (StringUtils.isEmpty(appId)) {
////            return envelop;
////        }
////        builder.addFilter("appId", "=", appId, null);
////        builder.setPageNumber(1)
////                .setPageSize(999);
////        String param = builder.toString();
////        String url = "/resources/grants";
////        String resultStr = "";
////        try {
////            RestTemplates template = new RestTemplates();
////            resultStr = template.doGet(comUrl + url + "?" + param);
////            Envelop resultGet = objectMapper.readValue(resultStr, Envelop.class);
////            if (resultGet.isSuccessFlg() && resultGet.getDetailModelList().size() != 0) {
////                List<RsAppResourceModel> rsAppModels = (List<RsAppResourceModel>) getEnvelopList(resultGet.getDetailModelList(), new ArrayList<RsAppResourceModel>(), RsAppResourceModel.class);
////                for (RsAppResourceModel m : rsAppModels) {
////                    list.add(m.getResourceId());
////                }
////                envelop.setSuccessFlg(true);
////            }
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////        }
////        envelop.setSuccessFlg(true);
////        envelop.setDetailModelList(list);
////        return envelop;
////        return envelop;
////    }
////    }
////
////
////    @RequestMapping("/app")
////    //根据资源id获取数据元列表
////    @RequestMapping("/resource/metadata")
////    @ResponseBody
////    @ResponseBody
////    public Object getAppById(String appId) {
////    public Object resourceMetadata(String resourceId){
////        Envelop envelop = new Envelop();
////        Envelop envelop = new Envelop();
////        try {
////            String url = "/apps/" + appId;
////        try{
////            String url = "/resources/"+resourceId+"/metadata_list";
////            RestTemplates template = new RestTemplates();
////            RestTemplates template = new RestTemplates();
////            String envelopStr = template.doGet(comUrl + url);
////            String envelopStr = template.doGet(comUrl+url);
////            return envelopStr;
////            return envelopStr;
////        } catch (Exception ex) {
////        }catch (Exception ex){
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////        }
////        }
////        envelop.setSuccessFlg(false);
////        envelop.setSuccessFlg(false);
////        return envelop;
////        return envelop;
////    }
////
////
////    //资源授权appId+resourceIds
////    @RequestMapping("/resource/grant")
////    @ResponseBody
////    public Object resourceGrant(String appId, String resourceIds) {
////        Envelop envelop = new Envelop();
////        try {
////            String url = "/resources/apps/" + appId + "/grant";
////            Map<String, Object> params = new HashMap<>();
////            params.put("appId", appId);
////            params.put("resourceIds", resourceIds);
////            String resultStr = HttpClientUtil.doPost(comUrl + url, params, username, password);
////            return resultStr;
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////        }
////        envelop.setSuccessFlg(false);
////        return envelop;
////    }
////
////    //批量、单个取消资源授权
////    @RequestMapping("/resource/cancel")
////    @ResponseBody
////    public Object resourceGrantCancel(String appId, String resourceIds) {
////        Envelop envelop = new Envelop();
////        envelop.setSuccessFlg(false);
////        if (StringUtils.isEmpty(appId)) {
////            envelop.setErrorMsg("应用id不能为空!");
////            return envelop;
////        }
////        if (StringUtils.isEmpty(resourceIds)) {
////            envelop.setErrorMsg("资源id不能为空!");
////            return envelop;
////        }
////        try {
////            //先获取授权关系表的ids
////            String url = "/resources/grants/no_paging";
////            Map<String, Object> params = new HashMap<>();
////            params.put("filters", "appId=" + appId + ";resourceId=" + resourceIds);
////            String envelopStrGet = HttpClientUtil.doGet(comUrl + url, params, username, password);
////            Envelop envelopGet = objectMapper.readValue(envelopStrGet, Envelop.class);
////            String ids = "";
////            if (envelopGet.isSuccessFlg() && envelopGet.getDetailModelList().size() != 0) {
////                List<MRsAppResource> list = (List<MRsAppResource>) getEnvelopList(envelopGet.getDetailModelList(),
////                        new ArrayList<MRsAppResource>(), MRsAppResource.class);
////                for (MRsAppResource m : list) {
////                    ids += m.getId() + ",";
////                }
////                ids = ids.substring(0, ids.length() - 1);
////            }
////            //取消资源授权
////            if (!StringUtils.isEmpty(ids)) {
////                String urlCancel = "/resources/grants";
////                Map<String, Object> args = new HashMap<>();
////                args.put("ids", ids);
////                String result = HttpClientUtil.doDelete(comUrl + urlCancel, args, username, password);
////                return result;
////            }
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////            return failed("系统出错");
////
////        }
////        return envelop;
////    }
////
////
////    /**
////     * 资源文件上传
////     *
////     * @param
////     * @return
////     */
////    @RequestMapping("appIconFileUpload")
////    @ResponseBody
////    public Object orgLogoFileUpload(
////            @RequestParam("iconFile") MultipartFile file) throws IOException {
////        Envelop result = new Envelop();
////        InputStream inputStream = file.getInputStream();
////        String fileName = file.getOriginalFilename(); //获取文件名
////        if (!file.isEmpty()) {
////            return uploadFile(inputStream, fileName);
////        }
////        return "fail";
////    }
////
////    public String uploadFile(InputStream inputStream, String fileName) {
////        try {
////            //读取文件流,将文件输入流转成 byte
////            int temp = 0;
////            int bufferSize = 1024;
////            byte tempBuffer[] = new byte[bufferSize];
////            byte[] fileBuffer = new byte[0];
////            while ((temp = inputStream.read(tempBuffer)) != -1) {
////                fileBuffer = ArrayUtils.addAll(fileBuffer, ArrayUtils.subarray(tempBuffer, 0, temp));
////            }
////            inputStream.close();
////            String restStream = Base64.getEncoder().encodeToString(fileBuffer);
////            String url = "";
////            url = fileUpload(restStream, fileName);
////            if (!StringUtils.isEmpty(url)) {
////                System.out.println("上传成功");
////                return url;
////            } else {
////                System.out.println("上传失败");
////            }
////
////        } catch (Exception e) {
////            return "fail";
////        }
////        return "fail";
////    }
////
////    /**
////     * 图片上传
////     *
////     * @param inputStream
////     * @param fileName
////     * @return
////     */
////    public String fileUpload(String inputStream, String fileName) {
////
////        RestTemplates templates = new RestTemplates();
////        Map<String, Object> params = new HashMap<>();
////
////        String url = null;
////        if (!StringUtils.isEmpty(inputStream)) {
////
////            //mime  参数 doctor 需要改变  --  需要从其他地方配置
////            FileResourceModel fileResourceModel = new FileResourceModel("", "org", "");
////            String fileResourceModelJsonData = toJson(fileResourceModel);
////
////            params.put("file_str", inputStream);
////            params.put("file_name", fileName);
////            params.put("json_data", fileResourceModelJsonData);
////            try {
////                url = HttpClientUtil.doPost(comUrl + "/filesReturnUrl", params, username, password);
////                return url;
////            } catch (Exception e) {
////                e.printStackTrace();
////            }
////        }
////        return url;
////    }
////
////
////
////    //修改、查看授权资源
////    //-------------------------------------------------------应用---资源授权管理---结束----------------
////
////    //-------------------------------------------------------应用----资源----数据元--管理开始--------------
////    @RequestMapping("/resourceManage/initial")
////    public String resourceManageInitial(Model model, String appId, String resourceId, String dataModel) {
////        model.addAttribute("dataModel", dataModel);
////        model.addAttribute("appRsId", getAppResId(appId, resourceId));
////        model.addAttribute("contentPage", "/app/resourceManage");
////        return "pageView";
////    }
////
////    //获取应用资源关联关系id
////    public String getAppResId(String appId, String resourceId) {
////        URLQueryBuilder builder = new URLQueryBuilder();
////        if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(resourceId)) {
////            return "";
////        }
////        builder.addFilter("appId", "=", appId, null);
////        builder.addFilter("resourceId", "=", resourceId, null);
////        builder.setPageNumber(1)
////                .setPageSize(1);
////        String param = builder.toString();
////        String url = "/resources/grants";
////        String resultStr = "";
////        try {
////            RestTemplates template = new RestTemplates();
////            resultStr = template.doGet(comUrl + url + "?" + param);
////            Envelop resultGet = objectMapper.readValue(resultStr, Envelop.class);
////            if (resultGet.isSuccessFlg()) {
////                List<RsAppResourceModel> rsAppModels = (List<RsAppResourceModel>) getEnvelopList(resultGet.getDetailModelList(), new ArrayList<RsAppResourceModel>(), RsAppResourceModel.class);
////                RsAppResourceModel resourceModel = rsAppModels.get(0);
////                return resourceModel.getId();
////            }
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////        }
////        return "";
////    }
////
//////    /**
//////     * 跳转维度管理页面顶部资源信息
//////     */
//////    @RequestMapping("/resource")
//////    @ResponseBody
//////    public Object getResourceById(String resourceId){
//////        Envelop envelop = new Envelop();
//////        try{
//////            String url = "/resources/"+resourceId;
//////            RestTemplates template = new RestTemplates();
//////            String envelopStr = template.doGet(comUrl+url);
//////            return envelopStr;
//////        }catch (Exception ex){
//////            LogService.getLogger(AppController.class).error(ex.getMessage());
//////        }
//////        envelop.setSuccessFlg(false);
//////        return envelop;
//////    }
//////
//////    //根据资源id获取数据元列表
//////    @RequestMapping("/resource/metadata")
//////    @ResponseBody
//////    public Object resourceMetadata(String resourceId){
//////        Envelop envelop = new Envelop();
//////        try{
//////            String url = "/resources/"+resourceId+"/metadata_list";
//////            RestTemplates template = new RestTemplates();
//////            String envelopStr = template.doGet(comUrl+url);
//////            return envelopStr;
//////        }catch (Exception ex){
//////            LogService.getLogger(AppController.class).error(ex.getMessage());
//////        }
//////        envelop.setSuccessFlg(false);
//////        return envelop;
//////
//////    }
////
////    //-------------------------------------------------------应用----资源----数据元--管理结束--------------
////
////
////    @RequestMapping("/roles/tree")
////    @ResponseBody
////    public Object getRoleArr() {
////        try {
////            String url = comUrl + "/roles/platformAppRolesTree";
////            Map<String, Object> params = new HashMap<>();
////            params.put("type", 0);
////            params.put("source_type", 1);
////            String envelopStr = HttpClientUtil.doGet(url, params, username, password);
////            return envelopStr;
////        } catch (Exception e) {
////            e.printStackTrace();
////            return failedSystem();
////        }
////    }
////
////    //获取平台应用
////    @RequestMapping("/getAppTreeByType")
////    @ResponseBody
////    public Object getAppTreeByType() {
////        try {
////            String url = "/getAppTreeByType";
////            Map<String, Object> params = new HashMap<>();
////            String envelopStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//////            Envelop envelop = objectMapper.readValue(envelopStr,Envelop.class);
////            return envelopStr;
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////            return failed("内部服务请求失败");
////        }
////    }
////
////    //应用一键授权
////    @RequestMapping("/grantByCategoryId")
////    @ResponseBody
////    public Object grantByCategoryId(String appId, String categoryIds, String resourceIds) {
////        System.out.print("---");
////        try {
////            String url = "/resource/api/v1.0" + ServiceApi.Resources.AppsGrantResourcesByCategoryId;
////            Map<String, Object> params = new HashMap<>();
////            params.put("appId", appId);
////            params.put("categoryIds", categoryIds);
////            params.put("resourceIds", resourceIds);
////            String envelopStr = HttpClientUtil.doPost(adminInnerUrl + url, params, username, password);
////            return envelopStr;
////        } catch (Exception ex) {
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////            return failed("内部服务请求失败");
////        }
////    }
////
////    //应用一键取消授权
////    @RequestMapping("/deleteAppsGrantResourcesByCategoryId")
////    @ResponseBody
////    public Object deleteAppsGrantResourcesByCategoryId(String appId, String categoryIds, String resourceIds) {
////        try {
////            String url = "/resource/api/v1.0" + ServiceApi.Resources.DeleteAppsGrantResourcesByCategoryId;
////            Map<String, Object> params = new HashMap<>();
////            params.put("appId", appId);
////            params.put("categoryIds", categoryIds);
////            params.put("resourceIds", resourceIds);
////            String envelopStr = HttpClientUtil.doPost(adminInnerUrl + url, params, username, password);
////            return envelopStr;
////        } catch (Exception ex){
////            LogService.getLogger(AppController.class).error(ex.getMessage());
////            return failed("内部服务请求失败");
////        }
////    }
////    }
//
//
//}
//    //-------------------------------------------------------应用----资源----数据元--管理结束--------------
//
//
//    @RequestMapping("/roles/tree")
//    @ResponseBody
//    public Object getRoleArr() {
//        try {
//            String url = comUrl + "/roles/platformAppRolesTree";
//            Map<String, Object> params = new HashMap<>();
//            params.put("type", 0);
//            params.put("source_type", 1);
//            String envelopStr = HttpClientUtil.doGet(url, params, username, password);
//            return envelopStr;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failedSystem();
//        }
//    }
//
//    //获取平台应用
//    @RequestMapping("/getAppTreeByType")
//    @ResponseBody
//    public Object getAppTreeByType() {
//        try {
//            String url = "/getAppTreeByType";
//            Map<String, Object> params = new HashMap<>();
//            String envelopStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
////            Envelop envelop = objectMapper.readValue(envelopStr,Envelop.class);
//            return envelopStr;
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//            return failed("内部服务请求失败");
//        }
//    }
//
//    //应用一键授权
//    @RequestMapping("/grantByCategoryId")
//    @ResponseBody
//    public Object grantByCategoryId(String appId, String categoryIds, String resourceIds) {
//        System.out.print("---");
//        try {
//            String url = "/resource/api/v1.0" + ServiceApi.Resources.AppsGrantResourcesByCategoryId;
//            Map<String, Object> params = new HashMap<>();
//            params.put("appId", appId);
//            params.put("categoryIds", categoryIds);
//            params.put("resourceIds", resourceIds);
//            String envelopStr = HttpClientUtil.doPost(adminInnerUrl + url, params, username, password);
//            return envelopStr;
//        } catch (Exception ex) {
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//            return failed("内部服务请求失败");
//        }
//    }
//
//    //应用一键取消授权
//    @RequestMapping("/deleteAppsGrantResourcesByCategoryId")
//    @ResponseBody
//    public Object deleteAppsGrantResourcesByCategoryId(String appId, String categoryIds, String resourceIds) {
//        try {
//            String url = "/resource/api/v1.0" + ServiceApi.Resources.DeleteAppsGrantResourcesByCategoryId;
//            Map<String, Object> params = new HashMap<>();
//            params.put("appId", appId);
//            params.put("categoryIds", categoryIds);
//            params.put("resourceIds", resourceIds);
//            String envelopStr = HttpClientUtil.doPost(adminInnerUrl + url, params, username, password);
//            return envelopStr;
//        } catch (Exception ex){
//            LogService.getLogger(AppController.class).error(ex.getMessage());
//            return failed("内部服务请求失败");
//        }
//    }
}

+ 1 - 6
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDataSaveController.java

@ -1,18 +1,13 @@
package com.yihu.jw.basic.agadmin.controller.quota;
package com.yihu.jw.basic.agadmin.controller.quota;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.quota.service.TjDataSaveService;
import com.yihu.jw.basic.quota.service.TjDataSaveService;
import com.yihu.jw.entity.ehr.quota.TjDataSave;
import com.yihu.jw.entity.ehr.quota.TjDataSave;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
@ -80,7 +75,7 @@ public class TjDataSaveController extends EnvelopRestEndpoint {
     * @return
     * @return
     * @throws IOException
     * @throws IOException
     */
     */
    @RequestMapping(value = "updateTjDataSave", produces = "text/html;charset=UTF-8")
    @RequestMapping(value = "updateTjDataSave")
    public Envelop updateTjDataSave(String tjDataSaveModelJsonData, HttpServletRequest request) throws IOException {
    public Envelop updateTjDataSave(String tjDataSaveModelJsonData, HttpServletRequest request) throws IOException {
        String url = "/tj/addTjDataSave";
        String url = "/tj/addTjDataSave";

+ 1 - 6
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDataSourceController.java

@ -1,18 +1,13 @@
package com.yihu.jw.basic.agadmin.controller.quota;
package com.yihu.jw.basic.agadmin.controller.quota;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.quota.service.TjDataSourceService;
import com.yihu.jw.basic.quota.service.TjDataSourceService;
import com.yihu.jw.entity.ehr.quota.TjDataSource;
import com.yihu.jw.entity.ehr.quota.TjDataSource;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -80,7 +75,7 @@ public class TjDataSourceController extends EnvelopRestEndpoint {
     * @return
     * @return
     * @throws IOException
     * @throws IOException
     */
     */
    @PostMapping(value = "updateTjDataSource", produces = "text/html;charset=UTF-8")
    @PostMapping(value = "updateTjDataSource")
    public Envelop updateTjDataSource(String tjDataSourceModelJsonData, HttpServletRequest request) throws IOException {
    public Envelop updateTjDataSource(String tjDataSourceModelJsonData, HttpServletRequest request) throws IOException {
        String url = "/tj/addTjDataSource";
        String url = "/tj/addTjDataSource";
        String[] strings = URLDecoder.decode(tjDataSourceModelJsonData, "UTF-8").split(";");
        String[] strings = URLDecoder.decode(tjDataSourceModelJsonData, "UTF-8").split(";");

+ 59 - 68
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDimensionMainController.java

@ -2,19 +2,22 @@ package com.yihu.jw.basic.agadmin.controller.quota;
import com.yihu.jw.basic.quota.service.TjDimensionMainService;
import com.yihu.jw.basic.quota.service.TjDimensionMainService;
import com.yihu.jw.basic.quota.service.TjQuotaDimensionMainService;
import com.yihu.jw.entity.ehr.quota.TjDimensionMain;
import com.yihu.jw.entity.ehr.quota.TjDimensionMain;
import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionMain;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLDecoder;
@ -25,19 +28,19 @@ import java.util.*;
 */
 */
@RestController
@RestController
@RequestMapping("/tjDimensionMain")
@RequestMapping("/tjDimensionMain")
@Api( tags = {"网关-统计维度"})
@Api( tags = {"网关-统计主维度"})
public class TjDimensionMainController extends EnvelopRestEndpoint {
public class TjDimensionMainController extends EnvelopRestEndpoint {
    @Autowired
    @Resource
    TjDimensionMainService tjDimensionMainService;
    TjDimensionMainService tjDimensionMainService;
    @Resource
    TjQuotaDimensionMainService tjQuotaDimensionMainService;
    //查询统计主维度
    //查询统计主维度
    @GetMapping("/getTjDimensionMain")
    @GetMapping("/getTjDimensionMain")
    public Object searchTjDimensionMain(String name, int page, int rows){
    public Object searchTjDimensionMain(String name, int page, int rows){
        String url = "/tj/getTjDimensionMainList";
        String url = "/tj/getTjDimensionMainList";
        String resultStr = "";
        String resultStr = "";
        Envelop envelop = new Envelop();
        Map<String, Object> params = new HashMap<>();
        StringBuffer stringBuffer = new StringBuffer();
        StringBuffer stringBuffer = new StringBuffer();
        if (!StringUtils.isEmpty(name)) {
        if (!StringUtils.isEmpty(name)) {
            stringBuffer.append("name?" + name );
            stringBuffer.append("name?" + name );
@ -73,7 +76,7 @@ public class TjDimensionMainController extends EnvelopRestEndpoint {
     * @return
     * @return
     * @throws IOException
     * @throws IOException
     */
     */
    @PostMapping(value = "updateTjDimensionMain", produces = "text/html;charset=UTF-8")
    @PostMapping(value = "updateTjDimensionMain")
    public Object updateTjDimensionMain(String tjDimensionMainModelJsonData, HttpServletRequest request) throws IOException {
    public Object updateTjDimensionMain(String tjDimensionMainModelJsonData, HttpServletRequest request) throws IOException {
        String url = "/tj/tjDimensionMain";
        String url = "/tj/tjDimensionMain";
@ -184,66 +187,54 @@ public class TjDimensionMainController extends EnvelopRestEndpoint {
        return  failed("查询失败");
        return  failed("查询失败");
    }
    }
//    @GetMapping("/getTjDimensionMainInfo")
//    public Envelop getTjDimensionMainInfo(String quotaCode, String name, int page, int rows){
//        String url = "/tj/getTjDimensionMainInfoList";
//        String resultStr = "";
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        StringBuffer mainFilter = new StringBuffer("status=1");
//        if (!StringUtils.isEmpty(quotaCode)) {
//            params.put("filter", "quotaCode=" + quotaCode);
//        }
//        if (!StringUtils.isEmpty(name)) {
//            mainFilter.append("name?" + name + " g1;code?" + name + " g1;");
//        }
//        String filters = mainFilter.toString();
//        if (!StringUtils.isEmpty(filters)) {
//            params.put("filters", filters);
//        }
//        params.put("page", page);
//        params.put("size", rows);
//        try {
//            ListResult listResult = tjDimensionMainClient.search(fields, filters, sorts, size, page);
//
//            List<TjDimensionMainModel> mainModelList  = new ArrayList<>();
//            if(listResult.getTotalCount() != 0){
//                List<Map<String,Object>> modelList = listResult.getDetailModelList();
//                for(Map<String,Object> map : modelList){
//                    TjDimensionMainModel tjDimensionMainModel = objectMapper.convertValue(map,TjDimensionMainModel.class);
//                    mainModelList.add(tjDimensionMainModel);
//                }
//                ListResult listResult2 = tjQuotaDimensionMainClient.search(fields, filter, sorts, size, page);
//                List<TjQuotaDimensionMainModel> mainModelList2  = new ArrayList<>();
//                if(listResult2.getTotalCount() != 0) {
//                    List<Map<String, Object>> modelList2 = listResult2.getDetailModelList();
//                    for (Map<String, Object> map : modelList2) {
//                        TjQuotaDimensionMainModel tjQuotaDimensionMainModel = objectMapper.convertValue(map, TjQuotaDimensionMainModel.class);
//                        TjDimensionMain tjDimensionMain = tjDimensionMainClient.getTjDimensionMain(tjQuotaDimensionMainModel.getMainCode());
//                        if (tjDimensionMain != null) {
//                            tjQuotaDimensionMainModel.setName(tjDimensionMain.getName());
//                        }
//                        mainModelList2.add(tjQuotaDimensionMainModel);
//                    }
//                }
//                List<String> list = getTjQuotaDimensionMainOfMainCode(filter, sorts);
//                for (int i=0; i<mainModelList.size(); i++) {
//                    if (list.contains(mainModelList.get(i).getCode())) {
//                        mainModelList.get(i).setChecked(true);
//                    } else {
//                        mainModelList.get(i).setChecked(false);
//                    }
//                }
//                Envelop result = getResult(mainModelList, listResult.getTotalCount(), listResult.getCurrPage(), listResult.getPageSize());
//                result.setObj(mainModelList2);
//                return result;
//            }else{
//                Envelop envelop = new Envelop();
//                return envelop;
//            }
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
    @GetMapping("/getTjDimensionMainInfo")
    public Envelop getTjDimensionMainInfo(String quotaCode, String name, int page, int rows){
        String url = "/tj/getTjDimensionMainInfoList";
        String resultStr = "";
        StringBuffer mainFilter = new StringBuffer("status=1");
        if (!StringUtils.isEmpty(name)) {
            mainFilter.append("name?" + name + " g1;code?" + name + " g1;");
        }
        String filters = mainFilter.toString();
        String filter = "quotaCode=" + quotaCode;
        try {
            List<TjDimensionMain> mainModelList = tjDimensionMainService.search(null, filters, null, page, rows);
            if(mainModelList.size()>0){
                List<TjQuotaDimensionMain> mainModelList2 = tjQuotaDimensionMainService.search(null, filter, null, page, rows);
                if(mainModelList2.size() > 0) {
                    for (TjQuotaDimensionMain tjQuotaDimensionMainModel : mainModelList2) {
                        List<TjDimensionMain> tjDimensionMains = tjDimensionMainService.search("code=" + tjQuotaDimensionMainModel.getMainCode());
                        if (tjDimensionMains.size()>0) {
                            tjQuotaDimensionMainModel.setName(tjDimensionMains.get(0).getName());
                        }
                    }
                }
                List<String> list = getTjQuotaDimensionMainOfMainCode(filter, null);
                for (int i=0; i<mainModelList.size(); i++) {
                    if (list.contains(mainModelList.get(i).getCode())) {
                        mainModelList.get(i).setChecked(true);
                    } else {
                        mainModelList.get(i).setChecked(false);
                    }
                }
                return MixEnvelop.getSuccess("查询成功",mainModelList2,mainModelList,page,rows,tjDimensionMainService.getCount(filters));
            }else{
                return success();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    public List<String> getTjQuotaDimensionMainOfMainCode(String filters, String sorts) throws Exception{
        List<TjQuotaDimensionMain> mainModelList = tjQuotaDimensionMainService.search(filters, sorts);
        List<String> list = new ArrayList<>();
        if(mainModelList.size() > 0){
            for (int i=0; i<mainModelList.size(); i++) {
                list.add(mainModelList.get(i).getMainCode());
            }
        }
        return list;
    }
}
}

+ 15 - 16
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDimensionSlaveController.java

@ -9,8 +9,11 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
@ -24,6 +27,7 @@ import java.util.*;
 */
 */
@RestController
@RestController
@RequestMapping("/tjDimensionSlave")
@RequestMapping("/tjDimensionSlave")
@Api( tags = {"网关-统计从维度"})
public class TjDimensionSlaveController extends EnvelopRestEndpoint {
public class TjDimensionSlaveController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
@ -32,7 +36,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
    TjQuotaDimensionSlaveService tjQuotaDimensionSlaveService;
    TjQuotaDimensionSlaveService tjQuotaDimensionSlaveService;
    //查询
    //查询
    @RequestMapping("/getTjDimensionSlave")
    @GetMapping("/getTjDimensionSlave")
    public Envelop searchTjDimensionSlave(String name, int page, int rows){
    public Envelop searchTjDimensionSlave(String name, int page, int rows){
        String url = "/tj/getTjDimensionSlaveList";
        String url = "/tj/getTjDimensionSlaveList";
        String resultStr = "";
        String resultStr = "";
@ -73,7 +77,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
     * @return
     * @return
     * @throws IOException
     * @throws IOException
     */
     */
    @RequestMapping(value = "updateTjDimensionSlave", produces = "text/html;charset=UTF-8")
    @PostMapping(value = "updateTjDimensionSlave")
    public Envelop updateTjDimensionSlave(String tjDimensionSlaveModelJsonData, HttpServletRequest request) throws IOException {
    public Envelop updateTjDimensionSlave(String tjDimensionSlaveModelJsonData, HttpServletRequest request) throws IOException {
        String url = "/tj/tjDimensionSlave";
        String url = "/tj/tjDimensionSlave";
@ -111,7 +115,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
     * @param tjDimensionSlaveId
     * @param tjDimensionSlaveId
     * @return
     * @return
     */
     */
    @RequestMapping("deleteTjDimensionSlave")
    @PostMapping("deleteTjDimensionSlave")
    public Envelop deleteTjDimensionSlave(Long tjDimensionSlaveId) {
    public Envelop deleteTjDimensionSlave(Long tjDimensionSlaveId) {
        String url = "/tj/tjDimensionSlave";
        String url = "/tj/tjDimensionSlave";
        try {
        try {
@ -131,7 +135,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
     * @param id
     * @param id
     * @return
     * @return
     */
     */
    @RequestMapping("getTjDimensionSlaveById")
    @GetMapping("getTjDimensionSlaveById")
    public Envelop getTjDimensionSlaveById( Long id ) {
    public Envelop getTjDimensionSlaveById( Long id ) {
        String url ="/tj/tjDimensionSlaveId/" +id;
        String url ="/tj/tjDimensionSlaveId/" +id;
        try {
        try {
@ -148,7 +152,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
     * @param name
     * @param name
     * @return
     * @return
     */
     */
    @RequestMapping("isNameExists")
    @GetMapping("isNameExists")
    public Envelop isNameExists(String name) {
    public Envelop isNameExists(String name) {
        String url = "/tj/tjDimensionSlaveName" ;
        String url = "/tj/tjDimensionSlaveName" ;
        try {
        try {
@ -166,7 +170,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
     * @param code
     * @param code
     * @return
     * @return
     */
     */
    @RequestMapping("isCodeExists")
    @GetMapping("isCodeExists")
    public Envelop isCodeExists(String code) {
    public Envelop isCodeExists(String code) {
        String url = "/tj/tjDimensionSlaveCode" ;
        String url = "/tj/tjDimensionSlaveCode" ;
        try {
        try {
@ -179,7 +183,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
        return failed("查询失败");
        return failed("查询失败");
    }
    }
    @RequestMapping("/getTjDimensionSlaveInfo")
    @GetMapping("/getTjDimensionSlaveInfo")
    public Envelop getTjDimensionSlaveInfo(String quotaCode, String name, int page, int rows){
    public Envelop getTjDimensionSlaveInfo(String quotaCode, String name, int page, int rows){
        String url = "/tj/getTjDimensionSlaveInfoList";
        String url = "/tj/getTjDimensionSlaveInfoList";
        StringBuffer slaveFilter = new StringBuffer("status=1");
        StringBuffer slaveFilter = new StringBuffer("status=1");
@ -192,20 +196,15 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
        }
        }
        String filters = slaveFilter.toString();
        String filters = slaveFilter.toString();
        try {
        try {
            List<TjDimensionSlave> qtjDimensionSlaveList = tjDimensionSlaveService.search(null, filters, null, page, rows);
            List<TjDimensionSlave> mainModelList = new ArrayList<>();
            if (qtjDimensionSlaveList.size()>0) {
                mainModelList.addAll(qtjDimensionSlaveList);
            List<TjDimensionSlave> mainModelList = tjDimensionSlaveService.search(null, filters, null, page, rows);
            if (mainModelList.size()>0) {
                List<TjQuotaDimensionSlave> qtjQuotaDimensionSlaveList = tjQuotaDimensionSlaveService.search(null, filter, null, page, rows);
                List<TjQuotaDimensionSlave> qtjQuotaDimensionSlaveList = tjQuotaDimensionSlaveService.search(null, filter, null, page, rows);
                List<TjQuotaDimensionSlave> tjQuotaDimensionSlaveModelList = new ArrayList<>();
                if (qtjQuotaDimensionSlaveList.size()>0) {
                if (qtjQuotaDimensionSlaveList.size()>0) {
                    for (TjQuotaDimensionSlave tjQuotaQuotaDimensionSlaveModel : tjQuotaDimensionSlaveModelList) {
                    for (TjQuotaDimensionSlave tjQuotaQuotaDimensionSlaveModel : qtjQuotaDimensionSlaveList) {
                        List<TjDimensionSlave> tjDimensionSlaves = tjDimensionSlaveService.search("code=" + tjQuotaQuotaDimensionSlaveModel.getSlaveCode());
                        List<TjDimensionSlave> tjDimensionSlaves = tjDimensionSlaveService.search("code=" + tjQuotaQuotaDimensionSlaveModel.getSlaveCode());
                        if (tjDimensionSlaves.size()>0) {
                        if (tjDimensionSlaves.size()>0) {
                            tjQuotaQuotaDimensionSlaveModel.setName(tjDimensionSlaves.get(0).getName());
                            tjQuotaQuotaDimensionSlaveModel.setName(tjDimensionSlaves.get(0).getName());
                        }
                        }
                        tjQuotaDimensionSlaveModelList.add(tjQuotaQuotaDimensionSlaveModel);
                    }
                    }
                }
                }
                List<String> list = getTjQuotaDimensionMainOfSlaveCode(filter, null);
                List<String> list = getTjQuotaDimensionMainOfSlaveCode(filter, null);
@ -216,7 +215,7 @@ public class TjDimensionSlaveController extends EnvelopRestEndpoint {
                        mainModelList.get(i).setChecked(false);
                        mainModelList.get(i).setChecked(false);
                    }
                    }
                }
                }
                return MixEnvelop.getSuccess("",tjQuotaDimensionSlaveModelList,mainModelList,page,rows,(long) qtjDimensionSlaveList.size());
                return MixEnvelop.getSuccess("",qtjQuotaDimensionSlaveList,mainModelList,page,rows,tjDimensionSlaveService.getCount(filters));
            } else {
            } else {
                return success();
                return success();
            }
            }

+ 81 - 110
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaController.java

@ -6,23 +6,20 @@ import com.yihu.jw.basic.dict.service.SystemDictEntryService;
import com.yihu.jw.basic.quota.controller.JobController;
import com.yihu.jw.basic.quota.controller.JobController;
import com.yihu.jw.basic.quota.model.SaveModel;
import com.yihu.jw.basic.quota.model.SaveModel;
import com.yihu.jw.basic.quota.service.*;
import com.yihu.jw.basic.quota.service.*;
import com.yihu.jw.basic.quota.util.QuartzHelper;
import com.yihu.jw.basic.resource.service.RsResourceQuotaService;
import com.yihu.jw.basic.resource.service.RsResourceQuotaService;
import com.yihu.jw.basic.util.TemPath;
import com.yihu.jw.basic.util.TemPath;
import com.yihu.jw.entity.ehr.dict.SystemDictEntry;
import com.yihu.jw.entity.ehr.quota.*;
import com.yihu.jw.entity.ehr.quota.*;
import com.yihu.jw.entity.ehr.resource.RsResourceQuota;
import com.yihu.jw.entity.ehr.resource.RsResourceQuota;
import com.yihu.jw.restmodel.ehr.dict.MConventionalDict;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.date.DateTimeUtil;
import com.yihu.jw.util.date.DateTimeUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -34,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.io.*;
import java.net.URLDecoder;
import java.net.URLDecoder;
import java.util.*;
import java.util.*;
import java.util.stream.Collectors;
/**
/**
 * Created by Administrator on 2017/6/13.
 * Created by Administrator on 2017/6/13.
@ -84,7 +82,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
        if (!StringUtils.isEmpty(name)) {
        if (!StringUtils.isEmpty(name)) {
            stringBuffer.append("name?" + name.trim() + " g1;code?" + name.trim() + " g1;");
            stringBuffer.append("name?" + name.trim() + " g1;code?" + name.trim() + " g1;");
        }
        }
        if (!StringUtils.isEmpty(quotaType)) {
        if (quotaType!=null) {
            stringBuffer.append("quotaType=" + quotaType + ";");
            stringBuffer.append("quotaType=" + quotaType + ";");
        } /*else {
        } /*else {
            stringBuffer.append("quotaType=-1");
            stringBuffer.append("quotaType=-1");
@ -114,19 +112,14 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 新增修改
     * 新增修改
     *
     * @param tjQuotaModelJsonData
     * @param request
     * @return
     * @throws IOException
     */
     */
    @PostMapping(value = "updateTjDataSource", produces = "text/html;charset=UTF-8")
    public Envelop updateTjQuota(String tjQuotaModelJsonData, HttpServletRequest request) throws IOException {
    @PostMapping(value = "updateTjDataSource")
    public ObjEnvelop updateTjQuota(String tjQuotaModelJsonData) {
        String url = "/tj/addTjQuota/";
        String url = "/tj/addTjQuota/";
        String[] strings = URLDecoder.decode(tjQuotaModelJsonData, "UTF-8").split(";");
        TjQuota detailModel = objectMapper.readValue(strings[0], TjQuota.class);
        try {
        try {
            if (!StringUtils.isEmpty(detailModel.getId())) {
            String[] strings = URLDecoder.decode(tjQuotaModelJsonData, "UTF-8").split(";");
            TjQuota detailModel = objectMapper.readValue(strings[0], TjQuota.class);
            if (detailModel.getId()!=null) {
                Long tjQuotaId = detailModel.getId();
                Long tjQuotaId = detailModel.getId();
                TjQuota updateTjQuota = tjQuotaService.getById(tjQuotaId);
                TjQuota updateTjQuota = tjQuotaService.getById(tjQuotaId);
                if (updateTjQuota!=null) {
                if (updateTjQuota!=null) {
@ -143,31 +136,31 @@ public class TjQuotaController extends EnvelopRestEndpoint {
                    updateTjQuota.setRemark(detailModel.getRemark());
                    updateTjQuota.setRemark(detailModel.getRemark());
                    TjQuotaDataSource tjquotaDataSource = null;
                    TjQuotaDataSource tjquotaDataSource = null;
                    TjQuotaDataSave tjQuotaDataSave = null;
                    TjQuotaDataSave tjQuotaDataSave = null;
                    if(detailModel.getTjQuotaDataSource() != null){
                        tjquotaDataSource = detailModel.getTjQuotaDataSource();
                    if(detailModel.getTjQuotaDataSourceModel() != null){
                        tjquotaDataSource = detailModel.getTjQuotaDataSourceModel();
                        tjquotaDataSource.setQuotaCode(detailModel.getCode());
                        tjquotaDataSource.setQuotaCode(detailModel.getCode());
                    }
                    }
                    if(detailModel.getTjQuotaDataSave() != null
                            && org.apache.commons.lang3.StringUtils.isNotEmpty(detailModel.getTjQuotaDataSave().getSaveCode())){
                        tjQuotaDataSave = detailModel.getTjQuotaDataSave();
                    if(detailModel.getTjQuotaDataSaveModel() != null
                            && org.apache.commons.lang3.StringUtils.isNotEmpty(detailModel.getTjQuotaDataSaveModel().getSaveCode())){
                        tjQuotaDataSave = detailModel.getTjQuotaDataSaveModel();
                        tjQuotaDataSave.setQuotaCode(detailModel.getCode());
                        tjQuotaDataSave.setQuotaCode(detailModel.getCode());
                    }
                    }
                    detailModel.setUpdateTime(new Date());
                    tjQuotaService.saves(detailModel, tjquotaDataSource, tjQuotaDataSave);
                    return ObjEnvelop.getSuccess("统计表更新成功!", detailModel);
                    updateTjQuota.setUpdateTime(new Date());
                    tjQuotaService.saves(updateTjQuota, tjquotaDataSource, tjQuotaDataSave);
                    return ObjEnvelop.getSuccess("统计表更新成功!", updateTjQuota);
                } else {
                } else {
                    return failed("参数错误");
                    return ObjEnvelop.getError("参数错误");
                }
                }
            } else {
            } else {
                TjQuotaDataSource tjquotaDataSource = null;
                TjQuotaDataSource tjquotaDataSource = null;
                TjQuotaDataSave tjQuotaDataSave = null;
                TjQuotaDataSave tjQuotaDataSave = null;
                if(detailModel.getTjQuotaDataSource() != null){
                    tjquotaDataSource = detailModel.getTjQuotaDataSource();
                if(detailModel.getTjQuotaDataSourceModel() != null){
                    tjquotaDataSource = detailModel.getTjQuotaDataSourceModel();
                    tjquotaDataSource.setQuotaCode(detailModel.getCode());
                    tjquotaDataSource.setQuotaCode(detailModel.getCode());
                }
                }
                if(detailModel.getTjQuotaDataSave() != null
                        && org.apache.commons.lang3.StringUtils.isNotEmpty(detailModel.getTjQuotaDataSave().getSaveCode())){
                    tjQuotaDataSave = detailModel.getTjQuotaDataSave();
                if(detailModel.getTjQuotaDataSaveModel() != null
                        && org.apache.commons.lang3.StringUtils.isNotEmpty(detailModel.getTjQuotaDataSaveModel().getSaveCode())){
                    tjQuotaDataSave = detailModel.getTjQuotaDataSaveModel();
                    tjQuotaDataSave.setQuotaCode(detailModel.getCode());
                    tjQuotaDataSave.setQuotaCode(detailModel.getCode());
                }
                }
                detailModel.setIsInitExec("0");
                detailModel.setIsInitExec("0");
@ -179,15 +172,12 @@ public class TjQuotaController extends EnvelopRestEndpoint {
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
            return ObjEnvelop.getError(ERR_SYSTEM_DES);
        }
        }
    }
    }
    /**
    /**
     * 删除
     * 删除
     *
     * @param tjQuotaId
     * @return
     */
     */
    @PostMapping("deleteTjDataSave")
    @PostMapping("deleteTjDataSave")
    public Envelop deleteTjQuota(Long tjQuotaId) {
    public Envelop deleteTjQuota(Long tjQuotaId) {
@ -211,29 +201,25 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 根据id获取消息
     * 根据id获取消息
     * @param id
     * @return
     */
     */
    @GetMapping("getTjQuotaById")
    @GetMapping("getTjQuotaById")
    public Envelop getTjQuotaById( Long id) {
    public Envelop getTjQuotaById(Long id) {
        String url = "/tj/getTjQuotaById/" + id;
        String url = "/tj/getTjQuotaById/" + id;
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        try {
        try {
            TjQuota tjQuota = tjQuotaService.getById(id);
            TjQuota tjQuota = tjQuotaService.getById(id);
            if (null != tjQuota) {
            if (null != tjQuota) {
                TjQuotaDataSave tjQuotaDataSave = tjQuotaDataSaveService.getByQuotaCode(tjQuota.getCode());
                TjQuotaDataSave tjQuotaDataSave = tjQuotaDataSaveService.getByQuotaCode(tjQuota.getCode());
                TjQuotaDataSource tjQuotaDataSource = tjQuotaDataSourceService.getByQuotaCode(tjQuota.getCode());
                TjQuotaDataSource tjQuotaDataSource = tjQuotaDataSourceService.getByQuotaCode(tjQuota.getCode());
                if (tjQuotaDataSave != null) {
                if (tjQuotaDataSave != null && tjQuotaDataSave.getSaveCode() != null) {
                    TjDataSave tjDataSave = tjDataSaveService.getByCode(tjQuotaDataSave.getSaveCode());
                    TjDataSave tjDataSave = tjDataSaveService.getByCode(tjQuotaDataSave.getSaveCode());
                    tjQuotaDataSave.setName(tjDataSave.getName());
                    tjQuotaDataSave.setName(tjDataSave.getName());
                }
                }
                if (tjQuotaDataSource != null) {
                if (tjQuotaDataSource != null && tjQuotaDataSource.getSourceCode() != null) {
                    TjDataSource tjDataSource = tjDataSourceService.getByCode(tjQuotaDataSource.getSourceCode());
                    TjDataSource tjDataSource = tjDataSourceService.getByCode(tjQuotaDataSource.getSourceCode());
                    tjQuotaDataSource.setName(tjDataSource.getName());
                    tjQuotaDataSource.setName(tjDataSource.getName());
                }
                }
                tjQuota.setTjQuotaDataSave(tjQuotaDataSave);
                tjQuota.setTjQuotaDataSource(tjQuotaDataSource);
                tjQuota.setTjQuotaDataSaveModel(tjQuotaDataSave);
                tjQuota.setTjQuotaDataSourceModel(tjQuotaDataSource);
            }
            }
            return ObjEnvelop.getSuccess("统计指标表删除成功!",tjQuota);
            return ObjEnvelop.getSuccess("统计指标表删除成功!",tjQuota);
        } catch (Exception e) {
        } catch (Exception e) {
@ -244,9 +230,6 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 校验name是否唯一,true已存在
     * 校验name是否唯一,true已存在
     *
     * @param name
     * @return
     */
     */
    @GetMapping("hasExistsName")
    @GetMapping("hasExistsName")
    public Envelop hasExistsName(String name) {
    public Envelop hasExistsName(String name) {
@ -256,16 +239,13 @@ public class TjQuotaController extends EnvelopRestEndpoint {
            List<TjQuota> list = tjQuotaService.search(filter);
            List<TjQuota> list = tjQuotaService.search(filter);
            return ObjEnvelop.getSuccess("查询成功",list.size() >0);
            return ObjEnvelop.getSuccess("查询成功",list.size() >0);
        } catch (Exception e) {
        } catch (Exception e) {
            e.getMessage();
            e.printStackTrace();
        }
        }
        return  failed("查询失败");
        return failed("查询失败");
    }
    }
    /**
    /**
     * 校验code是否唯一
     * 校验code是否唯一
     *
     * @param code
     * @return
     */
     */
    @GetMapping("hasExistsCode")
    @GetMapping("hasExistsCode")
    public Envelop hasExistsCode(String code) {
    public Envelop hasExistsCode(String code) {
@ -321,12 +301,9 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 指标结果页
     * 指标结果页
     *
     * @param model
     * @return
     */
     */
    @GetMapping("initialResult")
    @GetMapping("initialResult")
    public Envelop initialResult(Model model, long tjQuotaId, String quotaCode, String quotaType, String name) throws Exception {
    public Envelop initialResult(long tjQuotaId, String quotaCode, String quotaType, String name) throws Exception {
        try {
        try {
            Map<String,String> map = new HashMap<>();
            Map<String,String> map = new HashMap<>();
            List<TjQuotaDimensionSlave> slaveModelList = tjQuotaDimensionSlaveService.getTjQuotaDimensionSlaveByCode(quotaCode);
            List<TjQuotaDimensionSlave> slaveModelList = tjQuotaDimensionSlaveService.getTjQuotaDimensionSlaveByCode(quotaCode);
@ -350,25 +327,36 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 指标执行结果
     * 指标执行结果
     *
     * @param tjQuotaId
     * @return
     */
     */
    @RequestMapping("selectQuotaResult")
    @GetMapping("selectQuotaResult")
    public Envelop selectQuotaResult(Long tjQuotaId, int page, int rows,
    public Envelop selectQuotaResult(Long tjQuotaId, int page, int rows,
                                    String startTime, String endTime, String orgName,
                                    String startTime, String endTime, String orgName,
                                    String province, String city, String district,String res, HttpServletRequest request) {
                                    String province, String city, String district,String res, HttpServletRequest request) {
        String url = "/tj/tjGetQuotaResult";
        String url = "/tj/tjGetQuotaResult";
        try {
        try {
            Map<String, Object> filters = new HashMap<>();
            Map<String, Object> filters = new HashMap<>();
            filters.put("startTime", startTime);
            filters.put("endTime", endTime);
            filters.put("org", orgName);
            filters.put("province", province);
            filters.put("town", city);
            filters.put("district", district);
             // 结果大于0
            filters.put("result", res);
            if(StringUtils.isNotBlank(startTime)){
                filters.put("startTime", startTime);
            }
            if(StringUtils.isNotBlank(endTime)){
                filters.put("endTime", endTime);
            }
            if(StringUtils.isNotBlank(orgName)){
                filters.put("orgName", orgName);
            }
            if(StringUtils.isNotBlank(province)){
                filters.put("province", province);
            }
            if(StringUtils.isNotBlank(city)){
                filters.put("city", city);
            }
            if(StringUtils.isNotBlank(district)){
                filters.put("district", district);
            }
            if(StringUtils.isNotBlank(res)){
                // 结果大于0
                filters.put("result", res);
            }
            try {
            try {
                List<SaveModel> saveModelList = new ArrayList<>();
                List<SaveModel> saveModelList = new ArrayList<>();
                List<Map<String, Object>> resultList = quotaService.queryResultPage(tjQuotaId, filters.toString(), page, rows);
                List<Map<String, Object>> resultList = quotaService.queryResultPage(tjQuotaId, filters.toString(), page, rows);
@ -395,11 +383,8 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 获取指标日志信息
     * 获取指标日志信息
     *
     * @param
     * @return
     */
     */
    @RequestMapping("queryQuotaLog")
    @GetMapping("queryQuotaLog")
    public Envelop queryQuotaLog(String quotaCode, String startTime, String endTime, int page, int rows) throws Exception {
    public Envelop queryQuotaLog(String quotaCode, String startTime, String endTime, int page, int rows) throws Exception {
        String url = "/tj/getTjQuotaLogList";
        String url = "/tj/getTjQuotaLogList";
        String resultStr = "";
        String resultStr = "";
@ -430,8 +415,17 @@ public class TjQuotaController extends EnvelopRestEndpoint {
            conditionMap.put("startDate", startDate);
            conditionMap.put("startDate", startDate);
            conditionMap.put("endDate", endDate);
            conditionMap.put("endDate", endDate);
            List<TjQuotaLog> tjQuotaLogs = tjQuotaLogService.searchQuotaLogByParams(conditionMap);
            List<TjQuotaLog> tjQuotaLogs = tjQuotaLogService.searchQuotaLogByParams(conditionMap);
            Long totalCount =Long.parseLong(tjQuotaLogService.searchQuotaLogByParamsTotalCount(conditionMap).toString());
            if(tjQuotaLogs.size()>0){
                List<SystemDictEntry> dictEntries = dictEntryService.getDictEntries(82,null);
                Map<String, String> distMap = dictEntries.stream()
                        .collect(Collectors.toMap(SystemDictEntry::getCode, SystemDictEntry::getValue));
                for (TjQuotaLog log:tjQuotaLogs){
                    //获取类别字典
                    log.setStatusName(distMap.get(String.valueOf(log.getStatus())));
                }
            }
            Long totalCount =Long.parseLong(tjQuotaLogService.searchQuotaLogByParamsTotalCount(conditionMap).toString());
            return PageEnvelop.getSuccessListWithPage("",tjQuotaLogs,page,rows,totalCount);
            return PageEnvelop.getSuccessListWithPage("",tjQuotaLogs,page,rows,totalCount);
        } catch (Exception ex) {
        } catch (Exception ex) {
            ex.printStackTrace();
            ex.printStackTrace();
@ -441,11 +435,8 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 获取quotaCode查询是否配置维度
     * 获取quotaCode查询是否配置维度
     *
     * @param
     * @return
     */
     */
    @RequestMapping("hasConfigDimension")
    @GetMapping("hasConfigDimension")
    public Envelop hasConfigDimension(String quotaCode) throws Exception {
    public Envelop hasConfigDimension(String quotaCode) throws Exception {
        String url = "/tj/hasConfigDimension";
        String url = "/tj/hasConfigDimension";
        try {
        try {
@ -460,7 +451,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    //带检索分页的查找指标方法,用于下拉框
    //带检索分页的查找指标方法,用于下拉框
    @RequestMapping("/rsQuota")
    @GetMapping("/rsQuota")
    public Envelop searchRsQuota(String searchParm, int page, int rows) {
    public Envelop searchRsQuota(String searchParm, int page, int rows) {
        String url = "/tj/getTjQuotaList";
        String url = "/tj/getTjQuotaList";
        StringBuffer stringBuffer = new StringBuffer();
        StringBuffer stringBuffer = new StringBuffer();
@ -490,11 +481,9 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    }
    }
    @RequestMapping("/getTjQuotaChartList")
    public Envelop getQuotaChartList(String quotaCode, String name, int dictId, int page, int rows) {
    @GetMapping("/getTjQuotaChartList")
    public Envelop getQuotaChartList(String quotaCode, String name, Integer dictId, int page, int rows) {
        String url = "/tj/getTjQuotaChartList";
        String url = "/tj/getTjQuotaChartList";
        Map<String, Object> params = new HashMap<>();
        params.put("filters", "");
        StringBuffer stringBuffer = new StringBuffer();
        StringBuffer stringBuffer = new StringBuffer();
        if (!StringUtils.isEmpty(quotaCode)) {
        if (!StringUtils.isEmpty(quotaCode)) {
            stringBuffer.append("quotaCode=" + quotaCode);
            stringBuffer.append("quotaCode=" + quotaCode);
@ -503,30 +492,26 @@ public class TjQuotaController extends EnvelopRestEndpoint {
            stringBuffer.append("value?" + name);
            stringBuffer.append("value?" + name);
        }
        }
        String filters = stringBuffer.toString();
        String filters = stringBuffer.toString();
        if (!StringUtils.isEmpty(filters)) {
            params.put("filters", filters);
        }
        String filter = "";
        String filter = "";
        if (!StringUtils.isEmpty(dictId)) {
        if (dictId != null) {
            filter = "dictId=" + dictId;
            filter = "dictId=" + dictId;
        }
        }
        params.put("dictfilter", filter);
        params.put("page", page);
        params.put("size", rows);
//        params.put("dictfilter", filter);
        try {
        try {
            List<MConventionalDict> conventionalDictList = dictEntryService.search(null, filter, null, page, rows);
            List<MConventionalDict> mainModelList = new ArrayList<>();
            List<SystemDictEntry> conventionalDictList = dictEntryService.search(null, filter, null, page, rows);
            List<SystemDictEntry> mainModelList = new ArrayList<>();
            if (conventionalDictList.size() > 0) {
            if (conventionalDictList.size() > 0) {
                mainModelList.addAll(conventionalDictList);
                Map<String,String> dictMap = new HashMap<>();
                Map<String,String> dictMap = new HashMap<>();
                for(MConventionalDict dict:mainModelList){
                for(SystemDictEntry dict:mainModelList){
                    dictMap.put(dict.getCode(),dict.getValue());
                    dictMap.put(dict.getCode(),dict.getValue());
                }
                }
                List<TjQuotaChart> tjQuotaChartList = tjQuotaChartService.search(null, filters, null, page, rows);
                List<TjQuotaChart> tjQuotaChartList = tjQuotaChartService.search(null, filters, null, page, rows);
                List<MConventionalDict> checkedConventionalDicts = new ArrayList<>();
                List<SystemDictEntry> checkedConventionalDicts = new ArrayList<>();
                if (tjQuotaChartList.size() > 0) {
                if (tjQuotaChartList.size() > 0) {
                    for (TjQuotaChart tjQuotaChartModel : tjQuotaChartList) {
                    for (TjQuotaChart tjQuotaChartModel : tjQuotaChartList) {
                        MConventionalDict mConventionalDict = new MConventionalDict();
                        SystemDictEntry mConventionalDict = new SystemDictEntry();
                        String key = tjQuotaChartModel.getChartId()+"";
                        String key = tjQuotaChartModel.getChartId()+"";
                        if(dictMap.containsKey(key)){
                        if(dictMap.containsKey(key)){
                            mConventionalDict.setCode(key);
                            mConventionalDict.setCode(key);
@ -568,13 +553,8 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 添加主维度子表
     * 添加主维度子表
     *
     * @param jsonModel 维度子表信息的json串
     * @param request
     * @return
     * @throws IOException
     */
     */
    @RequestMapping(value = "addTjQuotaChart", produces = "text/html;charset=UTF-8")
    @PostMapping(value = "addTjQuotaChart")
    public Envelop addTjQuotaChart(String quotaCode, String jsonModel, HttpServletRequest request) throws IOException {
    public Envelop addTjQuotaChart(String quotaCode, String jsonModel, HttpServletRequest request) throws IOException {
        String url = "/tj/batchTjQuotaChart";
        String url = "/tj/batchTjQuotaChart";
        try {
        try {
@ -594,12 +574,6 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 指标文件导入
     * 指标文件导入
     *
     * @param file
     * @param request
     * @param response
     * @return
     * @throws IOException
     */
     */
    private static final String parentFile = "tjQuotaDataSet";
    private static final String parentFile = "tjQuotaDataSet";
@ -856,9 +830,6 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 根据指标分类的名称获取指标id和name
     * 根据指标分类的名称获取指标id和name
     *
     *
     * @param names 指标分类名称
     * @return
     * @throws Exception
     */
     */
    private Map<String, String> findExistQuotaType(Set<String> names) throws Exception {
    private Map<String, String> findExistQuotaType(Set<String> names) throws Exception {
        Map<String, String> map = new HashMap<>();
        Map<String, String> map = new HashMap<>();
@ -894,7 +865,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
//    }
//    }
    @RequestMapping("/downLoadErrInfo")
    @GetMapping("/downLoadErrInfo")
    public void downLoadErrInfo(String f, String datePath, HttpServletResponse response) throws IOException {
    public void downLoadErrInfo(String f, String datePath, HttpServletResponse response) throws IOException {
        try {
        try {
@ -940,7 +911,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 停止执行指标
     * 停止执行指标
     */
     */
    @RequestMapping("removeQuota")
    @PostMapping("removeQuota")
    public Object removeQuota(Long tjQuotaId) {
    public Object removeQuota(Long tjQuotaId) {
        Envelop envelop = new Envelop();
        Envelop envelop = new Envelop();
        try {
        try {

+ 4 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaDimensionMainController.java

@ -7,8 +7,10 @@ import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionMain;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
@ -22,6 +24,7 @@ import java.util.Map;
 */
 */
@RestController
@RestController
@RequestMapping("/tjQuotaDimensionMain")
@RequestMapping("/tjQuotaDimensionMain")
@Api( tags = {"网关-统计指标主维度"})
public class TjQuotaDimensionMainController extends EnvelopRestEndpoint {
public class TjQuotaDimensionMainController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
@ -34,7 +37,7 @@ public class TjQuotaDimensionMainController extends EnvelopRestEndpoint {
     * @return
     * @return
     * @throws IOException
     * @throws IOException
     */
     */
    @RequestMapping(value = "addTjQuotaDimensionMain", produces = "text/html;charset=UTF-8")
    @PostMapping(value = "addTjQuotaDimensionMain")
    public Object addTjQuotaDimensionMain(String quotaCode, String jsonModel, HttpServletRequest request) throws IOException {
    public Object addTjQuotaDimensionMain(String quotaCode, String jsonModel, HttpServletRequest request) throws IOException {
        String url = "/tj/addTjQuotaDimensionMain";
        String url = "/tj/addTjQuotaDimensionMain";
        String resultStr = "";
        String resultStr = "";

+ 4 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaDimensionSlaveController.java

@ -6,8 +6,10 @@ import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionSlave;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
@ -22,6 +24,7 @@ import java.util.Map;
 */
 */
@RestController
@RestController
@RequestMapping("/tjQuotaDimensionMain")
@RequestMapping("/tjQuotaDimensionMain")
@Api( tags = {"网关-统计指标从维度"})
public class TjQuotaDimensionSlaveController extends EnvelopRestEndpoint {
public class TjQuotaDimensionSlaveController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
@ -33,7 +36,7 @@ public class TjQuotaDimensionSlaveController extends EnvelopRestEndpoint {
     * @return
     * @return
     * @throws IOException
     * @throws IOException
     */
     */
    @RequestMapping(value = "addTjQuotaDimensionSlave", produces = "text/html;charset=UTF-8")
    @PostMapping(value = "addTjQuotaDimensionSlave")
    public Object addTjQuotaDimensionSlave(String quotaCode, String jsonModel, HttpServletRequest request) throws IOException {
    public Object addTjQuotaDimensionSlave(String quotaCode, String jsonModel, HttpServletRequest request) throws IOException {
        String url = "/tj/addTjQuotaDimensionSlave";
        String url = "/tj/addTjQuotaDimensionSlave";
        String resultStr = "";
        String resultStr = "";

+ 8 - 12
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/report/ReportController.java

@ -1,6 +1,5 @@
package com.yihu.jw.basic.agadmin.controller.report;
package com.yihu.jw.basic.agadmin.controller.report;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.report.controller.CalculatePointUtil;
import com.yihu.jw.basic.report.controller.CalculatePointUtil;
import com.yihu.jw.basic.report.service.QcQuotaResultService;
import com.yihu.jw.basic.report.service.QcQuotaResultService;
@ -10,18 +9,15 @@ import com.yihu.jw.restmodel.ehr.report.MQcDailyReportResultDetail;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import jxl.Workbook;
import jxl.Workbook;
import jxl.format.CellFormat;
import jxl.format.CellFormat;
import jxl.write.*;
import jxl.write.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;
@ -42,7 +38,7 @@ public class ReportController extends EnvelopRestEndpoint {
    CalculatePointUtil calculatePointUtil=new CalculatePointUtil();
    CalculatePointUtil calculatePointUtil=new CalculatePointUtil();
    //所有指标统计结果查询,初始化查询
    //所有指标统计结果查询,初始化查询
    @RequestMapping("/getQcOverAllIntegrity")
    @GetMapping("/getQcOverAllIntegrity")
    public Envelop searchQcOverAllIntegrity(String location,String startTime,String endTime){
    public Envelop searchQcOverAllIntegrity(String location,String startTime,String endTime){
        PageEnvelop result = new PageEnvelop();
        PageEnvelop result = new PageEnvelop();
        List<Object> quotaList = new ArrayList<Object>();
        List<Object> quotaList = new ArrayList<Object>();
@ -102,7 +98,7 @@ public class ReportController extends EnvelopRestEndpoint {
    }
    }
    //根据机构查询所有指标统计结果,初始化查询
    //根据机构查询所有指标统计结果,初始化查询
    @RequestMapping("/getQcOverAllOrgIntegrity")
    @GetMapping("/getQcOverAllOrgIntegrity")
    public Envelop searchQcOverAllOrgIntegrity(String location,String orgCode,String startTime,String endTime){
    public Envelop searchQcOverAllOrgIntegrity(String location,String orgCode,String startTime,String endTime){
        PageEnvelop result = new PageEnvelop();
        PageEnvelop result = new PageEnvelop();
        List<Object> quotaList = new ArrayList<Object>();
        List<Object> quotaList = new ArrayList<Object>();
@ -165,7 +161,7 @@ public class ReportController extends EnvelopRestEndpoint {
    }
    }
    //趋势分析 - 按区域列表查询,初始化查询
    //趋势分析 - 按区域列表查询,初始化查询
    @RequestMapping("/getQcQuotaIntegrity")
    @GetMapping("/getQcQuotaIntegrity")
    public Envelop searchQcQuotaIntegrity(String location,String quotaId,String startTime,String endTime){
    public Envelop searchQcQuotaIntegrity(String location,String quotaId,String startTime,String endTime){
        PageEnvelop result = new PageEnvelop();
        PageEnvelop result = new PageEnvelop();
        List<Object> quotaList = new ArrayList<Object>();
        List<Object> quotaList = new ArrayList<Object>();
@ -244,7 +240,7 @@ public class ReportController extends EnvelopRestEndpoint {
        return result;
        return result;
    }
    }
    //趋势分析 -按机构列表查询,初始化查询
    //趋势分析 -按机构列表查询,初始化查询
    @RequestMapping("/getQcQuotaOrgIntegrity")
    @GetMapping("/getQcQuotaOrgIntegrity")
    public Envelop searchQcQuotaOrgIntegrity(String orgCode,String quotaId,String startTime,String endTime){
    public Envelop searchQcQuotaOrgIntegrity(String orgCode,String quotaId,String startTime,String endTime){
        PageEnvelop result = new PageEnvelop();
        PageEnvelop result = new PageEnvelop();
        List<Object> quotaList = new ArrayList<Object>();
        List<Object> quotaList = new ArrayList<Object>();
@ -323,7 +319,7 @@ public class ReportController extends EnvelopRestEndpoint {
    }
    }
    //分析明细列表
    //分析明细列表
    @RequestMapping("/getQcQuotaDailyIntegrity")
    @GetMapping("/getQcQuotaDailyIntegrity")
    public Envelop searchQcQuotaDailyIntegrity(String location,String startTime,String endTime){
    public Envelop searchQcQuotaDailyIntegrity(String location,String startTime,String endTime){
        PageEnvelop result = new PageEnvelop();
        PageEnvelop result = new PageEnvelop();
        List<Object> quotaList = new ArrayList<Object>();
        List<Object> quotaList = new ArrayList<Object>();
@ -403,7 +399,7 @@ public class ReportController extends EnvelopRestEndpoint {
    }
    }
    //根据地区、期间查询各机构某项指标的值
    //根据地区、期间查询各机构某项指标的值
    @RequestMapping("/getQcQuotaByLocation")
    @GetMapping("/getQcQuotaByLocation")
    public Envelop searchQcQuotaByLocation(String location,String quotaId,String startTime,String endTime){
    public Envelop searchQcQuotaByLocation(String location,String quotaId,String startTime,String endTime){
        PageEnvelop result = new PageEnvelop();
        PageEnvelop result = new PageEnvelop();
        List<Object> quotaList = new ArrayList<Object>();
        List<Object> quotaList = new ArrayList<Object>();
@ -469,7 +465,7 @@ public class ReportController extends EnvelopRestEndpoint {
    }
    }
    //根据地区、期间查询分析明细列表,并导出
    //根据地区、期间查询分析明细列表,并导出
    @RequestMapping("/exportToExcel")
    @GetMapping("/exportToExcel")
    public void exportToExcel(HttpServletResponse response,String location,String startTime,String endTime){
    public void exportToExcel(HttpServletResponse response,String location,String startTime,String endTime){
        try {
        try {
            String fileName = "分析列表明细";
            String fileName = "分析列表明细";

+ 2 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/DictController.java

@ -5,9 +5,9 @@ import com.yihu.jw.entity.ehr.resource.RsDictionary;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.*;
@ -19,6 +19,7 @@ import java.util.*;
 */
 */
@RestController("resource-dict")
@RestController("resource-dict")
@RequestMapping("/resource/dict")
@RequestMapping("/resource/dict")
@Api( tags = {"网关-资源字典"})
public class DictController extends EnvelopRestEndpoint {
public class DictController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
@ -48,7 +49,6 @@ public class DictController extends EnvelopRestEndpoint {
    @RequestMapping("/searchCombo")
    @RequestMapping("/searchCombo")
    @ResponseBody
    public Envelop comboSearch(String searchParm, int page, int rows){
    public Envelop comboSearch(String searchParm, int page, int rows){
        try{
        try{
            String filters =  "code?"+searchParm+" g1;name?"+searchParm+";";
            String filters =  "code?"+searchParm+" g1;name?"+searchParm+";";

+ 0 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/MetaController.java

@ -5,7 +5,6 @@
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.util.excel.poi.AExcelReader;
//import com.yihu.jw.util.excel.poi.AExcelReader;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.MultiValueMap;
//import org.springframework.util.MultiValueMap;
//import org.springframework.util.StringUtils;
//import org.springframework.util.StringUtils;

+ 1 - 6
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportCategoryController.java

@ -15,15 +15,10 @@ import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.ArrayList;
@ -63,7 +58,7 @@ public class ReportCategoryController extends EnvelopRestEndpoint {
    }
    }
    @RequestMapping("/appConfig")
    @RequestMapping("/appConfig")
    public Envelop appConfig(String id, String dialogType, Model model) {
    public Envelop appConfig(String id, String dialogType) {
        try {
        try {
            String appIds = rsReportCategoryAppService.getAppIdByCategory(id);
            String appIds = rsReportCategoryAppService.getAppIdByCategory(id);
            return ObjEnvelop.getSuccess("获取成功",appIds);
            return ObjEnvelop.getSuccess("获取成功",appIds);

+ 726 - 888
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportController.java

@ -1,804 +1,305 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.yihu.ehr.constants.ErrorCode;
//import com.yihu.ehr.constants.ServiceApi;
//
//import com.yihu.fastdfs.FastDFSUtil;
//import com.yihu.jw.basic.quota.service.TjDimensionMainService;
//import com.yihu.jw.basic.quota.service.TjDimensionSlaveService;
//import com.yihu.jw.basic.quota.service.TjQuotaDimensionMainService;
//import com.yihu.jw.basic.quota.service.TjQuotaDimensionSlaveService;
//import com.yihu.jw.basic.resource.model.RsCategoryTypeTreeModel;
//import com.yihu.jw.basic.resource.model.RsResourcesModel;
//import com.yihu.jw.basic.resource.service.*;
//import com.yihu.jw.entity.ehr.quota.TjDimensionMain;
//import com.yihu.jw.entity.ehr.quota.TjDimensionSlave;
//import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionMain;
//import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionSlave;
//import com.yihu.jw.entity.ehr.resource.*;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.ehr.resource.MChartInfoModel;
//import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
//import com.yihu.jw.restmodel.ehr.resource.MRsReport;
//import com.yihu.jw.restmodel.ehr.resource.MRsResources;
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.ListEnvelop;
//import com.yihu.jw.restmodel.web.ObjEnvelop;
//import com.yihu.jw.restmodel.web.PageEnvelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.common.LogService;
//import com.yihu.jw.util.date.DateTimeUtil;
//import com.yihu.jw.util.http.HttpClientUtil;
//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.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.text.ParseException;
//import java.util.*;
//
//
///**
// * 资源报表管理 controller
// *
// * @author 张进军
// * @created 2017.8.15 19:18
// */
//@RestController("RsReportController")
//@RequestMapping("/resource/report")
//public class ReportController extends EnvelopRestEndpoint {
//
//    @Autowired
//    private RsResourceService rsResourceService;
//    @Autowired
//    private RsReportService rsReportService;
//    @Autowired
//    private RsResourceCategoryService rsCategoryService;
//    @Autowired
//    private RsReportViewService rsReportViewService;
//    @Autowired
//    private FastDFSUtil fastDFSUtil;
//    @Autowired
//    private RsResourceDefaultParamService resourceDefaultParamService;
//    @Autowired
//    private ResourceBrowseService resourceBrowseService;
//    @Autowired
//    private RsResourceQuotaService resourceQuotaService;
//    @Autowired
//    private TjQuotaDimensionMainService tjQuotaDimensionMainService;
//    @Autowired
//    private TjQuotaDimensionSlaveService tjQuotaDimensionSlaveService;
//    @Autowired
//    private TjDimensionMainService tjDimensionMainService;
//    @Autowired
//    private TjDimensionSlaveService tjDimensionSlaveService;
//
//    /**
//     * 展示明细
//     */
//    @RequestMapping(value = "detail")
//    public Envelop detail(Integer id) {
//        try {
//            if (id != null) {
//                RsReport rsReport = rsReportService.getById(id);
//                return ObjEnvelop.getSuccess("查询成功",rsReport);
//            }
//            return success("查询成功");
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 分页查询
//     */
//    @RequestMapping("/search")
//    public Envelop search(String codeName, String reportCategoryId, int page, int rows) {
//        Map<String, Object> params = new HashMap<>();
//        StringBuffer filters = new StringBuffer();
//
//        if (!StringUtils.isEmpty(codeName)) {
//            filters.append("code?" + codeName + " g1;name?" + codeName + " g1;");
//        }
//        if (!StringUtils.isEmpty(reportCategoryId)) {
//            filters.append("reportCategoryId=" + reportCategoryId + ";");
//        } else {
//            return success("查询成功");
//        }
//
package com.yihu.jw.basic.agadmin.controller.resource;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.basic.agadmin.service.ReportService;
import com.yihu.jw.basic.agadmin.service.ResourceBrowseControllerService;
import com.yihu.jw.basic.fileresource.service.FileResource;
import com.yihu.jw.basic.fileresource.service.FileResourceManager;
import com.yihu.jw.basic.quota.service.TjDimensionMainService;
import com.yihu.jw.basic.quota.service.TjDimensionSlaveService;
import com.yihu.jw.basic.quota.service.TjQuotaDimensionMainService;
import com.yihu.jw.basic.quota.service.TjQuotaDimensionSlaveService;
import com.yihu.jw.basic.resource.dao.RsReportDao;
import com.yihu.jw.basic.resource.model.RsCategoryTypeTreeModel;
import com.yihu.jw.basic.resource.service.*;
import com.yihu.jw.basic.util.FileUploadUtil;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.quota.TjDimensionMain;
import com.yihu.jw.entity.ehr.quota.TjDimensionSlave;
import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionMain;
import com.yihu.jw.entity.ehr.quota.TjQuotaDimensionSlave;
import com.yihu.jw.entity.ehr.resource.*;
import com.yihu.jw.restmodel.ehr.resource.MChartInfoModel;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.date.DateTimeUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.ParseException;
import java.util.*;
/**
 * 资源报表管理 controller
 *
 * @author 张进军
 * @created 2017.8.15 19:18
 */
@RestController("RsReportController")
@RequestMapping("/resource/report")
@Api(tags = {"网关-资源报表"})
public class ReportController extends EnvelopRestEndpoint {
    @Resource
    private FileResourceManager fileResourceManager;
    @Resource
    private RsResourceService rsResourceService;
    @Resource
    private RsReportService rsReportService;
    @Resource
    private RsReportDao rsReportDao;
    @Resource
    private RsResourceCategoryService rsCategoryService;
    @Resource
    private RsReportViewService rsReportViewService;
    @Resource
    private FastDFSUtil fastDFSUtil;
    @Resource
    private RsResourceDefaultParamService resourceDefaultParamService;
    @Resource
    private ResourceBrowseService resourceBrowseService;
    @Resource
    private RsResourceQuotaService resourceQuotaService;
    @Resource
    private TjQuotaDimensionMainService tjQuotaDimensionMainService;
    @Resource
    private TjQuotaDimensionSlaveService tjQuotaDimensionSlaveService;
    @Resource
    private TjDimensionMainService tjDimensionMainService;
    @Resource
    private TjDimensionSlaveService tjDimensionSlaveService;
    @Resource
    private ResourceBrowseControllerService resourceBrowseControllerService;
    @Resource
    private ReportService reportService;
    /**
     * 展示明细
     */
    @GetMapping(value = "detail")
    public Envelop detail(Integer id) {
        try {
            if (id != null) {
                RsReport rsReport = rsReportService.getById(id);
                return ObjEnvelop.getSuccess("查询成功",rsReport);
            }
            return success("查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 分页查询
     */
    @GetMapping("/search")
    public Envelop search(String codeName, String reportCategoryId, int page, int rows) {
        Map<String, Object> params = new HashMap<>();
        StringBuffer filters = new StringBuffer();
        if (!StringUtils.isEmpty(codeName)) {
            filters.append("code?" + codeName + " g1;name?" + codeName + " g1;");
        }
        if (!StringUtils.isEmpty(reportCategoryId)) {
            filters.append("reportCategoryId=" + reportCategoryId + ";");
        } else {
            return success("查询成功");
        }
        try {
            List<RsReport> rsReports = rsReportService.search(null, filters.toString(), null, page, rows);
            return PageEnvelop.getSuccessListWithPage("",rsReports,page,rows,rsReportService.getCount(filters.toString()));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 根据条件,获取视图树形数据(视图类别树下展示视图)
     */
    @GetMapping("/getViewsTreeData")
    public Envelop getViewsTreeData(String codeName, Integer reportId, HttpServletRequest request) {
        try {
            ListEnvelop envelop = new ListEnvelop();
            //获取到的顶级cda类别集合
            List<RsResourceCategory> categoryList = rsCategoryService.getRsCategoryByPid("");
            //顶级类别中符合条件的类别集合
            List<RsResourceCategory> mRsCategoriesSome = new ArrayList<>();
            //顶级类别中不符合条件的类别集合
            List<RsResourceCategory> mRsCategoriesOthers = new ArrayList<>();
            if (categoryList == null || categoryList.size() == 0){
                envelop.setStatus(-1);
                envelop.setMessage("没有匹配条件的资源类别!");
                return envelop;
            }
            List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
            if(StringUtils.isEmpty(codeName)){
                treeList = getRsCategoryTreeModelChild(categoryList);
                envelop.setDetailModelList(treeList);
                return envelop;
            }
            for(RsResourceCategory mRsCategory : categoryList){
                if(mRsCategory.getName().contains(codeName)){
                    mRsCategoriesSome.add(mRsCategory);
                    continue;
                }
                mRsCategoriesOthers.add(mRsCategory);
            }
            if (mRsCategoriesSome.size() != 0){
                treeList.addAll(getRsCategoryTreeModelChild(mRsCategoriesSome));
            }
            treeList .addAll(getRsCategoryTreeModelByName(mRsCategoriesOthers, codeName));
            this.setRsCategoryViews(treeList, reportId);
            envelop.setDetailModelList(treeList);
            return envelop;
        } catch (Exception e) {
            e.printStackTrace();
            LogService.getLogger(ReportController.class).error(e.getMessage());
            return failed("查询失败");
        }
    }
    // 设置视图类别拥有的视图
    private void setRsCategoryViews(List<RsCategoryTypeTreeModel> rsCategoryTypeTreeModelList, Integer reportId) throws Exception {
        RsCategoryTypeTreeModel rsCategoryTypeTreeModel;
        for (RsCategoryTypeTreeModel rsCategory : rsCategoryTypeTreeModelList) {
            List<RsResource> rsResourcesModelList = rsResourceService.search("categoryId=" + rsCategory.getId());
            for (RsResource rsResources : rsResourcesModelList) {
                if ((rsResources.getGrantType().equals("0"))) {
                    rsCategoryTypeTreeModel = new RsCategoryTypeTreeModel();
                    rsCategoryTypeTreeModel.setId(rsResources.getId());
                    rsCategoryTypeTreeModel.setName(rsResources.getName());
                    rsCategoryTypeTreeModel.setPid(rsCategory.getId());
                    RsReportView rsReportView = rsReportViewService.findByReportIdAndResourceId(reportId, rsResources.getId());
                    rsCategoryTypeTreeModel.setIschecked(rsReportView!=null);
                    rsCategory.getChildren().add(rsCategoryTypeTreeModel);
                }
            }
            if (rsCategory.getChildren() != null && rsCategory.getChildren().size() != 0) {
                setRsCategoryViews(rsCategory.getChildren(), reportId);
            }
        }
    }
    /**
     * 获取选择的报表视图
     */
    @RequestMapping("/getSelectedViews")
    public Envelop getSelectedViews(Integer reportId) {
        Map<String, Object> params = new HashMap<>();
        params.put("reportId", reportId);
        try {
            List<RsReportView> rsReportViews = rsReportViewService.findByReportId(reportId);
            return ListEnvelop.getSuccess("查询成功",rsReportViews);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 保存
     */
    @PostMapping("/save")
    public Envelop save(String data) {
        try {
            RsReport newRsReport = toEntity(data, RsReport.class);
            if (StringUtils.isEmpty(newRsReport.getCode())) {
                return failed("编码不能为空!");
            }
            if (StringUtils.isEmpty(newRsReport.getName())) {
                return failed("名称不能为空!");
            }
            if (newRsReport.getId() == null) {
                // 新增
                newRsReport = rsReportService.save(newRsReport);
                return ObjEnvelop.getSuccess("保存成功",newRsReport);
            } else {
                // 修改
                RsReport updateModel = rsReportService.getById(newRsReport.getId());
                updateModel.setCode(newRsReport.getCode());
                updateModel.setName(newRsReport.getName());
                updateModel.setReportCategoryId(newRsReport.getReportCategoryId());
                updateModel.setStatus(newRsReport.getStatus());
                updateModel.setRemark(newRsReport.getRemark());
                updateModel.setTemplatePath(newRsReport.getTemplatePath());
                updateModel.setShowType(newRsReport.getShowType());
                rsReportService.save(updateModel);
                return ObjEnvelop.getSuccess("保存成功",updateModel);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed("保存失败");
        }
    }
    /**
     * 删除
     */
    @PostMapping("/delete")
    public Envelop delete(Integer id) {
        try {
            rsReportDao.deleteById(id);
            return success("删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("删除失败");
        }
    }
    /**
     * 验证资源报表编码是否唯一
     */
    @GetMapping("/isUniqueCode")
    public Envelop isUniqueCode(@RequestParam Integer id, @RequestParam String code) {
        try {
            return ObjEnvelop.getSuccess("查询成功",rsReportService.isUniqueCode(id, code));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 验证资源报表名称是否唯一
     */
    @GetMapping("/isUniqueName")
    public Envelop isUniqueName(@RequestParam Integer id, @RequestParam String name) {
        try {
            return ObjEnvelop.getSuccess("查询成功",rsReportService.isUniqueName(id, name));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     * 列表:模版导入
     */
//    @RequestMapping("upload")
//    public Envelop upload(Integer id, String name, HttpServletRequest request) {
//        try {
//        try {
//            List<RsReport> rsReports = rsReportService.search(null, filters.toString(), null, page, rows);
//            return PageEnvelop.getSuccessListWithPage("",rsReports,page,rows,rsReportService.getCount(filters.toString()));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 根据条件,获取视图树形数据(视图类别树下展示视图)
//     */
//    @RequestMapping("/getViewsTreeData")
//    public Envelop getViewsTreeData(String codeName, Integer reportId, HttpServletRequest request) {
//        try {
//            ListEnvelop envelop = new ListEnvelop();
//            //获取到的顶级cda类别集合
//            List<RsResourceCategory> categoryList = rsCategoryService.getRsCategoryByPid("");
//            //顶级类别中符合条件的类别集合
//            List<RsResourceCategory> mRsCategoriesSome = new ArrayList<>();
//            //顶级类别中不符合条件的类别集合
//            List<RsResourceCategory> mRsCategoriesOthers = new ArrayList<>();
//            if (categoryList == null || categoryList.size() == 0){
//                envelop.setStatus(-1);
//                envelop.setMessage("没有匹配条件的资源类别!");
//                return envelop;
//            }
//            List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
//            if(StringUtils.isEmpty(codeName)){
//                treeList = getRsCategoryTreeModelChild(categoryList);
//                envelop.setDetailModelList(treeList);
//                return envelop;
//            }
//            for(RsResourceCategory mRsCategory : categoryList){
//                if(mRsCategory.getName().contains(codeName)){
//                    mRsCategoriesSome.add(mRsCategory);
//                    continue;
//                }
//                mRsCategoriesOthers.add(mRsCategory);
//            }
//            if (mRsCategoriesSome.size() != 0){
//                treeList.addAll(getRsCategoryTreeModelChild(mRsCategoriesSome));
//            }
//            treeList .addAll(getRsCategoryTreeModelByName(mRsCategoriesOthers, codeName));
//            this.setRsCategoryViews(treeList, reportId);
//
//            envelop.setDetailModelList(treeList);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            LogService.getLogger(ReportController.class).error(e.getMessage());
//            return failed("查询失败");
//        }
//    }
//
//    // 设置视图类别拥有的视图
//    private void setRsCategoryViews(List<RsCategoryTypeTreeModel> rsCategoryTypeTreeModelList, Integer reportId) throws Exception {
//        RsCategoryTypeTreeModel rsCategoryTypeTreeModel;
//        for (RsCategoryTypeTreeModel rsCategory : rsCategoryTypeTreeModelList) {
//            List<RsResource> rsResourcesModelList = rsResourceService.search("categoryId=" + rsCategory.getId());
//            for (RsResource rsResources : rsResourcesModelList) {
//                if ((rsResources.getGrantType().equals("0"))) {
//                    rsCategoryTypeTreeModel = new RsCategoryTypeTreeModel();
//                    rsCategoryTypeTreeModel.setId(rsResources.getId());
//                    rsCategoryTypeTreeModel.setName(rsResources.getName());
//                    rsCategoryTypeTreeModel.setPid(rsCategory.getId());
//                    RsReportView rsReportView = rsReportViewService.findByReportIdAndResourceId(reportId, rsResources.getId());
//                    rsCategoryTypeTreeModel.setIschecked(rsReportView!=null);
//                    rsCategory.getChildren().add(rsCategoryTypeTreeModel);
//                }
//            }
//            if (rsCategory.getChildren() != null && rsCategory.getChildren().size() != 0) {
//                setRsCategoryViews(rsCategory.getChildren(), reportId);
//            }
//        }
//    }
//
//    /**
//     * 获取选择的报表视图
//     */
//    @RequestMapping("/getSelectedViews")
//    public Envelop getSelectedViews(Integer reportId) {
//        Map<String, Object> params = new HashMap<>();
//        params.put("reportId", reportId);
//        try {
//            List<RsReportView> rsReportViews = rsReportViewService.findByReportId(reportId);
//            return ListEnvelop.getSuccess("查询成功",rsReportViews);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 保存
//     */
//    @RequestMapping("/save")
//    public Envelop save(String data) {
//        try {
//            RsReport newRsReport = toEntity(data, RsReport.class);
//            if (StringUtils.isEmpty(newRsReport.getCode())) {
//                return failed("编码不能为空!");
//            }
//            if (StringUtils.isEmpty(newRsReport.getName())) {
//                return failed("名称不能为空!");
//            }
//
//            if (newRsReport.getId() == null) {
//                // 新增
//                newRsReport = rsReportService.save(newRsReport);
//                return ObjEnvelop.getSuccess("保存成功",newRsReport);
//            } else {
//                // 修改
//                RsReport updateModel = rsReportService.getById(newRsReport.getId());
//                updateModel.setCode(newRsReport.getCode());
//                updateModel.setName(newRsReport.getName());
//                updateModel.setReportCategoryId(newRsReport.getReportCategoryId());
//                updateModel.setStatus(newRsReport.getStatus());
//                updateModel.setRemark(newRsReport.getRemark());
//                updateModel.setTemplatePath(newRsReport.getTemplatePath());
//                updateModel.setShowType(newRsReport.getShowType());
//
//                return ObjEnvelop.getSuccess("保存成功",updateModel);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("保存失败");
//        }
//    }
//
//    /**
//     * 删除
//     */
//    @RequestMapping("/delete")
//    public Envelop delete(String id) {
//        try {
//            rsReportService.delete(id);
//            return success("删除成功");
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("删除失败");
//        }
//    }
//
//    /**
//     * 验证资源报表编码是否唯一
//     */
//    @RequestMapping("/isUniqueCode")
//    public Envelop isUniqueCode(@RequestParam Integer id, @RequestParam String code) {
//        try {
//            return ObjEnvelop.getSuccess("查询成功",rsReportService.isUniqueCode(id, code));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 验证资源报表名称是否唯一
//     */
//    @RequestMapping("/isUniqueName")
//    public Envelop isUniqueName(@RequestParam Integer id, @RequestParam String name) {
//        try {
//            return ObjEnvelop.getSuccess("查询成功",rsReportService.isUniqueName(id, name));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("查询失败");
//        }
//    }
//
//    /**
//     * 列表:模版导入
//     */
////    @RequestMapping("upload")
////    public Envelop upload(Integer id, String name, HttpServletRequest request) {
////        try {
////            Envelop result = new Envelop();
////
////            Map<String, Object> uploadFileParams = FileUploadUtil.getParams(request.getInputStream(), name);
////            String storagePath = uploadFileParams.size() == 0 ? "" : HttpClientUtil.doPost(comUrl + "/filesReturnUrl", uploadFileParams, username, password);
////
////            String urlGet = comUrl + ServiceApi.Resources.RsReportPrefix + id;
////            String envelopGetStr = HttpClientUtil.doGet(urlGet, username, password);
////            Envelop envelopGet = objectMapper.readValue(envelopGetStr, Envelop.class);
////            RsReportModel updateModel = getEnvelopModel(envelopGet.getObj(), RsReportModel.class);
////            updateModel.setTemplatePath(storagePath);
////
////            Map<String, Object> params = new HashMap<>();
////            params.put("rsReport", objectMapper.writeValueAsString(updateModel));
////            String envelopUpdateStr = HttpClientUtil.doPut(comUrl + ServiceApi.Resources.RsReportSave, params, username, password);
////
////            Envelop envelopUpdate = objectMapper.readValue(envelopUpdateStr, Envelop.class);
////            if (envelopUpdate.isSuccessFlg()) {
////                result.setSuccessFlg(true);
////                result.setObj(storagePath);
////            } else {
////                result.setSuccessFlg(false);
////                result.setErrorMsg("文件保存失败!");
////            }
////            return result;
////        } catch (Exception e) {
////            e.printStackTrace();
////            return failed("导入模版发生异常");
////        }
////    }
//
//    /**
//     * 保存资源配置
//     */
//    @RequestMapping("saveSetting")
//    public Envelop saveSetting(@RequestParam Integer reportId, @RequestParam String data) {
//        try {
//            List<RsReportView> rsReportViewList = objectMapper.readValue(data, new TypeReference<List<RsReportView>>(){});
//            rsReportViewService.save(reportId, rsReportViewList);
//            return success("保存成功");
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("保存发生异常");
//        }
//    }
//
//    /**
//     * 获取报表模版内容及其各个图形数据
//     */
//    @RequestMapping("getTemplateData")
//    public Envelop getTemplateData(@RequestParam String reportCode, HttpServletRequest request) {
//        Envelop envelop = new Envelop();
//        Map<String, Object> resultMap = new HashMap<>();
//        List<Map<String, Object>> viewInfos = new ArrayList<>();
//        try {
//            // 获取报表模版内容
//            RsReport rsReport = rsReportService.getByCode(reportCode);
//            if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
//                return failed("模版未找到");
//            }
//            String[] paths = rsReport.getTemplatePath().split(":");
//            byte[] bytes = fastDFSUtil.download(paths[0], paths[1]);
//            String templateContent = new String(bytes, "UTF-8");
//            resultMap.put("templateContent", templateContent);
//
//            // 获取报表视图
//            RsReport report = rsReportService.getByCode(reportCode);
//            List<RsReportView> rsReportViews = rsReportViewService.findByReportId(report.getId());
//
//            // 获取图形配置
//            for (RsReportView view : rsReportViews) {
//                RsResource rsResource = rsResourceService.getResourceById(view.getResourceId());
//                if (rsResource.getEchartType().equals("twoDimensional")){//特殊二维表报表
//                    //数据另外查询
//                } else {
//                    List<RsResourceDefaultParam> rsDefaultParams = resourceDefaultParamService.search("resourcesId=" + view.getResourceId() + ";paramKey=q");
//                    Map<String, Object> conditions = translateViewCondition(rsResource.getDataSource(), rsDefaultParams);
//                    Map<String, Object> viewInfo = new HashMap<>();
//                    viewInfo.put("conditions", conditions); // 视图数据过滤条件。
//                    List<Map<String, Object>> options = new ArrayList<>();
//                    if (rsResource.getDataSource() == 1) {
//                        // 档案视图场合
//                        viewInfo.put("type", "record");
//                        viewInfo.put("resourceCode", rsResource.getCode());
//                        viewInfo.put("searchParams", rsDefaultParams.size() > 0 ? rsDefaultParams.get(0).getParamValue() : "[]");
//                        // 获取展示的列名
//                        List<MRsColumnsModel>  mRsColumnsModelList = resourceBrowseService.getResourceMetadata(rsResource.getCode(), "*");
//                        if (mRsColumnsModelList != null&&mRsColumnsModelList.size()>0) {
//                            viewInfo.put("columns", mRsColumnsModelList);
//                        }
//                        viewInfos.add(viewInfo);
//                    } else if (rsResource.getDataSource() == 2) {
//                        // 指标视图场合
//                        viewInfo.put("type", "quota");
//                        viewInfo.put("resourceId", view.getResourceId());
//                        String quotaFilter = "";
//                        String dimension = "";
//
//                        List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + rsResource.getId());
//                        if(list != null && list.size() > 0){
//                            String quotaCodestr  = "";
//                            String quotaIdstr  = "";
//                            String charstr = "";
//                            int charTypeNum = 0;
//                            boolean lineOrBarFlag = true;
//                            boolean pieFlag = true;
//                            for (RsResourceQuota m : list) {
//                                quotaCodestr = quotaCodestr + m.getQuotaCode() +",";
//                                quotaIdstr = quotaIdstr + m.getQuotaId() +",";
//                                charstr = charstr + m.getQuotaChart() +",";
//                                if(lineOrBarFlag && (m.getQuotaChart() == 1 || m.getQuotaChart() == 2)){
//                                    charTypeNum ++;
//                                    lineOrBarFlag = false;
//                                }else if(pieFlag && m.getQuotaChart() == 3) {
//                                    charTypeNum ++;
//                                    pieFlag = false;
//                                }
//                            }
//
//                            List<Map<String, String>> synthesiseDimensionMap = getTjQuotaSynthesiseDimension(quotaCodestr);
//                            Map<String, String> dimensionMap = new LinkedHashMap<>();
//                            String firstDimension = "";
//                            boolean firstFlag = true;
//                            for(Map<String, String> map :synthesiseDimensionMap){
//                                String name = "";
//                                String code = "";
//                                for(String key :map.keySet()){
//                                    if(key.equals("name")){
//                                        name = map.get(key);
//                                    }else{
//                                        code = map.get(key);
//                                    }
//                                }
//                                dimensionMap.put(code,name);
//                                if(firstFlag){
//                                    firstDimension = code;
//                                    firstFlag =  false;
//                                }
//                            }
//                            if(StringUtils.isEmpty(dimension) || dimension.equals(" ")){
//                                String defaultDimension = rsResource.getDimension();
//                                if (!org.apache.commons.lang.StringUtils.isEmpty(defaultDimension)) {
//                                    dimension = rsResource.getDimension();
//                                } else {
//                                    dimension = firstDimension;
//                                }
//                            }
//
//                            if(charTypeNum > 1){
//                                return failed("视图由多个指标组成时,预览图形支持 多指标都属于同一类型,混合型目前支持‘柱状+柱状’,请确认图表展示类型!");
//                            }else {
//                                if(StringUtils.isNotEmpty(rsResource.getEchartType()) && rsResource.getEchartType().equals("radar")){
//                                    chartInfoModel = getQuotaRadarGraphicReports(quotaIdstr, filter, dimension, rsResource.getName());
//                                }else if(StringUtils.isNotEmpty(rsResource.getEchartType()) && rsResource.getEchartType().equals("nestedPie")){
//                                    chartInfoModel = tjQuotaJobClient.getQuotaNestedPieGraphicReports(resourceId, quotaIdstr, filter, dimension, rsResource.getName());
//                                }else {
//                                    //修改后
//                                    String chart = "";
//                                    if(org.apache.commons.lang.StringUtils.isNotEmpty(rsResource.getEchartType())){
//                                        chart = rsResource.getEchartType();
//                                        if(chart.equals("bar")){
//                                            chart ="1";
//                                        }else if(chart.equals("line")){
//                                            chart ="2";
//                                        }else if(chart.equals("pie")){
//                                            chart ="3";
//                                        } else if ("mixed".equals(chart)) {
//                                            chart = charstr;
//                                        }
//                                    }else{
//                                        chart = charstr;
//                                    }
//                                    if(org.apache.commons.lang.StringUtils.isEmpty(dimension) && org.apache.commons.lang.StringUtils.isNotEmpty(rsResource.getDimension())){
//                                        dimension = rsResource.getDimension();
//                                    }else if (org.apache.commons.lang.StringUtils.isEmpty(dimension)) {
//                                        dimension =  firstDimension;
//                                    }
//                                    chartInfoModel = tjQuotaJobClient.getMoreQuotaGraphicReportPreviews(quotaIdstr, chart, filter, dimension , mRsResources.getName(), top, objectMapper.writeValueAsString(mRsResources));
//                                }
//                                if(chartInfoModel != null){
//                                    chartInfoModel.setResourceId(resourceId);
//                                    chartInfoModel.setDimensionMap(dimensionMap);
//                                    chartInfoModel.setFirstDimension(firstDimension);
//                                    envelop.setObj(chartInfoModel);
//                                    envelop.setSuccessFlg(true);
//                                }else {
//                                    envelop.setSuccessFlg(false);
//                                    envelop.setErrorMsg("视图数据查询错误");
//                                }
//                            }
//                        }else{
//                            envelop.setErrorMsg("视图中无指标,请确认!");
//                        }
//                        Map<String, Object> option = new HashMap<>();
//                        option.put("resourceCode", chartInfoModel.getResourceCode());
//                        option.put("resourceId", chartInfoModel.getResourceId());
//                        option.put("dimensionList", chartInfoModel.getDimensionMap());
//                        option.put("option", chartInfoModel.getOption());
//                        options.add(option);
//                        viewInfo.put("options", options); // 视图包含的指标echart图形的option。
//                        viewInfos.add(viewInfo);
//                    }
//                }
//            }
//            resultMap.put("viewInfos", viewInfos);
//            envelop.setObj(resultMap);
//            envelop.setSuccessFlg(true);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("获取报表数据发生异常");
//        }
//    }
//
//    public Envelop getQuotaRadarGraphicReports(String resourceId,String quotaFilter,String dimension,
//            @ApiParam(name = "title", value = "名称", defaultValue = "")String title) {
//        String filter = filterHandle(quotaFilter);
//        Envelop envelop = new Envelop();
//        MChartInfoModel chartInfoModel = new MChartInfoModel();
//        chartInfoModel.setResourceId(resourceId);
//        try {
//            RsResource rsResource = rsResourceService.getResourceById(resourceId);
//            if(rsResource==null){
//                return failed("视图不存在,请确认!");
//            }
//            List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + rsResource.getId());
//            String quotaIdStr = "";
//            if (null != list && list.size() > 0) {
//                for (RsResourceQuota rsResourceQuota : list) {
//                    quotaIdStr += rsResourceQuota.getQuotaId() + ",";
//                }
//            }
//            chartInfoModel = tjQuotaJobClient.getQuotaRadarGraphicReports(quotaIdStr, filter, dimension, title);
//            chartInfoModel.setFirstDimension(dimension);
//            chartInfoModel.setResourceId(resourceId);
//            envelop.setObj(chartInfoModel);
//            envelop.setSuccessFlg(true);
//        } catch (Exception e) {
//            envelop.setErrorMsg("获取图表出错!");
//        }
//        return envelop;
//    }
//
//    public Envelop getQuotaNestedPieGraphicReports(String resourceId, String filter,String dimension,String title) {
//        Envelop envelop = new Envelop();
//        MChartInfoModel chartInfoModel = new MChartInfoModel();
//        chartInfoModel.setResourceId(resourceId);
//        envelop.setObj(chartInfoModel);
//        envelop.setSuccessFlg(false);
//        String filters = filterHandle(filter);
//        try {
//            RsResource rsResource = rsResourceService.getResourceById(resourceId);
//            if(rsResource==null){
//                return failed("视图不存在,请确认!");
//            }
//            List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + resourceId);
//            String quotaIdStr = "";
//            if (null != list && list.size() > 0) {
//                for (RsResourceQuota ResourceQuota : list) {
//                    quotaIdStr += ResourceQuota.getQuotaId() + ",";
//                }
//            }
//            chartInfoModel = tjQuotaJobClient.getQuotaNestedPieGraphicReports(resourceId, quotaIdStr, filters, dimension, title);
//            chartInfoModel.setFirstDimension(dimension);
//            chartInfoModel.setResourceId(resourceId);
//            envelop.setObj(chartInfoModel);
//            envelop.setSuccessFlg(true);
//        } catch (Exception e) {
//            envelop.setErrorMsg("获取图表出错!");
//        }
//        return envelop;
//    }
//
//    private String filterHandle(String quotaFilter) {
//        String filter = "";
//        if(org.apache.commons.lang.StringUtils.isNotEmpty(quotaFilter)){
//            String [] quotaFilters = quotaFilter.split(";");
//            for(int i = 0;i < quotaFilters.length; i++){
//                String [] keyVal = quotaFilters[i].split("=");
//                if(keyVal[i].length()>1){
//                    if(i==0){
//                        filter = keyVal[0] + "='" + keyVal[1] +"' ";
//                    }else {
//                        filter = filter + " and "  + keyVal[0] + "='" + keyVal[1] +"' ";
//                    }
//                }
//            }
//        }
//        return filter;
//    }
//
//    private List<Map<String,String>>  getTjQuotaSynthesiseDimension(String quotaCodes) {
//        List<TjQuotaDimensionMain> tjQuotaDimensionMains = null;
//        List<TjQuotaDimensionSlave> tjQuotaDimensionSlaves = null;
//        //保存指标的 ID 和 所有维度的集合
//        Map<String,Map<String,String>> dimensionMap = new LinkedHashMap();
//        String [] quotaCode = quotaCodes.split(",");
//        for(int i=0 ; i < quotaCode.length ;i++){
//            Map<String,String> map = new LinkedHashMap<>();
//            tjQuotaDimensionMains = tjQuotaDimensionMainService.getTjQuotaDimensionMainByCode(quotaCode[i]);
////            int main = 1;
//            for(TjQuotaDimensionMain tjQuotaDimensionMain : tjQuotaDimensionMains){
//                TjDimensionMain tjDimensionMain = tjDimensionMainService.getTjDimensionMainByCode(tjQuotaDimensionMain.getMainCode());
//                if(tjDimensionMain !=null){
//                    map.put(tjDimensionMain.getCode(),tjDimensionMain.getName() + "-" + tjDimensionMain.getCode());
//                }
////                main ++;
//            }
//            tjQuotaDimensionSlaves = tjQuotaDimensionSlaveService.getTjQuotaDimensionSlaveByCode(quotaCode[i]);
//
//            int slave = 1;
//            for(TjQuotaDimensionSlave tjQuotaDimensionSlave : tjQuotaDimensionSlaves){
//                TjDimensionSlave tjDimensionSlave =  tjDimensionSlaveService.getTjDimensionSlaveByCode(tjQuotaDimensionSlave.getSlaveCode());
//                if(tjDimensionSlave != null){
//                    map.put(tjDimensionSlave.getCode(), tjDimensionSlave.getName()+"-slaveKey" + slave);//第几个维度
//                }
//                slave ++;
//            }
//            dimensionMap.put(quotaCode[i],map);
//        }
//
//        //取出第一个指标的所有维度
//        Map<String,String> tempMap = new LinkedHashMap();
//        for(String quotaCodeKey:dimensionMap.keySet() ){
//            Map<String,String> codeMap = dimensionMap.get(quotaCodeKey);
//            for(String dimenCode: codeMap.keySet()){
//                tempMap.put(dimenCode, codeMap.get(dimenCode));
//            }
//            break;
//        }
//
//        //用于保存共同交集的指标 key 保存交集的维度code
//        //value 保存 此维度在每个指标统计的结果集中对应的字段名称
//        Map<String,Map<String,String>> synthesiseMap = new LinkedHashMap<>();
//
//        Map<String,String> saveModelMap = new LinkedHashMap();
//        //其他指标与第一个指标维度对比,如果在第一个指标中都存在 交集维度
//        for(String tempDimenCode:tempMap.keySet() ){
//            int num = 0;
//            String quotaCodeStr = "";
//            for(String keyCode:dimensionMap.keySet() ){
//                quotaCodeStr = keyCode;
//                Map<String,String> codeMap = dimensionMap.get(keyCode);
//                for(String code: codeMap.keySet()){
//                    if( code.equals(tempDimenCode) &&  tempMap.get(tempDimenCode).equals(codeMap.get(code))){
//                        saveModelMap.put(quotaCodeStr + "-"+ tempDimenCode ,  tempMap.get(tempDimenCode) );
//                        //指标code + 维度编码 ->  科室-slaveKey2
//                        num ++;
//                    }
//                }
//            }
//            if(num == dimensionMap.size()){
//                Map<String,String> modelCloumnMap = new LinkedHashMap();
//                modelCloumnMap.put("name",tempMap.get(tempDimenCode).split("-")[0]);
//                for(String keyCode:dimensionMap.keySet() ){
//                    if(saveModelMap.containsKey(keyCode+"-"+ tempDimenCode)) {
//                        String str = keyCode+"-"+ tempDimenCode;
//                        if(saveModelMap.get(str).contains(tempDimenCode)){
//                            modelCloumnMap.put(keyCode,tempDimenCode);
//                        }
//                        if(saveModelMap.get(str).contains("slaveKey")){
//                            modelCloumnMap.put(keyCode,saveModelMap.get(str).split("-")[1]);
//                        }
//                    }
//                }
//                synthesiseMap.put(tempDimenCode,modelCloumnMap);
//            }
//        }
//
//        List<Map<String,String>> resultList = new ArrayList<>();
//        for(String key : synthesiseMap.keySet()){
//            resultList.add(synthesiseMap.get(key));
//        }
//        return  resultList;
//    }
//
//    @RequestMapping("getRsQuotaPreview")
//    public Envelop getRsQuotaPreview(@RequestParam String resourceId, HttpServletRequest request) {
//        Envelop envelop = new Envelop();
//        List<Map<String, Object>> options = new ArrayList<>();
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.clear();
//            params.put("resourceId", resourceId);
//            List<String> userOrgList  = getUserOrgSaasListRedis(request);
//            params.put("userOrgList", userOrgList);
//            params.put("quotaFilter", "");
//            String chartInfoStr = HttpClientUtil.doGet(comUrl + ServiceApi.Resources.GetRsQuotaPreview, params, username, password);
//            Envelop envelop1 = objectMapper.readValue(chartInfoStr, Envelop.class);
//            String s = objectMapper.writeValueAsString((HashMap<String,String>)envelop1.getObj());
//            MChartInfoModel chartInfoModel = objectMapper.readValue(s,MChartInfoModel.class);
//
//            Map<String, Object> option = new HashMap<>();
//            option.put("resourceCode", chartInfoModel.getResourceCode());
//            option.put("resourceId", chartInfoModel.getResourceId());
//            option.put("option", chartInfoModel.getOption());
//            options.add(option);
//            envelop.setSuccessFlg(true);
//            envelop.setDetailModelList(options);
//        }catch (Exception e){
//            e.printStackTrace();
//            return failed("获取报表数据发生异常");
//        }
//        return envelop;
//    }
//
//    /**
//     * 获取报表 联动图形数据
//     * @param reportCode 报表code
//     * @param linkageResourceIdStr 联动视图Id串,多个用;拼接    改为只用于一个视图查询
//     * @param linkageFilter  联动视图条件,多个用;拼接 town=361102;quotaDate >= '2018-03-01' and quotaDate <= '2018-03-31'
//     * @param linkageDimension  联动维度
//     */
//    @RequestMapping("/getLinkageTemplateData")
//    public Envelop getLinkageTemplateData(@RequestParam(name="reportCode",required=false) String reportCode,
//                                         @RequestParam(name="linkageResourceIdStr",required=true) String linkageResourceIdStr,
//                                         @RequestParam(name="linkageFilter",required=false) String linkageFilter,
//                                         @RequestParam(name="linkageDimension",required=false)String linkageDimension,
//                                         @RequestParam(name="limitCondition",required=false)String limitCondition) {
//        String filter = "";
//
//        if(StringUtils.isNotEmpty(linkageFilter)){
//            String [] quotaFilters = linkageFilter.split(";");
//            for(int i = 0;i < quotaFilters.length; i++){
//                if(i == 0){
//                    filter = quotaFilters[0];
//                }else{
//                    filter += " and " + quotaFilters[i];
//                }
//            }
//        }
//        return reportService.getTemplateData(reportCode,linkageResourceIdStr,filter,linkageDimension, limitCondition);
//    }
//
//    /**
//     * 转换视图数据筛选条件
//     */
//    private Map<String, Object> translateViewCondition(Integer type, List<RsResourceDefaultParam> queryList) throws IOException, ParseException {
//        Map<String, Object> conditions = new HashMap<>();
//        if (type == 1) {
//            // 档案视图场合
//            for (int i = 0; i < queryList.size(); i++) {
//                List<Map<String, String>> paramList = objectMapper.readValue(queryList.get(i).getParamValue(), List.class);
//                for (Map<String, String> filter : paramList) {
//                    String field = filter.get("field").toString();
//                    String condition = filter.get("condition").toString();
//                    String value = filter.get("value").toString();
//                    if ("event_date".equals(field)) {
//                        // 期间
//                        String date = DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(value));
//                        if (condition.contains(">")) {
//                            conditions.put("startDate", date);
//                        } else if (condition.contains("<")) {
//                            conditions.put("endDate", date);
//                        }
//                    }
//                    if ("EHR_000241".equals(field)) {
//                        // 地区
//                        conditions.put("area", value);
//                    }
//                }
//            }
//        } else if (type == 2) {
//            // 指标视图场合
//            for (int i = 0; i < queryList.size(); i ++) {
//                Map<String, String> filter = objectMapper.readValue(queryList.get(i).getParamValue(), Map.class);
//                if (filter.get("startTime") != null) {
//                    // 起始日期
//                    String date = filter.get("startTime").toString();
//                    conditions.put("startDate", DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(date)));
//                }
//                if (filter.get("endTime") != null) {
//                    // 终止日期
//                    String date = filter.get("endTime").toString();
//                    conditions.put("endDate", DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(date)));
//                }
//                // 地区
//                String area = "";
//                if (filter.get("province") != null) {
//                    area += filter.get("province").toString();
//                }
//                if (filter.get("city") != null) {
//                    area += filter.get("city").toString();
//                }
//                if (filter.get("town") != null) {
//                    area += filter.get("town").toString();
//                }
//                conditions.put("area", area);
//            }
//        }
//        return conditions;
//    }
//
//    /**
//     * 生成模板
//     * @param id
//     * @param content
//     * @return
//     */
//    @RequestMapping("/uploadTemplate")
//    public Envelop uploadTemplate(Integer id, String content, String reportData, String position) {
//        try {
//            saveSetting(id, reportData);
//            Envelop result = new Envelop();
//            Envelop result = new Envelop();
//            String filePath = this.getClass().getResource("/").getPath() + "temp/";
//            String fileName = System.currentTimeMillis() + "template.js";
//            // 生成模板
//            FileUploadUtil.createFile(filePath, fileName, content);
//            FileInputStream inputStream = new FileInputStream(filePath + fileName);
//            Map<String, Object> uploadFileParams = FileUploadUtil.getParams(inputStream, fileName);
//
//            Map<String, Object> uploadFileParams = FileUploadUtil.getParams(request.getInputStream(), name);
//            String storagePath = uploadFileParams.size() == 0 ? "" : HttpClientUtil.doPost(comUrl + "/filesReturnUrl", uploadFileParams, username, password);
//            String storagePath = uploadFileParams.size() == 0 ? "" : HttpClientUtil.doPost(comUrl + "/filesReturnUrl", uploadFileParams, username, password);
//
//
//            String urlGet = comUrl + ServiceApi.Resources.RsReportPrefix + id;
//            String urlGet = comUrl + ServiceApi.Resources.RsReportPrefix + id;
@ -806,14 +307,10 @@
//            Envelop envelopGet = objectMapper.readValue(envelopGetStr, Envelop.class);
//            Envelop envelopGet = objectMapper.readValue(envelopGetStr, Envelop.class);
//            RsReportModel updateModel = getEnvelopModel(envelopGet.getObj(), RsReportModel.class);
//            RsReportModel updateModel = getEnvelopModel(envelopGet.getObj(), RsReportModel.class);
//            updateModel.setTemplatePath(storagePath);
//            updateModel.setTemplatePath(storagePath);
//            // 设置报表中视图和位置的关系
//            updateModel.setPosition(position);
//
//
//            Map<String, Object> params = new HashMap<>();
//            Map<String, Object> params = new HashMap<>();
//            params.put("rsReport", objectMapper.writeValueAsString(updateModel));
//            params.put("rsReport", objectMapper.writeValueAsString(updateModel));
//            String envelopUpdateStr = HttpClientUtil.doPut(comUrl + ServiceApi.Resources.RsReportSave, params, username, password);
//            String envelopUpdateStr = HttpClientUtil.doPut(comUrl + ServiceApi.Resources.RsReportSave, params, username, password);
//            // 删除临时文件
//            FileUploadUtil.delDir(filePath);
//
//
//            Envelop envelopUpdate = objectMapper.readValue(envelopUpdateStr, Envelop.class);
//            Envelop envelopUpdate = objectMapper.readValue(envelopUpdateStr, Envelop.class);
//            if (envelopUpdate.isSuccessFlg()) {
//            if (envelopUpdate.isSuccessFlg()) {
@ -821,94 +318,435 @@
//                result.setObj(storagePath);
//                result.setObj(storagePath);
//            } else {
//            } else {
//                result.setSuccessFlg(false);
//                result.setSuccessFlg(false);
//                result.setErrorMsg("保存失败!");
//                result.setErrorMsg("文件保存失败!");
//            }
//            }
//            return result;
//            return result;
//        } catch (Exception e) {
//        } catch (Exception e) {
//            e.printStackTrace();
//            e.printStackTrace();
//            return failed("生成模版发生异常");
//        }
//    }
//
//    @RequestMapping("/getPositionMapByCode")
//    public Envelop getPositionByCode(String code) throws Exception {
//        Map<String, Object> params = new HashMap<>();
//        params.put("code", code);
//        String chartInfoStr = HttpClientUtil.doGet(comUrl + "/resources/report/getPositionMapByCode", params, username, password);
//        return chartInfoStr;
//    }
//
//    @RequestMapping("/getTemplateContent")
//    public Envelop getTemplateContent(String reportCode) {
//        Map<String, Object> params = new HashMap<>();
//        try {
//            // 获取报表模版内容
//            params.put("reportCode", reportCode);
//            String templateContent = HttpClientUtil.doGet(comUrl + ServiceApi.Resources.RsReportTemplateContent, params, username, password);
//            return templateContent ;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return "";
//        }
//    }
//
//
//    /**
//     *
//     * 根据父级信息获取全部的子级信息(树形model)
//     * @param info 父级信息
//     * @return 全部子级信息
//     */
//    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelChild(List<RsResourceCategory> info) {
//        List<RsCategoryTypeTreeModel> treeInfo = new ArrayList<>();
//        for (int i = 0; i < info.size(); i++) {
//            RsResourceCategory typeInfo = info.get(i);
//            RsCategoryTypeTreeModel tree = convertToModel(typeInfo, RsCategoryTypeTreeModel.class);
//            List<RsResourceCategory> categoryListChild = rsCategoryService.getRsCategoryByPid(typeInfo.getId());
//            List<RsCategoryTypeTreeModel> listChildTree = getRsCategoryTreeModelChild(categoryListChild);
//            tree.setChildren(listChildTree);
//            treeInfo.add(tree);
//        }
//        return treeInfo;
//    }
//
//    /**
//     * 递归不满足的父级类别集合的子集中满足条件TreeModel集合的方法
//     * @param mRsCategories 不符合的父级类别的集合
//     * @param name
//     * @return
//     */
//    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelByName(List<RsResourceCategory> mRsCategories, String name) throws ParseException {
//        //结构:treeList 包含treeModel,treeModel包含listOfParent
//        List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
//        for(RsResourceCategory mRsCategory:mRsCategories){
//            List<RsCategoryTypeTreeModel> childList = new ArrayList<>();
//            RsCategoryTypeTreeModel treeModel = convertToModel(mRsCategory,RsCategoryTypeTreeModel.class);
//            String pid = mRsCategory.getId();
//            //获取所有下一级cda类别
//            List<RsResourceCategory> listAll = rsCategoryService.getRsCategoryByPid(pid);
//            if(listAll.size() == 0){
//                continue;
//            }
//            //获取所有下一级符合要求的资源类别
//            String filters ="pid="+pid+";name?"+name;
//
//            //modify by cws
//            List<RsResourceCategory> listSome = rsCategoryService.search(filters);
//            //List<MRsCategory> listSome = (List<MRsCategory>)responseEntity.getBody();
//            if(listSome.size()!=0){
//                childList.addAll(getRsCategoryTreeModelChild(listSome));
//            }
//            //取剩下不符合要求的进行递归
//            listAll.removeAll(listSome);
//            if(listAll.size() != 0){
//                childList.addAll(getRsCategoryTreeModelByName(listAll, name));
//            }
//            if(childList.size() != 0){
//                treeModel.setChildren(childList);
//                treeList.add(treeModel);
//            }
//            return failed("导入模版发生异常");
//        }
//        }
//        return treeList;
//    }
//    }
//}
    /**
     * 保存资源配置
     */
    @PostMapping("saveSetting")
    public Envelop saveSetting(@RequestParam Integer reportId, @RequestParam String data) {
        try {
            List<RsReportView> rsReportViewList = objectMapper.readValue(data, new TypeReference<List<RsReportView>>(){});
            rsReportViewService.save(reportId, rsReportViewList);
            return success("保存成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("保存发生异常");
        }
    }
    /**
     * 获取报表模版内容及其各个图形数据
     */
    @GetMapping("getTemplateData")
    public Object getTemplateData(@RequestParam String reportCode, HttpServletRequest request) {
        Envelop envelop = new Envelop();
        Map<String, Object> params = new HashMap<>();
        Map<String, Object> resultMap = new HashMap<>();
        List<Map<String, Object>> viewInfos = new ArrayList<>();
        try {
            // 获取报表模版内容
            params.put("reportCode", reportCode);
            RsReport rsReport = rsReportService.getByCode(reportCode);
            if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
                return failed("模版未找到");
            }
            String[] paths = rsReport.getTemplatePath().split(":");
            byte[] bytes = fastDFSUtil.download(paths[0], paths[1]);
            String templateContent = new String(bytes, "UTF-8");
            resultMap.put("templateContent", templateContent);
            // 获取报表视图
            RsReport rsReportModel = rsReportService.getByCode(reportCode);
            params.put("reportId", rsReportModel.getId());
            List<RsReportView> rsReportViewList = rsReportViewService.findByReportId(rsReportModel.getId());
            // 获取图形配置
            for (RsReportView view : rsReportViewList) {
                RsResource rsResourcesModel = rsResourceService.getResourceById(view.getResourceId());
                if (rsResourcesModel.getEchartType().equals("twoDimensional")){//特殊二维表报表
                    //数据另外查询
                } else {
                    params.clear();
                    params.put("filters", "resourcesId=" + view.getResourceId() + ";paramKey=q");
                    List<RsResourceDefaultParam> queryList = resourceDefaultParamService.search("resourcesId=" + view.getResourceId() + ";paramKey=q");
                    Map<String, Object> viewInfo = new HashMap<>();
                    Map<String, Object> conditions = translateViewCondition(rsResourcesModel.getDataSource(), queryList);
                    viewInfo.put("conditions", conditions); // 视图数据过滤条件。
                    List<Map<String, Object>> options = new ArrayList<>();
                    if (rsResourcesModel.getDataSource() == 1) {
                        // 档案视图场合
                        viewInfo.put("type", "record");
                        viewInfo.put("resourceCode", rsResourcesModel.getCode());
                        viewInfo.put("searchParams", queryList.size() > 0 ? queryList.get(0).getParamValue() : "[]");
                        // 获取展示的列名
                        List<MRsColumnsModel> columns = resourceBrowseControllerService.getResourceMetadata(rsResourcesModel.getCode(),"");
                        viewInfo.put("columns", columns);
                        viewInfos.add(viewInfo);
                    } else if (rsResourcesModel.getDataSource() == 2) {
                        // 指标视图场合
                        viewInfo.put("type", "quota");
                        viewInfo.put("resourceId", view.getResourceId());
                        MChartInfoModel chartInfoModel = reportService.getRsQuotaPreview(view.getResourceId(),"","",null);
                        Map<String, Object> option = new HashMap<>();
                        option.put("resourceCode", chartInfoModel.getResourceCode());
                        option.put("resourceId", chartInfoModel.getResourceId());
                        option.put("dimensionList", chartInfoModel.getDimensionMap());
                        option.put("option", chartInfoModel.getOption());
                        options.add(option);
                        viewInfo.put("options", options); // 视图包含的指标echart图形的option。
                        viewInfos.add(viewInfo);
                    }
                }
            }
            resultMap.put("viewInfos", viewInfos);
            return ObjEnvelop.getSuccess("查询成功",resultMap);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("获取报表数据发生异常");
        }
    }
    private String filterHandle(String quotaFilter) {
        String filter = "";
        if(org.apache.commons.lang.StringUtils.isNotEmpty(quotaFilter)){
            String [] quotaFilters = quotaFilter.split(";");
            for(int i = 0;i < quotaFilters.length; i++){
                String [] keyVal = quotaFilters[i].split("=");
                if(keyVal[i].length()>1){
                    if(i==0){
                        filter = keyVal[0] + "='" + keyVal[1] +"' ";
                    }else {
                        filter = filter + " and "  + keyVal[0] + "='" + keyVal[1] +"' ";
                    }
                }
            }
        }
        return filter;
    }
    private List<Map<String,String>>  getTjQuotaSynthesiseDimension(String quotaCodes) {
        List<TjQuotaDimensionMain> tjQuotaDimensionMains = null;
        List<TjQuotaDimensionSlave> tjQuotaDimensionSlaves = null;
        //保存指标的 ID 和 所有维度的集合
        Map<String,Map<String,String>> dimensionMap = new LinkedHashMap();
        String [] quotaCode = quotaCodes.split(",");
        for(int i=0 ; i < quotaCode.length ;i++){
            Map<String,String> map = new LinkedHashMap<>();
            tjQuotaDimensionMains = tjQuotaDimensionMainService.getTjQuotaDimensionMainByCode(quotaCode[i]);
//            int main = 1;
            for(TjQuotaDimensionMain tjQuotaDimensionMain : tjQuotaDimensionMains){
                TjDimensionMain tjDimensionMain = tjDimensionMainService.getTjDimensionMainByCode(tjQuotaDimensionMain.getMainCode());
                if(tjDimensionMain !=null){
                    map.put(tjDimensionMain.getCode(),tjDimensionMain.getName() + "-" + tjDimensionMain.getCode());
                }
//                main ++;
            }
            tjQuotaDimensionSlaves = tjQuotaDimensionSlaveService.getTjQuotaDimensionSlaveByCode(quotaCode[i]);
            int slave = 1;
            for(TjQuotaDimensionSlave tjQuotaDimensionSlave : tjQuotaDimensionSlaves){
                TjDimensionSlave tjDimensionSlave =  tjDimensionSlaveService.getTjDimensionSlaveByCode(tjQuotaDimensionSlave.getSlaveCode());
                if(tjDimensionSlave != null){
                    map.put(tjDimensionSlave.getCode(), tjDimensionSlave.getName()+"-slaveKey" + slave);//第几个维度
                }
                slave ++;
            }
            dimensionMap.put(quotaCode[i],map);
        }
        //取出第一个指标的所有维度
        Map<String,String> tempMap = new LinkedHashMap();
        for(String quotaCodeKey:dimensionMap.keySet() ){
            Map<String,String> codeMap = dimensionMap.get(quotaCodeKey);
            for(String dimenCode: codeMap.keySet()){
                tempMap.put(dimenCode, codeMap.get(dimenCode));
            }
            break;
        }
        //用于保存共同交集的指标 key 保存交集的维度code
        //value 保存 此维度在每个指标统计的结果集中对应的字段名称
        Map<String,Map<String,String>> synthesiseMap = new LinkedHashMap<>();
        Map<String,String> saveModelMap = new LinkedHashMap();
        //其他指标与第一个指标维度对比,如果在第一个指标中都存在 交集维度
        for(String tempDimenCode:tempMap.keySet() ){
            int num = 0;
            String quotaCodeStr = "";
            for(String keyCode:dimensionMap.keySet() ){
                quotaCodeStr = keyCode;
                Map<String,String> codeMap = dimensionMap.get(keyCode);
                for(String code: codeMap.keySet()){
                    if( code.equals(tempDimenCode) &&  tempMap.get(tempDimenCode).equals(codeMap.get(code))){
                        saveModelMap.put(quotaCodeStr + "-"+ tempDimenCode ,  tempMap.get(tempDimenCode) );
                        //指标code + 维度编码 ->  科室-slaveKey2
                        num ++;
                    }
                }
            }
            if(num == dimensionMap.size()){
                Map<String,String> modelCloumnMap = new LinkedHashMap();
                modelCloumnMap.put("name",tempMap.get(tempDimenCode).split("-")[0]);
                for(String keyCode:dimensionMap.keySet() ){
                    if(saveModelMap.containsKey(keyCode+"-"+ tempDimenCode)) {
                        String str = keyCode+"-"+ tempDimenCode;
                        if(saveModelMap.get(str).contains(tempDimenCode)){
                            modelCloumnMap.put(keyCode,tempDimenCode);
                        }
                        if(saveModelMap.get(str).contains("slaveKey")){
                            modelCloumnMap.put(keyCode,saveModelMap.get(str).split("-")[1]);
                        }
                    }
                }
                synthesiseMap.put(tempDimenCode,modelCloumnMap);
            }
        }
        List<Map<String,String>> resultList = new ArrayList<>();
        for(String key : synthesiseMap.keySet()){
            resultList.add(synthesiseMap.get(key));
        }
        return  resultList;
    }
    @GetMapping("getRsQuotaPreview")
    public Envelop getRsQuotaPreview(@RequestParam String resourceId) {
        List<Map<String, Object>> options = new ArrayList<>();
        try {
            MChartInfoModel chartInfoModel = reportService.getRsQuotaPreview(resourceId,"","",null);
            Map<String, Object> option = new HashMap<>();
            option.put("resourceCode", chartInfoModel.getResourceCode());
            option.put("resourceId", chartInfoModel.getResourceId());
            option.put("option", chartInfoModel.getOption());
            options.add(option);
            return ListEnvelop.getSuccess("查询成功",options);
        }catch (Exception e){
            e.printStackTrace();
            return failed("获取报表数据发生异常");
        }
    }
    /**
     * 获取报表 联动图形数据
     * @param reportCode 报表code
     * @param linkageResourceIdStr 联动视图Id串,多个用;拼接    改为只用于一个视图查询
     * @param linkageFilter  联动视图条件,多个用;拼接 town=361102;quotaDate >= '2018-03-01' and quotaDate <= '2018-03-31'
     * @param linkageDimension  联动维度
     */
    @GetMapping("/getLinkageTemplateData")
    public Envelop getLinkageTemplateData(@RequestParam(name="reportCode",required=false) String reportCode,
                                         @RequestParam(name="linkageResourceIdStr",required=true) String linkageResourceIdStr,
                                         @RequestParam(name="linkageFilter",required=false) String linkageFilter,
                                         @RequestParam(name="linkageDimension",required=false)String linkageDimension,
                                         @RequestParam(name="limitCondition",required=false)String limitCondition) {
        String filter = "";
        if(StringUtils.isNotEmpty(linkageFilter)){
            String [] quotaFilters = linkageFilter.split(";");
            for(int i = 0;i < quotaFilters.length; i++){
                if(i == 0){
                    filter = quotaFilters[0];
                }else{
                    filter += " and " + quotaFilters[i];
                }
            }
        }
        return reportService.getTemplateData(reportCode,linkageResourceIdStr,filter,linkageDimension, limitCondition);
    }
    /**
     * 转换视图数据筛选条件
     */
    private Map<String, Object> translateViewCondition(Integer type, List<RsResourceDefaultParam> queryList) throws IOException, ParseException {
        Map<String, Object> conditions = new HashMap<>();
        if (type == 1) {
            // 档案视图场合
            for (int i = 0; i < queryList.size(); i++) {
                List<Map<String, String>> paramList = objectMapper.readValue(queryList.get(i).getParamValue(), List.class);
                for (Map<String, String> filter : paramList) {
                    String field = filter.get("field").toString();
                    String condition = filter.get("condition").toString();
                    String value = filter.get("value").toString();
                    if ("event_date".equals(field)) {
                        // 期间
                        String date = DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(value));
                        if (condition.contains(">")) {
                            conditions.put("startDate", date);
                        } else if (condition.contains("<")) {
                            conditions.put("endDate", date);
                        }
                    }
                    if ("EHR_000241".equals(field)) {
                        // 地区
                        conditions.put("area", value);
                    }
                }
            }
        } else if (type == 2) {
            // 指标视图场合
            for (int i = 0; i < queryList.size(); i ++) {
                Map<String, String> filter = objectMapper.readValue(queryList.get(i).getParamValue(), Map.class);
                if (filter.get("startTime") != null) {
                    // 起始日期
                    String date = filter.get("startTime").toString();
                    conditions.put("startDate", DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(date)));
                }
                if (filter.get("endTime") != null) {
                    // 终止日期
                    String date = filter.get("endTime").toString();
                    conditions.put("endDate", DateTimeUtil.simpleDateFormat(DateTimeUtil.simpleDateParse(date)));
                }
                // 地区
                String area = "";
                if (filter.get("province") != null) {
                    area += filter.get("province").toString();
                }
                if (filter.get("city") != null) {
                    area += filter.get("city").toString();
                }
                if (filter.get("town") != null) {
                    area += filter.get("town").toString();
                }
                conditions.put("area", area);
            }
        }
        return conditions;
    }
    /**
     * 生成模板
     * @param id
     * @param content
     * @return
     */
    @RequestMapping("/uploadTemplate")
    public Envelop uploadTemplate(Integer id, String content, String reportData, String position) {
        try {
            saveSetting(id, reportData);
            Envelop result = new Envelop();
            String filePath = this.getClass().getResource("/").getPath() + "temp/";
            String fileName = System.currentTimeMillis() + "template.js";
            // 生成模板
            FileUploadUtil.createFile(filePath, fileName, content);
            FileInputStream inputStream = new FileInputStream(filePath + fileName);
            Map<String, Object> uploadFileParams = FileUploadUtil.getParams(inputStream, fileName);
            String storagePath = "";
            if(uploadFileParams.size() > 0){
                FileResource fileResource = new FileResource();
                fileResource.setCreateDate(new Date());
                fileResource.setId(getObjectId(BizObject.FileResource));
                storagePath = fileResourceManager.saveFileResourceReturnUrl(uploadFileParams.get("file_str")+"", fileName, fileResource);
            }
            RsReport updateModel = rsReportService.getById(id);
            updateModel.setTemplatePath(storagePath);
            // 设置报表中视图和位置的关系
            updateModel.setPosition(position);
            rsReportService.save(updateModel);
            // 删除临时文件
            FileUploadUtil.delDir(filePath);
            return ObjEnvelop.getSuccess("操作成功",storagePath);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("生成模版发生异常");
        }
    }
    @GetMapping("/getPositionMapByCode")
    public Envelop getPositionByCode(String code) throws Exception {
        Map<String, Object> params = new HashMap<>();
        params.put("code", code);
        ObjEnvelop envelop = new ObjEnvelop();
        String positionMap = rsReportService.getPositionByCode(code);
        envelop.setStatus(200);
        envelop.setObj(positionMap);
        return envelop;
    }
    @GetMapping("/getTemplateContent")
    public Envelop getTemplateContent(String reportCode) {
        Map<String, Object> params = new HashMap<>();
        try {
            // 获取报表模版内容
            RsReport rsReport = rsReportService.getByCode(reportCode);
            if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
                return failed("模版未找到");
            }
            String[] paths = rsReport.getTemplatePath().split(":");
            byte[] bytes = fastDFSUtil.download(paths[0], paths[1]);
            String templateContent = new String(bytes, "UTF-8");
            return ObjEnvelop.getSuccess("查询成功",templateContent);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    /**
     *
     * 根据父级信息获取全部的子级信息(树形model)
     * @param info 父级信息
     * @return 全部子级信息
     */
    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelChild(List<RsResourceCategory> info) {
        List<RsCategoryTypeTreeModel> treeInfo = new ArrayList<>();
        for (int i = 0; i < info.size(); i++) {
            RsResourceCategory typeInfo = info.get(i);
            RsCategoryTypeTreeModel tree = convertToModel(typeInfo, RsCategoryTypeTreeModel.class);
            List<RsResourceCategory> categoryListChild = rsCategoryService.getRsCategoryByPid(typeInfo.getId());
            List<RsCategoryTypeTreeModel> listChildTree = getRsCategoryTreeModelChild(categoryListChild);
            tree.setChildren(listChildTree);
            treeInfo.add(tree);
        }
        return treeInfo;
    }
    /**
     * 递归不满足的父级类别集合的子集中满足条件TreeModel集合的方法
     * @param mRsCategories 不符合的父级类别的集合
     * @param name
     * @return
     */
    private List<RsCategoryTypeTreeModel> getRsCategoryTreeModelByName(List<RsResourceCategory> mRsCategories, String name) throws ParseException {
        //结构:treeList 包含treeModel,treeModel包含listOfParent
        List<RsCategoryTypeTreeModel> treeList = new ArrayList<>();
        for(RsResourceCategory mRsCategory:mRsCategories){
            List<RsCategoryTypeTreeModel> childList = new ArrayList<>();
            RsCategoryTypeTreeModel treeModel = convertToModel(mRsCategory,RsCategoryTypeTreeModel.class);
            String pid = mRsCategory.getId();
            //获取所有下一级cda类别
            List<RsResourceCategory> listAll = rsCategoryService.getRsCategoryByPid(pid);
            if(listAll.size() == 0){
                continue;
            }
            //获取所有下一级符合要求的资源类别
            String filters ="pid="+pid+";name?"+name;
            //modify by cws
            List<RsResourceCategory> listSome = rsCategoryService.search(filters);
            if(listSome.size()!=0){
                childList.addAll(getRsCategoryTreeModelChild(listSome));
            }
            //取剩下不符合要求的进行递归
            listAll.removeAll(listSome);
            if(listAll.size() != 0){
                childList.addAll(getRsCategoryTreeModelByName(listAll, name));
            }
            if(childList.size() != 0){
                treeModel.setChildren(childList);
                treeList.add(treeModel);
            }
        }
        return treeList;
    }
}

+ 0 - 3
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceBrowseController.java

@ -18,15 +18,12 @@ import jxl.write.WritableWorkbook;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.io.OutputStream;
import java.util.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Matcher;

+ 40 - 23
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceConfigurationController.java

@ -1,5 +1,6 @@
package com.yihu.jw.basic.agadmin.controller.resource;
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.resource.dao.RsResourceMetadataDao;
import com.yihu.jw.basic.resource.service.RsMetadataService;
import com.yihu.jw.basic.resource.service.RsMetadataService;
import com.yihu.jw.basic.resource.service.RsResourceMetadataService;
import com.yihu.jw.basic.resource.service.RsResourceMetadataService;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.id.BizObject;
@ -8,17 +9,16 @@ import com.yihu.jw.entity.ehr.resource.RsResourceMetadata;
import com.yihu.jw.restmodel.ehr.resource.MRsMetadata;
import com.yihu.jw.restmodel.ehr.resource.MRsMetadata;
import com.yihu.jw.restmodel.ehr.resource.MRsResourceMetadata;
import com.yihu.jw.restmodel.ehr.resource.MRsResourceMetadata;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.ui.Model;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.*;
@ -28,14 +28,17 @@ import java.util.*;
 */
 */
@RestController
@RestController
@RequestMapping("/resourceConfiguration")
@RequestMapping("/resourceConfiguration")
@Api(tags = {"网关-资源配置服务控制器","网关-资源配置服务控制器"})
public class ResourceConfigurationController extends EnvelopRestEndpoint {
public class ResourceConfigurationController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private RsResourceMetadataService rsMetadataService;
    private RsResourceMetadataService rsMetadataService;
    @Autowired
    @Autowired
    private RsResourceMetadataDao rsMetadataDao;
    @Autowired
    private RsMetadataService metadataService;
    private RsMetadataService metadataService;
    @RequestMapping("searchResourceConfiguration")
    @GetMapping("searchResourceConfiguration")
    public Object searchResourceConfiguration(String searchNm, int page, int rows) {
    public Object searchResourceConfiguration(String searchNm, int page, int rows) {
        Map<String, Object> params = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        String metaDataUrl = "/resources/metadata";
        String metaDataUrl = "/resources/metadata";
@ -74,57 +77,71 @@ public class ResourceConfigurationController extends EnvelopRestEndpoint {
    }
    }
    @RequestMapping("searchSelResourceConfiguration")
    @GetMapping("searchSelResourceConfiguration")
    public Object searchSelResourceConfiguration(String searchNm, String resourcesId, int page, int rows) {
    public Object searchSelResourceConfiguration(String searchNm, String resourcesId, int page, int rows) {
        Map<String, Object> params = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
        String ResourceMetadataUrl = "/resources/rs_metadata";
        String ResourceMetadataUrl = "/resources/rs_metadata";
        String selResourceMetadataListUrl = "/resources/" + resourcesId + "/metadata_list";
        String selResourceMetadataListUrl = "/resources/" + resourcesId + "/metadata_list";
        String resultStr = "";
        String resultStr = "";
        try {
        try {
            if (searchNm.equals("selAll")) {
//                resultStr = HttpClientUtil.doGet(comUrl + selResourceMetadataListUrl, params, username, password);
            if ("selAll".equals(searchNm)) {
                List<RsResourceMetadata> metadataList = rsMetadataService.getRsMetadataByResourcesId(resourcesId);
                return ListEnvelop.getSuccess("查询成功",metadataList);
            } else {
            } else {
                String filters = "";
                String filters = "";
                params.put("filters", "");
                if (!StringUtils.isEmpty(searchNm)) {
                if (!StringUtils.isEmpty(searchNm)) {
                    filters = "name?" + searchNm + " g1;id?" + searchNm + " g1";
                    filters = "name?" + searchNm + " g1;id?" + searchNm + " g1";
                }
                }
                params.put("resources_id", "");
                if (!StringUtils.isEmpty(resourcesId)) {
                if (!StringUtils.isEmpty(resourcesId)) {
                    params.put("resources_id", resourcesId);
                    params.put("resources_id", resourcesId);
                }
                }
                params.put("page", page);
                params.put("page", page);
                params.put("size", rows);
                params.put("size", rows);
                params.put("fields", "");
                params.put("sorts", "");
                long total = 0;
                long total = 0;
                //过滤条件为空
                //过滤条件为空
                if (StringUtils.isEmpty(filters)) {
                List<RsResourceMetadata> rsMetadatas;
                if (StringUtils.isEmpty(resourcesId)) {
                    Page<RsResourceMetadata> dimensions = rsMetadataService.getResourceMetadata(null, reducePage(page), rows);
                    Page<RsResourceMetadata> dimensions = rsMetadataService.getResourceMetadata(null, reducePage(page), rows);
                    total = dimensions.getTotalElements();
                    total = dimensions.getTotalElements();
                    return PageEnvelop.getSuccessListWithPage("查询成功",dimensions.toList(),page,rows,total);
                    rsMetadatas = dimensions.toList();
                } else {
                } else {
                    List<RsResourceMetadata> dimensions = rsMetadataService.search(null, filters, null, page, rows);
                    total = rsMetadataService.getCount(filters);
                    return PageEnvelop.getSuccessListWithPage("查询成功",dimensions,page,rows,total);
                    rsMetadatas = rsMetadataService.search(null, "resourcesId=" + resourcesId, null, page, rows);
                    total = rsMetadataService.getCount("resourcesId=" + resourcesId);
                }
                }
                List<RsResourceMetadata> rsResourceMetadataModels = getRsMetadata(rsMetadatas,filters,page,rows);
                return PageEnvelop.getSuccessListWithPage("查询成功",rsResourceMetadataModels,page,rows,total);
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return failed("查询失败");
        }
        }
        return resultStr;
    }
    public List<RsResourceMetadata> getRsMetadata(List<RsResourceMetadata> rsMetadatas,String filters,int page,int size) throws Exception{
        String fs = null;
        for (RsResourceMetadata rsMetadataModel : rsMetadatas){
            fs = "id=" + rsMetadataModel.getMetadataId()+" g2;"+filters;
            List<RsMetadata> metadata = metadataService.search("",fs,"",page,size);
            if (metadata.size()>0) {
                rsMetadataModel.setName(metadata.get(0).getName());
                rsMetadataModel.setColumnType(metadata.get(0).getColumnType());
                rsMetadataModel.setStdCode(metadata.get(0).getId());
            }
        }
        return rsMetadatas;
    }
    }
    @RequestMapping("/saveResourcConfiguration")
    @PostMapping("/saveResourceConfiguration")
    public Envelop saveResourceConfiguration(String addRowDatas, String delRowDatas) {
    public Envelop saveResourceConfiguration(String addRowDatas, String delRowDatas) {
        Map<String, Object> params = new HashMap<>();
        String resultStr = "";
        String resultStr = "";
        String metaDataUrl = "/resources/rs_metadata/batch";
        String metaDataUrl = "/resources/rs_metadata/batch";
        try {
        try {
            if (!StringUtils.isEmpty(delRowDatas)) {
            if (!StringUtils.isEmpty(delRowDatas)) {
                //执行删除操作
                //执行删除操作
                rsMetadataService.delete(delRowDatas);
                String ids[] = delRowDatas.split(",");
                for (String id:ids){
                    rsMetadataDao.deleteById(id);
                }
                return success("删除成功");
                return success("删除成功");
            }
            }
            if (!StringUtils.isEmpty(addRowDatas)) {
            if (!StringUtils.isEmpty(addRowDatas)) {
@ -134,7 +151,7 @@ public class ResourceConfigurationController extends EnvelopRestEndpoint {
                    metadata.setId(getObjectId(BizObject.ResourceMetadata));
                    metadata.setId(getObjectId(BizObject.ResourceMetadata));
                }
                }
                List<RsResourceMetadata> metadataList = rsMetadataService.saveMetadataBatch(rsMetadata);
                List<RsResourceMetadata> metadataList = rsMetadataService.saveMetadataBatch(rsMetadata);
                return success("新增成功");
                return ListEnvelop.getSuccess("新增成功",metadataList);
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();

+ 2 - 6
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceDefaultParamController.java

@ -1,6 +1,5 @@
package com.yihu.jw.basic.agadmin.controller.resource;
package com.yihu.jw.basic.agadmin.controller.resource;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.dao.RsResourceDefaultParamDao;
import com.yihu.jw.basic.resource.dao.RsResourceDefaultParamDao;
@ -10,14 +9,10 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.HashMap;
@ -29,6 +24,7 @@ import java.util.Map;
 */
 */
@RestController
@RestController
@RequestMapping("/resource/rsDefaultParam")
@RequestMapping("/resource/rsDefaultParam")
@Api(tags = {"网关-资源默认参数"})
public class ResourceDefaultParamController extends EnvelopRestEndpoint {
public class ResourceDefaultParamController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired

+ 2 - 6
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceIntegratedController.java

@ -15,9 +15,7 @@ import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.NumberUtil;
import com.yihu.jw.util.common.NumberUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
import io.swagger.annotations.Api;
import jxl.Cell;
import jxl.Cell;
import jxl.Workbook;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.Label;
@ -26,12 +24,9 @@ import jxl.write.WritableWorkbook;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
@ -47,6 +42,7 @@ import java.util.*;
 */
 */
@RestController
@RestController
@RequestMapping("/resourceIntegrated")
@RequestMapping("/resourceIntegrated")
@Api(tags = {"网关-资源综合查询服务控制器"})
public class ResourceIntegratedController extends EnvelopRestEndpoint {
public class ResourceIntegratedController extends EnvelopRestEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(ResourceIntegratedController.class);
    private static final Logger logger = LoggerFactory.getLogger(ResourceIntegratedController.class);

+ 6 - 15
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceManageController.java

@ -1,9 +1,7 @@
package com.yihu.jw.basic.agadmin.controller.resource;
package com.yihu.jw.basic.agadmin.controller.resource;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.dao.RsResourceDao;
import com.yihu.jw.basic.resource.dao.RsResourceDao;
import com.yihu.jw.basic.resource.model.ResourceQuotaJson;
import com.yihu.jw.basic.resource.model.ResourceQuotaJson;
@ -11,8 +9,6 @@ import com.yihu.jw.basic.resource.service.*;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.quota.TjQuota;
import com.yihu.jw.entity.ehr.quota.TjQuota;
import com.yihu.jw.entity.ehr.resource.*;
import com.yihu.jw.entity.ehr.resource.*;
import com.yihu.jw.restmodel.ehr.resource.MChartInfoModel;
import com.yihu.jw.restmodel.ehr.resource.MRsCategory;
import com.yihu.jw.restmodel.ehr.resource.MRsResources;
import com.yihu.jw.restmodel.ehr.resource.MRsResources;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -20,22 +16,16 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestClientException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
@ -48,6 +38,7 @@ import java.util.Map;
 */
 */
@RestController
@RestController
@RequestMapping("/resource/resourceManage")
@RequestMapping("/resource/resourceManage")
@Api(tags = {"网关-视图管理控制器"})
public class ResourceManageController extends EnvelopRestEndpoint {
public class ResourceManageController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
@ -91,7 +82,7 @@ public class ResourceManageController extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @RequestMapping(value = "/resourceInfo", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
    @RequestMapping(value = "/resourceInfo", method = RequestMethod.GET)
    public Envelop getResourceInfo(String id) throws Exception {
    public Envelop getResourceInfo(String id) throws Exception {
        RsResource  rsResource = rsResourceService.getResourceById(id);
        RsResource  rsResource = rsResourceService.getResourceById(id);
        return ObjEnvelop.getSuccess("查询成功",rsResource);
        return ObjEnvelop.getSuccess("查询成功",rsResource);
@ -404,7 +395,7 @@ public class ResourceManageController extends EnvelopRestEndpoint {
//        }
//        }
//    }
//    }
    @RequestMapping(value = "/addResourceQuota", produces = "text/html;charset=UTF-8")
    @RequestMapping(value = "/addResourceQuota")
    public Envelop addResourceQuota(String resourceId, String jsonModel, HttpServletRequest request) throws IOException {
    public Envelop addResourceQuota(String resourceId, String jsonModel, HttpServletRequest request) throws IOException {
        String url = "/resourceQuota/batchAddResourceQuota";
        String url = "/resourceQuota/batchAddResourceQuota";
        String resultStr = "";
        String resultStr = "";
@ -536,7 +527,7 @@ public class ResourceManageController extends EnvelopRestEndpoint {
        return false;
        return false;
    }
    }
    @RequestMapping(value = "/getQuotaByResourceId", produces = "text/html;charset=UTF-8")
    @RequestMapping(value = "/getQuotaByResourceId")
    public Envelop getQuotaByResourceId(String resourceId){
    public Envelop getQuotaByResourceId(String resourceId){
        Envelop envelop = new Envelop();
        Envelop envelop = new Envelop();
        String url = "/resourceQuota/getQuotaByResourceId";
        String url = "/resourceQuota/getQuotaByResourceId";
@ -551,7 +542,7 @@ public class ResourceManageController extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @RequestMapping(value = "/updateResourceQuota", produces = "text/html;charset=UTF-8")
    @RequestMapping(value = "/updateResourceQuota")
    public Envelop updateResourceQuota(String jsonModel){
    public Envelop updateResourceQuota(String jsonModel){
        Envelop envelop = new Envelop();
        Envelop envelop = new Envelop();
        String url = "/resourceQuota/updateResourceQuota";
        String url = "/resourceQuota/updateResourceQuota";

+ 2 - 5
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceMonitorTypeReportController.java

@ -1,16 +1,12 @@
package com.yihu.jw.basic.agadmin.controller.resource;
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.service.RsReportService;
import com.yihu.jw.basic.resource.service.RsReportService;
import com.yihu.jw.entity.ehr.resource.RsReport;
import com.yihu.jw.entity.ehr.resource.RsReport;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
@ -24,6 +20,7 @@ import java.util.Map;
@RestController
@RestController
@RequestMapping("/resource/monitorTypeReport")
@RequestMapping("/resource/monitorTypeReport")
@Api(tags = {"网关-监控报表"})
public class ResourceMonitorTypeReportController extends EnvelopRestEndpoint {
public class ResourceMonitorTypeReportController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired

+ 2 - 4
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceViewController.java

@ -8,17 +8,14 @@ import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import jxl.Workbook;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WritableWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.io.File;
@ -33,6 +30,7 @@ import java.util.Map;
@RestController
@RestController
@RequestMapping("/resourceView")
@RequestMapping("/resourceView")
@Api(tags = {"网关-资源视图"})
public class ResourceViewController extends EnvelopRestEndpoint {
public class ResourceViewController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired

+ 0 - 7
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/RsResourceCategoryController.java

@ -5,23 +5,16 @@ import com.yihu.jw.basic.resource.model.RsCategoryTypeTreeModel;
import com.yihu.jw.basic.resource.service.RsResourceCategoryService;
import com.yihu.jw.basic.resource.service.RsResourceCategoryService;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.resource.RsResourceCategory;
import com.yihu.jw.entity.ehr.resource.RsResourceCategory;
import com.yihu.jw.restmodel.ehr.resource.MRsCategory;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;

+ 148 - 171
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptController.java

@ -1,171 +1,148 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.yihu.ehr.constants.ServiceApi;
//
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * Created by linz on 2016/5/23.
// */
//
//@RestController
//@RequestMapping("/schemeAdapt")
//public class SchemeAdaptController extends EnvelopRestEndpoint {
//
//
//    @Value("${service-gateway.username}")
//    private String username;
//    @Value("${service-gateway.password}")
//    private String password;
//    @Value("${service-gateway.url}")
//    private String comUrl;
//
//    @Autowired
//    private ObjectMapper objectMapper;
//
//    public static final String SCHEME_PLATFORM="1";//平台类型
//    public static final String SCHEME_TP="2";//第三方
//
//
//    @RequestMapping("/initial")
//    public String resourceSchemeInitial(Model model){
//        model.addAttribute("contentPage","/resource/adaptview/schemeAdapt");
//        return "pageView";
//    }
//
//    @RequestMapping("/list")
//    @ResponseBody
//    public Object searchAdaptSchemes(String searchNm, String type, int page, int rows){
//        Map<String, Object> params = new HashMap<String, Object>();
//        StringBuffer stringBuffer = new StringBuffer();
//        if (!StringUtils.isEmpty(searchNm)) {
//            stringBuffer.append("code?").append(searchNm).append(" g1;").append("name?").append(searchNm).append(" g1;");
//        }
//        if (!StringUtils.isEmpty(type)) {
//            stringBuffer.append("type=").append(type).append(";");
//        }
//        params.put("filters", "");
//        params.put("page", page);
//        params.put("size", rows);
//        String filters = stringBuffer.toString();
//        if(filters.lastIndexOf(";")>0){
//            filters = filters.substring(0,filters.lastIndexOf(";"));
//        }
//        if (!StringUtils.isEmpty(filters)) {
//            params.put("filters", filters);
//        }
//        String url = ServiceApi.Adaptions.Schemes;
//        String result="";
//        try {
//            result = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return result;
//        } catch (Exception e){
//            e.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param mode
//     * @return
//     */
//    @RequestMapping("gotoModify")
//    public Object adapterSchemeTemplate(EnvelopRestEndpointString id,String mode) {
//        String resultStr = "";
//        Envelop result = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        params.put("id",id);
//        try {
//            if(mode.equals("view") || mode.equals("modify")) {
//                String url = "/adaptions/schemas/"+id;
//                resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//                model.addAttribute("rs", "success");
//            }
//            model.addAttribute("info", StringUtils.isEmpty(resultStr)?toJson(result):resultStr);
//            model.addAttribute("mode",mode);
//            model.addAttribute("contentPage","/resource/adaptview/schemeAdaptDialog");
//            return "emptyView";
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param dataJson
//     * @return
//     */
//    @RequestMapping("save")
//    @ResponseBody
//    public Object updateSchemeAdpat(Model model,String dataJson) {
//        Envelop result = new Envelop();
//        String resultStr = "";
//        Map<String, Object> params = new HashMap<>();
//        try{
//        MRsAdapterSchema mRsAdapterSchema = objectMapper.readValue(dataJson,MRsAdapterSchema.class);
//        if (StringUtils.isEmpty(mRsAdapterSchema.getType())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("方案类别不能为空!");
//            return result;
//        }
//        if (StringUtils.isEmpty(mRsAdapterSchema.getName())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("方案名称不能为空!");
//            return result;
//        }
//        if (StringUtils.isEmpty(mRsAdapterSchema.getCode())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("方案编码不能为空!");
//            return result;
//        }
//        if (StringUtils.isEmpty(mRsAdapterSchema.getAdapterVersion())&&this.SCHEME_PLATFORM.equals(mRsAdapterSchema.getType())) {
//            result.setSuccessFlg(false);
//            result.setErrorMsg("版本号不能为空!");
//            return result;
//        }
//        if(StringUtils.isEmpty(mRsAdapterSchema.getAdapterVersion())&&this.SCHEME_TP.equals(mRsAdapterSchema.getType())){
//            result.setSuccessFlg(false);
//            result.setErrorMsg("标准名称不能为空!");
//            return result;
//        }
//        params.put("adapterSchema",toJson(mRsAdapterSchema));
//        String url = ServiceApi.Adaptions.Schemes;
//        if(StringUtils.isNotBlank(mRsAdapterSchema.getId())){
//            resultStr = HttpClientUtil.doPut(comUrl + url, params, username, password);
//        }else{
//            resultStr = HttpClientUtil.doPost(comUrl + url, params, username, password);
//        }
//        return resultStr;
//        } catch(Exception ex){
//            ex.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//
//    @RequestMapping("delete")
//    @ResponseBody
//    public Object deleteScheme(String schemeId) {
//        Envelop result = new Envelop();
//        Map<String, Object> params = new HashMap<String, Object>();
//        String url = "/adaptions/schemas/"+schemeId;
//        try{
//           String resultStr =  HttpClientUtil.doDelete(comUrl+url,params,username,password);
//           return resultStr;
//        } catch(Exception ex){
//            ex.printStackTrace();
//            return failed("内部服务请求失败");
//        }
//    }
//}
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.service.RsAdapterSchemeService;
import com.yihu.jw.entity.ehr.id.BizObject;
import com.yihu.jw.entity.ehr.resource.RsAdapterScheme;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by linz on 2016/5/23.
 */
@RestController
@RequestMapping("/schemeAdapt")
@Api( tags = {"网关-资源适配管理"})
public class SchemeAdaptController extends EnvelopRestEndpoint {
    @Autowired
    private RsAdapterSchemeService schemaService;
    public static final String SCHEME_PLATFORM="1";//平台类型
    public static final String SCHEME_TP="2";//第三方
    @GetMapping("/list")
    public Object searchAdaptSchemes(String searchNm, String type, int page, int rows){
        StringBuffer stringBuffer = new StringBuffer();
        if (!StringUtils.isEmpty(searchNm)) {
            stringBuffer.append("code?").append(searchNm).append(" g1;").append("name?").append(searchNm).append(" g1;");
        }
        if (!StringUtils.isEmpty(type)) {
            stringBuffer.append("type=").append(type).append(";");
        }
        String filters = stringBuffer.toString();
        if(filters.lastIndexOf(";")>0){
            filters = filters.substring(0,filters.lastIndexOf(";"));
        }
        String url = ServiceApi.Adaptions.Schemes;
        try {
            long total = 0;
            //过滤条件为空
            List<RsAdapterScheme> metaList;
            if (org.springframework.util.StringUtils.isEmpty(filters)) {
                Page<RsAdapterScheme> metadataPage = schemaService.getAdapterScheme(null, reducePage(page), rows);
                total = metadataPage.getTotalElements();
                metaList = metadataPage.toList();
            } else {
                metaList = schemaService.search(null, filters, null, page, rows);
                total = schemaService.getCount(filters);
            }
            return PageEnvelop.getSuccessListWithPage("查询成功",metaList,page,rows,total);
        } catch (Exception e){
            e.printStackTrace();
            return failed("内部服务请求失败");
        }
    }
    /**
     * 资源适配:新增、修改窗口
     * @param mode
     * @return
     */
    @GetMapping("gotoModify")
    public Object adapterSchemeTemplate(String id,String mode) {
        String resultStr = "";
        Envelop result = new Envelop();
        Map<String, Object> params = new HashMap<>();
        params.put("id",id);
        try {
            if(mode.equals("view") || mode.equals("modify")) {
                String url = "/adaptions/schemas/"+id;
                ObjEnvelop.getSuccess("",schemaService.getAdapterSchemeById(id));
            }
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return failed("内部服务请求失败");
        }
    }
    /**
     * 资源适配:新增、修改窗口
     * @param dataJson
     * @return
     */
    @PostMapping("save")
    public Object updateSchemeAdpat(String dataJson) {
        Envelop result = new Envelop();
        String resultStr = "";
        Map<String, Object> params = new HashMap<>();
        try{
            RsAdapterScheme mRsAdapterSchema = toEntity(dataJson, RsAdapterScheme.class);
            if (StringUtils.isEmpty(mRsAdapterSchema.getType())) {
                return failed("方案类别不能为空");
            }
            if (StringUtils.isEmpty(mRsAdapterSchema.getName())) {
                return failed("方案名称不能为空");
            }
            if (StringUtils.isEmpty(mRsAdapterSchema.getCode())) {
                return failed("方案编码不能为空");
            }
            if (StringUtils.isEmpty(mRsAdapterSchema.getAdapterVersion())&&this.SCHEME_PLATFORM.equals(mRsAdapterSchema.getType())) {
                return failed("版本号不能为空");
            }
            if(StringUtils.isEmpty(mRsAdapterSchema.getAdapterVersion())&&this.SCHEME_TP.equals(mRsAdapterSchema.getType())){
                return failed("标准名称不能为空!");
            }
            params.put("adapterSchema",toJson(mRsAdapterSchema));
            String url = ServiceApi.Adaptions.Schemes;
            if(StringUtils.isNotBlank(mRsAdapterSchema.getId())){
                schemaService.save(mRsAdapterSchema);
            }else{
                mRsAdapterSchema.setId(getObjectId(BizObject.RsAdapterSchema));
                schemaService.saveAdapterScheme(mRsAdapterSchema);
            }
            return ObjEnvelop.getSuccess("操作成功",mRsAdapterSchema);
        } catch(Exception ex){
            ex.printStackTrace();
            return failed("内部服务请求失败");
        }
    }
    @PostMapping("delete")
    public Object deleteScheme(String schemeId) {
        Envelop result = new Envelop();
        String url = "/adaptions/schemas/"+schemeId;
        try{
            schemaService.deleteById(schemeId);
            return success();
        } catch(Exception ex){
            ex.printStackTrace();
            return failed("内部服务请求失败");
        }
    }
}

+ 111 - 107
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDataSetController.java

@ -1,107 +1,111 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.yihu.ehr.constants.ServiceApi;
//
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.common.LogService;
//import com.yihu.jw.util.http.HttpClientUtil;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * 资源适配管理方案适配管理
// * Created by linz on 2015/11/1.
// */
//
//@RequestMapping("/schemeAdaptDataSet")
//@RestController
//public class SchemeAdaptDataSetController extends EnvelopRestEndpoint {
//
//    @RequestMapping("/initial")
//    public String gotoList(Model model,String dataModel,String version){
//        model.addAttribute("dataModel",dataModel);
//        model.addAttribute("version",version);
//        String url = "/adaptions/schemas/"+dataModel;
//        String resultStr = "";
//        Envelop result = new Envelop();
//        Map<String, Object> params = new HashMap<>();
//        try {
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//        }catch (Exception e){
//            LogService.getLogger(SchemeAdaptDataSetController.class).error(e.getMessage());
//            model.addAttribute("rs", "error");
//        }
//        model.addAttribute("adapterScheme",resultStr);
//        model.addAttribute("contentPage","/resource/adaptview/dataSet/grid");
//        return "pageView";
//    }
//
//    @RequestMapping("/metaDataList")
//    @ResponseBody
//    public Object searchmetaData(String adapterSchemeId, String code, int page, int rows) {
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<String, Object>();
//        StringBuffer stringBuffer = new StringBuffer();
//        if(StringUtils.isNotBlank(adapterSchemeId)){
//            stringBuffer.append("schemeId=").append(adapterSchemeId).append(";");
//        }else{
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("请选择资源适配方案");
//        }
//        if(StringUtils.isNotBlank(code)){
//            stringBuffer.append("srcDatasetCode=").append(code).append(";");
//        }
//        params.put("filters", "");
//        params.put("page", page);
//        params.put("size", rows);
//        String filters = stringBuffer.toString();
//        if(filters.lastIndexOf(";")>0){
//            filters = filters.substring(0,filters.lastIndexOf(";"));
//        }
//        if (!StringUtils.isEmpty(filters)) {
//            params.put("filters", filters);
//        }
//        try {
//            String resultStr ="";
//            String url = ServiceApi.Adaptions.SchemaMetadataList;
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return resultStr;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param dataJson
//     * @return
//     */
//    @RequestMapping("save")
//    @ResponseBody
//    public Object updatesSchemeAdpatDataset(Model model,String dataJson) {
//        Envelop result = new Envelop();
//        String resultStr = "";
//        Map<String, Object> params = new HashMap<>();
//        try{
//            params.put("adapterMetadata",dataJson);
//            String url = ServiceApi.Adaptions.SchemaMetadataList;
//            resultStr = HttpClientUtil.doPut(comUrl + url, params, username, password);
//            return resultStr;
//        }catch(Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//      }
//    }
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.resource.service.RsAdapterMetadataService;
import com.yihu.jw.basic.resource.service.RsAdapterSchemeService;
import com.yihu.jw.entity.ehr.resource.RsAdapterMetadata;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 资源适配管理方案适配管理
 * Created by linz on 2015/11/1.
 */
@RequestMapping("/schemeAdaptDataSet")
@RestController
@Api( tags = {"网关-资源适配管理方案适配管理"})
public class SchemeAdaptDataSetController extends EnvelopRestEndpoint {
    @Autowired
    private RsAdapterSchemeService schemaService;
    @Autowired
    private RsAdapterMetadataService metadataService;
    @GetMapping("/initial")
    public Envelop gotoList(String dataModel,String version){
        String url = "/adaptions/schemas/"+dataModel;
        String resultStr = "";
        Envelop result = new Envelop();
        Map<String, Object> params = new HashMap<>();
        try {
            return ObjEnvelop.getSuccess("查询成功",schemaService.getAdapterSchemeById(dataModel));
        }catch (Exception e){
            e.printStackTrace();
            return failed("查询失败");
        }
    }
    @GetMapping("/metaDataList")
    public Object searchmetaData(String adapterSchemeId, String code, int page, int rows) {
        Envelop envelop = new Envelop();
        StringBuffer stringBuffer = new StringBuffer();
        if(StringUtils.isNotBlank(adapterSchemeId)){
            stringBuffer.append("schemeId=").append(adapterSchemeId).append(";");
        }else{
            return failed("请选择资源适配方案");
        }
        if(StringUtils.isNotBlank(code)){
            stringBuffer.append("srcDatasetCode=").append(code).append(";");
        }
        String filters = stringBuffer.toString();
        if(filters.lastIndexOf(";")>0){
            filters = filters.substring(0,filters.lastIndexOf(";"));
        }
        try {
            long total;
            List<RsAdapterMetadata> metaList;
            //过滤条件为空
            if (StringUtils.isEmpty(filters)) {
                Page<RsAdapterMetadata> metadataPage = metadataService.getAdapterMetadata(null, reducePage(page), rows);
                total = metadataPage.getTotalElements();
                metaList = metadataPage.toList();
            } else {
                metaList = metadataService.search(null, filters, null, page, rows);
                total = metadataService.getCount(filters);
            }
            return PageEnvelop.getSuccessListWithPage("查询成功",metaList,page,rows,total);
        } catch (Exception e) {
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 资源适配:新增、修改窗口
     * @param dataJson
     * @return
     */
    @PostMapping("save")
    public Object updatesSchemeAdpatDataset(String dataJson) {
        Envelop result = new Envelop();
        String resultStr = "";
        Map<String, Object> params = new HashMap<>();
        try{
            params.put("adapterMetadata",dataJson);
            String url = ServiceApi.Adaptions.SchemaMetadataList;
            RsAdapterMetadata metadata = toEntity(dataJson,RsAdapterMetadata.class);
            metadata = metadataService.saveAdapterMetadata(metadata);
            return ObjEnvelop.getSuccess("保存成功",metadata);
        }catch(Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
      }
    }

+ 89 - 85
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDictController.java

@ -1,85 +1,89 @@
//package com.yihu.jw.basic.agadmin.controller.resource;
//
//
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.util.http.HttpClientUtil;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * 资源适配管理方案适配管理
// * Created by linz on 2015/11/1.
// */
//
//@RequestMapping("/schemeAdaptDict")
//@RestController
//public class SchemeAdaptDictController extends EnvelopRestEndpoint {
//
//    @RequestMapping("/dictlist")
//    @ResponseBody
//    public Object searchmetaData(String adapterSchemeId, String code, int page, int rows) {
//        Envelop envelop = new Envelop();
//        Map<String, Object> params = new HashMap<String, Object>();
//        StringBuffer stringBuffer = new StringBuffer();
//        if(StringUtils.isNotBlank(adapterSchemeId)){
//            stringBuffer.append("schemeId=").append(adapterSchemeId).append(";");
//        }else{
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("请选择资源适配方案");
//            return envelop;
//        }
//        if(StringUtils.isNotBlank(code)){
//            stringBuffer.append("srcDictCode=").append(code).append(" g1").append(";");
//        }
//        params.put("filters", "");
//        params.put("page", page);
//        params.put("size", rows);
//        String filters = stringBuffer.toString();
//        if(filters.lastIndexOf(";")>0){
//            filters = filters.substring(0,filters.lastIndexOf(";"));
//        }
//        if (!StringUtils.isEmpty(filters)) {
//            params.put("filters", filters);
//        }
//        try {
//            String resultStr ="";
//            String url = "/adaptions/adapter/dictionaries";
//            resultStr = HttpClientUtil.doGet(comUrl + url, params, username, password);
//            return resultStr;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//
//    /**
//     * 资源适配:新增、修改窗口
//     * @param model
//     * @param dataJson
//     * @return
//     */
//    @RequestMapping("/save")
//    @ResponseBody
//    public Object updatesSchemeAdpatDict(Model model,String dataJson) {
//        Envelop result = new Envelop();
//        String resultStr = "";
//        Map<String, Object> params = new HashMap<>();
//        try{
//            params.put("jsonData",dataJson);
//            String url = "/adaptions/adapter/dictionaries";
//            resultStr = HttpClientUtil.doPut(comUrl + url, params, username, password);
//            return resultStr;
//        } catch(Exception ex){
//            ex.printStackTrace();
//            return failed(ERR_SYSTEM_DES);
//        }
//    }
//}
package com.yihu.jw.basic.agadmin.controller.resource;
import com.yihu.jw.basic.resource.service.RsAdapterDictionaryService;
import com.yihu.jw.entity.ehr.resource.RsAdapterDictionary;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 *
 * Created by linz on 2015/11/1.
 */
@RequestMapping("/schemeAdaptDict")
@RestController
@Api( tags = {"网关-资源适配管理方案适配管理"})
public class SchemeAdaptDictController extends EnvelopRestEndpoint {
    @Autowired
    private RsAdapterDictionaryService adapterDictionaryService;
    @GetMapping("/dictlist")
    public Object searchmetaData(String adapterSchemeId, String code, int page, int rows) {
        Envelop envelop = new Envelop();
        Map<String, Object> params = new HashMap<String, Object>();
        StringBuffer stringBuffer = new StringBuffer();
        if(StringUtils.isNotBlank(adapterSchemeId)){
            stringBuffer.append("schemeId=").append(adapterSchemeId).append(";");
        }else{
            return failed("请选择资源适配方案");
        }
        if(StringUtils.isNotBlank(code)){
            stringBuffer.append("srcDictCode=").append(code).append(" g1").append(";");
        }
        params.put("filters", "");
        params.put("page", page);
        params.put("size", rows);
        String filters = stringBuffer.toString();
        if(filters.lastIndexOf(";")>0){
            filters = filters.substring(0,filters.lastIndexOf(";"));
        }
        if (!StringUtils.isEmpty(filters)) {
            params.put("filters", filters);
        }
        try {
            String resultStr ="";
            String url = "/adaptions/adapter/dictionaries";
            List<RsAdapterDictionary> adapterDictionaries = adapterDictionaryService.search(null, filters, null, page, rows);
            return PageEnvelop.getSuccessListWithPage("查询成功",adapterDictionaries,page,rows,adapterDictionaryService.getCount(filters));
        } catch (Exception e) {
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
    /**
     * 资源适配:新增、修改窗口
     * @param model
     * @param dataJson
     * @return
     */
    @PostMapping("/save")
    public Object updatesSchemeAdpatDict(String dataJson) {
        Envelop result = new Envelop();
        String resultStr = "";
        Map<String, Object> params = new HashMap<>();
        try{
            params.put("jsonData",dataJson);
            String url = "/adaptions/adapter/dictionaries";
            RsAdapterDictionary adapterDictionary = toEntity(dataJson, RsAdapterDictionary.class);
            adapterDictionary = adapterDictionaryService.save(adapterDictionary);
            return ObjEnvelop.getSuccess("更新成功",adapterDictionary);
        } catch(Exception ex){
            ex.printStackTrace();
            return failed(ERR_SYSTEM_DES);
        }
    }
}

+ 767 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/service/ReportService.java

@ -0,0 +1,767 @@
package com.yihu.jw.basic.agadmin.service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.abel533.echarts.Option;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.quota.service.*;
import com.yihu.jw.basic.resource.model.RsResourcesModel;
import com.yihu.jw.basic.resource.service.RsReportService;
import com.yihu.jw.basic.resource.service.RsResourceQuotaService;
import com.yihu.jw.basic.resource.service.RsResourceService;
import com.yihu.jw.basic.util.BasesicUtil;
import com.yihu.jw.basic.util.ReportOption;
import com.yihu.jw.basic.util.model.ChartDataModel;
import com.yihu.jw.entity.ehr.quota.*;
import com.yihu.jw.entity.ehr.resource.RsReport;
import com.yihu.jw.entity.ehr.resource.RsResource;
import com.yihu.jw.entity.ehr.resource.RsResourceQuota;
import com.yihu.jw.restmodel.ehr.resource.MChartInfoModel;
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
import com.yihu.jw.restmodel.ehr.resource.MRsResources;
import com.yihu.jw.restmodel.ehr.tj.DictModel;
import com.yihu.jw.restmodel.ehr.tj.SaveModel;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.*;
/**
 * Created by janseny on 2017/11/10.
 */
@Service
public class ReportService {
    @Autowired
    protected ObjectMapper objectMapper;
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    ResourceBrowseControllerService resourceBrowseControllerService;
    @Autowired
    private RsResourceQuotaService resourceQuotaService;
    @Autowired
    private TjQuotaDimensionMainService tjQuotaDimensionMainService;
    @Autowired
    private TjQuotaDimensionSlaveService tjQuotaDimensionSlaveService;
    @Autowired
    private TjDimensionMainService tjDimensionMainService;
    @Autowired
    private TjDimensionSlaveService tjDimensionSlaveService;
    @Autowired
    private RsReportService rsReportService;
    @Autowired
    private QuotaService quotaService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseStatistsService baseStatistsService;
    public  List<Map<String,String>>  getTjQuotaSynthesiseDimension(String quotaCodes) {
        List<TjQuotaDimensionMain> tjQuotaDimensionMains = null;
        List<TjQuotaDimensionSlave> tjQuotaDimensionSlaves = null;
        //保存指标的 ID 和 所有维度的集合
        Map<String,Map<String,String>> dimensionMap = new LinkedHashMap();
        String [] quotaCode = quotaCodes.split(",");
        for(int i=0 ; i < quotaCode.length ;i++){
            Map<String,String> map = new LinkedHashMap<>();
            tjQuotaDimensionMains = tjQuotaDimensionMainService.getTjQuotaDimensionMainByCode(quotaCode[i]);
//            int main = 1;
            for(TjQuotaDimensionMain tjQuotaDimensionMain : tjQuotaDimensionMains){
                TjDimensionMain tjDimensionMain = tjDimensionMainService.getTjDimensionMainByCode(tjQuotaDimensionMain.getMainCode());
                if(tjDimensionMain !=null){
                    map.put(tjDimensionMain.getCode(),tjDimensionMain.getName() + "-" + tjDimensionMain.getCode());
                }
//                main ++;
            }
            tjQuotaDimensionSlaves = tjQuotaDimensionSlaveService.getTjQuotaDimensionSlaveByCode(quotaCode[i]);
            int slave = 1;
            for(TjQuotaDimensionSlave tjQuotaDimensionSlave : tjQuotaDimensionSlaves){
                TjDimensionSlave tjDimensionSlave =  tjDimensionSlaveService.getTjDimensionSlaveByCode(tjQuotaDimensionSlave.getSlaveCode());
                if(tjDimensionSlave != null){
                    map.put(tjDimensionSlave.getCode(), tjDimensionSlave.getName()+"-slaveKey" + slave);//第几个维度
                }
                slave ++;
            }
            dimensionMap.put(quotaCode[i],map);
        }
        //取出第一个指标的所有维度
        Map<String,String> tempMap = new LinkedHashMap();
        for(String quotaCodeKey:dimensionMap.keySet() ){
            Map<String,String> codeMap = dimensionMap.get(quotaCodeKey);
            for(String dimenCode: codeMap.keySet()){
                tempMap.put(dimenCode, codeMap.get(dimenCode));
            }
            break;
        }
        //用于保存共同交集的指标 key 保存交集的维度code
        //value 保存 此维度在每个指标统计的结果集中对应的字段名称
        Map<String,Map<String,String>> synthesiseMap = new LinkedHashMap<>();
        Map<String,String> saveModelMap = new LinkedHashMap();
        //其他指标与第一个指标维度对比,如果在第一个指标中都存在 交集维度
        for(String tempDimenCode:tempMap.keySet() ){
            int num = 0;
            String quotaCodeStr = "";
            for(String keyCode:dimensionMap.keySet() ){
                quotaCodeStr = keyCode;
                Map<String,String> codeMap = dimensionMap.get(keyCode);
                for(String code: codeMap.keySet()){
                    if( code.equals(tempDimenCode) &&  tempMap.get(tempDimenCode).equals(codeMap.get(code))){
                        saveModelMap.put(quotaCodeStr + "-"+ tempDimenCode ,  tempMap.get(tempDimenCode) );
                        //指标code + 维度编码 ->  科室-slaveKey2
                        num ++;
                    }
                }
            }
            if(num == dimensionMap.size()){
                Map<String,String> modelCloumnMap = new LinkedHashMap();
                modelCloumnMap.put("name",tempMap.get(tempDimenCode).split("-")[0]);
                for(String keyCode:dimensionMap.keySet() ){
                    if(saveModelMap.containsKey(keyCode+"-"+ tempDimenCode)) {
                        String str = keyCode+"-"+ tempDimenCode;
                        if(saveModelMap.get(str).contains(tempDimenCode)){
                            modelCloumnMap.put(keyCode,tempDimenCode);
                        }
                        if(saveModelMap.get(str).contains("slaveKey")){
                            modelCloumnMap.put(keyCode,saveModelMap.get(str).split("-")[1]);
                        }
                    }
                }
                synthesiseMap.put(tempDimenCode,modelCloumnMap);
            }
        }
        List<Map<String,String>> EnvelopList = new ArrayList<>();
        for(String key : synthesiseMap.keySet()){
            EnvelopList.add(synthesiseMap.get(key));
        }
        return  EnvelopList;
    }
    public String getQuotaDimensionDictSql(String quotaCode, String dimension) {
        String dictSql = "";
        //查询维度
        List<TjQuotaDimensionMain> dimensionMains = tjDimensionMainService.findTjQuotaDimensionMainByQuotaCode(quotaCode);
        if (dimensionMains != null && dimensionMains.size() > 0) {
            for (TjQuotaDimensionMain main : dimensionMains) {
                if (main.getMainCode().equals(dimension)) {
                    dictSql = main.getDictSql();
                }
            }
        }
        if (org.apache.commons.lang.StringUtils.isEmpty(dictSql)) {
            List<TjQuotaDimensionSlave> dimensionSlaves = tjDimensionSlaveService.findTjQuotaDimensionSlaveByQuotaCode(quotaCode);
            if (dimensionSlaves != null && dimensionSlaves.size() > 0) {
                int slave = Integer.valueOf(dimension.substring(dimension.length() - 1, dimension.length()));
                if (dimensionSlaves.size() >= slave) {
                    dictSql = dimensionSlaves.get(slave - 1).getDictSql();
                }
            }
        }
        return dictSql;
    }
    public Map<String, String> setDimensionMap(String dictSql, String dimension, Map<String, String> dimensionDicMap) {
        if (org.apache.commons.lang.StringUtils.isNotEmpty(dictSql)) {
            BasesicUtil baseUtil = new BasesicUtil();
            if (dimension.contains("slaveKey")) {
                //查询字典数据
                List<DictModel> dictDatas = jdbcTemplate.query(dictSql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel dictModel : dictDatas) {
                    String name = baseUtil.getFieldValueByName("name", dictModel);
                    String val = baseUtil.getFieldValueByName("code", dictModel).toLowerCase();
                    dimensionDicMap.put(val, name);
                }
            } else {
                List<SaveModel> dictDatas = jdbcTemplate.query(dictSql, new BeanPropertyRowMapper(SaveModel.class));
                if (dictDatas != null) {
                    for (SaveModel saveModel : dictDatas) {
                        String name = baseUtil.getFieldValueByName(dimension + "Name", saveModel);
                        String val = baseUtil.getFieldValueByName(dimension, saveModel).toLowerCase();
                        dimensionDicMap.put(val, name);
                    }
                }
            }
        }
        return dimensionDicMap;
    }
    public Integer getNum(Map<String, Object> dataMap) {
        Integer num = 0;
        for (String key : dataMap.keySet()) {
            Integer result = null != dataMap.get(key) ? Integer.parseInt(dataMap.get(key).toString()) : 0;
            num += result;
        }
        return num;
    }
    public MChartInfoModel getQuotaRadarGraphicReports(String quotaIdStr,String filter,String dimension,String title) {
        List<String> quotaIds = Arrays.asList(quotaIdStr.split(","));
        MChartInfoModel chartInfoModel = new MChartInfoModel();
        List<Integer> arrayNum = new ArrayList<>();
        Integer polorCount = 50;
        try {
            Option option = null;
            List<String> radarNames = new ArrayList<>();
            Map<String, Map<String, Object>> radarData = new HashMap<>();
            List<Map<String, Object>> listData = new ArrayList<>();
            Map<String, String> xAxisMap = new HashMap<>();
            for (String quotaId : quotaIds) {
                Map<String, Object> dataMap = new HashMap<>();
                TjQuota tjQuota = quotaService.findOne(Long.valueOf(quotaId));
                if (null != tjQuota) {
                    String dictSql = getQuotaDimensionDictSql(tjQuota.getCode(), dimension);
                    Map<String, String> dimensionDicMap = new HashMap<>();
                    dimensionDicMap = setDimensionMap(dictSql, dimension, dimensionDicMap);
                    //使用分组计算 返回结果实例: groupDataMap -> "4205000000-儿-1": 200 =>group by 三个字段
                    Map<String, Integer> groupDataMap = quotaService.searcherSumByGroupBySql(tjQuota, dimension, filter, "result", "", "");
                    for (String key : groupDataMap.keySet()) {
                        key = key.toLowerCase();
                        dataMap.put(dimensionDicMap.containsKey(key) ? dimensionDicMap.get(key) : key, groupDataMap.get(key));
                        xAxisMap.put(dimensionDicMap.containsKey(key) ? dimensionDicMap.get(key) : key, key);
                    }
                    radarNames.add(tjQuota.getName());
                    radarData.put(tjQuota.getCode(), dataMap);
                }
                Integer num = getNum(dataMap);
                arrayNum.add(num);
                Map<String, Object> map = new HashMap();
                map.put(tjQuota.getName(), num);
                listData.add(map);
            }
            ReportOption reportOption = new ReportOption();
            Integer[] array = arrayNum.toArray(new Integer[arrayNum.size()]);
            Arrays.sort(array); // 进行升序排序
            polorCount += array[arrayNum.size() - 1];   // 雷达图极坐标
            option = reportOption.getRadarEchartOption(title, listData, polorCount);
            chartInfoModel.setOption(option.toString());
            chartInfoModel.setTitle(title);
            chartInfoModel.setxAxisMap(xAxisMap);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return chartInfoModel;
    }
    public ChartDataModel getChartDataModel(List<Integer> quotaId, Integer count, String resourceId, String dimension, String filter, Map<String, String> xAxisMap) throws Exception {
        ChartDataModel chartDataModel = new ChartDataModel();
        List<RsResourceQuota> resultList = resourceQuotaService.getChildrenByPidList(quotaId, resourceId);
        quotaId.clear();
        for (RsResourceQuota rq : resultList) {
            quotaId.add(Integer.valueOf(rq.getQuotaId()));
        }
        count = count - resultList.size();
        if (null != resultList && resultList.size() > 0) {
            List<Map<String, Object>> list = new ArrayList<>();
            for (RsResourceQuota rq : resultList) {
                RsResourceQuota parent = rq;
                TjQuota tjQuota = quotaService.findOne(Long.valueOf(rq.getQuotaId()));
                Map<String, Object> dataMap = new HashMap<>();
                if (null != tjQuota) {
                    String dictSql = getQuotaDimensionDictSql(tjQuota.getCode(), dimension);
                    Map<String, String> dimensionDicMap = new HashMap<>();
                    dimensionDicMap = setDimensionMap(dictSql, dimension, dimensionDicMap);
                    //使用分组计算 返回结果实例: groupDataMap -> "4205000000-儿-1": 200 =>group by 三个字段
                    Map<String, Integer> groupDataMap = quotaService.searcherSumByGroupBySql(tjQuota, dimension, filter, "result", "", "");
                    for (String key : groupDataMap.keySet()) {
                        key = key.toLowerCase();
                        dataMap.put(dimensionDicMap.containsKey(key) ? dimensionDicMap.get(key) : key, groupDataMap.get(key));
                        xAxisMap.put(dimensionDicMap.containsKey(key) ? dimensionDicMap.get(key) : key, key);
                    }
                }
                Integer num = getNum(dataMap);
                List<Map<String, Object>> mapList = new ArrayList<>();
                Map<String, Object> map = new HashMap();
                map.put("NAME", tjQuota.getName());
                map.put("TOTAL", num);
                mapList.add(map);
                rq.setMapList(mapList);
                list.addAll(rq.getMapList());
            }
            chartDataModel.setList(list);
        }
        if (count > 0) {
            ChartDataModel chartDataModel2 = getChartDataModel(quotaId, count, resourceId, dimension, filter, xAxisMap);
            if (null != chartDataModel2) {
                chartDataModel.setChildren(chartDataModel2);
            }
        }
        return chartDataModel;
    }
    public MChartInfoModel getQuotaNestedPieGraphicReports(String resourceId,String quotaIdStr,String filter,String dimension, String title) {
        List<String> quotaIds = Arrays.asList(quotaIdStr.split(","));
        Option option = null;
        MChartInfoModel chartInfoModel = new MChartInfoModel();
        Map<String, String> xAxisMap = new HashMap<>();
        try {
            Integer quotaCount = resourceQuotaService.getQuotaCount(resourceId);
            // 获取最顶层的资源
            List<Integer> quotaId = new ArrayList<>();
            ChartDataModel chartDataModel = getChartDataModel(quotaId, quotaCount, resourceId, dimension, filter, xAxisMap);
            ReportOption reportOption = new ReportOption();
            option = reportOption.getNestedPieEchartOption(title, chartDataModel);
            chartInfoModel.setOption(option.toString());
            chartInfoModel.setTitle(title);
            chartInfoModel.setxAxisMap(xAxisMap);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return chartInfoModel;
    }
    private BasesicUtil basesicUtil = new BasesicUtil();
    /**
     * 如果有计量单位,则把数值换算成相应的数值单位
     * @param optionData
     * @param dataMeasurement
     * @return
     */
    public List<List<Object>> discountByMeasurement(List<List<Object>> optionData, String dataMeasurement) {
        if (!org.apache.commons.lang.StringUtils.isEmpty(dataMeasurement)) {
            List<List<Object>> handleList = new ArrayList<>();
            double v = Double.parseDouble(dataMeasurement);
            optionData.forEach(one -> {
                List<Object> list = new ArrayList<>();
                one.forEach(item -> {
                    if(item != null && !item.toString().equals("--")){
                        item = basesicUtil.decimalPointHandle(Double.parseDouble(item.toString()) / v);
                        list.add(item);
                    }else {
                        list.add(0);
                    }
                });
                handleList.add(list);
            });
            return handleList;
        }
        return optionData;
    }
    public MChartInfoModel getQuotaGraphicReports(String quotaIdStr,String charstr,String filter, String dimension,String title,String top,String mRsResource
    ) {
        String xName = "";
        String yName = "";
        List<String> quotaIds = Arrays.asList(quotaIdStr.split(","));
        List<String> charTypes = Arrays.asList(charstr.split(","));
        MChartInfoModel chartInfoModel = new MChartInfoModel();
        String dimensionName = dimension + "Name";
        if ("quotaName".equals(dimension)) {
            dimensionName = "quotaName";
        }
        try {
            Option option = null;
            List<List<Object>> optionData = new ArrayList<>();
            List<String> lineNames = new ArrayList<>();
            Map<String, Map<String, Object>> lineData = new LinkedHashMap<>();
            Map<String, String> xAxisMap = new LinkedHashMap<>();
            Integer i = 0;
            List<Map<String, Object>> listMap = new ArrayList<>();
            for (String quotaId : quotaIds) {
                Map<String, Object> dataMap = new LinkedHashMap<>();
                TjQuota tjQuota = quotaService.findOne(Long.valueOf(quotaId));
                if (tjQuota != null) {
                    List<Map<String, Object>> resultListMap = baseStatistsService.getSimpleQuotaReport(tjQuota.getCode(), filter, dimension,true, top);
                    if (resultListMap != null && resultListMap.size() > 0) {
                        for (Map<String, Object> map : resultListMap) {
                            if (map != null && map.size() > 0) {
                                if (map.containsKey("quotaName")) {
                                    map.put("quotaName",tjQuota.getName());
                                }
                                listMap.add(map);
                                //第一种 ES库中有定义的维度 如org,slaveKey1
                                //第二种 ES库中未定义的维度 如level,economic
                                if (map.containsKey(dimensionName)) {
                                    if(map.get(dimensionName) != null){
                                        dataMap.put(map.get(dimensionName).toString(), map.get("result"));
                                        xAxisMap.put(map.get(dimensionName).toString(), map.get(dimension).toString());
                                    }
                                } else {
                                    if(map.get(dimension) != null){
                                        dataMap.put(map.get(dimension).toString(), map.get("result"));
                                        xAxisMap.put(map.get(dimension).toString(), map.get(dimension).toString());
                                    }
                                }
                            }
                        }
                    }
                    lineData.put("" + i, dataMap);
                    lineNames.add(tjQuota.getName());
                    i++;
                }
            }
//            lineNames.add(title);
//            lineData.put("", dataMap);
            Map<String, Object> quotaMap = new LinkedHashMap<>();
            ReportOption reportOption = new ReportOption();
            int size = 0;
            String quota = "0";
            if (lineData != null && lineData.size() > 0) {
                for (String key : lineData.keySet()) {
                    int tempSize = lineData.get(key).size();
                    if (tempSize > size) {
                        size = tempSize;
                        quota = key;
                        quotaMap = lineData.get(key);
                    }
                }
                for (String key : lineData.keySet()) {
                    List<Object> dataList = new ArrayList<>();
                    Map<String, Object> valMap = lineData.get(key);
                    if (key != quota) {
                        for (String name : quotaMap.keySet()) {
                            if (valMap.containsKey(name)) {
                                dataList.add(valMap.get(name));
                            } else {
                                dataList.add(0);
                            }
                        }
                    } else {
                        for (String name : valMap.keySet()) {
                            dataList.add(valMap.get(name));
                        }
                    }
                    optionData.add(dataList);
                }
            }
            Object[] xData = (Object[]) quotaMap.keySet().toArray(new Object[quotaMap.size()]);
            for (String typeStr : charTypes) {
                if (typeStr.equals("common")) {
                    typeStr = "1";
                } else if (typeStr.equals("twoDimensional")) { // 这个需要与前端商榷  访问2次(二维表类型)
                    return null;
                }
                int type = Integer.valueOf(typeStr);
                String dataMeasurement = "";
                if (org.apache.commons.lang.StringUtils.isNotEmpty(mRsResource)) {
                    MRsResources mRsResources = objectMapper.readValue(mRsResource, MRsResources.class);
                    dataMeasurement = mRsResources.getDataMeasurement();
                    String dataPosition = mRsResources.getDataPosition();
                    if (org.apache.commons.lang.StringUtils.isNotEmpty(dataPosition) && "x".equalsIgnoreCase(dataPosition)) {
                        xName = "单位:" + mRsResources.getDataUnit();
                    } else if (org.apache.commons.lang.StringUtils.isNotEmpty(dataPosition) && "y".equalsIgnoreCase(dataPosition)) {
                        yName = "单位:" + mRsResources.getDataUnit();
                    }
                }
                if (type == ReportOption.bar) {
                    option = reportOption.getLineEchartOptionMoreChart(title, xName, yName, xData, discountByMeasurement(optionData, dataMeasurement), lineNames, charTypes);
                } else if (type == ReportOption.line) {
                    option = reportOption.getLineEchartOptionMoreChart(title, xName, yName, xData, discountByMeasurement(optionData, dataMeasurement), lineNames, charTypes);
                } else if (type == ReportOption.pie) {
                    List<Map<String, Object>> datalist = new ArrayList<>();
                    for (Map<String, Object> resultMap : listMap) {
                        Map<String, Object> map = new HashMap<>();
                        map.put("NAME", null == resultMap.get(dimensionName) ? resultMap.get(dimension) : resultMap.get(dimensionName));
                        map.put("TOTAL", resultMap.get("result"));
                        if(resultMap.get(dimensionName) != null){
                            map.put("NAME",resultMap.get(dimensionName));
                        }else {
                            //非 指标中配置的维度 关联出来的字段
                            if(dimensionName.equals("levelName")){
                                if(resultMap.get(dimension).equals("1")){
                                    map.put("NAME","一级医院");
                                }else  if(resultMap.get(dimension).equals("2")){
                                    map.put("NAME","二级医院");
                                }else  if(resultMap.get(dimension).equals("3")){
                                    map.put("NAME","三级医院");
                                }
                            }
                        }
                        map.put("TOTAL",resultMap.get("result"));
                        datalist.add(map);
                    }
                    option = reportOption.getPieEchartOption(title, "", "", datalist, lineNames.get(0), null);
                }
            }
            chartInfoModel.setOption(option.toString());
            chartInfoModel.setTitle(title);
            chartInfoModel.setxAxisMap(xAxisMap);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return chartInfoModel;
    }
//    @RequestMapping(value = ServiceApi.Resources.GetRsQuotaPreview, method = RequestMethod.GET)
//    @ApiOperation(value = "根据资源Id获取资源视图关联指标列表预览单个图表支持 柱状,线型,饼状,雷达,旭日,支持多个指标放在一个图形上展示")
    public MChartInfoModel getRsQuotaPreview(String resourceId, String quotaFilter,String dimension,String top) throws Exception {
        String filter = quotaFilter;
        //-----------------用户数据权限 end
        MChartInfoModel chartInfoModel = new MChartInfoModel();;
        RsResource rsResourcesModel = rsResourceService.getResourceById(resourceId);
        if(rsResourcesModel == null){
            System.out.println("视图不存在,请确认!");
            return chartInfoModel;
        }else {
            List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + resourceId);
            if(list != null && list.size() > 0){
                String quotaCodestr  = "";
                String quotaIdstr  = "";
                String charstr = "";
                int charTypeNum = 0;
                boolean lineOrBarFlag = true;
                boolean pieFlag = true;
                for (RsResourceQuota m : list) {
                    quotaCodestr = quotaCodestr + m.getQuotaCode() +",";
                    quotaIdstr = quotaIdstr + m.getQuotaId() +",";
                    charstr = charstr + m.getQuotaChart() +",";
                    if(lineOrBarFlag && (m.getQuotaChart() == 1 || m.getQuotaChart() == 2)){
                        charTypeNum ++;
                        lineOrBarFlag = false;
                    }else if(pieFlag && m.getQuotaChart() == 3) {
                        charTypeNum ++;
                        pieFlag = false;
                    }
                }
                List<Map<String, String>> synthesiseDimensionMap = getTjQuotaSynthesiseDimension(quotaCodestr);
                Map<String, String> dimensionMap = new LinkedHashMap<>();
                String firstDimension = "";
                boolean firstFlag = true;
                for(Map<String, String> map :synthesiseDimensionMap){
                    String name = "";
                    String code = "";
                    for(String key :map.keySet()){
                        if(key.equals("name")){
                            name = map.get(key);
                        }else{
                            code = map.get(key);
                        }
                    }
                    dimensionMap.put(code,name);
                    if(firstFlag){
                        firstDimension = code;
                        firstFlag =  false;
                    }
                }
                if(org.apache.commons.lang.StringUtils.isEmpty(dimension) || dimension.equals(" ")){
                    String defaultDimension = rsResourcesModel.getDimension();
                    if (!org.apache.commons.lang.StringUtils.isEmpty(defaultDimension)) {
                        dimension = rsResourcesModel.getDimension();
                    } else {
                        dimension = firstDimension;
                    }
                }
                if(charTypeNum > 1){
                    System.out.println("视图由多个指标组成时,预览图形支持 多指标都属于同一类型,混合型目前支持‘柱状+柱状’,请确认图表展示类型!");
                    return chartInfoModel;
                }else {
                    if(StringUtils.isNotEmpty(rsResourcesModel.getEchartType()) && rsResourcesModel.getEchartType().equals("radar")){
                        chartInfoModel = getQuotaRadarGraphicReports(quotaIdstr, filter, dimension, rsResourcesModel.getName());
                    }else if(StringUtils.isNotEmpty(rsResourcesModel.getEchartType()) && rsResourcesModel.getEchartType().equals("nestedPie")){
                        chartInfoModel = getQuotaNestedPieGraphicReports(resourceId, quotaIdstr, filter, dimension, rsResourcesModel.getName());
                    }else {
                        //修改前
//                        chartInfoModel = tjQuotaJobClient.getMoreQuotaGraphicReportPreviews(quotaIdstr, charstr, filter, dimension, mRsResources.getName());
                        //修改后
                        String chart = "";
                        if(org.apache.commons.lang.StringUtils.isNotEmpty(rsResourcesModel.getEchartType())){
                            chart = rsResourcesModel.getEchartType();
                            if(chart.equals("bar")){
                                chart ="1";
                            }else if(chart.equals("line")){
                                chart ="2";
                            }else if(chart.equals("pie")){
                                chart ="3";
                            } else if ("mixed".equals(chart)) {
                                chart = charstr;
                            }
                        }else{
                            chart = charstr;
                        }
                        if(StringUtils.isEmpty(dimension) && StringUtils.isNotEmpty(rsResourcesModel.getDimension())){
                            dimension = rsResourcesModel.getDimension();
                        }else if (StringUtils.isEmpty(dimension)) {
                            dimension =  firstDimension;
                        }
                        chartInfoModel = getQuotaGraphicReports(quotaIdstr, chart, filter, dimension , rsResourcesModel.getName(), top, objectMapper.writeValueAsString(rsResourcesModel));
                    }
                    if(chartInfoModel != null){
                        chartInfoModel.setResourceId(resourceId);
                        chartInfoModel.setDimensionMap(dimensionMap);
                        chartInfoModel.setFirstDimension(firstDimension);
                    }else {
                        System.out.println("视图数据查询错误!");
                    }
                }
            }else{
                System.out.println("视图中无指标,请确认!");
            }
        }
        return chartInfoModel;
    }
    public ObjEnvelop getTemplateData(String reportCode,String linkageResourceId,String linkageFilter,String linkageDimension, String limitCondition) {
        Map<String, Object> resultMap = new HashMap<>();
        List<Map<String, Object>> viewInfos = new ArrayList<>();
        Map<String, String> limitMap = new HashMap();   //  存放需要限制查询条数的resourceId及限制的条数
        try {
            if (StringUtils.isNotEmpty(limitCondition)) {
                limitMap = objectMapper.readValue(limitCondition, Map.class);
            }
            // 获取图形配置
            Map<String, Object> viewInfo = new HashMap<>();
            List<Map<String, Object>> options = new ArrayList<>();
            RsResource rsResourcesModel = rsResourceService.getResourceById(linkageResourceId);
            if (rsResourcesModel.getDataSource() == 1) {
                // 档案视图场合
                //params.put("filters", "resourcesId=" + linkageResourceId + ";paramKey=q");
                //HttpResponse httpResponse = HttpUtils.doGet(adminInnerUrl + "/resource/api/v1.0/resources/params/no_paging", params);
                String queryStr = "";
                viewInfo.put("type", "record");
                viewInfo.put("resourceCode", rsResourcesModel.getCode());
                viewInfo.put("searchParams", queryStr);
                // 获取展示的列名
                List<MRsColumnsModel> columns = resourceBrowseControllerService.getResourceMetadata(rsResourcesModel.getCode(),"");
                viewInfo.put("columns", columns);
                viewInfos.add(viewInfo);
                resultMap.put("viewInfos", viewInfos);
            } else if (rsResourcesModel.getDataSource() == 2) {
                //指标视图 展示图形类型:data 数值, bar 柱状,line 线型, pie 饼图, twoDimensional 二维表,radar 雷达图, nestedPie 旭日图
                if(rsResourcesModel.getEchartType().contains("data") || rsResourcesModel.getEchartType().contains("twoDimensional")){
                    resultMap.put("type", "twoDimensional");
                    resultMap.put("viewInfos", getTemplateDataTable(linkageResourceId,linkageFilter, limitCondition));
                }else {
                    resultMap.put("type", "echart");
                    // 指标视图场合
                    // 判断是否需要限制查询条数
                    String top = "";
                    if (limitMap.containsKey(linkageResourceId)) {
                        top = limitMap.get(linkageResourceId);
                    }
                    MChartInfoModel chartInfoModel = getRsQuotaPreview(linkageResourceId,linkageFilter,"",top);
                    if (chartInfoModel!=null && StringUtils.isEmpty(chartInfoModel.getResourceId())) {
                        Map<String, Object> option = new HashMap<>();
                        option.put("resourceCode", chartInfoModel.getResourceCode());
                        option.put("resourceId", chartInfoModel.getResourceId());
                        option.put("dimensionOptions", chartInfoModel.getDimensionMap());
                        option.put("option", chartInfoModel.getOption());
                        if(StringUtils.isNotEmpty(reportCode)) {
                            // 获取报表视图
                            RsReport rsReportModel = rsReportService.getByCode(reportCode);
                            String position = rsReportModel.getPosition();
                            if (StringUtils.isNotEmpty(position)) {
                                Map<String, String> map = new HashMap<>();
                                List<Map<String, String>> listMap = objectMapper.readValue(position, new TypeReference<List<Map<String, String>>>() {
                                });
                                if (null != listMap && listMap.size() > 0) {
                                    for (int i = 0; i < listMap.size(); i++) {
                                        map.put(listMap.get(i).get("key"), listMap.get(i).get("resourceId"));
                                    }
                                }
                                if (null != map && map.size() > 0) {
                                    for (Map.Entry<String, String> m : map.entrySet()) {
                                        if (m.getValue().equals(chartInfoModel.getResourceId())) {
                                            option.put(m.getKey(), m.getValue());
                                        }
                                    }
                                }
                            }
                        }
                        options.add(option);
                        viewInfo.put("options", options); // 视图包含的指标echart图形的option。
                        viewInfos.add(viewInfo);
                        resultMap.put("viewInfos", viewInfos);
                    }
                }
            }
            return ObjEnvelop.getSuccess("",resultMap);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("报表模板获取失败");
        }
    }
    public List<Map<String, Object>> getTemplateDataTable(String resourceId,String filter, String limitCondition) {
        List<Map<String, Object>> viewInfo = new ArrayList<>();
        try {
            Map<String, String> limitMap = new HashMap();   //  存放需要限制查询条数的resourceId及限制的条数
            if (StringUtils.isNotEmpty(limitCondition)) {
                limitMap = objectMapper.readValue(limitCondition, Map.class);
            }
            Map<String, Object> params = new HashMap<>();
            params.clear();
            params.put("resourceId", resourceId);
            params.put("filters", filter);
            // 判断是否需要限制查询条数
            String top = "";
            if (limitMap.containsKey(resourceId) ){
                top = limitMap.get( resourceId );
            }
            RsResource rsResourcesModel = rsResourceService.getResourceById(resourceId);
            String quotaCodeStr = "";
            if(rsResourcesModel!=null){
                System.out.println("视图不存在,请确认!");
                return viewInfo;
            }else {
                List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + resourceId);
                if (list != null && list.size() > 0) {
                    for (RsResourceQuota resourceQuotaModel : list) {
                        quotaCodeStr = quotaCodeStr + resourceQuotaModel.getQuotaCode() + ",";
                    }
                }
            }
            return quotaService.getQuotaReportTwoDimensionalTable(quotaCodeStr,filter,null,top);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 获取单个视图数据
     * @param viewCode
     * @param filter
     * @return
     */
//    public Envelop getViewData(String viewCode,String filter ) {
//        Envelop envelop = new Envelop();
//        List<Map<String, Object>> viewInfo = new ArrayList<>();
//        try {
//            Map<String, Object> params = new HashMap<>();
//            params.clear();
//            params.put("code", viewCode);
//            String resourceEnvelopStr = getHttpRespons(params, ServiceApi.Resources.ResourceByCode);
//            RsResourcesModel rsResourcesModel = objectMapper.readValue(resourceEnvelopStr, RsResourcesModel.class);
//            params.clear();
//            params.put("resourceId", rsResourcesModel.getId());
//            params.put("filters", filter);
//            String rowsEnvelopStr = getHttpRespons(params,ServiceApi.TJ.GetQuotaReportTwoDimensionalTable);
//            viewInfo = objectMapper.readValue(rowsEnvelopStr, new TypeReference<List<Map<String, Object>>>() {});
//            envelop.setDetailModelList(viewInfo);
//            envelop.setSuccessFlg(true);
//        } catch (Exception e) {
//            e.printStackTrace();
//            envelop.setSuccessFlg(false);
//            envelop.setErrorMsg("视图数据获取失败");
//            return null;
//        }
//        return envelop;
//    }
}

+ 0 - 3
svr/svr-basic/src/main/java/com/yihu/jw/basic/portal/controller/PortalSurveyQuestionAdminController.java

@ -13,11 +13,8 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Map;

+ 11 - 133
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/QuotaReportController.java

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.agadmin.service.ReportService;
import com.yihu.jw.basic.quota.service.*;
import com.yihu.jw.basic.quota.service.*;
import com.yihu.jw.basic.resource.service.RsResourceQuotaService;
import com.yihu.jw.basic.resource.service.RsResourceQuotaService;
import com.yihu.jw.basic.util.BasesicUtil;
import com.yihu.jw.basic.util.BasesicUtil;
@ -66,7 +67,8 @@ public class QuotaReportController extends EnvelopRestEndpoint {
    private BaseStatistsService baseStatistsService;
    private BaseStatistsService baseStatistsService;
    @Autowired
    @Autowired
    private DeviceService deviceService;
    private DeviceService deviceService;
    @Autowired
    private ReportService reportService;
    private BasesicUtil basesicUtil = new BasesicUtil();
    private BasesicUtil basesicUtil = new BasesicUtil();
    public static String orgHealthCategoryCode = "orgHealthCategoryCode";
    public static String orgHealthCategoryCode = "orgHealthCategoryCode";
@ -302,9 +304,9 @@ public class QuotaReportController extends EnvelopRestEndpoint {
                    }
                    }
                }
                }
                if (type == ReportOption.bar) {
                if (type == ReportOption.bar) {
                    option = reportOption.getLineEchartOptionMoreChart(title, xName, yName, xData, discountByMeasurement(optionData, dataMeasurement), lineNames, charTypes);
                    option = reportOption.getLineEchartOptionMoreChart(title, xName, yName, xData, reportService.discountByMeasurement(optionData, dataMeasurement), lineNames, charTypes);
                } else if (type == ReportOption.line) {
                } else if (type == ReportOption.line) {
                    option = reportOption.getLineEchartOptionMoreChart(title, xName, yName, xData, discountByMeasurement(optionData, dataMeasurement), lineNames, charTypes);
                    option = reportOption.getLineEchartOptionMoreChart(title, xName, yName, xData, reportService.discountByMeasurement(optionData, dataMeasurement), lineNames, charTypes);
                } else if (type == ReportOption.pie) {
                } else if (type == ReportOption.pie) {
                    List<Map<String, Object>> datalist = new ArrayList<>();
                    List<Map<String, Object>> datalist = new ArrayList<>();
                    for (Map<String, Object> resultMap : listMap) {
                    for (Map<String, Object> resultMap : listMap) {
@ -497,28 +499,7 @@ public class QuotaReportController extends EnvelopRestEndpoint {
    }
    }
    private String getQuotaDimensionDictSql(String quotaCode, String dimension) {
        String dictSql = "";
        //查询维度
        List<TjQuotaDimensionMain> dimensionMains = tjDimensionMainService.findTjQuotaDimensionMainByQuotaCode(quotaCode);
        if (dimensionMains != null && dimensionMains.size() > 0) {
            for (TjQuotaDimensionMain main : dimensionMains) {
                if (main.getMainCode().equals(dimension)) {
                    dictSql = main.getDictSql();
                }
            }
        }
        if (StringUtils.isEmpty(dictSql)) {
            List<TjQuotaDimensionSlave> dimensionSlaves = tjDimensionSlaveService.findTjQuotaDimensionSlaveByQuotaCode(quotaCode);
            if (dimensionSlaves != null && dimensionSlaves.size() > 0) {
                int slave = Integer.valueOf(dimension.substring(dimension.length() - 1, dimension.length()));
                if (dimensionSlaves.size() >= slave) {
                    dictSql = dimensionSlaves.get(slave - 1).getDictSql();
                }
            }
        }
        return dictSql;
    }
    @ApiOperation(value = "获取指标统计结果echart radar雷达图表")
    @ApiOperation(value = "获取指标统计结果echart radar雷达图表")
    @RequestMapping(value = ServiceApi.TJ.GetQuotaRadarGraphicReportPreviews, method = RequestMethod.GET)
    @RequestMapping(value = ServiceApi.TJ.GetQuotaRadarGraphicReportPreviews, method = RequestMethod.GET)
@ -546,9 +527,9 @@ public class QuotaReportController extends EnvelopRestEndpoint {
                Map<String, Object> dataMap = new HashMap<>();
                Map<String, Object> dataMap = new HashMap<>();
                TjQuota tjQuota = quotaService.findOne(Long.valueOf(quotaId));
                TjQuota tjQuota = quotaService.findOne(Long.valueOf(quotaId));
                if (null != tjQuota) {
                if (null != tjQuota) {
                    String dictSql = getQuotaDimensionDictSql(tjQuota.getCode(), dimension);
                    String dictSql = reportService.getQuotaDimensionDictSql(tjQuota.getCode(), dimension);
                    Map<String, String> dimensionDicMap = new HashMap<>();
                    Map<String, String> dimensionDicMap = new HashMap<>();
                    dimensionDicMap = setDimensionMap(dictSql, dimension, dimensionDicMap);
                    dimensionDicMap = reportService.setDimensionMap(dictSql, dimension, dimensionDicMap);
                    //使用分组计算 返回结果实例: groupDataMap -> "4205000000-儿-1": 200 =>group by 三个字段
                    //使用分组计算 返回结果实例: groupDataMap -> "4205000000-儿-1": 200 =>group by 三个字段
                    Map<String, Integer> groupDataMap = quotaService.searcherSumByGroupBySql(tjQuota, dimension, filter, "result", "", "");
                    Map<String, Integer> groupDataMap = quotaService.searcherSumByGroupBySql(tjQuota, dimension, filter, "result", "", "");
                    for (String key : groupDataMap.keySet()) {
                    for (String key : groupDataMap.keySet()) {
@ -559,7 +540,7 @@ public class QuotaReportController extends EnvelopRestEndpoint {
                    radarNames.add(tjQuota.getName());
                    radarNames.add(tjQuota.getName());
                    radarData.put(tjQuota.getCode(), dataMap);
                    radarData.put(tjQuota.getCode(), dataMap);
                }
                }
                Integer num = getNum(dataMap);
                Integer num = reportService.getNum(dataMap);
                arrayNum.add(num);
                arrayNum.add(num);
                Map<String, Object> map = new HashMap();
                Map<String, Object> map = new HashMap();
                map.put(tjQuota.getName(), num);
                map.put(tjQuota.getName(), num);
@ -601,7 +582,7 @@ public class QuotaReportController extends EnvelopRestEndpoint {
            Integer quotaCount = resourceQuotaService.getQuotaCount(resourceId);
            Integer quotaCount = resourceQuotaService.getQuotaCount(resourceId);
            // 获取最顶层的资源
            // 获取最顶层的资源
            List<Integer> quotaId = new ArrayList<>();
            List<Integer> quotaId = new ArrayList<>();
            ChartDataModel chartDataModel = getChartDataModel(quotaId, quotaCount, resourceId, dimension, filter, xAxisMap);
            ChartDataModel chartDataModel = reportService.getChartDataModel(quotaId, quotaCount, resourceId, dimension, filter, xAxisMap);
            ReportOption reportOption = new ReportOption();
            ReportOption reportOption = new ReportOption();
            option = reportOption.getNestedPieEchartOption(title, chartDataModel);
            option = reportOption.getNestedPieEchartOption(title, chartDataModel);
@ -615,85 +596,7 @@ public class QuotaReportController extends EnvelopRestEndpoint {
        }
        }
    }
    }
    private ChartDataModel getChartDataModel(List<Integer> quotaId, Integer count, String resourceId, String dimension, String filter, Map<String, String> xAxisMap) throws Exception {
        ChartDataModel chartDataModel = new ChartDataModel();
        List<RsResourceQuota> resultList = resourceQuotaService.getChildrenByPidList(quotaId, resourceId);
        quotaId.clear();
        for (RsResourceQuota rq : resultList) {
            quotaId.add(Integer.valueOf(rq.getQuotaId()));
        }
        count = count - resultList.size();
        if (null != resultList && resultList.size() > 0) {
            List<Map<String, Object>> list = new ArrayList<>();
            for (RsResourceQuota rq : resultList) {
                RsResourceQuota parent = rq;
                TjQuota tjQuota = quotaService.findOne(Long.valueOf(rq.getQuotaId()));
                Map<String, Object> dataMap = new HashMap<>();
                if (null != tjQuota) {
                    String dictSql = getQuotaDimensionDictSql(tjQuota.getCode(), dimension);
                    Map<String, String> dimensionDicMap = new HashMap<>();
                    dimensionDicMap = setDimensionMap(dictSql, dimension, dimensionDicMap);
                    //使用分组计算 返回结果实例: groupDataMap -> "4205000000-儿-1": 200 =>group by 三个字段
                    Map<String, Integer> groupDataMap = quotaService.searcherSumByGroupBySql(tjQuota, dimension, filter, "result", "", "");
                    for (String key : groupDataMap.keySet()) {
                        key = key.toLowerCase();
                        dataMap.put(dimensionDicMap.containsKey(key) ? dimensionDicMap.get(key) : key, groupDataMap.get(key));
                        xAxisMap.put(dimensionDicMap.containsKey(key) ? dimensionDicMap.get(key) : key, key);
                    }
                }
                Integer num = getNum(dataMap);
                List<Map<String, Object>> mapList = new ArrayList<>();
                Map<String, Object> map = new HashMap();
                map.put("NAME", tjQuota.getName());
                map.put("TOTAL", num);
                mapList.add(map);
                rq.setMapList(mapList);
                list.addAll(rq.getMapList());
            }
            chartDataModel.setList(list);
        }
        if (count > 0) {
            ChartDataModel chartDataModel2 = getChartDataModel(quotaId, count, resourceId, dimension, filter, xAxisMap);
            if (null != chartDataModel2) {
                chartDataModel.setChildren(chartDataModel2);
            }
        }
        return chartDataModel;
    }
    private Map<String, String> setDimensionMap(String dictSql, String dimension, Map<String, String> dimensionDicMap) {
        if (StringUtils.isNotEmpty(dictSql)) {
            BasesicUtil baseUtil = new BasesicUtil();
            if (dimension.contains("slaveKey")) {
                //查询字典数据
                List<DictModel> dictDatas = jdbcTemplate.query(dictSql, new BeanPropertyRowMapper(DictModel.class));
                for (DictModel dictModel : dictDatas) {
                    String name = baseUtil.getFieldValueByName("name", dictModel);
                    String val = baseUtil.getFieldValueByName("code", dictModel).toLowerCase();
                    dimensionDicMap.put(val, name);
                }
            } else {
                List<SaveModel> dictDatas = jdbcTemplate.query(dictSql, new BeanPropertyRowMapper(SaveModel.class));
                if (dictDatas != null) {
                    for (SaveModel saveModel : dictDatas) {
                        String name = baseUtil.getFieldValueByName(dimension + "Name", saveModel);
                        String val = baseUtil.getFieldValueByName(dimension, saveModel).toLowerCase();
                        dimensionDicMap.put(val, name);
                    }
                }
            }
        }
        return dimensionDicMap;
    }
    private Integer getNum(Map<String, Object> dataMap) {
        Integer num = 0;
        for (String key : dataMap.keySet()) {
            Integer result = null != dataMap.get(key) ? Integer.parseInt(dataMap.get(key).toString()) : 0;
            num += result;
        }
        return num;
    }
    @RequestMapping(value = "/tj/getCostAndNumOfOutPatient", method = RequestMethod.GET)
    @RequestMapping(value = "/tj/getCostAndNumOfOutPatient", method = RequestMethod.GET)
    @ApiOperation(value = "门急诊费用、人次")
    @ApiOperation(value = "门急诊费用、人次")
    public Map<String, String> getCostOfOutPatient() {
    public Map<String, String> getCostOfOutPatient() {
@ -897,30 +800,5 @@ public class QuotaReportController extends EnvelopRestEndpoint {
        return objectMapper.writeValueAsString(obj);
        return objectMapper.writeValueAsString(obj);
    }
    }
    /**
     * 如果有计量单位,则把数值换算成相应的数值单位
     * @param optionData
     * @param dataMeasurement
     * @return
     */
    public List<List<Object>> discountByMeasurement(List<List<Object>> optionData, String dataMeasurement) {
        if (!StringUtils.isEmpty(dataMeasurement)) {
            List<List<Object>> handleList = new ArrayList<>();
            double v = Double.parseDouble(dataMeasurement);
            optionData.forEach(one -> {
                List<Object> list = new ArrayList<>();
                one.forEach(item -> {
                    if(item != null && !item.toString().equals("--")){
                        item = basesicUtil.decimalPointHandle(Double.parseDouble(item.toString()) / v);
                        list.add(item);
                    }else {
                        list.add(0);
                    }
                });
                handleList.add(list);
            });
            return handleList;
        }
        return optionData;
    }
}
}

+ 1 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/service/TjQuotaService.java

@ -42,7 +42,7 @@ public class TjQuotaService extends BaseJpaService<TjQuota, XTjQuotaRepository>
            tjQuotaDataSaveService.save(dataSave);
            tjQuotaDataSaveService.save(dataSave);
        }
        }
        quota.setName(quota.getName().trim());
        quota.setName(quota.getName().trim());
        quota.setStatus(Integer.parseInt(quota.getCode()));
        quota.setCode(quota.getCode().trim());
        quota = save(quota);
        quota = save(quota);
        return quota;
        return quota;
    }
    }

+ 36 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterDataSetKeySchema.java

@ -0,0 +1,36 @@
package com.yihu.jw.basic.redis.schema;
import com.yihu.jw.redis.schema.KeySchema;
import org.springframework.stereotype.Component;
@Component
public class AdapterDataSetKeySchema extends KeySchema {
    private String AdapterDatasetCode = "adapter_dataset_code";
    private String AdapterDatasetName = "adapter_dataset_name";
    /**
     * 清空当前表的所有缓存
     * @param table
     */
    public void delete(String table){
        redisClient.delete(makeKey(table , "*","*"));
    }
    public String getAdapterDatasetCode(String dataSetTableName, String stdDatasetCode) {
        return redisClient.get(makeKey(dataSetTableName , stdDatasetCode, AdapterDatasetCode));
    }
    public void setAdapterDataSetCode(String table, String id,String value){
        redisClient.set(makeKey(table , id, AdapterDatasetCode),value);
    }
    public String getAdapterDatasetName(String dataSetTableName, String stdDatasetCode) {
        return redisClient.get(makeKey(dataSetTableName, stdDatasetCode, AdapterDatasetName));
    }
    public void setAdapterDatasetName(String table, String stdDatasetCode, String value) {
        redisClient.set(makeKey(table, stdDatasetCode, AdapterDatasetName), value);
    }
}

+ 25 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterDictEntryKeySchema.java

@ -0,0 +1,25 @@
package com.yihu.jw.basic.redis.schema;
import com.yihu.jw.redis.schema.KeySchema;
import org.springframework.stereotype.Component;
/**
 *  Created by hzp on 2017.04.25
 */
@Component
public class AdapterDictEntryKeySchema extends KeySchema {
    private String AdapterEntryCode = "adapter_entry_value";
    public void delete(String tableName) {
        redisClient.delete(makeKey(tableName , "*", "*"));
    }
    public void setAdapterDictEntryCode(String dictEntryTable, String stdDictCode, String stdEntryCode, String value) {
        redisClient.set(makeKey(dictEntryTable, stdDictCode + "." + stdEntryCode, AdapterEntryCode),value);
    }
    public String getAdapterDictEntryCode(String dictEntryTableName, String stdDictCode, String stdDictEntryCode) {
        return redisClient.get(makeKey(dictEntryTableName, stdDictCode + "." + stdDictEntryCode, AdapterEntryCode));
    }
}

+ 25 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/redis/schema/AdapterDictKeySchema.java

@ -0,0 +1,25 @@
package com.yihu.jw.basic.redis.schema;
import com.yihu.jw.redis.schema.KeySchema;
import org.springframework.stereotype.Component;
/**
 *  Created by hzp on 2017.04.25
 */
@Component
public class AdapterDictKeySchema extends KeySchema {
    private String AdapterDictCode="adapter_dict_code";
    public void delete(String tableName) {
        redisClient.delete(makeKey(tableName , "*", "*"));
    }
    public void setAdapterDictCode(String dictTable, String stdDictCode, String adapterDictCode) {
        redisClient.set(makeKey(dictTable , stdDictCode, AdapterDictCode),adapterDictCode);
    }
    public String getAdapterDictCode(String dictTable, String stdDictCode) {
        return redisClient.get(makeKey(dictTable , stdDictCode, AdapterDictCode));
    }
}

+ 1 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportEndPoint.java

@ -145,8 +145,7 @@ public class RsReportEndPoint extends EnvelopRestEndpoint {
    @RequestMapping(value = ServiceApi.Resources.RsReportTemplateContent, method = RequestMethod.GET)
    @RequestMapping(value = ServiceApi.Resources.RsReportTemplateContent, method = RequestMethod.GET)
    public Envelop getTemplateContent(
    public Envelop getTemplateContent(
            @ApiParam(name = "reportCode", value = "资源报表Code", required = true)
            @ApiParam(name = "reportCode", value = "资源报表Code", required = true)
            @RequestParam(value = "reportCode") String reportCode,
            HttpServletResponse response) throws Exception {
            @RequestParam(value = "reportCode") String reportCode) throws Exception {
        RsReport rsReport = rsReportService.getByCode(reportCode);
        RsReport rsReport = rsReportService.getByCode(reportCode);
        if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
        if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
            return failed("模版未找到");
            return failed("模版未找到");

+ 81 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/AdapterRedisEndPoint.java

@ -0,0 +1,81 @@
package com.yihu.jw.basic.standard.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.jw.basic.standard.service.redis.AdapterRedisService;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.thread.ContextAttributes;
import com.yihu.jw.util.thread.LocalContext;
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;
@RestController
@Api(value = "Redis", description = "Redis数据缓存服务")
public class AdapterRedisEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private AdapterRedisService adapterRedisService;
    @ApiOperation("Redis缓存适配方案")
    @RequestMapping(value = ServiceApi.Redis.InitAdapterVersions, method = RequestMethod.POST)
    public String cacheVersions(
            @ApiParam(name = "versions", value = "适配方案版本,多个用逗号分隔")
            @RequestParam("versions") String versions,
            @ApiParam(name = "force", value = "强制清除再缓存", defaultValue = "true")
            @RequestParam("force") boolean force) throws Exception {
        String schema = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
        adapterRedisService.cacheVersions(versions, force,schema);
        return "Redis适配方案缓存完成!";
    }
    @ApiOperation("根据适配版本号和目标数据集code,获取的源数据集code")
    @RequestMapping(value = ServiceApi.Redis.AdapterDataSetCode, method = RequestMethod.GET)
    public String getAdapterDatasetCode(
            @ApiParam(name = "version", value = "适配方案版本")
            @RequestParam("version") String version,
            @ApiParam(name = "stdDatasetCode", value = "标准数据集code")
            @RequestParam("stdDatasetCode") String stdDatasetCode){
        return adapterRedisService.getAdapterDatasetCode(version,stdDatasetCode);
    }
    @ApiOperation("根据适配版本号和目标数据集code,目标数据元code,获取的源数据元code")
    @RequestMapping(value = ServiceApi.Redis.AdapterMetadataCode, method = RequestMethod.GET)
    public String getAdapterMetadataCode(
            @ApiParam(name = "version", value = "适配方案版本")
            @RequestParam("version") String version,
            @ApiParam(name = "stdDatasetCode", value = "标准数据集code")
            @RequestParam("stdDatasetCode") String stdDatasetCode,
            @ApiParam(name = "stdMetadataCode", value = "标准数据元code")
            @RequestParam("stdMetadataCode") String stdMetadataCode){
        return adapterRedisService.getAdapterMetadataCode(version,stdDatasetCode,stdMetadataCode);
    }
    @ApiOperation("根据适配版本号和目标字典code,获取的源字典code")
    @RequestMapping(value = ServiceApi.Redis.AdapterDictCode, method = RequestMethod.GET)
    public String getAdapterDictCode(@ApiParam(name = "version", value = "适配方案版本")
                                     @RequestParam("version") String version,
                                     @ApiParam(name = "stdDictCode", value = "标准字典code")
                                     @RequestParam("stdDictCode") String stdDictCode){
        return adapterRedisService.getAdapterDictCode(version,stdDictCode);
    }
    @ApiOperation("根据适配版本号和目标字典code,目标字典项code,获取的源字典项code")
    @RequestMapping(value = ServiceApi.Redis.AdapterDictEntryCode, method = RequestMethod.GET)
    public String getAdapterDictEntryCode(@ApiParam(name = "version", value = "适配方案版本")
                                     @RequestParam("version") String version,
                                     @ApiParam(name = "stdDictCode", value = "标准字典code")
                                     @RequestParam("stdDictCode") String stdDictCode,
                                     @ApiParam(name = "stdDictEntryCode", value = "标准字典项code")
                                     @RequestParam("stdDictEntryCode") String stdDictEntryCode){
        return adapterRedisService.getAdapterDictEntryCode(version,stdDictCode,stdDictEntryCode);
    }
}

+ 0 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/controller/StdCdaTypeController.java

@ -12,7 +12,6 @@
//import com.yihu.hos.web.framework.util.controller.EnvelopRestEndpoint;
//import com.yihu.hos.web.framework.util.controller.EnvelopRestEndpoint;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.StringUtils;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.ResponseBody;

+ 147 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/service/redis/AdapterRedisService.java

@ -0,0 +1,147 @@
package com.yihu.jw.basic.standard.service.redis;
import com.yihu.jw.basic.redis.schema.AdapterDataSetKeySchema;
import com.yihu.jw.basic.redis.schema.AdapterDictEntryKeySchema;
import com.yihu.jw.basic.redis.schema.AdapterDictKeySchema;
import com.yihu.jw.basic.redis.schema.AdapterMetaDataKeySchema;
import com.yihu.jw.basic.standard.service.bo.AdapterVersion;
import com.yihu.jw.basic.standard.task.AdapterRedisTask;
import com.yihu.jw.redis.client.RedisClient;
import com.yihu.jw.util.thread.ContextAttributes;
import com.yihu.jw.util.thread.LocalContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
@Service
public class AdapterRedisService {
    @Resource(name = "jdbcTemplate")
    private JdbcTemplate jdbc;
    @Autowired
    private AdapterRedisTask adapterRedisTask;
    @Autowired
    private AdapterDataSetKeySchema adapterDataSetKeySchema;
    @Autowired
    private AdapterMetaDataKeySchema adapterMetaDataKeySchema;
    @Autowired
    private AdapterDictKeySchema adapterDictKeySchema;
    @Autowired
    private AdapterDictEntryKeySchema adapterDictEntryKeySchema;
    @Autowired
    private RedisClient redisClient;
    @Async
    public Future<Boolean> cacheVersions(String versions, boolean force,String schema) {
        LocalContext.getContext().setAttachment(ContextAttributes.SCHEMA,schema);
        for (String version : versions.split(",")) {
            List<Map<String, Object>> ver = jdbc.queryForList("select * from adapter_scheme_version where version='"+version+"'");
            if(!CollectionUtils.isEmpty(ver)){
                redisClient.set(version,ver.get(0).get("name")+"");
            }
            AdapterVersion adapterVersion = new AdapterVersion(version);
            String dataSetTable = adapterVersion.getDataSetTableName();
            String metaDataTable = adapterVersion.getMetaDataTableName();
            String dictTable = adapterVersion.getDictTableName();
            String dictEntryTable = adapterVersion.getDictEntryTableName();
            if(force) {
                adapterDataSetKeySchema.delete(dataSetTable);
                adapterMetaDataKeySchema.delete(metaDataTable);
                adapterDictKeySchema.delete(dictTable);
                adapterDictEntryKeySchema.delete(dictEntryTable);
            }
            String dataSetQuery = "SELECT std_dataset_id,std_dataset_code,std_dataset_name,adapter_dataset_id,adapter_dataset_code,adapter_dataset_name FROM data.set.table";
            List<Map<String,Object>> dataSetList = jdbc.queryForList(dataSetQuery.replace("data.set.table", dataSetTable));
            //缓存数据集和数据元
            Future<Boolean> datasetAndMetadataCache = adapterRedisTask.cacheDatasetAndMetadata(dataSetList, dataSetTable, metaDataTable,schema);
            //获取适配字典进行缓存
            List<Map<String,Object>> dictList = jdbc.queryForList("select * from "+dictTable);
            Map<String, String> stdDictMap = new HashMap<>();//目标字典map, key为目标字典id  value 为目标字典code
            Map<String, String> adapterDictMap = new HashMap<>();//源字典map, key为源字典id  value 为源字典code
            //缓存字典
            Future<Boolean> dictCache = adapterRedisTask.cacheDict(dictList, dictTable,schema);
            for (Map<String, Object> temDictMap: dictList) {
                String stdDictCode = (String) temDictMap.get("std_dict_code");
                String stdDictId = String.valueOf(temDictMap.get("std_dict_id"));
                String adapterDictId =  String.valueOf(temDictMap.get("adapter_dict_id"));
                String adapterDictCode = (String) temDictMap.get("adapter_dict_code");
                if(StringUtils.isEmpty(adapterDictCode)){
                    adapterDictCode="";
                }
                stdDictMap.put(stdDictId,stdDictCode);
                adapterDictMap.put(adapterDictId,adapterDictCode);
            }
            //获取字典项进行缓存
            List<Map<String,Object>> dictEntryList = jdbc.queryForList("select * from "+dictEntryTable);
            Future<Boolean> dictEntryCache = adapterRedisTask.cacheDictEntry(dictEntryList, dictEntryTable,stdDictMap,adapterDictMap,schema);
            //数据集,数据元,字典,字典项全部缓存好在进行下个适配版本的缓存
            for (;;) {
                if(datasetAndMetadataCache.isDone() && dictCache.isDone() && dictEntryCache.isDone()) {
                    // 三个任务都调用完成,退出循环等待
                    break;
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
        return new AsyncResult<Boolean>(true);
    }
    /**
     * 根据适配版本号和数据集code,获取源数据集code
     * @param version 适配版本号
     * @param stdDatasetCode 数据集code
     * @return
     */
    public String getAdapterDatasetCode(String version, String stdDatasetCode) {
        AdapterVersion adapterVersion = new AdapterVersion(version);
        return adapterDataSetKeySchema.getAdapterDatasetCode(adapterVersion.getDataSetTableName(),stdDatasetCode);
    }
    /**
     * 根据适配版本号和目标数据集code,目标数据元code,获取源数据元code
     * @param version 适配版本号
     * @param stdDatasetCode 数据集code
     * @return
     */
    public String getAdapterMetadataCode(String version, String stdDatasetCode, String stdMetadataCode) {
        AdapterVersion adapterVersion = new AdapterVersion(version);
        return adapterMetaDataKeySchema.getAdapterMetaDataCode(adapterVersion.getMetaDataTableName(),stdDatasetCode,stdMetadataCode);
    }
    /**
     * 根据适配版本号和目标字典code,获取的源字典code
     * @param version  适配版本号
     * @param stdDictCode  目标字典code
     * @return
     */
    public String getAdapterDictCode(String version, String stdDictCode) {
        AdapterVersion adapterVersion = new AdapterVersion(version);
        return adapterDictKeySchema.getAdapterDictCode(adapterVersion.getDictTableName(),stdDictCode);
    }
    public String getAdapterDictEntryCode(String version, String stdDictCode, String stdDictEntryCode) {
        AdapterVersion adapterVersion = new AdapterVersion(version);
        return adapterDictEntryKeySchema.getAdapterDictEntryCode(adapterVersion.getDictEntryTableName(),stdDictCode,stdDictEntryCode);
    }
}

+ 150 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/standard/task/AdapterRedisTask.java

@ -0,0 +1,150 @@
package com.yihu.jw.basic.standard.task;
import com.yihu.jw.basic.redis.schema.AdapterDataSetKeySchema;
import com.yihu.jw.basic.redis.schema.AdapterDictEntryKeySchema;
import com.yihu.jw.basic.redis.schema.AdapterDictKeySchema;
import com.yihu.jw.basic.redis.schema.AdapterMetaDataKeySchema;
import com.yihu.jw.util.thread.ContextAttributes;
import com.yihu.jw.util.thread.LocalContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
@Component
public class AdapterRedisTask {
    @Resource(name = "jdbcTemplate")
    private JdbcTemplate jdbc;
    @Autowired
    private AdapterDataSetKeySchema adapterDataSetKeySchema;
    @Autowired
    private AdapterMetaDataKeySchema adapterMetaDataKeySchema;
    @Autowired
    private AdapterDictKeySchema adapterDictKeySchema;
    @Autowired
    private AdapterDictEntryKeySchema adapterDictEntryKeySchema;
    /**
     * 异步缓存适配的数据集和数据元
     * @param dataSetList
     * @param dataSetTable
     * @param metaDataTable
     * @return
     */
    @Async
    public Future<Boolean> cacheDatasetAndMetadata(List<Map<String,Object>> dataSetList, String dataSetTable, String metaDataTable,String schema){
        System.out.println("开始缓存适配的数据集,数据元");
        LocalContext.getContext().setAttachment(ContextAttributes.SCHEMA,schema);
        Map<Long, String> map = new HashMap<>();//key 为adapter_dataset_id,   value 为adapter_dataset_code
        for (Map<String, Object> tempMap: dataSetList) {
            String stdDatasetName = tempMap.get("std_dataset_name").toString();
            String stdDatasetCode = tempMap.get("std_dataset_code").toString();
            Integer stdDatasetId = (Integer)tempMap.get("std_dataset_id");
            String adapterDatasetIds = (String) tempMap.get("adapter_dataset_id");
            String adapterDatasetCodes = (String) tempMap.get("adapter_dataset_code");
            String adapterDatasetNames = (String) tempMap.get("adapter_dataset_name");
            if(!StringUtils.isEmpty(adapterDatasetIds)){
                String[] adapterDatasetIdArray = adapterDatasetIds.split(",");
                String[] adapterDatasetCodeArray = adapterDatasetCodes.split(",");
                for(int i =0;i<adapterDatasetIdArray.length;i++){
                    map.put(Long.valueOf(adapterDatasetIdArray[i]),adapterDatasetCodeArray[i]);
                }
            }
            //1. 缓存数据集
            if(StringUtils.isEmpty(adapterDatasetCodes)){
                adapterDatasetCodes="";
            }
            adapterDataSetKeySchema.setAdapterDataSetCode(dataSetTable, stdDatasetCode, adapterDatasetCodes);
            adapterDataSetKeySchema.setAdapterDatasetName(dataSetTable, stdDatasetCode, adapterDatasetNames);
            //获取数据元进行缓存
            List<Map<String,Object>> metadataList = jdbc.queryForList("select * from "+metaDataTable+" t where t.std_dataset_id="+stdDatasetId);
            for (Map<String, Object> tempMetadaMap: metadataList) {
                String adapterCode = "";
                String adapterName = "";
                String stdName = "";
                String stdMetadataCode = (String) tempMetadaMap.get("std_metadata_code");
                String adapterDatasetId = String.valueOf(tempMetadaMap.get("adapter_dataset_id"));
                if(!StringUtils.isEmpty(adapterDatasetId) && !"null".equals(adapterDatasetId)){
                    String adapterDatasetCode = map.get(Long.valueOf(adapterDatasetId));
                    String adapterMetadataCode = (String) tempMetadaMap.get("adapter_metadata_code");
                    String adapterMetadataName = (String) tempMetadaMap.get("adapter_metadata_name");
                    String stdMetadataName = (String) tempMetadaMap.get("std_metadata_name");
                    adapterCode = adapterDatasetCode + "." + adapterMetadataCode;
                    adapterName = adapterDatasetNames + "." + adapterMetadataName;
                    stdName = stdDatasetName + "." + stdMetadataName;
                }
                //缓存数据元
                adapterMetaDataKeySchema.setAdapterMetaDataCode(metaDataTable, stdDatasetCode, stdMetadataCode, adapterCode);
                adapterMetaDataKeySchema.setAdapterMetaDataName(metaDataTable, stdDatasetCode, stdMetadataCode, adapterName);
                adapterMetaDataKeySchema.setStdMetaDataName(metaDataTable, stdDatasetCode, stdMetadataCode, stdName);
            }
        }
        System.out.println("缓存适配的数据集,数据元完成");
        return new AsyncResult<Boolean>(true);
    }
    /**
     * 缓存适配的字典
     * @param dictList
     * @param dictTable
     * @return
     */
    @Async
    public Future<Boolean> cacheDict(List<Map<String,Object>> dictList, String dictTable,String schema){
        System.out.println("开始缓存适配的字典");
        LocalContext.getContext().setAttachment(ContextAttributes.SCHEMA,schema);
        for (Map<String, Object> temDictMap: dictList) {
            String stdDictCode = (String) temDictMap.get("std_dict_code");
            String adapterDictCode = (String) temDictMap.get("adapter_dict_code");
            if(StringUtils.isEmpty(adapterDictCode)){
                adapterDictCode="";
            }
            adapterDictKeySchema.setAdapterDictCode(dictTable,stdDictCode,adapterDictCode);
        }
        System.out.println("缓存适配的字典完成");
        return new AsyncResult<Boolean>(true);
    }
    /**
     * 缓存适配的字典项
     * @param dictEntryList
     * @param dictEntryTable
     * @param stdDictMap
     * @param adapterDictMap
     * @return
     */
    @Async
    public Future<Boolean> cacheDictEntry(List<Map<String,Object>> dictEntryList, String dictEntryTable,Map<String, String> stdDictMap,Map<String, String> adapterDictMap,String schema){
        System.out.println("开始缓存适配的字典项");
        LocalContext.getContext().setAttachment(ContextAttributes.SCHEMA,schema);
        for (Map<String, Object> temDictMap: dictEntryList) {
            String value="";
            String stdDictId = String.valueOf(temDictMap.get("std_dict_id"));
            String stdDictCode = stdDictMap.get(stdDictId);
            String adapterDictId = String.valueOf(temDictMap.get("adapter_dict_id"));
            String adapterDictCode = adapterDictMap.get(adapterDictId);
            String stdEntryCode = (String) temDictMap.get("std_entry_code");
            if(!StringUtils.isEmpty(adapterDictCode)){//
                String adapterEntryCode = (String) temDictMap.get("adapter_entry_code");
                value=adapterDictCode+"."+adapterEntryCode;
            }
            adapterDictEntryKeySchema.setAdapterDictEntryCode(dictEntryTable,stdDictCode,stdEntryCode,value);
        }
        System.out.println("缓存适配的字典项完成");
        return new AsyncResult<Boolean>(true);
    }
}

+ 0 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/DatasourceController.java

@ -11,7 +11,6 @@
//import org.apache.commons.beanutils.BeanUtils;
//import org.apache.commons.beanutils.BeanUtils;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.collections4.CollectionUtils;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RequestParam;

+ 0 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/DictController.java

@ -6,7 +6,6 @@
//import com.yihu.hos.web.framework.model.Result;
//import com.yihu.hos.web.framework.model.Result;
//import org.apache.commons.beanutils.BeanUtils;
//import org.apache.commons.beanutils.BeanUtils;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.StringUtils;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.ResponseBody;

+ 0 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/FlowController.java

@ -14,7 +14,6 @@
//import com.yihu.hos.web.framework.util.controller.BaseController;
//import com.yihu.hos.web.framework.util.controller.BaseController;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.StringUtils;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestMethod;

+ 0 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/OrgController.java

@ -7,7 +7,6 @@
//import com.yihu.hos.web.framework.util.controller.BaseController;
//import com.yihu.hos.web.framework.util.controller.BaseController;
//import org.apache.commons.beanutils.BeanUtils;
//import org.apache.commons.beanutils.BeanUtils;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//

+ 0 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/system/controller/ParamController.java

@ -6,7 +6,6 @@
//import com.yihu.hos.web.framework.util.controller.BaseController;
//import com.yihu.hos.web.framework.util.controller.BaseController;
//import org.apache.commons.beanutils.BeanUtils;
//import org.apache.commons.beanutils.BeanUtils;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.util.StringUtils;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestMethod;

+ 91 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/util/FileUploadUtil.java

@ -0,0 +1,91 @@
package com.yihu.jw.basic.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.basic.util.model.FileResourceModel;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
 * 文件上传相关
 *
 * @author 张进军
 * @date 2017/8/18 11:58
 */
public class FileUploadUtil {
    private static ObjectMapper objectMapper = new ObjectMapper();
    /**
     * 获取上传文件的参数
     *
     * @param inputStream 文件流
     * @param fileName    文件名
     * @return 上传文件的参数
     */
    public static Map<String, Object> getParams(InputStream inputStream, String fileName) throws Exception {
        int temp = 0;
        byte tempBuffer[] = new byte[1024];
        byte[] fileBuffer = new byte[0];
        while ((temp = inputStream.read(tempBuffer)) != -1) {
            fileBuffer = ArrayUtils.addAll(fileBuffer, ArrayUtils.subarray(tempBuffer, 0, temp));
        }
        inputStream.close();
        String fileBase64Str = Base64.getEncoder().encodeToString(fileBuffer);
        FileResourceModel fileResourceModel = new FileResourceModel("", "org", "");
        Map<String, Object> params = new HashMap<>();
        if(!StringUtils.isEmpty(fileBase64Str)) {
            params.put("file_str", fileBase64Str);
            params.put("file_name", fileName);
            params.put("json_data", objectMapper.writeValueAsString(fileResourceModel));
        }
        return params;
    }
    public static void createFile(String filePath, String fileName, String content) {
        File f = new File(filePath);
        if (!f.exists()) {
            f.mkdirs();
        }
        File file = new File(f,fileName);
        if (!file.exists()) {
            try {
                boolean newFile = file.createNewFile();
                if (newFile) {
                    FileOutputStream out = new FileOutputStream(filePath + fileName);
                    out.write(content.getBytes("UTF-8"));
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    public static void delDir(String filePath) {
        File dir = new File(filePath);
        if(dir.exists()) {
            File[] tmp=dir.listFiles();
            for(int i = 0; i < tmp.length; i++) {
                if(tmp[i].isDirectory()) {
                    delDir(filePath + tmp[i].getName());
                }
                 else {
                    tmp[i].delete();
                }
            }
            dir.delete();
        }
    }
}

+ 109 - 0
svr/svr-basic/src/main/java/com/yihu/jw/basic/util/model/FileResourceModel.java

@ -0,0 +1,109 @@
package com.yihu.jw.basic.util.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * Created by yeshijie on 2022/9/20.
 */
public class FileResourceModel {
    private String id;
    private String storagePath;
    private String mime;
    private String objectId;
    private String purpose;
    private Date createDate;
    private String createUser;
    private Date updateDate;
    private String updateUser;
    public String getId() {
        return this.id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getStoragePath() {
        return this.storagePath;
    }
    public void setStoragePath(String storagePath) {
        this.storagePath = storagePath;
    }
    public String getMime() {
        return this.mime;
    }
    public void setMime(String mime) {
        this.mime = mime;
    }
    public String getObjectId() {
        return this.objectId;
    }
    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }
    public String getPurpose() {
        return this.purpose;
    }
    public void setPurpose(String purpose) {
        this.purpose = purpose;
    }
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    public Date getCreateDate() {
        return this.createDate;
    }
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
    public String getCreateUser() {
        return this.createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    public Date getUpdateDate() {
        return this.updateDate;
    }
    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }
    public String getUpdateUser() {
        return this.updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public FileResourceModel(String objectId, String mime, String purpose) {
        this.objectId = objectId;
        this.mime = mime;
        this.purpose = purpose;
    }
    public FileResourceModel() {
    }
}