From f6ebd9e321cd3b742ee807bb56414abe5f9f11d7 Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Fri, 13 Oct 2023 14:52:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E3=80=81=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E4=BA=A7=E9=87=8F=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MesReportWorkController.java | 85 ++++++++++- .../java/com/op/mes/domain/MesHourReport.java | 143 ++++++++++++++++++ .../op/mes/mapper/MesReportWorkMapper.java | 9 +- .../op/mes/service/IMesReportWorkService.java | 8 +- .../impl/MesReportWorkServiceImpl.java | 34 ++++- .../mapper/mes/MesReportWorkMapper.xml | 70 +++++++++ 6 files changed, 329 insertions(+), 20 deletions(-) create mode 100644 op-modules/op-mes/src/main/java/com/op/mes/domain/MesHourReport.java diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java index 54a48bd3..716b708b 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java @@ -1,13 +1,17 @@ package com.op.mes.controller; -import java.util.List; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; import javax.servlet.http.HttpServletResponse; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.uuid.IdUtils; -import com.op.mes.domain.MesDailyReport; -import com.op.mes.domain.MesProcessReport; -import com.op.mes.domain.MesReportProduction; +import com.op.mes.domain.*; import com.op.mes.domain.dto.LineChartDto; import com.op.mes.domain.dto.SysFactoryDto; import com.op.mes.mapper.MesReportWorkMapper; @@ -24,7 +28,6 @@ import org.springframework.web.bind.annotation.RestController; import com.op.common.log.annotation.Log; import com.op.common.log.enums.BusinessType; import com.op.common.security.annotation.RequiresPermissions; -import com.op.mes.domain.MesReportWork; import com.op.mes.service.IMesReportWorkService; import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.domain.AjaxResult; @@ -42,8 +45,6 @@ import com.op.common.core.utils.poi.ExcelUtilDailyReport; public class MesReportWorkController extends BaseController { @Autowired private IMesReportWorkService mesReportWorkService; - @Autowired - private MesReportWorkMapper mesReportWorkMapper; /** * 查询报工报表列表 */ @@ -189,6 +190,76 @@ public class MesReportWorkController extends BaseController { return mesReportWorkService.getLineChartData(mesReportProduction); } + + /** + * 小时产量表头 + */ + @RequiresPermissions("mes:hourProduction:list") + @GetMapping("/getHourProductionTitle") + public List getProcessFinishList(MesHourReport mesHourReport) { + //默认时间范围T 00:00:00~T+1 00:00:00 + if(StringUtils.isEmpty(mesHourReport.getProductDateStart())){ + mesHourReport.setProductDateStart(DateUtils.getDate()+" 00:00:00");//start + LocalDate date = LocalDate.now(); + LocalDate dateEnd = date.plusDays(1); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String dateEndStr = dtf.format(dateEnd)+" 00:00:00"; + mesHourReport.setProductDateEnd(dateEndStr);//end + } + // 返回的日期集合 + List dayHours = new ArrayList(); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH"); + try { + Date start = dateFormat.parse(mesHourReport.getProductDateStart()); + Date end = dateFormat.parse(mesHourReport.getProductDateEnd()); + + Calendar tempStart = Calendar.getInstance(); + tempStart.setTime(start); + + Calendar tempEnd = Calendar.getInstance(); + tempEnd.setTime(end); + while (tempStart.before(tempEnd)) { + dayHours.add(dateFormat.format(tempStart.getTime())); + tempStart.add(Calendar.HOUR_OF_DAY, 1); + } + } catch (ParseException e) { + e.printStackTrace(); + } + + return dayHours; + } + /** + * 小时产量数据体 + */ + @RequiresPermissions("mes:hourProduction:list") + @GetMapping("/getHourProductionList") + public List getHourProductionList(MesHourReport mesHourReport) { + List hourNames = this.getProcessFinishList(mesHourReport); + mesHourReport.setHourNames(hourNames); + List list = mesReportWorkService.getHourProductionList(mesHourReport); + return list; + } + + + public static void main(String args[]){ + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00"); + try { + Date start = dateFormat.parse("2023-10-12 09:00:00"); + Date end = dateFormat.parse("2023-10-13 18:00:00"); + + Calendar tempStart = Calendar.getInstance(); + tempStart.setTime(start); + + Calendar tempEnd = Calendar.getInstance(); + tempEnd.setTime(end); + while (tempStart.before(tempEnd)) { + System.out.println(dateFormat.format(tempStart.getTime())); + tempStart.add(Calendar.HOUR_OF_DAY, 1); + } + } catch (ParseException e) { + e.printStackTrace(); + } + } } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesHourReport.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesHourReport.java new file mode 100644 index 00000000..9a5d0750 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesHourReport.java @@ -0,0 +1,143 @@ +package com.op.mes.domain; + +import com.op.common.core.web.domain.BaseEntity; + +import java.util.Date; +import java.util.List; + +/** + * 小时产量 + * + * @author Open Platform + * @date 2023-08-24 + */ +public class MesHourReport extends BaseEntity { + private static final long serialVersionUID = 1L; + + private String productCode;//产品编码 + private String productName;//产品名称 + private String quantity;//数量 + private String unit;//单位 + private String hourName; + private String productDateStart; + private String productDateEnd; + private String ymdh; + private String equCode; + private String equName; + private String orderCode; + private String workorderCode; + private List hourNames; + private String equCodeHour; + + public String getEquCodeHour() { + return equCodeHour; + } + + public void setEquCodeHour(String equCodeHour) { + this.equCodeHour = equCodeHour; + } + + public List getHourNames() { + return hourNames; + } + + public void setHourNames(List hourNames) { + this.hourNames = hourNames; + } + + public String getOrderCode() { + return orderCode; + } + + public void setOrderCode(String orderCode) { + this.orderCode = orderCode; + } + + public String getWorkorderCode() { + return workorderCode; + } + + public void setWorkorderCode(String workorderCode) { + this.workorderCode = workorderCode; + } + + public String getYmdh() { + return ymdh; + } + + public void setYmdh(String ymdh) { + this.ymdh = ymdh; + } + + public String getEquCode() { + return equCode; + } + + public void setEquCode(String equCode) { + this.equCode = equCode; + } + + public String getEquName() { + return equName; + } + + public void setEquName(String equName) { + this.equName = equName; + } + + public String getProductDateStart() { + return productDateStart; + } + + public void setProductDateStart(String productDateStart) { + this.productDateStart = productDateStart; + } + + public String getProductDateEnd() { + return productDateEnd; + } + + public void setProductDateEnd(String productDateEnd) { + this.productDateEnd = productDateEnd; + } + + 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 String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getHourName() { + return hourName; + } + + public void setHourName(String hourName) { + this.hourName = hourName; + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java index 9d5938b0..c8f777df 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java @@ -3,10 +3,7 @@ package com.op.mes.mapper; import java.util.List; import java.util.Map; -import com.op.mes.domain.MesDailyReport; -import com.op.mes.domain.MesProcessReport; -import com.op.mes.domain.MesReportProduction; -import com.op.mes.domain.MesReportWork; +import com.op.mes.domain.*; import com.op.mes.domain.dto.SysFactoryDto; import org.apache.ibatis.annotations.MapKey; @@ -84,4 +81,8 @@ public interface MesReportWorkMapper { Map getLineChartsDatas(MesReportProduction mesReportProduction); List getLineChartsNames(MesReportProduction mesReportProduction); + @MapKey("equCodeHour") + Map getHourProductionList(MesHourReport mesHourReport); + + List getEquNames(MesHourReport mesHourReport); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java index ab5f2218..4583c09e 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java @@ -1,11 +1,9 @@ package com.op.mes.service; +import java.util.HashMap; import java.util.List; -import com.op.mes.domain.MesDailyReport; -import com.op.mes.domain.MesProcessReport; -import com.op.mes.domain.MesReportProduction; -import com.op.mes.domain.MesReportWork; +import com.op.mes.domain.*; import com.op.mes.domain.dto.LineChartDto; import com.op.mes.domain.dto.SysFactoryDto; @@ -75,4 +73,6 @@ public interface IMesReportWorkService { List getWorkcenterList(MesDailyReport mesDailyReport); LineChartDto getLineChartData(MesReportProduction mesReportProduction); + + List getHourProductionList(MesHourReport mesHourReport); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java index c578ce34..beb37413 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java @@ -8,16 +8,13 @@ import java.util.*; import com.baomidou.dynamic.datasource.annotation.DS; import com.op.common.core.utils.DateUtils; -import com.op.mes.domain.MesDailyReport; -import com.op.mes.domain.MesProcessReport; -import com.op.mes.domain.MesReportProduction; +import com.op.mes.domain.*; import com.op.mes.domain.dto.LineChartDto; import com.op.mes.domain.dto.LineChartSeriesDto; import com.op.mes.domain.dto.SysFactoryDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.mes.mapper.MesReportWorkMapper; -import com.op.mes.domain.MesReportWork; import com.op.mes.service.IMesReportWorkService; import org.springframework.util.CollectionUtils; @@ -191,7 +188,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { * data: [120, 132, 101, 134, 90, 230, 210,120, 132, 101, 134, 90, 230, 210] * } * ] - * @param mesDailyReport + * @param * @return */ @Override @@ -238,6 +235,33 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { lineChartDto.setSeriesDatas(seriesDatas); return lineChartDto; } + @DS("#header.poolName") + @Override + public List getHourProductionList(MesHourReport mesHourReport) { + List hourPros = new ArrayList<>(); + List equs = mesReportWorkMapper.getEquNames(mesHourReport); + List hourNames = mesHourReport.getHourNames(); + Map equProMap = mesReportWorkMapper.getHourProductionList(mesHourReport); + + for(MesHourReport equ:equs){ + HashMap result = new HashMap(); + result.put("equCode",equ.getEquCode()); + result.put("equName",equ.getEquName()); + for(int n = 0;n < hourNames.size();n++){ + String hourName = hourNames.get(n); + String key = equ.getEquCode()+hourName; + MesHourReport hourdto = equProMap.get(key); + if(hourdto!=null){ + result.put("hourPro"+n,hourdto.getQuantity()); + }else{ + result.put("hourPro"+n,"0"); + } + } + hourPros.add(result); + } + return hourPros; + } + /**两个日期之间的所有日期**/ public static List getDays(String startTime,String endTime) { diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml index 8340b9dc..b0885e3b 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml @@ -244,6 +244,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart} and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120) + + insert into mes_report_work