From dc1b0e330dc46a44d7db0957896e4490fde7ae37 Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Mon, 17 Jun 2024 17:04:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E6=BA=90=E5=8D=95=E8=80=97=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/domain/RecordDnbInstant.java | 19 ++ .../record/mapper/RecordDnbInstantMapper.java | 2 + .../controller/dataAnalysisController.java | 30 ++- .../report/domain/ReportOrderEnergyDTO.java | 173 ++++++++++++++++++ .../report/mapper/ReportPointDnbMapper.java | 3 + .../report/service/IDataAnalysisService.java | 3 + .../service/impl/DataAnalysisServiceImpl.java | 40 +++- .../mapper/record/RecordDnbInstantMapper.xml | 28 +++ .../mapper/report/ReportPointDnbMapper.xml | 48 +++++ 9 files changed, 344 insertions(+), 2 deletions(-) create mode 100644 op-modules/op-energy/src/main/java/com/op/energy/report/domain/ReportOrderEnergyDTO.java diff --git a/op-modules/op-energy/src/main/java/com/op/energy/record/domain/RecordDnbInstant.java b/op-modules/op-energy/src/main/java/com/op/energy/record/domain/RecordDnbInstant.java index 629eaa78..6fad8b34 100644 --- a/op-modules/op-energy/src/main/java/com/op/energy/record/domain/RecordDnbInstant.java +++ b/op-modules/op-energy/src/main/java/com/op/energy/record/domain/RecordDnbInstant.java @@ -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; } diff --git a/op-modules/op-energy/src/main/java/com/op/energy/record/mapper/RecordDnbInstantMapper.java b/op-modules/op-energy/src/main/java/com/op/energy/record/mapper/RecordDnbInstantMapper.java index bfa610d6..0c4bdc58 100644 --- a/op-modules/op-energy/src/main/java/com/op/energy/record/mapper/RecordDnbInstantMapper.java +++ b/op-modules/op-energy/src/main/java/com/op/energy/record/mapper/RecordDnbInstantMapper.java @@ -83,4 +83,6 @@ public interface RecordDnbInstantMapper { * @return */ List tablewareDetailsInfo(Map paramMap); + + List selectRecordDnbInstantByTime(RecordDnbInstant recordDnbInstant); } diff --git a/op-modules/op-energy/src/main/java/com/op/energy/report/controller/dataAnalysisController.java b/op-modules/op-energy/src/main/java/com/op/energy/report/controller/dataAnalysisController.java index ae4df9de..412cf097 100644 --- a/op-modules/op-energy/src/main/java/com/op/energy/report/controller/dataAnalysisController.java +++ b/op-modules/op-energy/src/main/java/com/op/energy/report/controller/dataAnalysisController.java @@ -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 util = new ExportExcelUtil(ExportReport.class); util.exportExcel(response, list, "层级导出报表", originalList); } + /** + * 工单耗能分析 + */ + @RequiresPermissions("energy:orderenergy:list") + @GetMapping("/OrderEnergyReport") + public TableDataInfo OrderEnergyReport(ReportOrderEnergyDTO reportOrderEnergyDTO) { + startPage(); + List 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 orderEnergyList=dataAnalysisService.OrderEnergyList(reportOrderEnergyDTO); + ExcelUtil util = new ExcelUtil(ReportOrderEnergyDTO.class); + util.exportExcel(response, orderEnergyList, "单耗统计数据"); + } } diff --git a/op-modules/op-energy/src/main/java/com/op/energy/report/domain/ReportOrderEnergyDTO.java b/op-modules/op-energy/src/main/java/com/op/energy/report/domain/ReportOrderEnergyDTO.java new file mode 100644 index 00000000..f808bfec --- /dev/null +++ b/op-modules/op-energy/src/main/java/com/op/energy/report/domain/ReportOrderEnergyDTO.java @@ -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; + } +} diff --git a/op-modules/op-energy/src/main/java/com/op/energy/report/mapper/ReportPointDnbMapper.java b/op-modules/op-energy/src/main/java/com/op/energy/report/mapper/ReportPointDnbMapper.java index 40e338f0..e6863d75 100644 --- a/op-modules/op-energy/src/main/java/com/op/energy/report/mapper/ReportPointDnbMapper.java +++ b/op-modules/op-energy/src/main/java/com/op/energy/report/mapper/ReportPointDnbMapper.java @@ -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> energyStatisticsData(Map map); + + public List OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO); } diff --git a/op-modules/op-energy/src/main/java/com/op/energy/report/service/IDataAnalysisService.java b/op-modules/op-energy/src/main/java/com/op/energy/report/service/IDataAnalysisService.java index 742507ea..cde409d2 100644 --- a/op-modules/op-energy/src/main/java/com/op/energy/report/service/IDataAnalysisService.java +++ b/op-modules/op-energy/src/main/java/com/op/energy/report/service/IDataAnalysisService.java @@ -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 classificationExportReport(Map paramMap); + + public List OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO); } diff --git a/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java b/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java index c76e80be..4c4e19ed 100644 --- a/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java +++ b/op-modules/op-energy/src/main/java/com/op/energy/report/service/impl/DataAnalysisServiceImpl.java @@ -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 generateExportReport(List 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 OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO) { + List 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 lineLossMap = new HashMap<>(); + recordDnbInstant.setMonitorId(monitorid); + lineLossMap.put("beginCollectTime", StartWorkTime); + lineLossMap.put("endCollectTime", EndWorkTime); + recordDnbInstant.setParams(lineLossMap); + List 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; + } } diff --git a/op-modules/op-energy/src/main/resources/mapper/record/RecordDnbInstantMapper.xml b/op-modules/op-energy/src/main/resources/mapper/record/RecordDnbInstantMapper.xml index 4b5d7f86..88af389a 100644 --- a/op-modules/op-energy/src/main/resources/mapper/record/RecordDnbInstantMapper.xml +++ b/op-modules/op-energy/src/main/resources/mapper/record/RecordDnbInstantMapper.xml @@ -19,6 +19,8 @@ + + @@ -35,6 +37,32 @@ left join base_monitor_info m on m.monitor_id = record_dnb_instant.monitor_id + + insert into report_point_dnb