能源单耗统计

master
Yangwl 7 months ago
parent 6e30ae994e
commit dc1b0e330d

@ -151,6 +151,25 @@ public class RecordDnbInstant extends BaseEntity {
private String startTime;
private String endTime;
private BigDecimal kw;
private BigDecimal ct;
public BigDecimal getCt() {
return ct;
}
public void setCt(BigDecimal ct) {
this.ct = ct;
}
public BigDecimal getKw() {
return kw;
}
public void setKw(BigDecimal kw) {
this.kw = kw;
}
public String getStartTime() {
return startTime;
}

@ -83,4 +83,6 @@ public interface RecordDnbInstantMapper {
* @return
*/
List<RecordDnbInstant> tablewareDetailsInfo(Map paramMap);
List<RecordDnbInstant> selectRecordDnbInstantByTime(RecordDnbInstant recordDnbInstant);
}

@ -1,12 +1,18 @@
package com.op.energy.report.controller;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.web.page.TableDataInfo;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.energy.base.domain.BaseCollectCommunicate;
import com.op.energy.base.domain.BaseLineLoss;
import com.op.energy.base.utils.ExportExcelUtil;
import com.op.energy.base.utils.SpringUtils;
import com.op.energy.report.domain.ExportReport;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.service.IDataAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -27,7 +33,7 @@ import static com.op.energy.base.utils.ExportExcelUtil.findConsecutiveIndices;
* @author YinQ
* @date 2023-04-05
*/
@Controller
@RestController
@RequestMapping("/report/analysis")
public class dataAnalysisController extends BaseController {
private String prefix = "report/dataAnalysis";
@ -241,5 +247,27 @@ public class dataAnalysisController extends BaseController {
ExportExcelUtil<ExportReport> util = new ExportExcelUtil<ExportReport>(ExportReport.class);
util.exportExcel(response, list, "层级导出报表", originalList);
}
/**
*
*/
@RequiresPermissions("energy:orderenergy:list")
@GetMapping("/OrderEnergyReport")
public TableDataInfo OrderEnergyReport(ReportOrderEnergyDTO reportOrderEnergyDTO) {
startPage();
List<ReportOrderEnergyDTO> orderEnergyList=dataAnalysisService.OrderEnergyList(reportOrderEnergyDTO);
return getDataTable(orderEnergyList);
}
/**
*
*/
@RequiresPermissions("energy:orderenergy:export")
@Log(title = "单耗统计", businessType = BusinessType.EXPORT)
@PostMapping("/orderenergy/export")
public void export(HttpServletResponse response, ReportOrderEnergyDTO reportOrderEnergyDTO) {
List<ReportOrderEnergyDTO> orderEnergyList=dataAnalysisService.OrderEnergyList(reportOrderEnergyDTO);
ExcelUtil<ReportOrderEnergyDTO> util = new ExcelUtil<ReportOrderEnergyDTO>(ReportOrderEnergyDTO.class);
util.exportExcel(response, orderEnergyList, "单耗统计数据");
}
}

@ -0,0 +1,173 @@
package com.op.energy.report.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
public class ReportOrderEnergyDTO extends BaseEntity {
private String workorderId;
@Excel(name = "订单号")
private String workorderCode;
@Excel(name = "产线编码")
private String workorderName;
@Excel(name = "产线名称")
private String equipmentName;
@Excel(name = "产品编码")
private String productCode;
@Excel(name = "产品名称")
private String productName;
@Excel(name = "生产数量(箱)")
private int totalQuantityFeedback;
@Excel(name = "电表编号")
private String electricityNo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startWorkTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endWorkTime;
private String workorderCodeSap;
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生产日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date productDate;
@Excel(name = "开始值")
private BigDecimal startKW;
@Excel(name = "结束值")
private BigDecimal endKW;
@Excel(name = "倍率")
private BigDecimal multiplier;
public BigDecimal getMultiplier() {
return multiplier;
}
public void setMultiplier(BigDecimal multiplier) {
this.multiplier = multiplier;
}
public BigDecimal getStartKW() {
return startKW;
}
public void setStartKW(BigDecimal startKW) {
this.startKW = startKW;
}
public BigDecimal getEndKW() {
return endKW;
}
public void setEndKW(BigDecimal endKW) {
this.endKW = endKW;
}
@Excel(name = "能耗KW·h")
private BigDecimal kw;
public BigDecimal getKw() {
return kw;
}
public void setKw(BigDecimal kw) {
this.kw = kw;
}
public String getEquipmentName() {
return equipmentName;
}
public void setEquipmentName(String equipmentName) {
this.equipmentName = equipmentName;
}
public String getWorkorderId() {
return workorderId;
}
public void setWorkorderId(String workorderId) {
this.workorderId = workorderId;
}
public String getWorkorderName() {
return workorderName;
}
public void setWorkorderName(String workorderName) {
this.workorderName = workorderName;
}
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public int getTotalQuantityFeedback() {
return totalQuantityFeedback;
}
public void setTotalQuantityFeedback(int totalQuantityFeedback) {
this.totalQuantityFeedback = totalQuantityFeedback;
}
public String getElectricityNo() {
return electricityNo;
}
public void setElectricityNo(String electricityNo) {
this.electricityNo = electricityNo;
}
public Date getStartWorkTime() {
return startWorkTime;
}
public void setStartWorkTime(Date startWorkTime) {
this.startWorkTime = startWorkTime;
}
public Date getEndWorkTime() {
return endWorkTime;
}
public void setEndWorkTime(Date endWorkTime) {
this.endWorkTime = endWorkTime;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getWorkorderCodeSap() {
return workorderCodeSap;
}
public void setWorkorderCodeSap(String workorderCodeSap) {
this.workorderCodeSap = workorderCodeSap;
}
public Date getProductDate() {
return productDate;
}
public void setProductDate(Date productDate) {
this.productDate = productDate;
}
}

@ -1,6 +1,7 @@
package com.op.energy.report.mapper;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.domain.ReportPointDnb;
import com.op.energy.report.domain.ReportPointDnbDTO;
@ -77,4 +78,6 @@ public interface ReportPointDnbMapper {
* @return
*/
List<Map<String, String>> energyStatisticsData(Map map);
public List<ReportOrderEnergyDTO> OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO);
}

@ -2,6 +2,7 @@ package com.op.energy.report.service;
import com.op.energy.base.domain.BaseLineLoss;
import com.op.energy.report.domain.ExportReport;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import java.util.List;
import java.util.Map;
@ -105,4 +106,6 @@ public interface IDataAnalysisService {
* @return
*/
List<ExportReport> classificationExportReport(Map paramMap);
public List<ReportOrderEnergyDTO> OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO);
}

@ -13,7 +13,10 @@ import com.op.energy.base.mapper.BaseTypeRelationMapper;
import com.op.energy.base.service.IBaseMonitorInfoService;
import com.op.energy.base.utils.DateUtils;
import com.op.energy.base.utils.sortReportUitls;
import com.op.energy.record.domain.RecordDnbInstant;
import com.op.energy.record.mapper.RecordDnbInstantMapper;
import com.op.energy.report.domain.ExportReport;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.domain.ReportPointDnb;
import com.op.energy.report.domain.ReportPointWater;
import com.op.energy.report.mapper.ReportPointDnbMapper;
@ -62,6 +65,9 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
@Autowired
private BaseLineMonitorMapper baseLineMonitorMapper;
@Autowired
private RecordDnbInstantMapper recordDnbInstantMapper;
/**
*
@ -962,6 +968,7 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
return exportReportList;
}
private List<ExportReport> generateExportReport(List<ExportReport> exportReportList, int grade, String timeRange, String monitorId, String monitorName, BigDecimal expend) {
switch (grade) {
case 1:
@ -1005,5 +1012,36 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
}
return exportReportList;
}
@Override
@DS("#header.poolName")
public List<ReportOrderEnergyDTO> OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO) {
List<ReportOrderEnergyDTO> reportOrderEnergyDTOList = reportPointDnbMapper.OrderEnergyList(reportOrderEnergyDTO);
if (reportOrderEnergyDTOList != null && reportOrderEnergyDTOList.size() > 0) {
for (int i = 0; i < reportOrderEnergyDTOList.size(); i++) {
if (reportOrderEnergyDTOList.get(i).getElectricityNo() != null && reportOrderEnergyDTOList.get(i).getStartWorkTime() != null && reportOrderEnergyDTOList.get(i).getEndWorkTime() != null) {
//获取这个工单所在产线的电表编号
String monitorid = reportOrderEnergyDTOList.get(i).getElectricityNo();
//获取这个工单的开始日期和结束日期
String StartWorkTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", reportOrderEnergyDTOList.get(i).getStartWorkTime());
String EndWorkTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", reportOrderEnergyDTOList.get(i).getEndWorkTime());
//查询这个工单在开始和最终报工之间的表底值
RecordDnbInstant recordDnbInstant = new RecordDnbInstant();
Map<String, Object> lineLossMap = new HashMap<>();
recordDnbInstant.setMonitorId(monitorid);
lineLossMap.put("beginCollectTime", StartWorkTime);
lineLossMap.put("endCollectTime", EndWorkTime);
recordDnbInstant.setParams(lineLossMap);
List<RecordDnbInstant> recordDnbInstantList = recordDnbInstantMapper.selectRecordDnbInstantByTime(recordDnbInstant);
if (recordDnbInstantList.size() > 0 && recordDnbInstantList.size() == 2) {
BigDecimal kw = recordDnbInstantList.get(0).getKw().subtract(recordDnbInstantList.get(1).getKw()).abs();
reportOrderEnergyDTOList.get(i).setStartKW(recordDnbInstantList.get(0).getZxyg());
reportOrderEnergyDTOList.get(i).setEndKW(recordDnbInstantList.get(1).getZxyg());
reportOrderEnergyDTOList.get(i).setMultiplier(recordDnbInstantList.get(0).getCt());
reportOrderEnergyDTOList.get(i).setKw(kw);
}
}
}
}
return reportOrderEnergyDTOList;
}
}

@ -19,6 +19,8 @@
<result property="recordTime" column="record_time"/>
<result property="glys" column="glys"/>
<result property="zxyg" column="zxyg"/>
<result property="kw" column="kw"/>
<result property="ct" column="ct"/>
<result property="activePower" column="active_power"/>
<result property="reactivePower" column="reactive_power"/>
<result property="consumption" column="consumption"/>
@ -35,6 +37,32 @@
left join base_monitor_info m on m.monitor_id = record_dnb_instant.monitor_id
</sql>
<select id="selectRecordDnbInstantByTime" parameterType="RecordDnbInstant" resultMap="RecordDnbInstantResult">
WITH OrderedRecords AS (
SELECT
rdi.*,
rdi.zxyg * bmi.ct AS kw,
bmi.ct,
ROW_NUMBER() OVER (ORDER BY rdi.collect_time ASC) AS RowAsc,
ROW_NUMBER() OVER (ORDER BY rdi.collect_time DESC) AS RowDesc
FROM
record_dnb_instant rdi
LEFT JOIN base_monitor_info bmi ON rdi.monitor_id=bmi.monitor_id
<where>
<if test="monitorId != null and monitorId != ''">and rdi.monitor_id = #{monitorId}</if>
<if test="params.beginCollectTime != null and params.beginCollectTime != '' and params.endCollectTime != null and params.endCollectTime != ''">
and rdi.collect_time between #{params.beginCollectTime} and #{params.endCollectTime}
</if>
</where>
)
SELECT
*
FROM
OrderedRecords odr
WHERE
RowAsc = 1 OR RowDesc = 1
ORDER BY collect_time ASC;
</select>
<select id="selectRecordDnbInstantList" parameterType="RecordDnbInstant" resultMap="RecordDnbInstantResult">
<include refid="selectRecordDnbInstantVo"/>
<where>

@ -48,6 +48,19 @@
<result property="userId" column="user_id"/>
</resultMap>
<resultMap type="ReportOrderEnergyDTO" id="ReportOrderEnergyDTOResult">
<result property="workorderCode" column="workorder_code"/>
<result property="workorderName" column="workorder_name"/>
<result property="equipmentName" column="equipment_name"/>
<result property="productCode" column="product_code"/>
<result property="productDate" column="product_date"/>
<result property="productName" column="product_name"/>
<result property="totalQuantityFeedback" column="total_quantity_feedback"/>
<result property="electricityNo" column="electricity_no"/>
<result property="startWorkTime" column="start_work_time"/>
<result property="endWorkTime" column="end_work_time"/>
</resultMap>
<sql id="selectReportPointDnbVo">
select report_point_dnb.objid, report_point_dnb.dept_id, dept_name, report_point_dnb.monitor_id,m.monitor_name,
p_monitor_id, m.monitor_addr address, expend, price,
@ -248,6 +261,41 @@
rpd.monitor_id, m.monitor_name, m.monitor_addr, m.monitor_hierarchy, m.grade
order by m.parentName, m.monitor_name
</select>
<select id="OrderEnergyList" resultMap="ReportOrderEnergyDTOResult">
SELECT
pow.workorder_code_sap as workorder_code,
pow.workorder_name,
be.equipment_name,
pow.product_code,
pow.product_date,
pow.product_name,
mrw_summary.total_quantity_feedback,
pow.start_work_time,
pow.end_work_time,
be.attr2 AS electricity_no
FROM
pro_order_workorder pow
LEFT JOIN base_equipment be ON pow.workorder_name = be.equipment_code
LEFT JOIN (
SELECT
workorder_code,
SUM(quantity_feedback) AS total_quantity_feedback
FROM
mes_report_work
GROUP BY
workorder_code
) mrw_summary ON pow.workorder_code = mrw_summary.workorder_code
<where>
<if test="electricityNo != null and electricityNo != ''">and be.attr2 = #{electricityNo}</if>
<if test="workorderName != null and workorderName != ''">and pow.workorder_name like concat('%', #{workorderName}, '%')</if>
<if test="equipmentName != null and equipmentName != ''">and be.equipment_name like concat('%', #{equipmentName}, '%')</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
and pow.product_date between #{params.beginTime} and #{params.endTime}
</if>
AND pow.status = 'w3'
AND pow.parent_order = '0';
</where>
</select>
<insert id="insertReportPointDnb" parameterType="ReportPointDnb">
insert into report_point_dnb

Loading…
Cancel
Save