beaa9e42 张雷

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

2 个父辈 72eb82e2 88dbe1d8
......@@ -72,9 +72,9 @@ public class ReportViewUtil {
if(!StringUtils.isEmpty(itemIds)) {
itemIds = itemIds.substring(1);
}
sb.append("`a`.`depart_id` AS `depart_id`,`a`.`data_id` AS `id`,`a`.`data_time` AS `time` from (( ");
sb.append(" `a`.`depart_id` AS `depart_id`,`a`.`data_id` AS `id`,`a`.`data_time` AS `time` from (( ");
sb.append("SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv v WHERE 1=1 ");
sb.append(" SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv v WHERE 1=1 ");
if(StringUtils.isNotEmpty(departIds)){
sb.append(" and depart_id in ("+inSqlPart+") ");
}
......@@ -141,16 +141,16 @@ public class ReportViewUtil {
itemIds = itemIds.substring(1);
}
sb.append("`a`.`depart_id` AS `depart_id`,`a`.`data_id` AS `id`,`a`.`data_time` AS `time` from (( ");
sb.append("SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv WHERE 1=1 ");
sb.append(" SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv WHERE 1=1 ");
if(StringUtils.isNotEmpty(departIds)){
sb.append("and depart_id in ("+inSqlPart+")");
sb.append(" and depart_id in ("+inSqlPart+")");
}
if(!StringUtils.isEmpty(dataTime)) {
sb.append("and data_time like'"+dataTime+"%'");
}
sb.append("and reit_id in ("+itemIds+")");
sb.append(" and reit_id in ("+itemIds+")");
sb.append(") `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`data_id`,`a`.`depart_id`,`a`.`data_time` order by `a`.`data_time`)");
sb.append(" ) `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`data_id`,`a`.`depart_id`,`a`.`data_time` order by `a`.`data_time`)");
return sb.toString();
}
......@@ -204,17 +204,17 @@ public class ReportViewUtil {
sb.append("SELECT data_id,reit_id,item_value,data_time,depart_id FROM f_report_itemv WHERE 1=1 ");
if(!StringUtils.isEmpty(departIds)) {
sb.append(" and depart_id in ("+inSqlPart+")");
sb.append(" and depart_id in ("+inSqlPart+") ");
}
if(!StringUtils.isEmpty(startTime)) {
sb.append("and data_time >='"+startTime+"'");
sb.append(" and data_time >='"+startTime+"' ");
}
if(!StringUtils.isEmpty(endTime)) {
sb.append("and data_time <='"+endTime+"'");
sb.append(" and data_time <='"+endTime+"' ");
}
sb.append("and reit_id in ("+itemIds+")");
sb.append(" and reit_id in ("+itemIds+") ");
sb.append(") `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`depart_id`)");
sb.append(") `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`depart_id`) ");
return sb.toString();
}
......
......@@ -64,15 +64,16 @@ public class DateVO {
this.nowYear = Integer.parseInt(DateUtils.dateformat(currentDate,"yyyy"));
//同比时间
this.lastYear = nowYear -1 ;//去年
this.lastYearMonth = DateUtils.getHbMonth(currentDate);
System.out.println(" lastYearMonth "+lastYearMonth);
this.lastYearMonth = DateUtils.getTbMonth(this.nowMonth);
//System.out.println(" lastYearMonth "+lastYearMonth);
this.lastYearMonthStartTime = lastYearMonth+"-01";
this.lastYearMonthStartTime = lastYearMonth+"-31";
this.lastYearMonthEndTime = lastYearMonth+"-31";
this.lastYearStartDate = this.lastYear+"-01-01";
this.lastYearEndDate = this.lastYear+"-12-31";
//环比时间
this.lastMonth = DateUtils.getHbMonth(currentDate);//
this.lastMonth = DateUtils.getHbMonth(this.nowMonth);//
System.out.println(" lastMonth "+lastMonth);
this.lastMonthStartTime = lastMonth+"-01";
this.lastMonthEndTime = lastMonth+"-31";
......
......@@ -51,6 +51,7 @@ public class DigitalUtils {
if(StringUtils.isNotEmpty(val2)){
BigDecimal num2 = new BigDecimal(val2);
result = result.add( num2 );
result = result.multiply( num2).setScale(2, BigDecimal.ROUND_HALF_UP);
}
return result.toString();
}
......
......@@ -19,23 +19,51 @@ import java.util.regex.Pattern;
*/
public class JSUtils {
// 表达式字符合法性校验正则模式,静态常量化可以降低每次使用都要编译地消耗
private static final Pattern EXPRESSION_PATTERN = Pattern.compile("[0-9\\.+-/*()= ]+");
// 运算符优先级map
private static final Map<String, Integer> OPT_PRIORITY_MAP = new HashMap<String, Integer>() {
private static final long serialVersionUID = 6968472606692771458L;
{
put("(", 0);
put("+", 2);
put("-", 2);
put("*", 3);
put("/", 3);
put(")", 7);
put("=", 20);
public static String add(Object obj1 , Object obj2){
String expression = obj1+ "+" + obj2;
return executeExpression(expression,"0.00");
}
public static String subtract(Object obj1 , Object obj2){
String expression = obj1+ "-" + obj2;
return executeExpression(expression,"0.00");
}
public static String multiply(Object obj1 , Object obj2){
String expression = obj1+ "*" + obj2;
return executeExpression(expression,"0.00");
}
public static String divide(Object obj1 , Object obj2){
String expression = obj1+ "/" + obj2;
return executeExpression(expression,"0.00");
}
};
/***
* 格式化结果,保留两位小数
* @param obj1
* @return
*/
public static String format(Object obj1 ){
return format(obj1,null);
}
/***
* 格式化结果,指定格式,默认保留两位小数
* @param obj1
* @param decimalFormat
* @return
*/
public static String format(Object obj1 , String decimalFormat){
String result = null;
try{
if(obj1 != null ){
if(decimalFormat == null ) decimalFormat = "0.00";
DecimalFormat df = new DecimalFormat(decimalFormat);
result = df.format(Double.parseDouble(obj1.toString()));
}
}catch(Exception e){
e.printStackTrace();
}
return result;
}
/**
* 输入加减乘除表达式字符串,返回计算结果
*
......@@ -54,6 +82,25 @@ public class JSUtils {
}
return result;
}
// 表达式字符合法性校验正则模式,静态常量化可以降低每次使用都要编译地消耗
private static final Pattern EXPRESSION_PATTERN = Pattern.compile("[0-9\\.+-/*()= ]+");
// 运算符优先级map
private static final Map<String, Integer> OPT_PRIORITY_MAP = new HashMap<String, Integer>() {
private static final long serialVersionUID = 6968472606692771458L;
{
put("(", 0);
put("+", 2);
put("-", 2);
put("*", 3);
put("/", 3);
put(")", 7);
put("=", 20);
}
};
public static double executeExpression(String expression) {
// 非空校验
if (null == expression || "".equals(expression.trim())) {
......
package com.skua.modules.algorithm.service.impl;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.SpringContextUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
/**
* @auther kangwei
* @create 2024-11-01-10:09
*/
@Service("reportItemvService")
public class ReportItemvService {
String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";// 水 COD TP TN NH3H
String view3a24 = "3a243d5715b9e1a3753c180872ca0df9";//能耗报表
String view4411 = "4411ed3d78634bcdcd700f6e33724025";//生产运营周报
private JdbcTemplate getJdbcTemplate(){
//主库数据源
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
return masterDB;
}
public String getSumCSL(String departId ,String startTime ,String endTime){
String dataViewName2119 = ReportViewUtil.buildViewLike(view2119,"CSL", departId, startTime,endTime);
String sql = "select sum(aaa.CSL) from " + dataViewName2119+ "aaa";
String csl = getJdbcTemplate().queryForObject(sql,String.class);
return csl;
}
/* public List<Map<String,Object>> getDeptCSL(String departId , String startTime , String endTime){
}*/
public String getSumDLHJ(String departId ,String startTime ,String endTime){
String dataViewName3a24 = ReportViewUtil.buildViewLike(view3a24,"DLHJ", departId, startTime,endTime);
String sql = "select sum(aaa.DLHJ) from " + dataViewName3a24+ "aaa";
String dlhj = getJdbcTemplate().queryForObject(sql,String.class);
return dlhj;
}
/* public List<Map<String,Object>> getDeptDLHJ(String departId , String startTime , String endTime){
}*/
}
......@@ -23,13 +23,12 @@ import javax.servlet.http.HttpServletRequest;
* @create 2024-10-14-16:46
*/
@Slf4j
@Api(tags="在线考试-试卷")
@Api(tags="测试报表")
@RestController("testReportController")
@RequestMapping("/web/edu/paper")
public class TestReportSqlController {
@AutoLog(value = "在线考试--构造填报报表视图")
@ApiOperation(value="在线考试-构造填报报表视图", notes="在线考试-构造填报报表视图")
@AutoLog(value = "测试报表")
@ApiOperation(value="测试报表", notes="测试报表")
@GetMapping(value = "/testReportSql")
public Result<String> testReportSql(
@RequestParam(name="reportId") String reportId,
......
package com.skua.modules.quartz.util;
import com.skua.core.util.ConvertUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
......@@ -16,6 +17,22 @@ import java.util.regex.Pattern;
public class BaseUtil {
private static DecimalFormat df = new DecimalFormat("#.00");
/**
* 格式化
* @param obj
* @param defval
* @return
*/
public static String getValue(Object obj ,Double defval ){
Double d = ConvertUtils.getDouble(obj,defval);
if(d.doubleValue() != 0 ){
return df.format( d );
}
return d.toString();
}
/***
* 计算时间的前几个月的月份
* @param month
......
......@@ -67,7 +67,7 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
dataList = masterDB.queryForList(dataViewName2119);
for(Map<String, Object> dataMap : dataList) {
factoryInfoVO = factoryInfoMap.get(dataMap.get("depart_id").toString());
if(factoryInfoVO != null ) factoryInfoVO.setCsl_lastDay(dataMap.get("CSL").toString() ) ;
if(factoryInfoVO != null ) factoryInfoVO.setCsl_lastDay( BaseUtil.getValue( dataMap.get("CSL"),0d) ) ;
// resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title")));
}
//本月处理水量(m³)
......@@ -75,7 +75,7 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
dataList = masterDB.queryForList(dataViewName2119);
for(Map<String, Object> dataMap : dataList) {
factoryInfoVO = factoryInfoMap.get(dataMap.get("depart_id").toString());
if(factoryInfoVO != null ) factoryInfoVO.setCsl_month(dataMap.get("CSL").toString() ) ;
if(factoryInfoVO != null ) factoryInfoVO.setCsl_month( BaseUtil.getValue( dataMap.get("CSL"),0d) ) ;
// resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title")));
}
//本年处理水量(万m³)
......@@ -84,13 +84,11 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
for(Map<String, Object> dataMap : dataList) {
factoryInfoVO = factoryInfoMap.get(dataMap.get("depart_id").toString());
if(factoryInfoVO != null ){
factoryInfoVO.setCsl_year(dataMap.get("CSL").toString() ) ;
factoryInfoVO.setCsl_avg_day(DigitalUtils.division( dataMap.get("CSL").toString() ,differenceTime+"" ) );
factoryInfoVO.setCsl_year( BaseUtil.getValue( ConvertUtils.getDouble(dataMap.get("CSL"),0d) / 10000,0d) ) ;
factoryInfoVO.setCsl_avg_day( BaseUtil.getValue( ConvertUtils.getDouble(dataMap.get("CSL"),0d) / differenceTime,0d) );
}
// resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title")));
}
factoryInfoVOList = new ArrayList(factoryInfoMap.values());
// 添加:中冶数据
......@@ -239,9 +237,12 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
StringBuffer sql = new StringBuffer("select round(aaa.CSL,2) 'csl',round(( aaa.JSCOD - aaa.CSCOD ),2) 'codxjl', round(( aaa.JSAD -aaa.CSAD ),2) 'adxjl' from ");
sql.append(" "+dataViewName2119 +" aaa ");
System.out.println(sql.toString());
waterQualityVO = getJdbcTemplate().queryForObject(sql.toString(),new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class));
List<WaterQualityVO> waterQualityVOList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class));
if(waterQualityVOList != null && !waterQualityVOList.isEmpty()){
waterQualityVO = waterQualityVOList.get(0);
}else{
waterQualityVO = new WaterQualityVO();
}
// if(waterQualityVO == null )waterQualityVO = new WaterQualityVO();
//负荷率 CSL/设计规模 ()
String factoryProScaleSql = "select round( ("+waterQualityVO.getCsl() +"/(pro_scale * 100) ),2) fhl from sys_factory_info where depart_id = '"+departId+"'";
......@@ -257,10 +258,15 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
sql2.append( " "+dataViewName3a24+" aaa ");
System.out.println("sql2 = "+sql2.toString());
WaterQualityVO waterQualityVOTemp = getJdbcTemplate().queryForObject( sql2.toString(), new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class));
waterQualityVOList = getJdbcTemplate().query( sql2.toString(), new BeanPropertyRowMapper<WaterQualityVO>(WaterQualityVO.class));
if(waterQualityVOList != null && !waterQualityVOList.isEmpty() ){
WaterQualityVO waterQualityVOTemp = waterQualityVOList.get(0);
waterQualityVO.setTnl(waterQualityVOTemp.getTnl() );
waterQualityVO.setDsdh(waterQualityVOTemp.getDsdh());
waterQualityVO.setDsyh(waterQualityVOTemp.getDsyh());
}
return waterQualityVO;
}
......
......@@ -100,7 +100,7 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
" v6.dhgyqntqyy, " +
" round(v4.yjhl/sum(v1.CSL),2) as yyh, " +
" v6.yyf," +
" round(ifnull(v5.yjhl/tb.clsl_tb,0),2) qntqyh, " +
" round(ifnull(v5.yjhl/tb.clsl_tb/10000,0),2) qntqyh, " +
" round(100*(v4.yjhl-ifnull(v5.yjhl,0))/ifnull(v5.yjhl,v4.yjhl),2) as yhdbbhl, " +
" v6.yhgyqntqyy, " +
" rtc.target_power as bndhmb, " +
......@@ -128,9 +128,9 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
" ) v4 on v4.month_tb = right(left(v1.time,7),2) " +
" left join ( " +
" select right(left(time,7),2) month_tb, " +
" SUM(DLHJ) dlhj,(SUM( PAMRJ ) + SUM( SCLPAMZ ) + SUM( SCLPAMF ) + SUM( NACLO ) + SUM( PACGT ) + SUM( PACYT ) + SUM( PFS ) + SUM( FHTY ) + " +
" SUM( RYXNJ ) + SUM( YWL ) + SUM( GXCLJ ) + SUM( CH3COONA ) + SUM( HXT ) + SUM( FECL3 ) + SUM( SH ) + SUM( CH3COOH ) + SUM( FESO4G ) + " +
" SUM( FESO4Y ) + SUM( H2O2 )) yjhl " +
" SUM(DLHJ) dlhj,(SUM( IFNULL(PAMRJ,0) ) + SUM( IFNULL(SCLPAMZ,0) ) + SUM( IFNULL(SCLPAMF,0) ) + SUM( IFNULL(NACLO,0) ) + SUM( IFNULL(PACGT,0) ) + SUM( IFNULL(PACYT,0) ) + SUM( IFNULL(PFS,0) ) + SUM( IFNULL(FHTY,0) ) + " +
" SUM( IFNULL(RYXNJ,0) ) + SUM( IFNULL(YWL,0) ) + SUM( IFNULL(GXCLJ,0) ) + SUM( IFNULL(CH3COONA,0) ) + SUM( IFNULL(HXT,0) ) + SUM( IFNULL(FECL3,0) ) + SUM( IFNULL(SH,0) ) + SUM( IFNULL(CH3COOH,0) ) + SUM( IFNULL(FESO4G,0) ) + " +
" SUM( IFNULL(FESO4Y,0) ) + SUM( IFNULL(H2O2,0) )) yjhl " +
" from "+dataViewName3a24tb+" v3 " +
" where v3.depart_id = '"+departId+"' and v3.time like CONCAT('"+tbYear+"','%') GROUP BY left(time,7) " +
" ) v5 on v5.month_tb = right(left(v1.time,7),2) " +
......
......@@ -33,7 +33,7 @@ public class OperationReportServiceImpl implements IOperationReportService {
String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";// 水 COD TP TN NH3H
String view3a24 = "3a243d5715b9e1a3753c180872ca0df9";//能耗报表
String view4411 = "4411ed3d78634bcdcd700f6e33724025";
String view4411 = "4411ed3d78634bcdcd700f6e33724025";//生产运营周报
private JdbcTemplate getJdbcTemplate(){
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
......
......@@ -34,4 +34,10 @@ public class FRportlCommandCenterVO implements Serializable {
this.valueTb = valueTb;
this.valueHb = valueHb;
}
public FRportlCommandCenterVO(String title ,String value, String valueTb, String valueHb) {
this.title = title;
this.value = value;
this.valueTb = valueTb;
this.valueHb = valueHb;
}
}
......
package com.skua.modules.report.vo;
import com.skua.tool.util.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
/**
* 季度时间
* @auther kangwei
......@@ -24,7 +28,7 @@ public class SeasonTimeVO {
@ApiModelProperty(value = "季度结束时间")
private String endTime;
@ApiModelProperty(value = "季度天数")
private String disparityDay;
private Long disparityDay;
public SeasonTimeVO(){
......@@ -38,37 +42,32 @@ public class SeasonTimeVO {
public void getTimeBySeason(int year,int season){
int startMonth = 0;
int endMonth = 0;
int startDay = 1;
int endDay = 31;
switch (season) {
case 1:
startMonth = 1;
endMonth = 3;
break;
case 2:
startMonth = 4;
endMonth = 6;
break;
case 3:
startMonth = 7;
endMonth = 9;
break;
case 4:
startMonth = 10;
endMonth = 12;
break;
default:
System.out.println("季度输入无效,请输入1-4之间的数字。");
case 1: startMonth = 1;endMonth = 3; endDay=31; break;
case 2: startMonth = 4;endMonth = 6; endDay=30; break;
case 3:startMonth = 7;endMonth = 9;endDay=30; break;
case 4: startMonth = 10; endMonth = 12; endDay=31; break;
default:System.out.println("季度输入无效,请输入1-4之间的数字。");return ;
}
Calendar startDate = Calendar.getInstance();
/* startDate.set(Calendar.YEAR,year);
startDate.set(Calendar.MONTH, startMonth-1);
startDate.set(Calendar.DATE, startDay);*/
startDate.set(year,startMonth-1,startDay);
LocalDate startDate = LocalDate.of(year, startMonth, 1);
LocalDate endDate = LocalDate.of(year, endMonth, startDate.lengthOfMonth());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
Calendar endDate = Calendar.getInstance();
/* endDate.set(Calendar.YEAR,year);
endDate.set(Calendar.MONTH, endMonth-1);
endDate.set(Calendar.DATE, endDay);*/
endDate.set(year,endMonth-1,endDay);
this.startTime = startDate.format(formatter);;
this.endTime = endDate.format(formatter); ;
long daysBetween = daysBetween(startDate, endDate);
this.disparityDay = daysBetween+"";
}
public static long daysBetween(LocalDate startDate, LocalDate endDate) {
return ChronoUnit.DAYS.between(startDate, endDate);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
this.startTime = formatter.format(startDate.getTime());
this.endTime = formatter.format(endDate.getTime());
//long daysBetween = daysBetween(this.startTime, this.endTime );
this.disparityDay = DateUtils.differenceDay( this.startTime, this.endTime );
}
}
......
......@@ -34,11 +34,8 @@ import java.util.List;
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class Swagger2Config implements WebMvcConfigurer {
/**
*
* 显示swagger-ui.html文档展示页,还必须注入swagger资源:
*
* @param registry
*/
@Override
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!