From f785fa3cfd7da1e4491c5759e107222958a60025 Mon Sep 17 00:00:00 2001 From: zch Date: Tue, 26 May 2026 10:14:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E6=97=A5=E6=8A=A5=E6=8A=A5=E8=A1=A8=E6=A8=A1=E5=9D=97=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=EF=BC=88TASK-xxx=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现完整的生产日报业务功能,包含查询汇总、按日列表、工单明细、设备产出明细接口,配套Mapper、实体类和Controller层代码 --- .../ProductionDailyReportController.java | 64 ++++++++ .../aucma/report/domain/vo/ParamRawPoint.java | 54 +++++++ .../vo/ProductionDailyReportDeviceVo.java | 41 +++++ .../vo/ProductionDailyReportOrderVo.java | 86 +++++++++++ .../domain/vo/ProductionDailyReportQuery.java | 78 ++++++++++ .../domain/vo/ProductionDailyReportRowVo.java | 95 ++++++++++++ .../vo/ProductionDailyReportSummaryVo.java | 104 +++++++++++++ .../mapper/ProductionDailyReportMapper.java | 39 +++++ .../IProductionDailyReportService.java | 37 +++++ .../ProductionDailyReportServiceImpl.java | 86 +++++++++++ .../report/ProductionDailyReportMapper.xml | 146 ++++++++++++++++++ 11 files changed, 830 insertions(+) create mode 100644 aucma-report/src/main/java/com/aucma/report/controller/ProductionDailyReportController.java create mode 100644 aucma-report/src/main/java/com/aucma/report/domain/vo/ParamRawPoint.java create mode 100644 aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportDeviceVo.java create mode 100644 aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportOrderVo.java create mode 100644 aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportQuery.java create mode 100644 aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportRowVo.java create mode 100644 aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportSummaryVo.java create mode 100644 aucma-report/src/main/java/com/aucma/report/mapper/ProductionDailyReportMapper.java create mode 100644 aucma-report/src/main/java/com/aucma/report/service/IProductionDailyReportService.java create mode 100644 aucma-report/src/main/java/com/aucma/report/service/impl/ProductionDailyReportServiceImpl.java create mode 100644 aucma-report/src/main/resources/mapper/report/ProductionDailyReportMapper.xml diff --git a/aucma-report/src/main/java/com/aucma/report/controller/ProductionDailyReportController.java b/aucma-report/src/main/java/com/aucma/report/controller/ProductionDailyReportController.java new file mode 100644 index 0000000..6d6a346 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/controller/ProductionDailyReportController.java @@ -0,0 +1,64 @@ +package com.aucma.report.controller; + +import com.aucma.common.core.controller.BaseController; +import com.aucma.common.core.domain.AjaxResult; +import com.aucma.common.core.page.TableDataInfo; +import com.aucma.report.domain.vo.ProductionDailyReportDeviceVo; +import com.aucma.report.domain.vo.ProductionDailyReportOrderVo; +import com.aucma.report.domain.vo.ProductionDailyReportQuery; +import com.aucma.report.service.IProductionDailyReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 生产日报Controller。 + * + * @author Codex + */ +@RestController +@RequestMapping("/report/productionDailyReport") +public class ProductionDailyReportController extends BaseController { + + @Autowired + private IProductionDailyReportService productionDailyReportService; + + /** + * 查询生产日报汇总。 + */ + @GetMapping("/summary") + public AjaxResult summary(ProductionDailyReportQuery query) { + return success(productionDailyReportService.getSummary(query)); + } + + /** + * 查询按日汇总列表。 + */ + @GetMapping("/dailyList") + public AjaxResult dailyList(ProductionDailyReportQuery query) { + return success(productionDailyReportService.getDailyList(query)); + } + + /** + * 查询计划工单明细。 + */ + @GetMapping("/orderList") + public TableDataInfo orderList(ProductionDailyReportQuery query) { + startPage(); + List list = productionDailyReportService.getOrderList(query); + return getDataTable(list); + } + + /** + * 查询设备实际产出明细。 + */ + @GetMapping("/deviceList") + public TableDataInfo deviceList(ProductionDailyReportQuery query) { + startPage(); + List list = productionDailyReportService.getDeviceList(query); + return getDataTable(list); + } +} diff --git a/aucma-report/src/main/java/com/aucma/report/domain/vo/ParamRawPoint.java b/aucma-report/src/main/java/com/aucma/report/domain/vo/ParamRawPoint.java new file mode 100644 index 0000000..6a2fea3 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/domain/vo/ParamRawPoint.java @@ -0,0 +1,54 @@ +package com.aucma.report.domain.vo; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 状态/产量计数器原始采集点实体类。 + * 用于一次性批量从数据库加载参数点后在 Java 内存中做差值累加,消除 N+1 慢 SQL 问题。 + * + * @author Antigravity + */ +public class ParamRawPoint implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 设备编码 + */ + private String deviceCode; + + /** + * 采集时间 + */ + private Date collectTime; + + /** + * 去重并转换后的数值型参数值 + */ + private BigDecimal paramValue; + + public String getDeviceCode() { + return deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public Date getCollectTime() { + return collectTime; + } + + public void setCollectTime(Date collectTime) { + this.collectTime = collectTime; + } + + public BigDecimal getParamValue() { + return paramValue; + } + + public void setParamValue(BigDecimal paramValue) { + this.paramValue = paramValue; + } +} diff --git a/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportDeviceVo.java b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportDeviceVo.java new file mode 100644 index 0000000..be6c3b7 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportDeviceVo.java @@ -0,0 +1,41 @@ +package com.aucma.report.domain.vo; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 生产日报设备产出明细。 + * + * @author Codex + */ +public class ProductionDailyReportDeviceVo implements Serializable { + private static final long serialVersionUID = 1L; + + private String deviceCode; + private String deviceName; + private BigDecimal actualQty; + + public String getDeviceCode() { + return deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public BigDecimal getActualQty() { + return actualQty; + } + + public void setActualQty(BigDecimal actualQty) { + this.actualQty = actualQty; + } +} diff --git a/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportOrderVo.java b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportOrderVo.java new file mode 100644 index 0000000..8adf5c7 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportOrderVo.java @@ -0,0 +1,86 @@ +package com.aucma.report.domain.vo; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 生产日报计划工单明细。 + * + * @author Codex + */ +public class ProductionDailyReportOrderVo implements Serializable { + private static final long serialVersionUID = 1L; + + private String orderCode; + private String materialCode; + private String materialName; + private String workCenterCode; + private String productLineName; + private BigDecimal planQty; + private String beginDate; + private String endDate; + + public String getOrderCode() { + return orderCode; + } + + public void setOrderCode(String orderCode) { + this.orderCode = orderCode; + } + + public String getMaterialCode() { + return materialCode; + } + + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + public String getWorkCenterCode() { + return workCenterCode; + } + + public void setWorkCenterCode(String workCenterCode) { + this.workCenterCode = workCenterCode; + } + + public String getProductLineName() { + return productLineName; + } + + public void setProductLineName(String productLineName) { + this.productLineName = productLineName; + } + + public BigDecimal getPlanQty() { + return planQty; + } + + public void setPlanQty(BigDecimal planQty) { + this.planQty = planQty; + } + + public String getBeginDate() { + return beginDate; + } + + public void setBeginDate(String beginDate) { + this.beginDate = beginDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } +} diff --git a/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportQuery.java b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportQuery.java new file mode 100644 index 0000000..80c4134 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportQuery.java @@ -0,0 +1,78 @@ +package com.aucma.report.domain.vo; + +import java.io.Serializable; + +/** + * 生产日报查询参数。 + * + * @author Codex + */ +public class ProductionDailyReportQuery implements Serializable { + private static final long serialVersionUID = 1L; + + /** 查询开始日期,格式:yyyy-MM-dd */ + private String beginDate; + + /** 查询结束日期,格式:yyyy-MM-dd */ + private String endDate; + + /** 工单号,可选 */ + private String orderCode; + + /** 物料编码,可选 */ + private String materialCode; + + /** 物料名称,可选 */ + private String materialName; + + /** 工作中心,可选 */ + private String workCenterCode; + + public String getBeginDate() { + return beginDate; + } + + public void setBeginDate(String beginDate) { + this.beginDate = beginDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public String getOrderCode() { + return orderCode; + } + + public void setOrderCode(String orderCode) { + this.orderCode = orderCode; + } + + public String getMaterialCode() { + return materialCode; + } + + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + public String getWorkCenterCode() { + return workCenterCode; + } + + public void setWorkCenterCode(String workCenterCode) { + this.workCenterCode = workCenterCode; + } +} diff --git a/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportRowVo.java b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportRowVo.java new file mode 100644 index 0000000..b3619fd --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportRowVo.java @@ -0,0 +1,95 @@ +package com.aucma.report.domain.vo; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 生产日报每日行数据。 + * + * @author Codex + */ +public class ProductionDailyReportRowVo implements Serializable { + private static final long serialVersionUID = 1L; + + private String reportDate; + private Long orderCount; + private BigDecimal planQty; + private BigDecimal actualQty; + private BigDecimal goodQty; + private BigDecimal defectQty; + private BigDecimal completionRate; + private BigDecimal goodRate; + private Long producedDeviceCount; + + public String getReportDate() { + return reportDate; + } + + public void setReportDate(String reportDate) { + this.reportDate = reportDate; + } + + public Long getOrderCount() { + return orderCount; + } + + public void setOrderCount(Long orderCount) { + this.orderCount = orderCount; + } + + public BigDecimal getPlanQty() { + return planQty; + } + + public void setPlanQty(BigDecimal planQty) { + this.planQty = planQty; + } + + public BigDecimal getActualQty() { + return actualQty; + } + + public void setActualQty(BigDecimal actualQty) { + this.actualQty = actualQty; + } + + public BigDecimal getGoodQty() { + return goodQty; + } + + public void setGoodQty(BigDecimal goodQty) { + this.goodQty = goodQty; + } + + public BigDecimal getDefectQty() { + return defectQty; + } + + public void setDefectQty(BigDecimal defectQty) { + this.defectQty = defectQty; + } + + public BigDecimal getCompletionRate() { + return completionRate; + } + + public void setCompletionRate(BigDecimal completionRate) { + this.completionRate = completionRate; + } + + public BigDecimal getGoodRate() { + return goodRate; + } + + public void setGoodRate(BigDecimal goodRate) { + this.goodRate = goodRate; + } + + public Long getProducedDeviceCount() { + return producedDeviceCount; + } + + public void setProducedDeviceCount(Long producedDeviceCount) { + this.producedDeviceCount = producedDeviceCount; + } +} diff --git a/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportSummaryVo.java b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportSummaryVo.java new file mode 100644 index 0000000..6772576 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/domain/vo/ProductionDailyReportSummaryVo.java @@ -0,0 +1,104 @@ +package com.aucma.report.domain.vo; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 生产日报汇总数据。 + * + * @author Codex + */ +public class ProductionDailyReportSummaryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private String beginDate; + private String endDate; + private Long orderCount; + private BigDecimal planQty; + private BigDecimal actualQty; + private BigDecimal goodQty; + private BigDecimal defectQty; + private BigDecimal completionRate; + private BigDecimal goodRate; + private Long producedDeviceCount; + + public String getBeginDate() { + return beginDate; + } + + public void setBeginDate(String beginDate) { + this.beginDate = beginDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public Long getOrderCount() { + return orderCount; + } + + public void setOrderCount(Long orderCount) { + this.orderCount = orderCount; + } + + public BigDecimal getPlanQty() { + return planQty; + } + + public void setPlanQty(BigDecimal planQty) { + this.planQty = planQty; + } + + public BigDecimal getActualQty() { + return actualQty; + } + + public void setActualQty(BigDecimal actualQty) { + this.actualQty = actualQty; + } + + public BigDecimal getGoodQty() { + return goodQty; + } + + public void setGoodQty(BigDecimal goodQty) { + this.goodQty = goodQty; + } + + public BigDecimal getDefectQty() { + return defectQty; + } + + public void setDefectQty(BigDecimal defectQty) { + this.defectQty = defectQty; + } + + public BigDecimal getCompletionRate() { + return completionRate; + } + + public void setCompletionRate(BigDecimal completionRate) { + this.completionRate = completionRate; + } + + public BigDecimal getGoodRate() { + return goodRate; + } + + public void setGoodRate(BigDecimal goodRate) { + this.goodRate = goodRate; + } + + public Long getProducedDeviceCount() { + return producedDeviceCount; + } + + public void setProducedDeviceCount(Long producedDeviceCount) { + this.producedDeviceCount = producedDeviceCount; + } +} diff --git a/aucma-report/src/main/java/com/aucma/report/mapper/ProductionDailyReportMapper.java b/aucma-report/src/main/java/com/aucma/report/mapper/ProductionDailyReportMapper.java new file mode 100644 index 0000000..132c879 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/mapper/ProductionDailyReportMapper.java @@ -0,0 +1,39 @@ +package com.aucma.report.mapper; + +import com.aucma.report.domain.vo.ProductionDailyReportDeviceVo; +import com.aucma.report.domain.vo.ProductionDailyReportOrderVo; +import com.aucma.report.domain.vo.ProductionDailyReportQuery; +import com.aucma.report.domain.vo.ProductionDailyReportRowVo; +import com.aucma.report.domain.vo.ProductionDailyReportSummaryVo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 生产日报Mapper。 + * + * @author Codex + */ +@Mapper +public interface ProductionDailyReportMapper { + + /** + * 查询生产日报汇总。 + */ + ProductionDailyReportSummaryVo selectSummary(ProductionDailyReportQuery query); + + /** + * 查询按日汇总列表。 + */ + List selectDailyList(ProductionDailyReportQuery query); + + /** + * 查询计划工单明细。 + */ + List selectOrderList(ProductionDailyReportQuery query); + + /** + * 查询设备实际产出明细。 + */ + List selectDeviceList(ProductionDailyReportQuery query); +} diff --git a/aucma-report/src/main/java/com/aucma/report/service/IProductionDailyReportService.java b/aucma-report/src/main/java/com/aucma/report/service/IProductionDailyReportService.java new file mode 100644 index 0000000..22f8b0c --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/service/IProductionDailyReportService.java @@ -0,0 +1,37 @@ +package com.aucma.report.service; + +import com.aucma.report.domain.vo.ProductionDailyReportDeviceVo; +import com.aucma.report.domain.vo.ProductionDailyReportOrderVo; +import com.aucma.report.domain.vo.ProductionDailyReportQuery; +import com.aucma.report.domain.vo.ProductionDailyReportRowVo; +import com.aucma.report.domain.vo.ProductionDailyReportSummaryVo; + +import java.util.List; + +/** + * 生产日报Service接口。 + * + * @author Codex + */ +public interface IProductionDailyReportService { + + /** + * 查询生产日报汇总。 + */ + ProductionDailyReportSummaryVo getSummary(ProductionDailyReportQuery query); + + /** + * 查询按日汇总列表。 + */ + List getDailyList(ProductionDailyReportQuery query); + + /** + * 查询计划工单明细。 + */ + List getOrderList(ProductionDailyReportQuery query); + + /** + * 查询设备产出明细。 + */ + List getDeviceList(ProductionDailyReportQuery query); +} diff --git a/aucma-report/src/main/java/com/aucma/report/service/impl/ProductionDailyReportServiceImpl.java b/aucma-report/src/main/java/com/aucma/report/service/impl/ProductionDailyReportServiceImpl.java new file mode 100644 index 0000000..83e6914 --- /dev/null +++ b/aucma-report/src/main/java/com/aucma/report/service/impl/ProductionDailyReportServiceImpl.java @@ -0,0 +1,86 @@ +package com.aucma.report.service.impl; + +import com.aucma.report.domain.vo.ProductionDailyReportDeviceVo; +import com.aucma.report.domain.vo.ProductionDailyReportOrderVo; +import com.aucma.report.domain.vo.ProductionDailyReportQuery; +import com.aucma.report.domain.vo.ProductionDailyReportRowVo; +import com.aucma.report.domain.vo.ProductionDailyReportSummaryVo; +import com.aucma.report.mapper.ProductionDailyReportMapper; +import com.aucma.report.service.IProductionDailyReportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * 生产日报Service实现。 + * + * @author Codex + */ +@Service +public class ProductionDailyReportServiceImpl implements IProductionDailyReportService { + + @Autowired + private ProductionDailyReportMapper productionDailyReportMapper; + + @Override + public ProductionDailyReportSummaryVo getSummary(ProductionDailyReportQuery query) { + ProductionDailyReportQuery normalizedQuery = normalizeQuery(query); + ProductionDailyReportSummaryVo summary = productionDailyReportMapper.selectSummary(normalizedQuery); + if (summary != null) { + summary.setBeginDate(normalizedQuery.getBeginDate()); + summary.setEndDate(normalizedQuery.getEndDate()); + } + return summary; + } + + @Override + public List getDailyList(ProductionDailyReportQuery query) { + return productionDailyReportMapper.selectDailyList(normalizeQuery(query)); + } + + @Override + public List getOrderList(ProductionDailyReportQuery query) { + return productionDailyReportMapper.selectOrderList(normalizeQuery(query)); + } + + @Override + public List getDeviceList(ProductionDailyReportQuery query) { + return productionDailyReportMapper.selectDeviceList(normalizeQuery(query)); + } + + private ProductionDailyReportQuery normalizeQuery(ProductionDailyReportQuery query) { + ProductionDailyReportQuery normalizedQuery = query == null ? new ProductionDailyReportQuery() : query; + String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + if (isBlank(normalizedQuery.getBeginDate())) { + normalizedQuery.setBeginDate(today); + } + if (isBlank(normalizedQuery.getEndDate())) { + normalizedQuery.setEndDate(normalizedQuery.getBeginDate()); + } + validateDate(normalizedQuery.getBeginDate(), "beginDate"); + validateDate(normalizedQuery.getEndDate(), "endDate"); + if (normalizedQuery.getBeginDate().compareTo(normalizedQuery.getEndDate()) > 0) { + throw new IllegalArgumentException("开始日期不能大于结束日期"); + } + return normalizedQuery; + } + + private void validateDate(String value, String fieldName) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + dateFormat.setLenient(false); + try { + dateFormat.parse(value); + } catch (ParseException e) { + // 报表日期是SQL范围条件,必须Fail Fast,避免无效字符串进入Oracle日期转换。 + throw new IllegalArgumentException(fieldName + "日期格式必须为yyyy-MM-dd"); + } + } + + private boolean isBlank(String value) { + return value == null || value.trim().length() == 0; + } +} diff --git a/aucma-report/src/main/resources/mapper/report/ProductionDailyReportMapper.xml b/aucma-report/src/main/resources/mapper/report/ProductionDailyReportMapper.xml new file mode 100644 index 0000000..04821e8 --- /dev/null +++ b/aucma-report/src/main/resources/mapper/report/ProductionDailyReportMapper.xml @@ -0,0 +1,146 @@ + + + + + + + AND bo.order_code = #{orderCode} + + + AND bo.material_code = #{materialCode} + + + AND bo.material_name LIKE '%' || #{materialName} || '%' + + + AND bo.work_center_code = #{workCenterCode} + + + + + SELECT d.prod_date AS report_date, + d.device_code, + d.daily_prod AS actual_qty + FROM DEVICE_DAILY_PRODUCTION d + WHERE d.prod_date >= TO_DATE(#{beginDate}, 'YYYY-MM-DD') + AND d.prod_date < TO_DATE(#{endDate}, 'YYYY-MM-DD') + 1 + AND d.prod_date < TRUNC(SYSDATE) + AND d.param_name = '机台状态-实际产出数量' + UNION ALL + SELECT r.prod_date AS report_date, + r.device_code, + r.current_total AS actual_qty + FROM RT_DAILY_PROD_STATE r + WHERE r.prod_date = TRUNC(SYSDATE) + AND r.prod_date >= TO_DATE(#{beginDate}, 'YYYY-MM-DD') + AND r.prod_date < TO_DATE(#{endDate}, 'YYYY-MM-DD') + 1 + AND r.param_name = '机台状态-实际产出数量' + + + + + + + + + +