71cc97aa 康伟

Merge remote-tracking branch 'origin/master'

2 个父辈 09b64370 7f614fea
......@@ -6,6 +6,7 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
......@@ -559,4 +560,46 @@ public class DateUtils {
return sdf.format(preDate);
}
/**
* 获取日期时间集合
* @param start
* @param end
* @return
*/
public static List<String> getDatesBetween(String start, String end) {
List<String> dateList = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(start, formatter);
LocalDate endDate = LocalDate.parse(end, formatter);
if (!startDate.isAfter(endDate)) {
LocalDate currentDate = startDate;
while (!currentDate.isAfter(endDate)) {
dateList.add(currentDate.toString());
currentDate = currentDate.plusDays(1);
}
}
return dateList;
}
/**
* 获取月份时间集合
* @param start
* @param end
* @return
*/
public static List<String> getMonthsBetween(String start, String end) {
List<String> monthList = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(start, formatter);
LocalDate endDate = LocalDate.parse(end, formatter);
YearMonth startMonth = YearMonth.from(startDate);
YearMonth endMonth = YearMonth.from(endDate);
YearMonth currentMonth = startMonth;
while (!currentMonth.isAfter(endMonth)) {
monthList.add(currentMonth.toString());
currentMonth = currentMonth.plusMonths(1);
}
return monthList;
}
}
......
......@@ -80,38 +80,46 @@ public class ScreenDataServiceImpl implements IScreenDataService {
//日数据
for (Map<String, Object> map : dayList) {
if (map.get("index_tag").equals(item)) {
if(map.get("daySum")!=null){
Double daySum = Double.parseDouble(map.get("daySum").toString());
v += daySum;
}
}
}
//小时数据
for (Map<String, Object> hour : hourList) {
if(hour.get(mid)!=null){
Double hourValue = Double.parseDouble(hour.get(mid).toString());
v += hourValue;
}
}
//一小时内数据
if (minuteList.size() > 0) {
if (type.equals("differ")) {//累计值求差
Map<String, Object> minMap = minuteList.get(0);//最小值
Double minValue = Double.parseDouble(minMap.get(mid).toString());
Map<String, Object> maxMap = minuteList.get(minuteList.size() - 1);//最大值
if(minMap.get(mid)!=null&&maxMap.get(mid)!=null){
Double minValue = Double.parseDouble(minMap.get(mid).toString());
Double maxValue = Double.parseDouble(maxMap.get(mid).toString());
Double hourDiffer = maxValue - minValue;
if (hourDiffer > 0) {
v += hourDiffer;
}
}
} else {//求平均
Double sumV = 0.00;
int count = 0;
for (Map<String, Object> minute : minuteList) {
Double minValue = Double.parseDouble(minute.get(mid).toString());
Double minValue = 0.00;
if(minute.get(mid)!=null){
minValue = Double.parseDouble(minute.get(mid).toString());
}
if (minValue > 0) {
sumV += minValue;
count += 1;
}
}
String avg = numberFormat.format(sumV / count);
v = Double.parseDouble(avg);
}
......
package com.skua.modules.custom.handle.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.skua.common.report.entity.ValueEntity;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.custom.handle.ICustomHandle;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
@Component("testHandle")
public class DayRunReportHandle implements ICustomHandle{
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
String departId,String indexCode) {
//主库数据源
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
System.out.println("程序进入自定义逻辑");
Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>();
//获取数据集
List<FCustomReportDatasetVO> dataSetList = fCustomReportDatasetService.getDataset(reportId);
for(FCustomReportDatasetVO fv : dataSetList) {
String dataSetId = fv.getDatasetId();
//获取填报数据及报表数据项信息,组装报表所需数据机构
List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>();
//根据数据集id获取数据项及填报数据
List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(dataSetId);
Map<String,String> dataFieldDict = new HashMap<String,String>();
for(FCustomReportDatasetVO dataField : dataFieldList) {
dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName());
}
//添加厂站、时间字段
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("time", "时间");
//获取填报数据
String dataViewName = "view_"+dataSetId.substring(0,4);
//结果集
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
//处理结果集数据
for(Map<String,Object> valueMap : valueMapList) {
Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>();
Set<String> keySet = valueMap.keySet();
for(String key : keySet) {
if(!StringUtils.isEmpty(dataFieldDict.get(key))) {
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(ConvertUtils.getString(valueMap.get(key)));
handleMap.put(dataFieldDict.get(key),valueEntity);
}
}
list.add(handleMap);
}
dataMap.put(fv.getDatasetName(), list);
}
return dataMap;
}
@Override
public String buildWaterQualityAlarmValue(String reportId, String departId, String json) {
return json;
}
}
package com.skua.modules.custom.handle.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.skua.common.report.ReportViewUtil;
import com.skua.common.report.entity.ValueEntity;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DoubleOperaUtils;
import com.skua.modules.custom.handle.ICustomHandle;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
/**
* <pre>
* 新版化验室日报自定义逻辑
* 2021年11月27日,业主程欣要求开发新版化验室日报
* </pre>
* @author Li Yuanyuan
* @version V0.1, 2021年11月27日 下午3:36:55
*/
@Component("hysrbReportNewHandle")
public class HysrbReportNewHandle implements ICustomHandle{
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
String departId,String indexCode) {
//主库数据源
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>();
//获取数据集
List<FCustomReportDatasetVO> dataSetList = fCustomReportDatasetService.getDataset(reportId);
for(FCustomReportDatasetVO fv : dataSetList) {
String dataSetId = fv.getDatasetId();
//获取填报数据及报表数据项信息,组装报表所需数据机构
List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>();
//根据数据集id获取数据项及填报数据
List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(dataSetId);
Map<String,String> dataFieldDict = new HashMap<String,String>();
for(FCustomReportDatasetVO dataField : dataFieldList) {
dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName());
}
//添加厂站、时间字段
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("time", "时间");
dataFieldDict.put("paramTime", "参数时间");
//获取填报数据
//String dataViewName = "view_"+dataSetId.substring(0,4);
String dataViewName = ReportViewUtil.buildView(dataSetId,"", departId, startTime, endTime);
//结果集
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
for(Map<String,Object> valueMap : valueMapList) {
Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>();
//添加时间参数
ValueEntity startTimeValueEntity = new ValueEntity();
startTimeValueEntity.setValue(startTime);
handleMap.put("参数时间", startTimeValueEntity);
Set<String> keySet = valueMap.keySet();
for(String key : keySet) {
if(!StringUtils.isEmpty(dataFieldDict.get(key))) {
String fieldName = dataFieldDict.get(key);
String fieldValue = ConvertUtils.getString(valueMap.get(key));
if(fieldName.contains("总氮")) {
//业主要求总氮保留三位小数
if(!StringUtils.isEmpty(fieldValue)) {
fieldValue = String.valueOf(DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(fieldValue, 0), 3));
}
}else if(fieldName.contains("总磷")&&!StringUtils.isEmpty(fieldValue)){
//总磷保留四位小数
if(!StringUtils.isEmpty(fieldValue)) {
fieldValue = String.valueOf(DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(fieldValue, 0), 4));
}
}
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(fieldValue);
handleMap.put(dataFieldDict.get(key),valueEntity);
}
}
list.add(handleMap);
}
dataMap.put(fv.getDatasetName(), list);
}
List<Map<String,ValueEntity>> bzList = new ArrayList<Map<String,ValueEntity>>();
Map<String,ValueEntity> bzMap = new HashMap<String,ValueEntity>();
bzList.add(bzMap);
dataMap.put("水质标准", bzList);
//添加进出水标准及污泥含水率
//获取污泥含水率
List<Map<String, Object>> moistureRateList = masterDB.queryForList("select moisture_rate from sys_factory_info where depart_id='"+departId+"'");
Map<String,Object> moistureRateMap = new HashMap<String,Object>();
if(moistureRateList!=null&&moistureRateList.size()>0) {
moistureRateMap = moistureRateList.get(0);
}
String wnhsl = ConvertUtils.getString(moistureRateMap.get("moisture_rate"), "-");
ValueEntity wnhslValueEntity = new ValueEntity();
wnhslValueEntity.setValue(wnhsl=="-"?"-":"≤"+wnhsl);
bzMap.put("污泥含水率", wnhslValueEntity);
//获取进水
Map<String,Object> inLevelMap = new HashMap<String,Object>();
List<Map<String, Object>> inLevelList = masterDB.queryForList("select index_code,upper from water_quality_in_level where depart_id='"+departId+"'");
if(inLevelList!=null&&inLevelList.size()>0) {
for(Map<String,Object> map :inLevelList) {
inLevelMap.put(String.valueOf(map.get("index_code")), map.get("upper"));
}
}
String jscod = ConvertUtils.getString(inLevelMap.get("JSCOD"), "-");
ValueEntity jscodValueEntity = new ValueEntity();
jscodValueEntity.setValue(jscod=="-"?"-":"≤"+jscod);
bzMap.put("进水化学需氧量 CODcr", jscodValueEntity);
String jsbod = ConvertUtils.getString(inLevelMap.get("JSBOD"), "-");
ValueEntity jsbodValueEntity = new ValueEntity();
jsbodValueEntity.setValue(jsbod=="-"?"-":"≤"+jsbod);
bzMap.put("进水五日生化需氧量BOD5", jsbodValueEntity);
String jsss = ConvertUtils.getString(inLevelMap.get("JSSS"), "-");
ValueEntity jsssValueEntity = new ValueEntity();
jsssValueEntity.setValue(jsss=="-"?"-":"≤"+jsss);
bzMap.put("进水悬浮固体SS", jsssValueEntity);
String jsnh3n = ConvertUtils.getString(inLevelMap.get("JSNH3N"), "-");
ValueEntity jsnh3nValueEntity = new ValueEntity();
jsnh3nValueEntity.setValue(jsnh3n=="-"?"-":"≤"+jsnh3n);
bzMap.put("进水氨氮NH₃-N", jsnh3nValueEntity);
String jstn = ConvertUtils.getString(inLevelMap.get("JSTN"), "-");
ValueEntity jstnValueEntity = new ValueEntity();
jstnValueEntity.setValue(jstn=="-"?"-":"≤"+jstn);
bzMap.put("进水总氮TN", jstnValueEntity);
String jstp = ConvertUtils.getString(inLevelMap.get("JSTP"), "-");
ValueEntity jstpValueEntity = new ValueEntity();
jstpValueEntity.setValue(jstp=="-"?"-":"≤"+jstp);
bzMap.put("进水总磷TP", jstpValueEntity);
//获取出水
Map<String,Object> outLevelMap = new HashMap<String,Object>();
List<Map<String, Object>> outLevelList = masterDB.queryForList("select a.id,b.alarm_param_code as index_code,b.alarm_param_upper_limit as upper,alarm_param_lower_limit from alarm_level_standard_config a left join alarm_param_standard_config b\r\n" +
"on a.id=b.alarm_level_standard_id where a.alarm_standard_level_code=(select out_level from sys_factory_info where depart_id='"+departId+"')");
if(outLevelList!=null&&outLevelList.size()>0) {
for(Map<String,Object> map :outLevelList) {
outLevelMap.put(String.valueOf(map.get("index_code")), map.get("upper"));
}
}
String cscod = ConvertUtils.getString(outLevelMap.get("CSCOD"), "-");
ValueEntity cscodValueEntity = new ValueEntity();
cscodValueEntity.setValue(cscod=="-"?"-":"≤"+cscod);
bzMap.put("出水化学需氧量 CODcr", cscodValueEntity);
String csbod = ConvertUtils.getString(outLevelMap.get("CSBOD"), "-");
ValueEntity csbodValueEntity = new ValueEntity();
csbodValueEntity.setValue(csbod=="-"?"-":"≤"+csbod);
bzMap.put("出水五日生化需氧量BOD5", csbodValueEntity);
String csss = ConvertUtils.getString(outLevelMap.get("CSSS"), "-");
ValueEntity csssValueEntity = new ValueEntity();
csssValueEntity.setValue(csss=="-"?"-":"≤"+csss);
bzMap.put("出水悬浮固体SS", csssValueEntity);
String csnh3n = ConvertUtils.getString(outLevelMap.get("CSNH3N"), "-");
ValueEntity csnh3nValueEntity = new ValueEntity();
csnh3nValueEntity.setValue(csnh3n=="-"?"-":"≤"+csnh3n);
bzMap.put("出水氨氮NH₃-N", csnh3nValueEntity);
String cstn = ConvertUtils.getString(outLevelMap.get("CSTN"), "-");
ValueEntity cstnValueEntity = new ValueEntity();
cstnValueEntity.setValue(cstn=="-"?"-":"≤"+cstn);
bzMap.put("出水总氮TN", cstnValueEntity);
String cstp = ConvertUtils.getString(outLevelMap.get("CSTP"), "-");
ValueEntity cstpValueEntity = new ValueEntity();
cstpValueEntity.setValue(cstp=="-"?"-":"≤"+cstp);
bzMap.put("出水总磷TP", cstpValueEntity);
return dataMap;
}
@Override
public String buildWaterQualityAlarmValue(String reportId, String departId, String json) {
return json;
}
}
package com.skua.modules.custom.handle.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.skua.common.report.ReportViewUtil;
import com.skua.common.report.entity.ValueEntity;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.custom.handle.ICustomHandle;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
/**
* <pre>
* 化验室月报
* </pre>
* @author Li Yuanyuan
* @version V0.1, 2021年3月30日 下午7:39:22
*/
@Component("hysybHandle")
public class HysybReportHandle implements ICustomHandle{
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
String departId,String indexCode) {
Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>();
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
//获取数据集
List<FCustomReportDatasetVO> dataSetList = fCustomReportDatasetService.getDataset(reportId);
for(FCustomReportDatasetVO fv : dataSetList) {
String dataSetId = fv.getDatasetId();
//获取填报数据及报表数据项信息,组装报表所需数据机构
List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>();
//根据数据集id获取数据项及填报数据
List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(dataSetId);
Map<String,String> dataFieldDict = new HashMap<String,String>();
for(FCustomReportDatasetVO dataField : dataFieldList) {
dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName());
}
//添加厂站、时间字段
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("time", "时间");
dataFieldDict.put("paramTime", "参数时间");
//获取填报数据
//String dataViewName = "view_"+dataSetId.substring(0,4);
String dataViewName = ReportViewUtil.buildView(dataSetId,"", departId, startTime, endTime);
System.out.println(dataViewName);
dataViewName="(select case when b.collection_time!='' then 'cj' else 'tb' end as datasource,a.* from \r\n" + dataViewName+
" a left join f_report_itemv_collection_info b on a.id=b.data_id)";
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
//获取采集数据信息
//采集指标包括
List<String> collectionIndexList = buildCollectionIndexList();
//获取异常补录数据
String alarmSql="select data_id,abnormal_time,targer_value,item_code,depart_id from f_report_itemv_abnormal where abnormal_time>='"+startTime+"' and abnormal_time<='"+endTime+"' and depart_id='"+departId+"'";
List<Map<String,Object>> alarmDataList = masterDB.queryForList(alarmSql);
//构造异常补录数据集合
Map<String,Object> alarmMap = new HashMap<String,Object>();
for(Map<String,Object> map : alarmDataList) {
alarmMap.put(map.get("data_id")+"_"+map.get("item_code"), map.get("targer_value"));
}
for(Map<String,Object> valueMap : valueMapList) {
Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>();
//添加时间参数
ValueEntity startTimeValueEntity = new ValueEntity();
startTimeValueEntity.setValue(DateUtils.dateformat(startTime, "yyyy-MM"));
handleMap.put("参数时间", startTimeValueEntity);
Set<String> keySet = valueMap.keySet();
//数据源状态,cj采集 tb填报
String datasource = ConvertUtils.getString(valueMap.get("datasource"));
String id = ConvertUtils.getString(valueMap.get("id"));
System.out.println(datasource);
for(String key : keySet) {
if(!StringUtils.isEmpty(dataFieldDict.get(key))) {
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(ConvertUtils.getString(valueMap.get(key)));
if("cj".equals(datasource)&&collectionIndexList.contains(key)) {
if(!StringUtils.isEmpty(ConvertUtils.getString(alarmMap.get(id+"_"+key)))) {
valueEntity.setDataSourceColor("limegreen");
valueEntity.setTitle("异常补录");
}else {
valueEntity.setDataSourceColor("blue");
valueEntity.setTitle("实时采集");
}
}
// if("JSCOD".equals(key)) {
// valueEntity.setDataSourceColor("blue");
// }
handleMap.put(dataFieldDict.get(key),valueEntity);
}
}
list.add(handleMap);
}
dataMap.put(fv.getDatasetName(), list);
}
return dataMap;
}
@Override
public String buildWaterQualityAlarmValue(String reportId, String departId, String json) {
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
//获取厂站报警阈值,后面性能上需要优化此处逻辑
String sql="SELECT\r\n" +
" 'IN' AS type,\r\n" +
" index_code AS level_code,\r\n" +
" upper,\r\n" +
" lower\r\n" +
" FROM\r\n" +
" water_quality_in_level\r\n" +
" WHERE\r\n" +
" depart_id = '"+departId+"'\r\n" +
" UNION ALL\r\n" +
" SELECT\r\n" +
" 'OUT' AS type,\r\n" +
" alarm_param_code AS level_code,\r\n" +
" alarm_param_upper_limit AS upper,\r\n" +
" alarm_param_lower_limit AS lower\r\n" +
" FROM\r\n" +
" alarm_level_standard_config a\r\n" +
" LEFT JOIN alarm_param_standard_config b ON a.id = b.alarm_level_standard_id\r\n" +
" WHERE\r\n" +
" a.alarm_standard_level_code = (\r\n" +
" SELECT\r\n" +
" out_level\r\n" +
" FROM\r\n" +
" sys_factory_info\r\n" +
" WHERE\r\n" +
" depart_id = '"+departId+"'\r\n" +
" )";
List<Map<String,Object>> levelMapList = masterDB.queryForList(sql);
Map<String,Object> LevelMap = new HashMap<String,Object>();
for(Map<String,Object> map : levelMapList) {
LevelMap.put(ConvertUtils.getString(map.get("level_code")), map.get("upper"));
}
//动态修改json模板
Map<String,Object> jsonMap = JSON.parseObject(json, new TypeReference<Map<String, Object>>(){} );
recursionMap(jsonMap,LevelMap);
return JSONObject.toJSONString(jsonMap);
}
/**
* <pre>
* 递归处理
* </pre>
* @param jsonMap
* @param levelMap
* @author Li Yuanyuan, 2022年2月19日 下午10:27:17
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
public static void recursionMap(Map<String,Object> jsonMap,Map<String,Object> levelMap){
if(jsonMap!=null&&jsonMap.size()>0) {
Set<String> keySet = jsonMap.keySet();
for(String key : keySet) {
if(jsonMap.get(key) instanceof Map){
Map<String,Object> childJb = (Map<String,Object>)jsonMap.get(key);
recursionMap(childJb,levelMap);
}else if(jsonMap.get(key) instanceof List){
//数组类型暂不做处理
//List<Map<String,Object>> childArr = (List<Map<String,Object>>) jsonMap.get(key);
}else{
if("alarmTagCode".equals(key)) {
//判断如果存在超标报警标记,则进行报警值填充
jsonMap.put("alarmTagUpper", levelMap.get(jsonMap.get(key)));
}
}
}
}
}
/**
* <pre>
* 构造化验日报填报,可采集指标集合
* </pre>
* @return
* @author Li Yuanyuan, 2022年2月22日 下午4:51:24
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
public List<String> buildCollectionIndexList() {
List<String> collectionIndex=new ArrayList<String>();
collectionIndex.add("JSCOD");
collectionIndex.add("JSAD");
collectionIndex.add("JSPH");
collectionIndex.add("CSCOD");
collectionIndex.add("CSAD");
collectionIndex.add("CSPH");
collectionIndex.add("CSZL");
collectionIndex.add("CSTN");
collectionIndex.add("CSSW");
return collectionIndex;
}
}
package com.skua.modules.custom.handle.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.skua.common.report.entity.ValueEntity;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.core.util.DoubleOperaUtils;
import com.skua.modules.custom.handle.ICustomHandle;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
import com.skua.modules.util.CustomReportViewUtil;
/**
* <pre>
* 污染物去除量月报自定义数据获取逻辑
* </pre>
* @author Li Yuanyuan
* @version V0.1, 2021年1月19日 上午11:43:47
*/
@Component("wrwqclybHandle")
public class WrwqclybReportHandle implements ICustomHandle{
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
String departId,String indexCode) {
if(StringUtils.isEmpty(startTime)) {
startTime = "2020-11-01";
}
if(StringUtils.isEmpty(indexCode)) {
indexCode = "cod";
}
//主库数据源
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
System.out.println("程序进入污染物去除量月报自定义数据获取逻辑");
Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>();
//获取数据集
List<FCustomReportDatasetVO> dataSetList = fCustomReportDatasetService.getDataset(reportId);
for(FCustomReportDatasetVO fv : dataSetList) {
String dataSetId = fv.getDatasetId();
//获取填报数据及报表数据项信息,组装报表所需数据机构
List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>();
//根据数据集id获取数据项及填报数据
List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(dataSetId);
Map<String,String> dataFieldDict = new HashMap<String,String>();
for(FCustomReportDatasetVO dataField : dataFieldList) {
dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName());
}
//添加厂站、时间字段
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("time", "时间");
dataFieldDict.put("rownum", "序号");
dataFieldDict.put("area", "区域");
dataFieldDict.put("index", "指标");
dataFieldDict.put("paramTime", "参数时间");
//污泥
dataFieldDict.put("qcl01", "去除量1");
dataFieldDict.put("qcl02", "去除量2");
dataFieldDict.put("qcl03", "去除量3");
dataFieldDict.put("qcl04", "去除量4");
dataFieldDict.put("qcl05", "去除量5");
dataFieldDict.put("qcl06", "去除量6");
dataFieldDict.put("qcl07", "去除量7");
dataFieldDict.put("qcl08", "去除量8");
dataFieldDict.put("qcl09", "去除量9");
dataFieldDict.put("qcl10", "去除量10");
dataFieldDict.put("qcl11", "去除量11");
dataFieldDict.put("qcl12", "去除量12");
dataFieldDict.put("qcl13", "去除量13");
dataFieldDict.put("qcl14", "去除量14");
dataFieldDict.put("qcl15", "去除量15");
dataFieldDict.put("qcl16", "去除量16");
dataFieldDict.put("qcl17", "去除量17");
dataFieldDict.put("qcl18", "去除量18");
dataFieldDict.put("qcl19", "去除量19");
dataFieldDict.put("qcl20", "去除量20");
dataFieldDict.put("qcl21", "去除量21");
dataFieldDict.put("qcl22", "去除量22");
dataFieldDict.put("qcl23", "去除量23");
dataFieldDict.put("qcl24", "去除量24");
dataFieldDict.put("qcl25", "去除量25");
dataFieldDict.put("qcl26", "去除量26");
dataFieldDict.put("qcl27", "去除量27");
dataFieldDict.put("qcl28", "去除量28");
dataFieldDict.put("qcl29", "去除量29");
dataFieldDict.put("qcl30", "去除量30");
dataFieldDict.put("qcl31", "去除量31");
//获取填报数据
//String dataViewName = "view_"+dataSetId.substring(0,4);
//String dataViewName = ReportViewUtil.buildView(dataSetId, "", departId, startTime, endTime);
String selectFields = "";
//结果集
String paramName = "COD减排量";
if(indexCode.equals("bod")) {
selectFields = "JSBOD as JSVAL,CSBOD AS CSVAL";
paramName = "BOD5减排量";
}else if(indexCode.equals("cod")) {
selectFields = "JSCOD as JSVAL,CSCOD AS CSVAL";
paramName = "COD减排量";
}else if(indexCode.equals("tn")) {
selectFields = "JSZD as JSVAL,CSTN AS CSVAL";
paramName = "总氮减排量";
}else if(indexCode.equals("tp")) {
selectFields = "JSZL as JSVAL,CSZL AS CSVAL";
paramName = "总磷减排量";
}else if(indexCode.equals("ss")) {
selectFields = "JSSS as JSVAL,CSSS AS CSVAL";
paramName = "SS减排量";
}else if(indexCode.equals("nh3n")) {
selectFields = "JSAD as JSVAL,CSAD AS CSVAL";
paramName = "氨氮减排量";
}else if(indexCode.equals("cl")) {
selectFields = "JSLHW as JSVAL,CSLHW AS CSVAL";
paramName = "氯化物减排量";
}else if(indexCode.equals("no3n")) {
selectFields = "JSXSY as JSVAL,CSXSY AS CSVAL";
paramName = "硝酸盐减排量";
}
String dataViewName = CustomReportViewUtil.buildYyrbView("5b542809fa0821a5e0ec6c3b378fbb23", "b78f82e1d9d01016ad72517dc430c3b5", selectFields, "CLSL", departId, startTime, endTime);
List<Map<String, Object>> extList = masterDB.queryForList("select * from (" +
"select b.depart_order,b.depart_name as depart_name,(select depart_name from sys_depart where id=b.parent_id) as area_name,depart_id,time,"+selectFields+",CLSL from "+dataViewName+" a inner join sys_depart b on a.depart_id=b.id where time >=? and time <=? " +
") aa order by area_name,depart_order,time",startTime,endTime);
//构造报表数据集
List<Map<String, Object>> valueMapList = new ArrayList<Map<String, Object>>();
String departName = "";
Map<String,Object> buildMap = null;
int rowum = 0;
String timeTag = "";
for(Map<String ,Object> extMap : extList) {
String extDepartName = ConvertUtils.getString(extMap.get("depart_name"));
String extTime = ConvertUtils.getString(extMap.get("time"));
timeTag = extTime.substring(extTime.length()-2, extTime.length());
//减排量=(进水溶度(mg/L])-出水浓度(mg/L]))*处理水量(万吨)*10000*1000/1000/1000/1000
double qcl = DoubleOperaUtils.bigDecimalRound((ConvertUtils.getDouble(extMap.get("JSVAL"), 0.0) - ConvertUtils.getDouble(extMap.get("CLSL"), 0.0)) * ConvertUtils.getDouble(extMap.get("CLSL"), 0.0) / 100,2);
if(!StringUtils.isEmpty(departName)&&departName.equals(extDepartName)) {
buildMap.put("qcl"+timeTag, ConvertUtils.getString(qcl));
}else {
departName = extDepartName;
buildMap = new HashMap<String,Object>();
rowum = rowum +1;
//添加片区、厂站
buildMap.put("area", extMap.get("area_name"));
buildMap.put("rownum",rowum);
buildMap.put("depart_name",extDepartName);
buildMap.put("qcl"+timeTag, qcl);
valueMapList.add(buildMap);
//本月没有日期数据用/补充
int dayCount = DateUtils.getDayCountOfMonth(startTime);
for(int i=31;i>dayCount;i--) {
buildMap.put("qcl"+i, "/");
}
}
}
//处理结果集数据
for(Map<String,Object> valueMap : valueMapList) {
Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>();
Set<String> keySet = valueMap.keySet();
for(String key : keySet) {
if(!StringUtils.isEmpty(dataFieldDict.get(key))) {
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(ConvertUtils.getString(valueMap.get(key)));
handleMap.put(dataFieldDict.get(key),valueEntity);
}
}
list.add(handleMap);
}
dataMap.put(fv.getDatasetName(), list);
//添加参数到结果集
List<Map<String,ValueEntity>> paramList = new ArrayList<Map<String,ValueEntity>>();
Map<String,ValueEntity> paramMap = new HashMap<String,ValueEntity>();
ValueEntity paramNameValueEntity = new ValueEntity();
paramNameValueEntity.setValue(paramName);
paramMap.put("指标", paramNameValueEntity);
ValueEntity startTimeValueEntity = new ValueEntity();
startTimeValueEntity.setValue(DateUtils.dateformat(startTime, "yyyy-MM"));
paramMap.put("参数时间", startTimeValueEntity);
paramList.add(paramMap);
dataMap.put("参数数据集", paramList);
}
return dataMap;
}
@Override
public String buildWaterQualityAlarmValue(String reportId, String departId, String json) {
return json;
}
}
package com.skua.modules.custom.handle.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.skua.common.report.ReportViewUtil;
import com.skua.common.report.entity.ValueEntity;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.custom.handle.ICustomHandle;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
/**
* <pre>
* 药耗月报自定义数据获取逻辑
* </pre>
* @author Li Yuanyuan
* @version V0.1, 2021年1月19日 上午11:43:00
*/
@Component("yhybHandle")
public class YhybReportHandle implements ICustomHandle{
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
String departId,String indexCode) {
//主库数据源
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
System.out.println("程序进入药耗月报数据自定义获取逻辑");
Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>();
//获取数据集
List<FCustomReportDatasetVO> dataSetList = fCustomReportDatasetService.getDataset(reportId);
for(FCustomReportDatasetVO fv : dataSetList) {
String dataSetId = fv.getDatasetId();
//获取填报数据及报表数据项信息,组装报表所需数据机构
List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>();
//根据数据集id获取数据项及填报数据
List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(dataSetId);
Map<String,String> dataFieldDict = new HashMap<String,String>();
for(FCustomReportDatasetVO dataField : dataFieldList) {
dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName());
}
//添加厂站、时间字段
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("time", "时间");
dataFieldDict.put("rownum", "序号");
dataFieldDict.put("paramTime", "参数时间");
//污泥
dataFieldDict.put("wn_val", "污泥其他用量");
dataFieldDict.put("wn_dj", "污泥其他单价");
dataFieldDict.put("wn_zj", "污泥其他总价");
dataFieldDict.put("wn_hdj", "污泥其他核定价");
//污水
dataFieldDict.put("ws_val", "污水其他用量");
dataFieldDict.put("ws_dj", "污水其他单价");
dataFieldDict.put("ws_zj", "污水其他总价");
dataFieldDict.put("ws_hdj", "污水其他核定价");
//消毒药剂
dataFieldDict.put("xdyj_val", "消毒药剂其他用量");
dataFieldDict.put("xdyj_dj", "消毒药剂其他单价");
dataFieldDict.put("xdyj_zj", "消毒药剂其他总价");
dataFieldDict.put("xdyj_hdj", "消毒药剂其他核定价");
//获取填报数据
//String dataViewName = "view_"+dataSetId.substring(0,4);
String dataViewName = ReportViewUtil.buildView(dataSetId, "", departId, startTime, endTime);
//结果集
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
for(int i=0;i<valueMapList.size();i++) {
Map<String,Object> valueMap = valueMapList.get(i);
valueMap.put("rownum", String.valueOf(i+1));
//获取id
String dataId = valueMap.get("id").toString();
//获取其他指标
List<Map<String, Object>> extList = masterDB.queryForList("select * from f_report_item_yyyb_ext where data_id='"+dataId+"'");
for(Map<String, Object> extMap : extList) {
String type = extMap.get("item_type").toString();
valueMap.put(type+"_val", extMap.get("item_value"));
valueMap.put(type+"_dj", extMap.get("item_dj"));
valueMap.put(type+"_zj", extMap.get("item_zj"));
valueMap.put(type+"_hdj", extMap.get("item_hdj"));
}
}
//处理结果集数据
for(Map<String,Object> valueMap : valueMapList) {
Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>();
Set<String> keySet = valueMap.keySet();
for(String key : keySet) {
if(!StringUtils.isEmpty(dataFieldDict.get(key))) {
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(ConvertUtils.getString(valueMap.get(key)));
handleMap.put(dataFieldDict.get(key),valueEntity);
}
}
list.add(handleMap);
}
dataMap.put(fv.getDatasetName(), list);
}
return dataMap;
}
@Override
public String buildWaterQualityAlarmValue(String reportId, String departId, String json) {
return json;
}
}
package com.skua.modules.custom.handle.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.skua.common.report.ReportViewUtil;
import com.skua.common.report.entity.ValueEntity;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.custom.handle.ICustomHandle;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
/**
* <pre>
* 运营年报自定义逻辑
* </pre>
* @author Li Yuanyuan
* @version V0.1, 2021年3月30日 下午7:50:24
*/
@Component("yynbHandle")
public class YynbReportHandle implements ICustomHandle{
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
String departId,String indexCode) {
Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>();
//获取数据集
List<FCustomReportDatasetVO> dataSetList = fCustomReportDatasetService.getDataset(reportId);
for(FCustomReportDatasetVO fv : dataSetList) {
String dataSetId = fv.getDatasetId();
//获取填报数据及报表数据项信息,组装报表所需数据机构
List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>();
//根据数据集id获取数据项及填报数据
List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(dataSetId);
Map<String,String> dataFieldDict = new HashMap<String,String>();
for(FCustomReportDatasetVO dataField : dataFieldList) {
dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName());
}
//添加厂站、时间字段
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("show_time", "时间");
//添加计算类型
dataFieldDict.put("calculation_type", "calculation_type");
dataFieldDict.put("paramTime", "参数时间");
dataFieldDict.put("CODXJL", "COD削减量");
dataFieldDict.put("ADXJL", "氨氮削减量");
dataFieldDict.put("BODXJL", "BOD削减量");
dataFieldDict.put("SSXJL", "SS削减量");
dataFieldDict.put("ZDXJL", "总氮削减量");
dataFieldDict.put("ZLXJL", "总磷削减量");
//获取填报数据
//String dataViewName = "view_"+dataSetId.substring(0,4);
String dataViewName = ReportViewUtil.buildView(dataSetId,"", departId, startTime, endTime);
dataViewName = buildSystemFullDataSql(startTime.substring(0, 4),departId,dataViewName);
System.out.println(dataViewName);
//sql语句中添加消减量计算
dataViewName = "(select '0' as calculation_type,date as show_time,(JSCOD-CSCOD)*BYCLSL/100 as CODXJL,(JSAD-CSAD)*BYCLSL/100 as ADXJL,(JSBOD-CSBOD)*BYCLSL/100 as BODXJL,(JSSS-CSSS)*BYCLSL/100 as SSXJL,(JSZD-CSTN)*BYCLSL/100 as ZDXJL,(JSZL-CSZL)*BYCLSL/100 as ZLXJL,WSCLYJZL,BYWNYJF,BYWSCLYJF,CSTN,LXR,CSBOD,JSCOD,WNCLYJZL,ZSHYL,BZ,BYCLSL,CSZL,BYSJYXTS,ZSJYFY,JSSS,CSSS,CSAD,BYGWNCL,BYYYL,BYDF,ZLSYLZJ,JSBOD,CSCOD,ZLSYLDJ,JSZL,BYZSYL,BYWNCZF,SJCLGM,BYZLSYL,BYZLSF,JSAD,JSZD,HDLDJ,BYYDL,HDLZJ,LXDH,BYSWNCL,depart_id as depart_id,id,date as time\r\n" +
" from "+dataViewName+" aa"
+ " union all\r\n" +
"select '1' as calculation_type,\r\n" +
"case when QUARTER(concat(date,'-01 00:00:00'))='1' then '第一季度' when QUARTER(concat(date,'-01 00:00:00'))='2' then '第二季度' when QUARTER(concat(date,'-01 00:00:00'))='3' then '第三季度' when QUARTER(concat(date,'-01 00:00:00'))='4' then '第四季度' end as show_time,\r\n" +
"sum((JSCOD-CSCOD)*BYCLSL/100) as CODXJL,\r\n" +
"sum((JSAD-CSAD)*BYCLSL/100) as ADXJL,\r\n" +
"sum((JSBOD-CSBOD)*BYCLSL/100) as BODXJL,\r\n" +
"sum((JSSS-CSSS)*BYCLSL/100) as SSXJL,\r\n" +
"sum((JSZD-CSTN)*BYCLSL/100) as ZDXJL,\r\n" +
"sum((JSZL-CSZL)*BYCLSL/100) as ZLXJL,\r\n" +
"sum(WSCLYJZL) as WSCLYJZL,\r\n" +
"sum(BYWNYJF) as BYWNYJF,\r\n" +
"sum(BYWSCLYJF) as BYWSCLYJF,\r\n" +
"avg(CSTN) as CSTN,\r\n" +
"'/' as LXR,\r\n" +
"avg(CSBOD) as CSBOD,\r\n" +
"avg(JSCOD) as JSCOD,\r\n" +
"sum(WNCLYJZL) as WNCLYJZL,\r\n" +
"sum(ZSHYL) as ZSHYL,\r\n" +
"'/' as BZ,\r\n" +
"sum(BYCLSL) as BYCLSL,\r\n" +
"avg(CSZL) as CSZL,\r\n" +
"sum(BYSJYXTS) as BYSJYXTS,\r\n" +
"sum(ZSJYFY) as ZSJYFY,\r\n" +
"avg(JSSS) as JSSS,\r\n" +
"avg(CSSS) as CSSS,\r\n" +
"avg(CSAD) as CSAD,\r\n" +
"sum(BYGWNCL) as BYGWNCL,\r\n" +
"sum(BYYYL) as BYYYL,\r\n" +
"sum(BYDF) as BYDF,\r\n" +
"sum(ZLSYLZJ) as ZLSYLZJ,\r\n" +
"avg(JSBOD) as JSBOD,\r\n" +
"avg(CSCOD) as CSCOD,\r\n" +
"avg(ZLSYLDJ) as ZLSYLDJ,\r\n" +
"avg(JSZL) as JSZL,\r\n" +
"sum(BYZSYL) as BYZSYL,\r\n" +
"sum(BYWNCZF) as BYWNCZF,\r\n" +
"avg(SJCLGM) as SJCLGM,\r\n" +
"sum(BYZLSYL) as BYZLSYL,\r\n" +
"sum(BYZLSF) as BYZLSF,\r\n" +
"avg(JSAD) as JSAD,\r\n" +
"avg(JSZD) as JSZD,\r\n" +
"avg(HDLDJ) as HDLDJ,\r\n" +
"sum(BYYDL) as BYYDL,\r\n" +
"sum(HDLZJ) as HDLZJ,\r\n" +
"'/' as LXDH,\r\n" +
"sum(BYSWNCL) as BYSWNCL,\r\n" +
"depart_id as depart_id,\r\n" +
"'/' as id,\r\n" +
"max(concat(date,QUARTER(concat(date,'-01 00:00:00')))) as time\r\n" +
" from "+dataViewName+" aa group by depart_id,show_time)";
System.out.println("===================");
System.out.println(dataViewName);
//结果集
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
//按厂站计算季度数据
//1.判断当前月份处于几
for(Map<String,Object> valueMap : valueMapList) {
Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>();
//添加时间参数
ValueEntity startTimeValueEntity = new ValueEntity();
startTimeValueEntity.setValue(DateUtils.dateformat(startTime, "yyyy"));
handleMap.put("参数时间",startTimeValueEntity);
Set<String> keySet = valueMap.keySet();
for(String key : keySet) {
if(!StringUtils.isEmpty(dataFieldDict.get(key))) {
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(ConvertUtils.getString(valueMap.get(key)));
handleMap.put(dataFieldDict.get(key),valueEntity);
}
}
list.add(handleMap);
}
dataMap.put(fv.getDatasetName(), list);
}
return dataMap;
}
/**
* <pre>
* <请输入描述信息>
* </pre>
* @param year
* @param departIds
* @param dataViewName
* @return
* @author Li Yuanyuan, 2022年2月17日 下午3:24:46
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
public String buildSystemFullDataSql(String year,String departIds,String dataViewName) {
//解析厂站id
String inSqlPart = "";
String[] factoryArray = departIds.split(",");
for(String departId : factoryArray) {
inSqlPart = inSqlPart+",'"+departId+"'";
}
if(!StringUtils.isEmpty(inSqlPart)) {
inSqlPart = inSqlPart.substring(1);
}
String sql="select a.id,a.depart_name,b.date from view_sys_depart a inner join (";
for(int i=1;i<=12;i++) {
if(i<10) {
if(i>1) {
sql = sql +"union all select '"+year+"-0"+i+"' AS date ";
}else {
sql = sql +"select '"+year+"-0"+i+"' AS date ";
}
}else {
sql = sql +"union all select '"+year+"-"+i+"' AS date ";
}
}
sql = sql +") b on 1=1 where a.id in("+inSqlPart+")";
sql="(select a.depart_name,a.id as depart_id,a.date,case when b.time=a.date then 'yes' else 'no' end as is_system_full,b.* from ("+sql+") a left join "+dataViewName+" b on (a.id=b.depart_id and a.date=b.time))";
return sql;
}
@Override
public String buildWaterQualityAlarmValue(String reportId, String departId, String json) {
return json;
}
}
......@@ -104,18 +104,6 @@ public class YyrbReportHandle implements ICustomHandle{
inLevelMap.put(String.valueOf(map.get("index_code")), map.get("upper"));
}
}
// String jscod = ConvertUtils.getString(inLevelMap.get("JSCOD"), "-");
// bzMap.put("进水化学需氧量 CODcr", jscod=="-"?"-":"≤"+jscod);
// String jsbod = ConvertUtils.getString(inLevelMap.get("JSBOD"), "-");
// bzMap.put("进水五日生化需氧量BOD5", jsbod=="-"?"-":"≤"+jsbod);
// String jsss = ConvertUtils.getString(inLevelMap.get("JSSS"), "-");
// bzMap.put("进水悬浮固体SS", jsss=="-"?"-":"≤"+jsss);
// String jsnh3n = ConvertUtils.getString(inLevelMap.get("JSNH3N"), "-");
// bzMap.put("进水氨氮NH₃-N", jsnh3n=="-"?"-":"≤"+jsnh3n);
// String jstn = ConvertUtils.getString(inLevelMap.get("JSTN"), "-");
// bzMap.put("进水总氮TN", jstn=="-"?"-":"≤"+jstn);
// String jstp = ConvertUtils.getString(inLevelMap.get("JSTP"), "-");
// bzMap.put("进水总磷TP", jstp=="-"?"-":"≤"+jstp);
String jscod = ConvertUtils.getString(inLevelMap.get("JSCOD"), "-");
ValueEntity jscodValueEntity = new ValueEntity();
jscodValueEntity.setValue(jscod=="-"?"-":"≤"+jscod);
......@@ -156,18 +144,6 @@ public class YyrbReportHandle implements ICustomHandle{
outLevelMap.put(String.valueOf(map.get("index_code")), map.get("upper"));
}
}
// String cscod = ConvertUtils.getString(outLevelMap.get("CSCOD"), "-");
// bzMap.put("出水化学需氧量 CODcr", cscod=="-"?"-":"≤"+cscod);
// String csbod = ConvertUtils.getString(outLevelMap.get("CSBOD"), "-");
// bzMap.put("出水五日生化需氧量BOD5", csbod=="-"?"-":"≤"+csbod);
// String csss = ConvertUtils.getString(outLevelMap.get("CSSS"), "-");
// bzMap.put("出水悬浮固体SS", csss=="-"?"-":"≤"+csss);
// String csnh3n = ConvertUtils.getString(outLevelMap.get("CSNH3N"), "-");
// bzMap.put("出水氨氮NH₃-N", csnh3n=="-"?"-":"≤"+csnh3n);
// String cstn = ConvertUtils.getString(outLevelMap.get("CSTN"), "-");
// bzMap.put("出水总氮TN", cstn=="-"?"-":"≤"+cstn);
// String cstp = ConvertUtils.getString(outLevelMap.get("CSTP"), "-");
// bzMap.put("出水总磷TP", cstp=="-"?"-":"≤"+cstp);
String cscod = ConvertUtils.getString(outLevelMap.get("CSCOD"), "-");
ValueEntity cscodValueEntity = new ValueEntity();
......
package com.skua.modules.custom.handle.impl;
import com.skua.common.report.ReportViewUtil;
import com.skua.common.report.entity.ValueEntity;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.custom.handle.ICustomHandle;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
import com.skua.modules.dataAnalysis.service.IFactoryCenterService;
import com.skua.tool.util.DateUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* <pre>
* 运营月报自定义逻辑
* </pre>
* @author zhanglei
* @version V0.1, 2024年11月17日 上午9:40:17
*/
@Component("yyybReportHandle")
public class YyybReportHandle implements ICustomHandle{
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
@Resource
private IFactoryCenterService factoryCenterService;
@Override
public Map<String, List<Map<String, ValueEntity>>> buildDataMap(String reportId, String startTime, String endTime,
String departId,String indexCode) {
List<String> timeList = DateUtils.getDatesBetween(startTime, endTime);
Map<String, Object> levelMap = factoryCenterService.getMonitorThreshold(departId);
Map<String,List<Map<String,ValueEntity>>> resMap = new HashMap<String,List<Map<String,ValueEntity>>>();
Map<String,List<Map<String,ValueEntity>>> dataMap = new HashMap<String,List<Map<String,ValueEntity>>>();
//获取数据集
List<FCustomReportDatasetVO> dataSetList = fCustomReportDatasetService.getDataset(reportId);
for(FCustomReportDatasetVO fv : dataSetList) {
String dataSetId = fv.getDatasetId();
//获取填报数据及报表数据项信息,组装报表所需数据机构
List<Map<String,ValueEntity>> list = new ArrayList<Map<String,ValueEntity>>();
//根据数据集id获取数据项及填报数据
List<FCustomReportDatasetVO> dataFieldList = fCustomReportDatasetService.getDataField(dataSetId);
Map<String,String> dataFieldDict = new HashMap<String,String>();
for(FCustomReportDatasetVO dataField : dataFieldList) {
dataFieldDict.put(dataField.getDatasetId(), dataField.getDatasetName());
}
//添加厂站、时间字段
dataFieldDict.put("depart_name", "厂站名称");
dataFieldDict.put("time", "时间");
dataFieldDict.put("paramTime", "参数时间");
//获取填报数据
String dataViewName = ReportViewUtil.buildView(dataSetId,"", departId, startTime,endTime);
//结果集
List<Map<String, Object>> valueMapList = fCustomReportDatasetService.queryReportValue(dataViewName,startTime,endTime,departId);
for(Map<String,Object> valueMap : valueMapList) {
Map<String,ValueEntity> handleMap = new HashMap<String,ValueEntity>();
//添加时间参数
ValueEntity startTimeValueEntity = new ValueEntity();
startTimeValueEntity.setValue(startTime);
handleMap.put("参数时间", startTimeValueEntity);
Set<String> keySet = valueMap.keySet();
for(String key : keySet) {
if(!StringUtils.isEmpty(dataFieldDict.get(key))) {
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(ConvertUtils.getString(valueMap.get(key)));
handleMap.put(dataFieldDict.get(key),valueEntity);
}
}
list.add(handleMap);
}
dataMap.put(fv.getDatasetName(), list);
}
List<Map<String,ValueEntity>> dList = new ArrayList<>();
for (String time: timeList) {
Map<String,ValueEntity> newDataMap = new HashMap<>();
ValueEntity valueEntity = new ValueEntity();
valueEntity.setValue(time);
newDataMap.put("时间", valueEntity);
for (Map.Entry<String, List<Map<String,ValueEntity>>> entry : dataMap.entrySet()) {
List<Map<String,ValueEntity>> list = entry.getValue();
for (Map<String,ValueEntity> dMap: list) {
if(time.equals(dMap.get("时间").getValue())){
if(levelMap!=null){
dMap = changeDataColor(dMap,levelMap);
}
newDataMap.putAll(dMap);
}
}
}
dList.add(newDataMap);
}
resMap.put("综合数据源", dList);
return resMap;
}
@Override
public String buildWaterQualityAlarmValue(String reportId, String departId, String json) {
return json;
}
/**
* 指标变色
* @param map
* @param levelMap
* @return
*/
public Map<String,ValueEntity> changeDataColor(Map<String,ValueEntity> map,Map<String, Object> levelMap){
for (Map.Entry<String, ValueEntity> entry : map.entrySet()) {
String key = entry.getKey();
ValueEntity value = entry.getValue();
if("进水COD".equals(key)){
if(levelMap.get("JSCOD")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("JSCOD").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("出水COD".equals(key)){
if(levelMap.get("CSCOD")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("CSCOD").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("进水氨氮".equals(key)){
if(levelMap.get("JSNH3N")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("JSNH3N").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("出水氨氮".equals(key)){
if(levelMap.get("CSNH3N")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("CSNH3N").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("进水总氮".equals(key)){
if(levelMap.get("JSTN")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("JSTN").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("出水总氮".equals(key)){
if(levelMap.get("CSTN")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("CSTN").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("进水总磷".equals(key)){
if(levelMap.get("JSTP")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("JSTP").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("出水总磷".equals(key)){
if(levelMap.get("CSTP")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("CSTP").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("进水pH".equals(key)){
if(levelMap.get("JSPH")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("JSPH").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l);
}
}
}
}
if("出水pH".equals(key)){
if(levelMap.get("CSPH")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("CSPH").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l);
}
}
}
}
if("进水SS".equals(key)){
if(levelMap.get("JSSS")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("JSSS").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
if("出水SS".equals(key)){
if(levelMap.get("CSSS")!=null){
if(ConvertUtils.isNotEmpty(value.getValue())){
double v = Double.parseDouble(value.getValue());
double l = Double.parseDouble(levelMap.get("CSSS").toString());
if(v > l){
value.setDataSourceColor("red");
value.setTitle("超过上限"+l+"mg/L");
}
}
}
}
}
return map;
}
}
......@@ -41,9 +41,7 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
private IFCustomReportDatasetService fCustomReportDatasetService;
@Autowired
private ISysBaseAPI iSysBaseAPI;
/* (non-Javadoc)
* @see com.skua.modules.custom.service.IFCustomReportInfoService#reportShow(java.lang.String)
*/
@Override
public Map<String,Object> reportShow(String reportId,String startTime,String endTime,String departId,String indexCode) {
//添加报表数据权限
......@@ -52,6 +50,15 @@ public class FCustomReportInfoServiceImpl extends ServiceImpl<FCustomReportInfoM
}
//获取自定义报表对象
FCustomReportInfo reportInfo = this.getById(reportId);
if("3".equals(reportInfo.getReportTimeQueryType())){//年
startTime = startTime + "-01-01";
endTime = endTime + "-12-31";
}else if("2".equals(reportInfo.getReportTimeQueryType())){//月
startTime = startTime + "-01";
endTime = endTime + "-31";
}else{
//无需转换时间
}
String customService = reportInfo.getCustomService();
//锁定行号
String lockRowNum = reportInfo.getLockRowNum();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!