bb32c1fc 张雷

Merge remote-tracking branch 'origin/master' into master

2 个父辈 20472ca1 4204d028
......@@ -22,9 +22,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.ajh.service.IAjhMeetingService;
import com.skua.modules.ajh.vo.AjhMeetingSendVO;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.entity.SysUser;
import com.skua.modules.system.service.ISysDepartService;
import com.skua.modules.system.service.ISysUserService;
import com.skua.tool.util.QRCodeUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
......@@ -61,6 +66,11 @@ public class AjhMeetingSendController {
@Value("${skua.web-url}")
private String webUrl;
@Autowired
private ISysUserService userService;
@Autowired
private ISysDepartService departService;
/**
* <pre>
* 分页列表查询
......@@ -335,6 +345,17 @@ public class AjhMeetingSendController {
public Result<AjhMeetingSend> queryById(@RequestParam(name="id",required=true) String id) {
Result<AjhMeetingSend> result = new Result<AjhMeetingSend>();
AjhMeetingSend ajhMeetingSend = ajhMeetingSendService.getById(id);
if(ajhMeetingSend != null ){
if(StringUtils.isNotEmpty(ajhMeetingSend.getMeetCompere())){
SysUser sysUser = userService.getById(ajhMeetingSend.getMeetCompere());
ajhMeetingSend.setMeetCompereName( sysUser.getRealname());
}
if(StringUtils.isNotEmpty(ajhMeetingSend.getDepartId()) && StringUtils.isEmpty(ajhMeetingSend.getDepartName())){
SysDepart depart = departService.getById(ajhMeetingSend.getDepartId());
ajhMeetingSend.setDepartName( depart.getDepartName());
}
}
if(ajhMeetingSend==null) {
result.error500("未找到对应实体");
}else {
......
......@@ -130,6 +130,11 @@ public class AjhMeetingSend {
@TableField(exist = false)
@ApiModelProperty(value = "机构名称")
private java.lang.String departName;
@TableField(exist = false)
@ApiModelProperty(value = "主持人")
private java.lang.String meetCompereName;
/**邀请人数*/
@Excel(name = "邀请人数", width = 15,orderNum = "7")
@TableField(exist = false)
......@@ -146,8 +151,5 @@ public class AjhMeetingSend {
@ApiModelProperty(value = "会议内容")
private String meetContentHtml;
public String getMeetContentHtml() {
meetContentHtml = BaseUtil.delHTMLTag( this.getMeetContent());
return meetContentHtml;
}
}
......
......@@ -34,15 +34,16 @@ public class CustomConsumeController {
* <pre>
* 自定义分析获取数据类型
* </pre>
* @param granularity 时间粒度
* @return
* @author Li Yuanyuan, 2021年1月29日 下午3:07:12
*/
@ApiOperation(value="自定义分析获取数据类型", notes="自定义分析获取数据类型")
@GetMapping(value = "/getDataType")
public Result<List<TreeData>> getDataType(){
public Result<List<TreeData>> getDataType(String granularity){
Result<List<TreeData>> result = new Result<List<TreeData>>();
List<TreeData> dataTypeList = new ArrayList<TreeData>();
dataTypeList = customConsumeService.getDataType();
dataTypeList = customConsumeService.getDataType(granularity);
result.setResult(dataTypeList);
result.setSuccess(true);
return result;
......@@ -140,9 +141,9 @@ public class CustomConsumeController {
@ApiOperation(value="填报指标获取", notes="填报指标获取")
@GetMapping(value = "/queryDataFillIndex")
public Result<List<Map<String,Object>>> queryDataFillIndex(String reportId) {
public Result<List<Map<String,Object>>> queryDataFillIndex(String reportId,String granularity) {
Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
List<Map<String, Object>> list = customConsumeService.queryDataFillIndex(reportId);
List<Map<String, Object>> list = customConsumeService.queryDataFillIndex(reportId,granularity);
result.setResult(list);
result.setSuccess(true);
return result;
......
......@@ -41,4 +41,9 @@ public class AnalyseCustomConsume {
@Excel(name = "历史指标标记名称", width = 15)
@ApiModelProperty(value = "历史指标标记名称")
private java.lang.String analyseTitle;
@Excel(name = "分析指标时间粒度", width = 15)
@ApiModelProperty(value = "分析指标时间粒度")
private java.lang.String analyseGranularity;
}
......
......@@ -54,7 +54,7 @@ public interface ICustomConsumeService {
* @return
* @author Li Yuanyuan, 2021年1月29日 下午3:10:42
*/
public List<TreeData> getDataType();
public List<TreeData> getDataType(String granularity);
/**
* <pre>
* 实时数据/水质水量
......@@ -89,10 +89,11 @@ public interface ICustomConsumeService {
* 报表数据项获取
* </pre>
* @param reportId
* @param granularity 时间粒度
* @return
* @author Li Yuanyuan, 2021年2月3日 下午3:39:44
*/
public List<Map<String, Object>> queryDataFillIndex(String reportId);
public List<Map<String, Object>> queryDataFillIndex(String reportId,String granularity);
}
......
......@@ -274,7 +274,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
pattern = "yyyy-MM";
type = "year";
}
List<Map<String, Object>> list = reportItemService.getReportItemData(departId,reportId, startTime, endTime, indexs);
List<Map<String, Object>> list = reportItemService.getReportItemData(departId,reportId, startTime, endTime, indexs,granularity);
//获取部门数据
List<Map<String, Object>> handleList = new ArrayList<Map<String,Object>>();//接收处理结果
String[] factoryArray = departId.split(",");
......@@ -366,7 +366,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("tb")) {
String tbStartTime = DateUtils.formatAddTime(startTime,pattern,Calendar.YEAR,-1);
String tbEndTime = DateUtils.formatAddTime(endTime,pattern,Calendar.YEAR,-1);
List<Map<String, Object>> tbList =reportItemService.getReportItemData(departId,reportId, tbStartTime, tbEndTime, indexs);
List<Map<String, Object>> tbList =reportItemService.getReportItemData(departId,reportId, tbStartTime, tbEndTime, indexs,granularity);
for(Map<String, Object> map : tbList) {
tbMap.put(ConvertUtils.getString(map.get("time")+""+map.get("departId")), map);
}
......@@ -374,7 +374,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("hb")) {
String hbStartTime = DateUtils.formatAddTime(startTime,pattern,Calendar.MONTH,-1);
String hbEndTime = DateUtils.formatAddTime(endTime,pattern,Calendar.MONTH,-1);
List<Map<String, Object>> hbList =reportItemService.getReportItemData(departId,reportId, hbStartTime, hbEndTime, indexs);
List<Map<String, Object>> hbList =reportItemService.getReportItemData(departId,reportId, hbStartTime, hbEndTime, indexs,granularity);
for(Map<String, Object> map : hbList) {
hbMap.put(ConvertUtils.getString(map.get("time")+""+map.get("departId")), map);
}
......@@ -402,26 +402,31 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
}
@Override
public List<TreeData> getDataType() {
public List<TreeData> getDataType(String granularity) {
List<Map<String,Object>> dataTypeList = new ArrayList<Map<String,Object>>();
Map<String,Object> ssmap = new HashMap<String,Object>();
ssmap.put("id", "ss");
ssmap.put("pid", "");
ssmap.put("title", "实时");
dataTypeList.add(ssmap);
Map<String,Object> szmap = new HashMap<String,Object>();
szmap.put("id", "sz");
szmap.put("pid", "ss");
szmap.put("title", "采集数据");
if("hour".equals(granularity)||"day".equals(granularity)) {
dataTypeList.add(ssmap);
dataTypeList.add(szmap);
}
Map<String,Object> tbmap = new HashMap<String,Object>();
tbmap.put("id", "tb");
tbmap.put("pid", "");
tbmap.put("title", "填报");
dataTypeList.add(szmap);
if("day".equals(granularity)||"month".equals(granularity)) {
dataTypeList.add(tbmap);
}
QueryWrapper<FReportManage> fReportManageQueryWrapper = new QueryWrapper<>();
fReportManageQueryWrapper.eq("status","1");
fReportManageQueryWrapper.eq("pro_status","1");
fReportManageQueryWrapper.eq("time_type", granularity);
fReportManageQueryWrapper.orderByAsc("sort_num");
List<FReportManage> fReportManages = reportManageService.list(fReportManageQueryWrapper);
for (FReportManage fReportManage : fReportManages) {
......@@ -431,6 +436,12 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
report.put("title", fReportManage.getReportName());
dataTypeList.add(report);
}
//填报追加公式计算字段
Map<String, Object> formulaReport = new HashMap<>();
formulaReport.put("id", "formula");
formulaReport.put("pid", "tb");
formulaReport.put("title", "填报计算");
dataTypeList.add(formulaReport);
//将业务数据转换为构造树所需的数据结构
List<TransTreeModel> transTreeModels = dataTypeList.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList());
List<TreeData> treeList=TreeUtils.buildTreeByRootId(transTreeModels, "");
......@@ -477,9 +488,14 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
}
@Override
public List<Map<String, Object>> queryDataFillIndex(String reportId) {
public List<Map<String, Object>> queryDataFillIndex(String reportId,String granularity) {
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
List<Map<String, Object>> list = masterDB.queryForList("select item_code as indexCode,item_alias as indexName,unit as indexUnit from f_report_item where report_id='"+reportId+"' and is_use_power_analyse='1' order by sort_num");
List<Map<String, Object>> list = null;
if("formula".equals(reportId)) {
list = masterDB.queryForList("select formula_code as indexCode,formula_name as indexName,formula_unit as indexUnit from f_report_itemv_formula where report_id='"+reportId+"' and formula_granularity='"+granularity+"' order by sort_num");
}else {
list = masterDB.queryForList("select item_code as indexCode,item_alias as indexName,unit as indexUnit from f_report_item where report_id='"+reportId+"' and is_use_power_analyse='1' order by sort_num");
}
return list;
}
}
......
package com.skua.modules.erp.controller;
import cn.hutool.core.util.RandomUtil;
import com.skua.common.util.ChineseInital;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.service.IFactoryInfoService;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.equipment.vo.EquipmentRealTimeVO;
import com.skua.modules.erp.vo.MetricInfoVO;
import com.skua.modules.erp.vo.RealTimeHistoryDataVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Api(tags="设备-设备运行台时报表")
@RestController
@RequestMapping("/test/metricInfo")
public class TestMetricInfoController {
@Autowired
private IFactoryInfoService iFactoryInfoService;
@AutoLog(value = "设备-设备运行台时报表")
@ApiOperation(value = "设备-设备运行台时报表", notes = "设备-设备运行台时报表")
@GetMapping(value = "/realTimeHistoryData")
public Result<RealTimeHistoryDataVO> equipRealTimeHistoryDataCtrl(@RequestParam(value = "departId") String departId,
@RequestParam(value = "startTime") String startTime,
@RequestParam(value = "endTime") String endTime) {
Result<RealTimeHistoryDataVO> result = new Result<>();
RealTimeHistoryDataVO realTimeHistoryDataVO = new RealTimeHistoryDataVO();
//String fields = "TCSWSCLC_PLC300_Tag182,TCSWSCLC_PLC300_Tag185";
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
String metricInfoSql = "select ei.equipment_name , t.metric_express1 'gzExpress' , t.metric_express2 'yxExpress' ,t.metric_express3 'tzExpress' from sys_monitor_metric_info t ";
metricInfoSql += " left join equipment_info ei on ei.id = t.equipment_code ";
metricInfoSql += " where t.metric_type = 1 and t.depart_id = '"+departId+"' and t.equipment_code > 0 " ;
List<MetricInfoVO> metricInfoVOList = masterDB.query(metricInfoSql,new BeanPropertyRowMapper<MetricInfoVO>(MetricInfoVO.class));
//StringBuffer fields= new StringBuffer();
String fields = "";
if(metricInfoVOList != null ){
for(MetricInfoVO metricInfoVO : metricInfoVOList){
String equipmentName = metricInfoVO.getEquipmentName().replaceAll("[^\\u4e00-\\u9fa5]", "");
String equipmentCode = ChineseInital.getAllFirstLetter(equipmentName)+"_"+ RandomUtil.randomNumbers(2);
metricInfoVO.setEquipmentName(equipmentName );
metricInfoVO.setEquipmentCode(equipmentCode );
if(StringUtils.isNotEmpty(metricInfoVO.getGzExpress())){
fields += metricInfoVO.getGzExpress()+",";
}
if(StringUtils.isNotEmpty(metricInfoVO.getYxExpress())){
fields += metricInfoVO.getYxExpress()+",";
}
if(StringUtils.isNotEmpty(metricInfoVO.getTzExpress())){
fields += metricInfoVO.getTzExpress()+",";
}
}
}
if (fields.endsWith(",")) {
fields = fields.substring(0, fields.length() - 1);
}
List<Map<String, Object>> pgDataList = iFactoryInfoService.queryFactoryInfos(departId, fields, startTime, endTime, "1");
List<Map<String, Object>> dataList = null;
if(pgDataList != null ) {
dataList = new ArrayList<>(pgDataList.size());
Map<String, Object> dataMap = null;
//elect ts as time,nm as monitorId,v as monitorValue
String equipmentCode = null;
for (Map<String, Object> paramMap : pgDataList) {
dataMap = new HashMap<>();
dataMap.put("time",DateUtils.formatTime(Long.parseLong(paramMap.get("time") + "000")) );
for(MetricInfoVO metricInfoVO : metricInfoVOList){
dataMap.put( metricInfoVO.getEquipmentCode()+"_YX" , ConvertUtils.getString(paramMap.get(metricInfoVO.getYxExpress())));//运行
dataMap.put( metricInfoVO.getEquipmentCode()+"_GZ" , ConvertUtils.getString(paramMap.get(metricInfoVO.getGzExpress())));//故障
dataMap.put( metricInfoVO.getEquipmentCode()+"_ZT" ,60 - ConvertUtils.getDouble(paramMap.get(metricInfoVO.getYxExpress()),0) - ConvertUtils.getDouble(paramMap.get(metricInfoVO.getGzExpress()) ,0) );//暂停
}
dataList.add( dataMap );
}
}
/* //拼装数据
Map<String, Map<String,String>> linkedHashMap = new LinkedHashMap<String, Map<String,String>>();//返回数据结果
String timeTemp = null;
Map<String,String> dataMap = null;
if(pgDataList != null ){
//elect ts as time,nm as monitorId,v as monitorValue
for( Map<String, Object> paramMap : pgDataList){
timeTemp = DateUtils.formatTime(Long.parseLong(paramMap.get("time") + "000"));
dataMap = linkedHashMap.get(timeTemp);
if(dataMap == null ){
dataMap = new HashMap<>();
dataMap.put("time",timeTemp);
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
dataMap.put(entry.getKey(),"0");
}
}
// 使用For-Each迭代entries,通过Map.entrySet遍历key和value
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
System.out.println("entry.getKey()" +entry.getKey()+ "****"+"paramMap.get() = "+paramMap.get(entry.getKey()));
if(entry.getKey().equals( ConvertUtils.getString(paramMap.get(entry.getKey())) )){
dataMap.put( entry.getValue() , ConvertUtils.getString(paramMap.get(entry.getKey())));
}
}
linkedHashMap.put(timeTemp,dataMap);
}
}*/
realTimeHistoryDataVO.setHeadList( metricInfoVOList);
realTimeHistoryDataVO.setDataList( dataList );
result.setResult( realTimeHistoryDataVO);
return result;
}
}
package com.skua.modules.erp.vo;
import cn.hutool.core.util.RandomUtil;
import com.skua.common.util.ChineseInital;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="sys_monitor_metric_info对象", description="数据项管理")
public class MetricInfoVO {
@ApiModelProperty(value = "名称")
private String equipmentName;//
@ApiModelProperty(value = "设备编码")
private java.lang.String equipmentCode;
@ApiModelProperty(value = "故障表达式")
private String gzExpress;
@ApiModelProperty(value = "运行表达式")
private String yxExpress;
@ApiModelProperty(value = "停止编码")
private String tzExpress;
}
package com.skua.modules.erp.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="设备运行台时报表对象", description="设备运行台时报表对象")
public class RealTimeHistoryDataVO {
@ApiModelProperty(value = "表头集合")
private List<MetricInfoVO> headList;
@ApiModelProperty(value = "列表集合数据")
private List<Map<String, Object>> dataList;
}
......@@ -39,7 +39,7 @@ public interface IFReportItemService extends IService<FReportItem> {
* @return
* @author Li Yuanyuan, 2021年2月3日 下午5:03:47
*/
List<Map<String,Object>> getReportItemData(String departIds,String reportId,String startTime,String endTime,String index);
List<Map<String,Object>> getReportItemData(String departIds,String reportId,String startTime,String endTime,String index,String granularity);
Map<String, Object> getReportData(String reportId, String dataId);
......
package com.skua.modules.report.service.impl;
import com.skua.common.report.ReportViewUtil;
import com.skua.modules.report.entity.FReportItem;
import com.skua.modules.report.mapper.FReportItemMapper;
import com.skua.modules.report.service.IFReportItemService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.lang.StringUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.skua.common.report.CustomReportUtil;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.report.entity.FReportItem;
import com.skua.modules.report.mapper.FReportItemMapper;
import com.skua.modules.report.service.IFReportItemService;
/**
* 报表数据项管理
......@@ -96,35 +103,104 @@ public class FReportItemServiceImpl extends ServiceImpl<FReportItemMapper, FRepo
return list;
}
//fReportManageQueryWrapper.eq("status","1");
//fReportManageQueryWrapper.eq("pro_status","1");
//fReportManageQueryWrapper.eq("time_type", granularity);
@Override
public List<Map<String, Object>> getReportItemData(String departIds,String reportId, String startTime, String endTime,String indexs) {
public List<Map<String, Object>> getReportItemData(String departIds,String reportId, String startTime, String endTime,String indexs,String granularity) {
String[] indexArray = indexs.split(",");
//查询报表计算指标
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
String formulaSql = "select formula_code,formula_info from f_report_itemv_formula where formula_granularity='"+granularity+"'";
List<Map<String, Object>> formulaList = masterDB.queryForList(formulaSql);
Map<String,String> formulaMap = new HashMap<String,String>();
for(Map<String,Object> map : formulaList) {
formulaMap.put(ConvertUtils.getString(map.get("formula_code")), ConvertUtils.getString(map.get("formula_info")));
}
//对计算指标进行解析,追加到基础查询指标
Set<String> indexSet = new LinkedHashSet<String>();//查询指标
//存在计算指标,重新构造基础指标集合
String selectPart = "";
String headSelectPart = "";
String formulaIds = "";
for(String index : indexArray) {
if(index.contains("formula_")) {
String formula = formulaMap.get(index);
selectPart = selectPart+",round("+formulaMap.get(index).replace("{", "IFNULL(").replace("}", ",0)")+",2) as "+index;
//提取计算指标
List<String> formulaIndexList = CustomReportUtil.getFormulaElement(formula);
for(String formulaIndex : formulaIndexList) {
indexSet.add(formulaIndex);
}
}else {
selectPart = selectPart+","+index;
headSelectPart = headSelectPart+", max(case when item_code = '"+index+"' then CONCAT(item_alias,'(',unit,')') else '' end) as '"+index+"'";
formulaIds = formulaIds+","+"'"+index+"'";
}
if(!StringUtils.isEmpty(formulaIds)) {
selectPart = selectPart.substring(1);
headSelectPart = headSelectPart.substring(1);
formulaIds = formulaIds.substring(1);
}
String headWhereInPart = "item_code IN("+formulaIds+")";
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("viewName", ReportViewUtil.buildView(reportId, indexs, departIds, startTime, endTime));
//paramMap.put("viewName", "view_"+reportId.substring(0, 4));
paramMap.put("startTime", startTime);
paramMap.put("endTime", endTime);
paramMap.put("dataSelectPart", selectPart);
paramMap.put("headSelectPart", headSelectPart);
paramMap.put("headWhereInPart", headWhereInPart);
paramMap.put("reportId", reportId);
paramMap.put("departIds", departIds);
return fReportItemMapper.getReportItemData(paramMap);
indexSet.add(index);
}
}
indexs = String.join(",", indexSet);
//对基础查询指标按照报表进行分组
String queryDataFillFieldSql="select item_code,report_id from f_report_item where report_id in(select id from f_report_manage where status='1' and pro_status='1' and time_type='"+granularity+"')";
List<Map<String, Object>> baseDataFillFieldList = masterDB.queryForList(queryDataFillFieldSql);
Map<String,String> fieldToReportIdMap = new HashMap<String,String>();
for(Map<String,Object> map : baseDataFillFieldList) {
fieldToReportIdMap.put(ConvertUtils.getString(map.get("item_code")), ConvertUtils.getString(map.get("report_id")));
}
String[] tempIndexArray = indexs.split(",");
Map<String,List<String>> reportIndexGroup = new HashMap<String,List<String>>();
for(String key : tempIndexArray) {
String tempReportId = fieldToReportIdMap.get(key);
List<String> reportIndexList = reportIndexGroup.get(tempReportId);
if(reportIndexList!=null) {
reportIndexList.add(key);
}else {
reportIndexList = new ArrayList<String>();
reportIndexList.add(key);
reportIndexGroup.put(tempReportId, reportIndexList);
}
}
//基于报表做基础指标查询
Set<String> reportIdSet = reportIndexGroup.keySet();
//构造日期机构主参照表动态视图
String baseViewPattern = "%Y-%m-%d";
String baseViewGranularity = "DAY";
String[] departIdArray = departIds.split(",");
String temp = "";
for(String tempDepartId : departIdArray) {
temp = temp+",'"+tempDepartId+"'";
}
if(StringUtils.isNotEmpty(temp)) {
temp = temp.substring(1);
}
String tempStartTime = startTime;
String tempEndTime = endTime;
if("month".equals(granularity)) {
baseViewPattern = "%Y-%m";
baseViewGranularity = "MONTH";
tempStartTime = startTime+"-01";
tempEndTime = endTime+"-01";
}
String baseViewName= "(SELECT a.time,b.id as depart_id,b.depart_name FROM (\r\n" +
"SELECT \r\n" +
" DATE_FORMAT(DATE_ADD('"+tempStartTime+"', INTERVAL t.help_topic_id "+baseViewGranularity+"), '"+baseViewPattern+"') AS time\r\n" +
"FROM \r\n" +
" mysql.help_topic t \r\n" +
"WHERE \r\n" +
" t.help_topic_id <= TIMESTAMPDIFF("+baseViewGranularity+", '"+tempStartTime+"', '"+tempEndTime+"')\r\n" +
") a left join (select * from sys_depart where id in("+Arrays.stream(departIds.split(",")).map(id -> "'" + id + "'").collect(Collectors.joining(","))+")) b on 1=1)";
int tag=1;
String sql = "select aa.time,aa.depart_id as departId,aa.depart_name as departName"+selectPart+" from "+baseViewName+" aa ";
for(String tempReportId : reportIdSet) {
String viewName = "view"+tag;
List<String> indexList = reportIndexGroup.get(tempReportId);
sql = sql +"left join "+ReportViewUtil.buildView(tempReportId, String.join(",", indexList), departIds, startTime, endTime) +viewName+ " on aa.time = "+viewName+".time and aa.depart_id = "+viewName+".depart_id ";
tag++;
}
System.out.println("======>>>>"+sql);
return masterDB.queryForList(sql);
}
public static void main(String[] args) {
String ids = "1,2,3,4";
String str = Arrays.stream(ids.split(",")).map(id -> "'" + id + "'").collect(Collectors.joining(","));
System.out.println(str);
}
@Override
......
......@@ -110,8 +110,6 @@ public class EquipmentController {
@Autowired
private ISysStructDictService sysStructDictService;
@Autowired
private ISysMetricDictService sysMetricDictService;
@Autowired
private IFactoryInfoService iFactoryInfoService;
@Autowired
private IPgQueryService pgQueryService;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!