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 d8bccd09..8d28fcab 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 @@ -392,6 +392,116 @@ public class MesReportWorkController extends BaseController { List list = mesReportWorkService.getHourProductionList(mesHourReport); return list; } + /** + * 小时产量表头new(成型机) + */ + //@RequiresPermissions("mes:hourProduction:list") + @GetMapping("/getHourProductionTitleNew") + public List getHourProductionTitleNew(MesHourReport mesHourReport) { + //根据根据时间范围得工单,获取最早和最晚小时 + List dateStartEnd = this.getStartEndTimeByProDate(mesHourReport); + mesHourReport.setProductDateStart(dateStartEnd.get(0)); + mesHourReport.setProductDateEnd(dateStartEnd.get(1)); + // 返回的日期集合 + 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());//结束 + + //如果有分钟数,默认加一小时 + String endTimeStr1 = mesHourReport.getProductDateEnd(); + String[] endTime2 = endTimeStr1.split(" "); + String endTime3 = endTime2[1].split(":")[1]; + if(Integer.parseInt(endTime3)!=0){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(end); + calendar.add(Calendar.HOUR_OF_DAY, 1); + end = calendar.getTime(); + } + + 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; + } + public List getStartEndTimeByProDate(MesHourReport mesHourReport){ + return mesReportWorkService.getStartEndTimeByProDate(mesHourReport); + } + /** + * 小时产量数据体new(给烘房和成型机用) + */ + @GetMapping("/getHourProductionListNew") + @Log(title = "设备小时产量查询(烘房、成型机)", businessType = BusinessType.QUERY) + public List getHourProductionListNew(MesHourReport mesHourReport) { + List hourNames = null; + if("equ_type_hf".equals(mesHourReport.getEquTypeCode())){ + hourNames = this.getHourProductionTitle(mesHourReport); + }else if("equ_type_cxj".equals(mesHourReport.getEquTypeCode())){ + hourNames = this.getHourProductionTitleNew(mesHourReport); + } + + mesHourReport.setHourNames(hourNames); + List list = mesReportWorkService.getHourProductionHFList(mesHourReport); + return list; + } + + @PostMapping("/getHourProductionNewExport") + public void getHourProductionNewExport(HttpServletResponse response,MesHourReport mesHourReport) { + List hourNames = null; + + if("equ_type_hf".equals(mesHourReport.getEquTypeCode())){ + hourNames = this.getHourProductionTitle(mesHourReport); + mesHourReport.setHourNames(hourNames); + }else if("equ_type_cxj".equals(mesHourReport.getEquTypeCode())){ + hourNames = this.getHourProductionTitleNew(mesHourReport); + mesHourReport.setHourNames(hourNames); + } + List list = mesReportWorkService.getHourProductionHFList(mesHourReport); + + //表格结构数据 + String title = "表主标题"; + ArrayList excelCols = new ArrayList<>(); + excelCols.add(new ExcelCol("设备编码","equCode",20)); + excelCols.add(new ExcelCol("设备名称","equName",20)); + excelCols.add(new ExcelCol("设备总产量","quantity",20)); + + for(int n = 0;n getHourProductionLists(MesHourReport mesHourReport) { 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 index 8b0dd924..7ae28e33 100644 --- 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 @@ -32,6 +32,15 @@ public class MesHourReport extends BaseEntity { private String shiftId; @JsonFormat(pattern = "yyyy-MM-dd") private Date pdate; + private String equTypeCode; + + public String getEquTypeCode() { + return equTypeCode; + } + + public void setEquTypeCode(String equTypeCode) { + this.equTypeCode = equTypeCode; + } public Date getPdate() { return pdate; 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 6758c9d4..0e9db0e8 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 @@ -103,6 +103,10 @@ public interface MesReportWorkMapper { @MapKey("equCodeHour") Map getHourProductionList(MesHourReport mesHourReport); + @MapKey("equCodeHour") + Map getHourProductionHFList(MesHourReport mesHourReport); + @MapKey("equCodeHour") + Map getHourProductionCXJList(MesHourReport mesHourReport); //烘房当班产量 @MapKey("shiftId") List getHFDailyProduction(String shiftId); @@ -221,4 +225,12 @@ public interface MesReportWorkMapper { List getHFProductionTitle(HFProduction dto); List getCXJProductionList(HFProduction dto); + + List getEquNamesByEquType(MesHourReport mesHourReport); + + String getCXJFirstTime(MesHourReport mesHourReport); + String getCXJLastTime(MesHourReport mesHourReport); + + List getHFEquNames(MesHourReport mesHourReport); + List getCXJEquNames(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 33c98953..62a7e8d0 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 @@ -87,6 +87,7 @@ public interface IMesReportWorkService { LineChartDto getLineChartData(MesReportProduction mesReportProduction); List getHourProductionList(MesHourReport mesHourReport); + List getHourProductionHFList(MesHourReport mesHourReport); List getHourProductionLists(MesHourReport mesHourReport); List> getMachineProductionList(MesMachineReport mesMachineReport); @@ -143,4 +144,6 @@ public interface IMesReportWorkService { Map getmonthProductionSut(MesMonthReportVo mesMonthReportVo); AjaxResult PlanAchievementRate(); + + List getStartEndTimeByProDate(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 1c1ff7dc..e05e58ac 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 @@ -731,6 +731,40 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { return hourPros; } + /**烘房小时产量**/ + @DS("#header.poolName") + @Override + public List getHourProductionHFList(MesHourReport mesHourReport) { + List hourPros = new ArrayList<>(); + List equs = null; + List hourNames = mesHourReport.getHourNames(); + Map equProMap = null; + if("equ_type_hf".equals(mesHourReport.getEquTypeCode())) { + equs = mesReportWorkMapper.getHFEquNames(mesHourReport); + equProMap = mesReportWorkMapper.getHourProductionHFList(mesHourReport); + }else{ + equs = mesReportWorkMapper.getCXJEquNames(mesHourReport); + equProMap = mesReportWorkMapper.getHourProductionCXJList(mesHourReport); + } + for(MesHourReport equ:equs){ + HashMap result = new HashMap(); + result.put("equCode",equ.getEquCode()); + result.put("equName",equ.getEquName()); + result.put("quantity",equ.getQuantity()); + 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; + } @DS("#header.poolName") @Override @@ -1001,6 +1035,38 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { return AjaxResult.success(percentage,resultmap); } + + @Override + @DS("#header.poolName") + public List getStartEndTimeByProDate(MesHourReport mesHourReport) { + List arrays = new ArrayList<>(); + //班次为空,则找白班的第一车的开始时间和夜班的最后一车的时间 + if("equ_type_cxj".equals(mesHourReport.getEquTypeCode())){ + String startTime = mesReportWorkMapper.getCXJFirstTime(mesHourReport); + if(StringUtils.isBlank(startTime)){ + startTime = DateUtils.getDate()+" 00:00:00"; + } + arrays.add(startTime); + String endTime = mesReportWorkMapper.getCXJLastTime(mesHourReport); + if(StringUtils.isBlank(endTime)){ + LocalDate date = LocalDate.now(); + LocalDate dateEnd = date.plusDays(1); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + endTime = dtf.format(dateEnd)+" 00:00:00"; + } + arrays.add(endTime); + } + + 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 + + return arrays; + } + public static String calculatePercentage(int numerator, int denominator) { if (denominator == 0) { return "0%"; // 防止除以零 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 542c6b44..be271d0a 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 @@ -415,6 +415,80 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt.equipmentCode, equ.equipment_name + + + + + + from mes_cxj_producted mdi + join pro_order_workorder pow on mdi.workorder_code = pow.workorder_id + left join base_equipment be on be.equipment_code = mdi.workorder_name + where pow.product_date >=#{productDateStart} and #{productDateEnd} >= pow.product_date + and pow.shift_id = #{shiftId} + + and pow.order_code like concat('%', #{orderCode}, '%') + + + and pow.product_code like concat('%', #{productCode}, '%') + + + and pow.product_name like concat('%', #{productName}, '%') + + + and pow.workorder_code like concat('%', #{workorderCode}, '%') + + + and equ.equipment_name like concat('%', #{equName}, '%') + + + + + + insert into mes_report_work diff --git a/op-modules/op-technology/src/main/java/com/op/technology/controller/ProProcessController.java b/op-modules/op-technology/src/main/java/com/op/technology/controller/ProProcessController.java index 3e015843..5635df76 100644 --- a/op-modules/op-technology/src/main/java/com/op/technology/controller/ProProcessController.java +++ b/op-modules/op-technology/src/main/java/com/op/technology/controller/ProProcessController.java @@ -159,12 +159,12 @@ public class ProProcessController extends BaseController { /** * 查询工厂模型列表 */ -// @RequiresPermissions("mes:pro:process:list") -// @GetMapping("/selectSysFactoryList") -// public AjaxResult selectSysFactoryList(SysFactory sysFactory) { -// List list = proProcessService.selectSysFactoryList(sysFactory); -// return success(list); -// } + @RequiresPermissions("mes:pro:process:list") + @GetMapping("/selectSysFactoryList") + public AjaxResult selectSysFactoryList(SysFactory sysFactory) { + List list = proProcessService.selectSysFactoryList(sysFactory); + return success(list); + } /** * 查询设工作中心 diff --git a/op-modules/op-technology/src/main/java/com/op/technology/mapper/ProProcessMapper.java b/op-modules/op-technology/src/main/java/com/op/technology/mapper/ProProcessMapper.java index f2c2fc98..881ab96e 100644 --- a/op-modules/op-technology/src/main/java/com/op/technology/mapper/ProProcessMapper.java +++ b/op-modules/op-technology/src/main/java/com/op/technology/mapper/ProProcessMapper.java @@ -74,7 +74,7 @@ public interface ProProcessMapper { List selectBaseBomComponentList(BomComponent bomComponent); //查询树形工厂模型 -// public List selectSysFactoryList(SysFactory sysFactory); + public List selectSysFactoryList(SysFactory sysFactory); //查询下拉式工作中心 public List getWorkCenterList(SysFactory sysFactory); diff --git a/op-modules/op-technology/src/main/java/com/op/technology/service/IProProcessService.java b/op-modules/op-technology/src/main/java/com/op/technology/service/IProProcessService.java index ebdbfa7d..4ee0898b 100644 --- a/op-modules/op-technology/src/main/java/com/op/technology/service/IProProcessService.java +++ b/op-modules/op-technology/src/main/java/com/op/technology/service/IProProcessService.java @@ -73,11 +73,12 @@ public interface IProProcessService { public List selectBaseBomComponentList(BomComponent bomComponent); //查询树形工作中心结构 - //public List selectSysFactoryList(SysFactory sysFactory); + public List selectSysFactoryList(SysFactory sysFactory); //查询下拉式工作中心 List getWorkCenterList(SysFactory sysFactory); //查询设备类型 List getEquipmentTypeList(Equipment equipment); + } diff --git a/op-modules/op-technology/src/main/java/com/op/technology/service/impl/ProProcessServiceImpl.java b/op-modules/op-technology/src/main/java/com/op/technology/service/impl/ProProcessServiceImpl.java index cde0acd0..0d5d2885 100644 --- a/op-modules/op-technology/src/main/java/com/op/technology/service/impl/ProProcessServiceImpl.java +++ b/op-modules/op-technology/src/main/java/com/op/technology/service/impl/ProProcessServiceImpl.java @@ -223,17 +223,17 @@ public class ProProcessServiceImpl implements IProProcessService { return proProcessMapper.selectBaseBomComponentList(bomComponent); } -// /** -// * 查询工厂模型列表 -// * -// * @param sysFactory 工厂模型 -// * @return 工厂模型 -// */ -// @Override -// @DS("#header.poolName") -// public List selectSysFactoryList(SysFactory sysFactory) { -// return proProcessMapper.selectSysFactoryList(sysFactory); -// } + /** + * 查询工厂模型列表 + * + * @param sysFactory 工厂模型 + * @return 工厂模型 + */ + @Override + @DS("#header.poolName") + public List selectSysFactoryList(SysFactory sysFactory) { + return proProcessMapper.selectSysFactoryList(sysFactory); + } /** * 查询工厂模型列表