b609ff3e 张雷

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

2 个父辈 e8f72998 73d2b11a
package com.skua.modules.dataAnalysis.controller;
import com.skua.common.constant.ReportConstant;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.api.vo.Result;
import com.skua.core.context.SpringContextUtils;
import com.skua.modules.dataAnalysis.vo.WorkProgressVO;
import com.skua.tool.util.DateUtils;
import com.skua.tool.util.JSUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
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.List;
/**
* @auther kangwei
* @create 2025-01-23-17:01
*/
@Slf4j
@Api(tags="运营工作进度统计")
@RestController
@RequestMapping("/v1/dataAnalysis/work")
public class WorkAnalysisController {
@ApiOperation(value = "工作进度统计", notes = "工作进度统计 timeType = 1 表示月份,timeType=2 表示年")
@GetMapping("/analysisByWorkProgress")
public Result<List<WorkProgressVO>> analysisByWorkProgress(@RequestParam(defaultValue = "1") Integer timeType, String startTime, String endTime) {
Result<List<WorkProgressVO>> result = new Result<>();
String month = DateUtils.formatDate(startTime,"YYYY-MM");
if(2 == timeType){//表示年
month = DateUtils.formatDate(startTime,"YYYY");
}
String departIds = null;//DAY(LAST_DAY('"+startTime+"'))
String sql = "select d.id 'depart_id' , d.depart_name , (DATEDIFF('"+endTime+"', '"+startTime+"') +1) 'day_num' , (month('"+endTime+"') - month('"+startTime+"') + 1) month_num,ifnull(aaa.count,0) 'nh_num' ,ifnull(bbb.count,0) 'szsl_num' ,ifnull(ccc.count,0) 'hy_num' ,ifnull(ddd.count,0) 'yy_month_num',ifnull(fff.count,0) 'df_month_num' ,ifnull(ggg.count,0) 'year_target_num' from sys_depart d ";
sql += getSql(departIds, startTime, endTime, month);
sql += " where d.depart_type =1 ";
if(StringUtils.isNotEmpty(departIds)){
sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")";
}
sql += " order by (ifnull(aaa.count,0) + ifnull(bbb.count,0)+ifnull(ccc.count,0) +ifnull(ddd.count,0)+ifnull(fff.count,0) +ifnull(ggg.count,0) ) asc ";
System.out.println("sql = "+sql);
JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master");
List<WorkProgressVO> dataList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<WorkProgressVO>(WorkProgressVO.class));
result.setResult(dataList);
result.setSuccess(true);
return result;
}
@ApiOperation(value = "工作进度统计-数量", notes = "工作进度统计 timeType = 1 表示月份,timeType=2 表示年")
@GetMapping("/analysisTotalByWorkProgress")
public Result<WorkProgressVO> analysisTotalByWorkProgress(@RequestParam(defaultValue = "1") Integer timeType, String startTime, String endTime) {
Result<WorkProgressVO> result = new Result<>();
WorkProgressVO workProgressVO = null;
String month = DateUtils.formatDate(startTime,"YYYY-MM");
if(2 == timeType){//表示年
month = DateUtils.formatDate(startTime,"YYYY");
}
String departIds = null;//DAY(LAST_DAY('"+startTime+"'))
String sql = "select count(d.id) 'departNum', (DATEDIFF('"+endTime+"', '"+startTime+"') +1) 'day_num' , (month('"+endTime+"') - month('"+startTime+"') + 1) month_num,";
sql += " ifnull(sum(aaa.count),0) 'nh_num' ,ifnull(sum(bbb.count),0) 'szsl_num' ,ifnull(sum(ccc.count),0) 'hy_num' ,ifnull(sum(ddd.count),0) 'yy_month_num',ifnull(sum(fff.count),0) 'df_month_num' ,ifnull(sum(ggg.count),0) 'year_target_num' ";
sql += " from sys_depart d ";
sql += getSql(departIds, startTime, endTime, month);
sql += " where d.depart_type =1 ";
if(StringUtils.isNotEmpty(departIds)){
sql += " d.id in ("+ JSUtils.quoteEach(departIds,",") +")";
}
System.out.println("sql = "+sql);
JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master");
List<WorkProgressVO> dataList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<WorkProgressVO>(WorkProgressVO.class));
if(dataList != null && !dataList.isEmpty()){
workProgressVO = dataList.get(0);
}
result.setResult(workProgressVO);
result.setSuccess(true);
return result;
}
private String getSql( String departIds,String startTime, String endTime,String month){
String sql = "";
//能耗日报
String view3a24Sql = ReportViewUtil.buildView(ReportConstant.view3a24,"DLHJ",departIds,startTime,endTime);
sql += " left join (select aa.depart_id ,count(1) 'count' from "+view3a24Sql+ " aa group by aa.depart_id )aaa on aaa.depart_id = d.id ";
//水质水量日报表
String view2119Sql = ReportViewUtil.buildView(ReportConstant.view2119,"CSL",departIds,startTime,endTime);
sql += " left join ( select bb.depart_id ,count(1) 'count' from "+view2119Sql+ " bb group by bb.depart_id )bbb on bbb.depart_id = d.id ";
//化验日报
String viewbffaSql = ReportViewUtil.buildView(ReportConstant.view9bff,"JSCODHY",departIds,startTime,endTime);
sql += " left join (select cc.depart_id ,count(1) 'count' from "+viewbffaSql+ " cc group by cc.depart_id )ccc on ccc.depart_id = d.id ";
//电费月报
sql += " left join( select ec.depart_id , ec.cost , count(1) 'count' from report_electric_cost ec where ec.month like '"+month+"%' group by ec.depart_id) ddd on ddd.depart_id = d.id ";
//生产运营月报表
String view4411Sql = ReportViewUtil.buildView(ReportConstant.view4411,"yyf,ysfsl",departIds,startTime,endTime);
sql += " left join (select eee.depart_id ,count(1) 'count' from (select left(ee.time,7) time , ee.depart_id from "+view4411Sql+ " ee where 1=1 group by ee.depart_id ,left(ee.time,7) HAVING ifnull(sum(ee.yyf),0) >0 and ifnull(sum(ee.ysfsl),0) > 0 )eee group by eee.depart_id )fff on fff.depart_id = d.id ";
//目标年报
sql += " left join(select depart_id ,count(depart_id) 'count' from report_target_config where target_year = year('"+startTime+"') group by depart_id) ggg on ggg.depart_id = d.id ";
return sql;
}
}
package com.skua.modules.dataAnalysis.vo;
/**
* @auther kangwei
* @create 2025-01-23-9:24
*/
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 工作进度
*/
@Data
@ApiModel(value = "WorkProgressVO工作进度", description = "工作进度")
public class WorkProgressVO {
@ApiModelProperty(value = "所属厂站")
private String departId;
@ApiModelProperty(value = "所属厂站")
private String departName;
@ApiModelProperty(value = "所属厂站-数量")
private String departNum;
@ApiModelProperty(value = "日数量(天)")
private Integer dayNum = 30;
@ApiModelProperty(value = "月数量(月)")
private Integer monthNum =1;
@ApiModelProperty(value = "年数量(年)")
private Integer yearNum = 1;
@ApiModelProperty(value = "能耗-填报天数")
private Integer nhNum;
@ApiModelProperty(value = "水质水量-填报天数")
private Integer szslNum;
@ApiModelProperty(value = "化验报表-填报天数")
private Integer hyNum;
@ApiModelProperty(value = "运营月报-填报月数")
private Integer yyMonthNum;
@ApiModelProperty(value = "电费月报-填报月数")
private Integer dfMonthNum;
@ApiModelProperty(value = "年度目标表-填报年数")
private Integer yearTargetNum;
@ApiModelProperty(value = "是否完成: 0 未完成 1 已完成")
private Integer completeFlag ;
public Integer getCompleteFlag() {
completeFlag = 0;
if((nhNum +szslNum +hyNum) >=(dayNum*3) && (yyMonthNum +dfMonthNum) >=(monthNum*2) && yearTargetNum >=yearNum){
completeFlag = 1;
}
return completeFlag;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!