Browse Source

代码修改

LAPTOP-KB9HII50\70708 2 years ago
parent
commit
4a528dae5d
20 changed files with 2138 additions and 1458 deletions
  1. 2 14
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/app/AppController.java
  2. 1 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDataSaveController.java
  3. 1 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDataSourceController.java
  4. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDimensionMainController.java
  5. 11 7
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDimensionSlaveController.java
  6. 26 28
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaController.java
  7. 4 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaDimensionMainController.java
  8. 4 1
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaDimensionSlaveController.java
  9. 8 11
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/report/ReportController.java
  10. 2 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/DictController.java
  11. 736 888
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ReportController.java
  12. 4 4
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceManageController.java
  13. 151 171
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptController.java
  14. 118 107
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDataSetController.java
  15. 89 85
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/SchemeAdaptDictController.java
  16. 767 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/service/ReportService.java
  17. 11 133
      svr/svr-basic/src/main/java/com/yihu/jw/basic/quota/controller/QuotaReportController.java
  18. 1 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/controller/RsReportEndPoint.java
  19. 91 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/util/FileUploadUtil.java
  20. 109 0
      svr/svr-basic/src/main/java/com/yihu/jw/basic/util/model/FileResourceModel.java

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

@ -1,32 +1,19 @@
package com.yihu.jw.basic.agadmin.controller.app;
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.apps.service.AppService;
import com.yihu.jw.basic.apps.service.AppService;
import com.yihu.jw.basic.user.service.GetInfoService;
import com.yihu.jw.basic.user.service.GetInfoService;
import com.yihu.jw.entity.ehr.apps.App;
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.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.http.HttpClientUtil;
import org.apache.commons.lang.ArrayUtils;
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.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.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.*;
/**
/**
@ -34,6 +21,7 @@ import java.util.*;
 */
 */
@RequestMapping("/app")
@RequestMapping("/app")
@RestController
@RestController
@Api( tags = {"网关-应用"})
public class AppController extends EnvelopRestEndpoint {
public class AppController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired

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

@ -80,7 +80,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 - 1
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjDataSourceController.java

@ -80,7 +80,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(";");

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

@ -25,7 +25,7 @@ import java.util.*;
 */
 */
@RestController
@RestController
@RequestMapping("/tjDimensionMain")
@RequestMapping("/tjDimensionMain")
@Api( tags = {"网关-统计维度"})
@Api( tags = {"网关-统计主维度"})
public class TjDimensionMainController extends EnvelopRestEndpoint {
public class TjDimensionMainController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
@ -73,7 +73,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";

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

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

@ -114,18 +114,16 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    /**
    /**
     * 新增修改
     * 新增修改
     *
     * @param tjQuotaModelJsonData
     * @param tjQuotaModelJsonData
     * @param request
     * @return
     * @return
     * @throws IOException
     * @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 {
            String[] strings = URLDecoder.decode(tjQuotaModelJsonData, "UTF-8").split(";");
            TjQuota detailModel = objectMapper.readValue(strings[0], TjQuota.class);
            if (!StringUtils.isEmpty(detailModel.getId())) {
            if (!StringUtils.isEmpty(detailModel.getId())) {
                Long tjQuotaId = detailModel.getId();
                Long tjQuotaId = detailModel.getId();
                TjQuota updateTjQuota = tjQuotaService.getById(tjQuotaId);
                TjQuota updateTjQuota = tjQuotaService.getById(tjQuotaId);
@ -143,31 +141,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());
                    detailModel.setUpdateTime(new Date());
                    tjQuotaService.saves(detailModel, tjquotaDataSource, tjQuotaDataSave);
                    tjQuotaService.saves(detailModel, tjquotaDataSource, tjQuotaDataSave);
                    return ObjEnvelop.getSuccess("统计表更新成功!", detailModel);
                    return ObjEnvelop.getSuccess("统计表更新成功!", detailModel);
                } 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,7 +177,7 @@ 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);
        }
        }
    }
    }
@ -232,8 +230,8 @@ public class TjQuotaController extends EnvelopRestEndpoint {
                    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) {
@ -354,7 +352,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
     * @param tjQuotaId
     * @param tjQuotaId
     * @return
     * @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) {
@ -399,7 +397,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
     * @param
     * @param
     * @return
     * @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 = "";
@ -445,7 +443,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
     * @param
     * @param
     * @return
     * @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 +458,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,7 +488,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    }
    }
    @RequestMapping("/getTjQuotaChartList")
    @GetMapping("/getTjQuotaChartList")
    public Envelop getQuotaChartList(String quotaCode, String name, int dictId, int page, int rows) {
    public Envelop getQuotaChartList(String quotaCode, String name, int dictId, int page, int rows) {
        String url = "/tj/getTjQuotaChartList";
        String url = "/tj/getTjQuotaChartList";
        Map<String, Object> params = new HashMap<>();
        Map<String, Object> params = new HashMap<>();
@ -574,7 +572,7 @@ public class TjQuotaController extends EnvelopRestEndpoint {
     * @return
     * @return
     * @throws IOException
     * @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 {
@ -894,7 +892,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 +938,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 - 11
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,9 +9,7 @@ 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;
@ -20,8 +17,8 @@ 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.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 +39,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 +99,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 +162,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 +241,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 +320,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 +400,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 +466,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+";";

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

@ -1,804 +1,309 @@
//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.ehr.constants.ErrorCode;
import com.yihu.ehr.constants.ServiceApi;
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.controller.RsReportEndPoint;
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.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.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;
    @Autowired
    private ResourceBrowseControllerService resourceBrowseControllerService;
    @Autowired
    private ReportService reportService;
    /**
     * 展示明细
     */
    @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("查询成功");
        }
        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 {
//        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 +311,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 +322,441 @@
//                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;
//    }
//    }
//}
    /**
     * 保存资源配置
     */
    @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("保存发生异常");
        }
    }
    @Autowired
    private RsReportEndPoint rsReportEndPoint;
    /**
     * 获取报表模版内容及其各个图形数据
     */
    @RequestMapping("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;
    }
    @RequestMapping("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  联动维度
     */
    @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;
    }
    @Autowired
    private FileResourceManager fileResourceManager;
    /**
     * 生成模板
     * @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("生成模版发生异常");
        }
    }
    @RequestMapping("/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;
    }
    @RequestMapping("/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;
    }
}

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

@ -91,7 +91,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 +404,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 +536,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 +551,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";

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

@ -1,171 +1,151 @@
//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.ehr.resource.MRsAdapterSchema;
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 com.yihu.jw.util.http.HttpClientUtil;
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.ui.Model;
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("内部服务请求失败");
        }
    }
}

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

@ -1,107 +1,118 @@
//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.ehr.resource.MRsAdapterMetadata;
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 com.yihu.jw.util.common.LogService;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.ui.Model;
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(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 {
            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;
//    }
}

+ 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 - 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("模版未找到");

+ 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() {
    }
}