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