|  | @ -1,6 +1,5 @@ | 
			
		
	
		
		
			
				
					|  |  | package com.epmet.service.impl; |  |  | package com.epmet.service.impl; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | import com.alibaba.fastjson.JSON; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
		
			
				
					|  |  | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |  |  | import com.baomidou.mybatisplus.core.toolkit.IdWorker; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.feignclient.dtos.JiMuPage; |  |  | import com.epmet.commons.feignclient.dtos.JiMuPage; | 
			
		
	
	
		
		
			
				
					|  | @ -19,7 +18,6 @@ import com.epmet.commons.tools.exception.EpmetException; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.redis.RedisUtils; |  |  | import com.epmet.commons.tools.redis.RedisUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.ConvertUtils; |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.EpmetRequestHolder; |  |  | import com.epmet.commons.tools.utils.EpmetRequestHolder; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.HttpClientManager; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.Result; |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.constant.CustomerFunctionConstant; |  |  | import com.epmet.constant.CustomerFunctionConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.IcCustomerReportDao; |  |  | import com.epmet.dao.IcCustomerReportDao; | 
			
		
	
	
		
		
			
				
					|  | @ -44,8 +42,10 @@ import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.transaction.annotation.Transactional; |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.util.MultiValueMap; |  |  | import org.springframework.util.MultiValueMap; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | import java.net.InetAddress; |  |  | import java.util.ArrayList; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | import java.util.*; |  |  | import java.util.Arrays; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | import java.util.List; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import java.util.Map; | 
			
		
	
		
		
			
				
					|  |  | import java.util.stream.Collectors; |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | /** |  |  | /** | 
			
		
	
	
		
		
			
				
					|  | @ -87,28 +87,19 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor | 
			
		
	
		
		
			
				
					|  |  |      */ |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public List<ReportResultDTO> reportList() { |  |  |     public List<ReportResultDTO> reportList() { | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         String authorization = EpmetRequestHolder.getHeader("Authorization"); |  |  |         String authorization = EpmetRequestHolder.getHeader("Authorization"); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         // 自定义header传递
 |  |  |         // 自定义header传递
 | 
			
		
	
		
		
			
				
					|  |  |         MultiValueMap<String, String> headers = new HttpHeaders(); |  |  |         MultiValueMap<String, String> headers = new HttpHeaders(); | 
			
		
	
		
		
			
				
					|  |  |         headers.add("token", authorization); |  |  |         headers.add("token", authorization); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         JiMuResult<JiMuPage<JiMuReportDetailResultDTO>> result = jiMuReportOpenFeignClient.getList(1, 10000, "", "datainfo", authorization, headers); |  |  |         JiMuResult<JiMuPage<JiMuReportDetailResultDTO>> result = jiMuReportOpenFeignClient.getList(1, 10000, "", "datainfo", authorization, headers); | 
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |         if (!result.isSuccess()){ | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         // todo 下面的删掉吧
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Result<String> url = getUrl(2, null); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         log.info("所有jm报表"+url); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Map<String,Object> map = JSON.parseObject(url.getData(), Map.class); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         if (!map.containsValue(true)){ |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |             throw new EpmetException("获取所有jm报表失败"); |  |  |             throw new EpmetException("获取所有jm报表失败"); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |         Map<String,Object> map2 = (Map<String,Object>)map.get("result"); |  |  |         List<Map<String,Object>> records = (List<Map<String,Object>>)result.getResult().getRecords(); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         List<Map<String,Object>> map3 = (List<Map<String,Object>>) map2.get("records"); |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |         List<JiMuReportResultDTO> allReports = new ArrayList<>(); |  |  |         List<JiMuReportResultDTO> allReports = new ArrayList<>(); | 
			
		
	
		
		
			
				
					
					|  |  |         map3.forEach(m -> { |  |  |         for (Map<String, Object> record : records) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             allReports.add(ConvertUtils.mapToEntity(m,JiMuReportResultDTO.class)); |  |  |             allReports.add(ConvertUtils.mapToEntity(record,JiMuReportResultDTO.class)); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         }); |  |  |         } | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         if (CollectionUtils.isEmpty(allReports)){ |  |  |         if (CollectionUtils.isEmpty(allReports)){ | 
			
		
	
		
		
			
				
					|  |  |             return new ArrayList<>(); |  |  |             return new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
	
		
		
			
				
					|  | @ -174,11 +165,13 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |         if (formDTO.getType().equals(CustomerFunctionConstant.REPORT_EDIT)){ |  |  |         if (formDTO.getType().equals(CustomerFunctionConstant.REPORT_EDIT)){ | 
			
		
	
		
		
			
				
					|  |  |             // 单个编辑
 |  |  |             // 单个编辑
 | 
			
		
	
		
		
			
				
					
					|  |  |             baseDao.delCustomerReport(Arrays.asList(formDTO.getCustomerList().get(NumConstant.ZERO).getCustomerId())); |  |  |             baseDao.delCustomerReport(Arrays.asList(formDTO.getCustomerList().get(NumConstant.ZERO).getCustomerId()), formDTO.getReportId()); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         }else if (formDTO.getType().equals(CustomerFunctionConstant.REPORT_ADD)){ |  |  |         }else if (formDTO.getType().equals(CustomerFunctionConstant.REPORT_ADD)){ | 
			
		
	
		
		
			
				
					
					|  |  |             baseDao.delCustomerReport(null); |  |  |             baseDao.delCustomerReport(null, formDTO.getReportId()); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (CollectionUtils.isNotEmpty(reportIds)){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             baseDao.delCustomerReportFun(reportIds); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |         baseDao.delCustomerReportFun(reportIds); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         if (CollectionUtils.isNotEmpty(formDTO.getCustomerList())){ |  |  |         if (CollectionUtils.isNotEmpty(formDTO.getCustomerList())){ | 
			
		
	
		
		
			
				
					|  |  |             List<IcCustomerReportEntity> entities = new ArrayList<>(); |  |  |             List<IcCustomerReportEntity> entities = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |             List<IcReportFunEntity> funEntities = new ArrayList<>(); |  |  |             List<IcReportFunEntity> funEntities = new ArrayList<>(); | 
			
		
	
	
		
		
			
				
					|  | @ -218,14 +211,16 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor | 
			
		
	
		
		
			
				
					|  |  |         recordIds.forEach(r -> { |  |  |         recordIds.forEach(r -> { | 
			
		
	
		
		
			
				
					|  |  |             JiMuReportFormDTO form = new JiMuReportFormDTO(); |  |  |             JiMuReportFormDTO form = new JiMuReportFormDTO(); | 
			
		
	
		
		
			
				
					|  |  |             form.setId(r); |  |  |             form.setId(r); | 
			
		
	
		
		
			
				
					
					|  |  |             Result<String> url = getUrl(NumConstant.ONE, r); |  |  |             String authorization = EpmetRequestHolder.getHeader("Authorization"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             log.info("模板详情"+url); |  |  |             // 自定义header传递
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             Map<String,Object> map = JSON.parseObject(url.getData(), Map.class); |  |  |             MultiValueMap<String, String> headers = new HttpHeaders(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             if (!map.containsValue(true)){ |  |  |             headers.add("token", authorization); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |             headers.add("Authorization", authorization); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             JiMuResult<Map<String, Object>> report = jiMuReportOpenFeignClient.getReport(r,"","",headers); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (!report.isSuccess()){ | 
			
		
	
		
		
			
				
					|  |  |                 throw new EpmetException("获取jm报表详情失败:"+r); |  |  |                 throw new EpmetException("获取jm报表详情失败:"+r); | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |             Map<String,Object> map2 = (Map<String,Object>)map.get("result"); |  |  |             JiMuReportResultDTO data = ConvertUtils.mapToEntity(report.getResult(), JiMuReportResultDTO.class); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |             JiMuReportResultDTO data = ConvertUtils.mapToEntity(map2, JiMuReportResultDTO.class); |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |             data.setReportId(data.getId()); |  |  |             data.setReportId(data.getId()); | 
			
		
	
		
		
			
				
					|  |  |             data.setReportName(data.getName()); |  |  |             data.setReportName(data.getName()); | 
			
		
	
		
		
			
				
					|  |  |             result.add(data); |  |  |             result.add(data); | 
			
		
	
	
		
		
			
				
					|  | @ -243,50 +238,4 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |  | 
			
		
	
		
		
			
				
					|  |  |      * Desc: |  |  |  | 
			
		
	
		
		
			
				
					|  |  |      * @param type 1:代表根据ID查询;2查询全部 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |      * @author zxc |  |  |  | 
			
		
	
		
		
			
				
					|  |  |      * @date 2022/8/9 10:14 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |      */ |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     public Result<String> getUrl(Integer type,String id) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         String add = ""; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         Result<String> result; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         try { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             InetAddress localHost = InetAddress.getLocalHost(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             add = "http://"+localHost.getHostAddress()+":8118"; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             System.out.println(add); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }catch (Exception e){ |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             log.warn("获取url失败"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         if (type.compareTo(NumConstant.TWO) == NumConstant.ZERO){ |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             add = add.concat("/jmreport/excelQuery"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             Map<String,Object> params = new HashMap<>(16); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("pageNo",1); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("pageSize",10000); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("reportType","datainfo"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("name",""); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("token", EpmetRequestHolder.getHeader("Authorization")); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             Map<String,Object> headers = new HashMap<>(16); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("token", EpmetRequestHolder.getHeader("Authorization")); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("X-Access-Token", EpmetRequestHolder.getHeader("Authorization")); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("Accept", "application/json, text/plain, */*"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("Content-Type", "application/json;charset=utf-8"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             result = HttpClientManager.getInstance().sendGet(add, params, headers); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }else { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             add = add.concat("/jmreport/show"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             Map<String,Object> params = new HashMap<>(16); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("id",id); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("apiUrl",""); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             params.put("params",""); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             Map<String,String> headers = new HashMap<>(16); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("token", EpmetRequestHolder.getHeader("Authorization")); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("X-Access-Token", EpmetRequestHolder.getHeader("Authorization")); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("Accept", "application/json, text/plain, */*"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             headers.put("Content-Type", "application/json;charset=utf-8"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             result = HttpClientManager.getInstance().sendPostByJSONAndHeader(add, JSON.toJSONString(params), headers); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         return result; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } |