From 979fba0209946d44c12f65268e0c3912f7d04e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=83=E6=B0=94=E6=BB=A1=E6=BB=A1=28jgy=29?= Date: Tue, 5 Nov 2024 13:32:42 +0800 Subject: [PATCH 1/6] =?UTF-8?q?2024-11-5=20Device=E8=AE=BE=E5=A4=87=20-=20?= =?UTF-8?q?=E7=82=B9=E6=A3=80=20-=E5=8F=AA=E7=94=9F=E6=88=90=E5=BD=93?= =?UTF-8?q?=E6=97=A5=E8=AE=A1=E5=88=92=E7=94=9F=E4=BA=A7=E7=9A=84=E4=BA=A7?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/controller/EquPlanController.java | 8 +-- .../java/com/op/device/domain/EquPlan.java | 11 ++++ .../op/device/mapper/DeviceTaskMapper.java | 6 +- .../service/impl/DeviceTaskServiceImpl.java | 58 ++++++++++++++++--- .../mapper/device/DeviceTaskMapper.xml | 15 ++++- 5 files changed, 80 insertions(+), 18 deletions(-) diff --git a/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java b/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java index b6729a34..a0412e63 100644 --- a/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java +++ b/op-modules/op-device/src/main/java/com/op/device/controller/EquPlanController.java @@ -118,7 +118,7 @@ public class EquPlanController extends BaseController { * 导出计划列表 */ @RequiresPermissions("device:inspectionPlan:export") - @Log(title = "计划", businessType = BusinessType.EXPORT) + @Log(title = "导出计划", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, EquPlan equPlan) { List list = equPlanService.selectEquPlanList(equPlan); @@ -139,7 +139,7 @@ public class EquPlanController extends BaseController { * 新增计划 */ @RequiresPermissions("device:inspectionPlan:add") - @Log(title = "计划", businessType = BusinessType.INSERT) + @Log(title = "新增计划", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody EquPlan equPlan) { return equPlanService.insertEquPlan(equPlan); @@ -149,7 +149,7 @@ public class EquPlanController extends BaseController { * 修改计划 */ @RequiresPermissions("device:inspectionPlan:edit") - @Log(title = "计划", businessType = BusinessType.UPDATE) + @Log(title = "修改计划", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody EquPlan equPlan) { return equPlanService.updateEquPlan(equPlan); @@ -159,7 +159,7 @@ public class EquPlanController extends BaseController { * 删除计划 */ @RequiresPermissions("device:inspectionPlan:remove") - @Log(title = "计划", businessType = BusinessType.DELETE) + @Log(title = "删除计划", businessType = BusinessType.DELETE) @DeleteMapping("/{planIds}") public AjaxResult remove(@PathVariable String[] planIds) { return equPlanService.deleteEquPlanByPlanIds(planIds); diff --git a/op-modules/op-device/src/main/java/com/op/device/domain/EquPlan.java b/op-modules/op-device/src/main/java/com/op/device/domain/EquPlan.java index f2d4b503..8ffb5b7b 100644 --- a/op-modules/op-device/src/main/java/com/op/device/domain/EquPlan.java +++ b/op-modules/op-device/src/main/java/com/op/device/domain/EquPlan.java @@ -205,6 +205,9 @@ public class EquPlan extends BaseEntity { @Excel(name = "委外原因") private String workReason; + //jgy 新增 生产线体编码 每天生成线体信息的时候只生成计划生产的 + private String lineCode; + public String getWorkOutsourcingUnit() { return workOutsourcingUnit; } @@ -581,6 +584,14 @@ public class EquPlan extends BaseEntity { return delFlag; } + public void setLineCode(String lineCode) { + this.lineCode = lineCode; + } + + public String getLineCode() { + return lineCode; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceTaskMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceTaskMapper.java index d812d27e..f3b252f8 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceTaskMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceTaskMapper.java @@ -1,12 +1,8 @@ package com.op.device.mapper; -import com.op.common.core.domain.BaseFileData; -import com.op.device.domain.EquFile; import com.op.device.domain.EquOrder; import com.op.device.domain.EquPlan; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - import java.util.List; /** @@ -23,4 +19,6 @@ public interface DeviceTaskMapper { EquOrder getNewTaskOrder(EquPlan quPlan); EquOrder getNewTaskOrder0(EquPlan plan); + + List getPlanProduceLine();//计划生产产线查询 } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java index 27d3c429..1430fd29 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceTaskServiceImpl.java @@ -1,14 +1,12 @@ package com.op.device.service.impl; -import com.baomidou.dynamic.datasource.annotation.DS; +import com.alibaba.fastjson.JSONArray; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; -import com.op.common.core.context.SecurityContextHolder; import com.op.common.core.domain.R; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.domain.AjaxResult; -import com.op.common.security.utils.SecurityUtils; import com.op.device.domain.*; import com.op.device.mapper.*; import com.op.device.service.IDeviceTaskService; @@ -19,18 +17,15 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import static com.op.common.core.web.domain.AjaxResult.error; import static com.op.common.core.web.domain.AjaxResult.success; @@ -253,8 +248,9 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { EquPlan equPlan = new EquPlan(); equPlan.setPlanType("spotInspection"); List plans = deviceTaskMapper.getPlans(equPlan); + List producePlans = this.confirmPlanProduceLine(plans,poolName); - for (EquPlan plan : plans) { + for (EquPlan plan : producePlans) { EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan); if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) { //生成点检计划 @@ -560,4 +556,48 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { System.out.println("------>" + batchCount); } + //筛选出 当天要计划生成的数据 + private List confirmPlanProduceLine(List plans,String poolName) { + //查询到当天要生产的产线 + List planProduceLine = deviceTaskMapper.getPlanProduceLine();//计划生产产线 + List planProduceLineCode = new ArrayList<>(); + List produceLine = new ArrayList<>(); + + for(String str : planProduceLine){ + str = str.substring(1, str.length() - 1); + String[] subArrays = str.split("],\\["); + for (String subArrayStr : subArrays) { + subArrayStr = subArrayStr.substring(1, subArrayStr.length() - 1); + String[] parts = subArrayStr.split("\",\""); + for (int i = 1 ; i < parts.length ; i++) { + if(i == parts.length - 1){ + planProduceLineCode.add(parts[i].replaceAll("\"", "")); + }else{ + planProduceLineCode.add(parts[i]); + } + } + } + } + + List uniqueLineCodeList = planProduceLineCode.stream().distinct().collect(Collectors.toList()); + List returnPlanList = new ArrayList<>(); + if(!CollectionUtils.isEmpty(uniqueLineCodeList) && !CollectionUtils.isEmpty(plans)){ + for(String lineCode : uniqueLineCodeList){ + for(EquPlan equPlan : plans){ + if(!StringUtils.isBlank(equPlan.getLineCode())){ + if(equPlan.getLineCode().equals(lineCode)){ + returnPlanList.add(equPlan); + produceLine.add(lineCode);//生成产线 + } + } + } + } + } + + produceLine = produceLine.stream().distinct().collect(Collectors.toList()); + logger.info(poolName + "工厂今日生成的产线:" + JSONArray.toJSONString(produceLine)); + logger.info(poolName + "工厂返回生成今日生产的产线点检计划信息:" + JSONArray.toJSONString(returnPlanList)); + return returnPlanList; + } + } diff --git a/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml index 03821183..9dc26062 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml @@ -25,11 +25,18 @@ ep.plan_code planCode, epe.equipment_code equipmentCode, epe.equipment_name equipmentName, + ebae.equipment_code lineCode, epe.id planEquId from equ_plan ep left join equ_plan_equ epe on ep.plan_code = epe.plan_code + left join equ_bind_auxiliary_equipment ebae on epe.equipment_code = ebae.auxiliary_equipment_code where ep.del_flag = '0' and epe.del_flag = '0' and ep.plan_status = '0' - and epe.equipment_code in ( select be.equipment_code from base_equipment be where be.del_flag = '0' ) + and epe.equipment_code in( + select be.equipment_code from base_equipment be + left join equ_bind_auxiliary_equipment ebae0 on be.equipment_code = ebae0.auxiliary_equipment_code + where be.del_flag = '0' + and ebae0.del_flag = '0' + ) and ep.plan_type = #{planType} and CONVERT(varchar(10),GETDATE(), 120) >= CONVERT(varchar(10),ep.plan_loop_start, 120) @@ -66,4 +73,10 @@ and del_flag = '0' order by create_time desc + + From 8ef8eb43d1725c043c823ce99d416d29b48acfe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=83=E6=B0=94=E6=BB=A1=E6=BB=A1=28jgy=29?= Date: Tue, 5 Nov 2024 14:13:57 +0800 Subject: [PATCH 2/6] =?UTF-8?q?2024-11-05=20Device=E8=AE=BE=E5=A4=87=20-?= =?UTF-8?q?=20=E6=9F=A5=E8=AF=A2=E7=82=B9=E6=A3=80=E4=BA=A7=E7=BA=BF-?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=E5=BA=94=E4=B8=BAw1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/device/DeviceTaskMapper.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml index 9dc26062..42687941 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/DeviceTaskMapper.xml @@ -78,5 +78,6 @@ select prod_line_code AS planProduceLine from pro_order_workorder pow where CONVERT(varchar(10),pow.product_date, 120) = CONVERT(varchar(10),GETDATE(), 120) + and status = 'w1' From 7376533d626a4e91fbdfd78f293e8b0cc6d67f61 Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Tue, 5 Nov 2024 17:54:50 +0800 Subject: [PATCH 3/6] =?UTF-8?q?H5=E6=8A=A5=E8=A1=A8=EF=BC=8C4=E6=A5=BC?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- op-api/op-api.iml | 39 ------ op-common/op-common-core/op-common-core.iml | 104 ---------------- op-common/op-common-core/pom.xml | 2 + .../op/common/core/utils/poi/ExcelUtil.java | 98 ++++++++++++--- .../op-common-datascope.iml | 117 +----------------- .../src/main/java/com/op/mes/domain/H5.java | 8 ++ .../java/com/op/mes/mapper/H5ApiMapper.java | 5 +- .../op/mes/mapper/MesReportWorkMapper.java | 8 +- .../op/mes/service/impl/H5ApiServiceImpl.java | 40 +++++- .../service/impl/IWCInterfaceServiceImpl.java | 53 +++++++- .../impl/MesReportWorkServiceImpl.java | 19 ++- .../main/resources/mapper/mes/H5ApiMapper.xml | 39 +++--- .../mapper/mes/MesReportWorkMapper.xml | 13 +- 13 files changed, 232 insertions(+), 313 deletions(-) delete mode 100644 op-api/op-api.iml delete mode 100644 op-common/op-common-core/op-common-core.iml diff --git a/op-api/op-api.iml b/op-api/op-api.iml deleted file mode 100644 index e27a22bf..00000000 --- a/op-api/op-api.iml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/op-common/op-common-core/op-common-core.iml b/op-common/op-common-core/op-common-core.iml deleted file mode 100644 index f8927566..00000000 --- a/op-common/op-common-core/op-common-core.iml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/op-common/op-common-core/pom.xml b/op-common/op-common-core/pom.xml index 95274fd2..4791f75b 100644 --- a/op-common/op-common-core/pom.xml +++ b/op-common/op-common-core/pom.xml @@ -112,6 +112,8 @@ io.swagger swagger-annotations + + diff --git a/op-common/op-common-core/src/main/java/com/op/common/core/utils/poi/ExcelUtil.java b/op-common/op-common-core/src/main/java/com/op/common/core/utils/poi/ExcelUtil.java index 13bfbf5d..0af1f9eb 100644 --- a/op-common/op-common-core/src/main/java/com/op/common/core/utils/poi/ExcelUtil.java +++ b/op-common/op-common-core/src/main/java/com/op/common/core/utils/poi/ExcelUtil.java @@ -1,8 +1,10 @@ package com.op.common.core.utils.poi; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.math.BigDecimal; @@ -20,6 +22,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import com.alibaba.ttl.threadpool.agent.internal.javassist.Modifier; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -49,6 +53,7 @@ import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFDataValidation; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.op.common.core.annotation.Excel; @@ -246,7 +251,7 @@ public class ExcelUtil { /** * 对excel表单默认第一个索引名转换成list - * + * * @param is 输入流 * @return 转换后集合 */ @@ -256,7 +261,7 @@ public class ExcelUtil { /** * 对excel表单默认第一个索引名转换成list - * + * * @param is 输入流 * @param titleNum 标题占用行数 * @return 转换后集合 @@ -267,7 +272,7 @@ public class ExcelUtil { /** * 对excel表单指定表格索引名转换成list - * + * * @param sheetName 表格索引名 * @param titleNum 标题占用行数 * @param is 输入流 @@ -433,7 +438,7 @@ public class ExcelUtil { /** * 对list数据源将其里面的数据导入到excel表单 - * + * * @return 结果 */ public void exportExcel(HttpServletResponse response) { @@ -481,7 +486,7 @@ public class ExcelUtil { /** * 填充excel数据 - * + * * @param index 序号 * @param row 单元格行 */ @@ -538,7 +543,7 @@ public class ExcelUtil { /** * 创建表格样式 - * + * * @param wb 工作薄对象 * @return 样式列表 */ @@ -590,7 +595,7 @@ public class ExcelUtil { /** * 根据Excel注解创建表格头样式 - * + * * @param wb 工作薄对象 * @return 自定义样式列表 */ @@ -620,7 +625,7 @@ public class ExcelUtil { /** * 根据Excel注解创建表格列样式 - * + * * @param wb 工作薄对象 * @return 自定义样式列表 */ @@ -678,7 +683,7 @@ public class ExcelUtil { /** * 设置单元格信息 - * + * * @param value 单元格值 * @param attr 注解相关 * @param cell 单元格信息 @@ -802,7 +807,7 @@ public class ExcelUtil { /** * 设置 POI XSSFSheet 单元格提示或选择框 - * + * * @param sheet 表单 * @param textlist 下拉框显示的内容 * @param promptContent 提示内容 @@ -835,7 +840,7 @@ public class ExcelUtil { /** * 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框). - * + * * @param sheet 要设置的sheet. * @param textlist 下拉框显示的内容 * @param promptContent 提示内容 @@ -911,7 +916,7 @@ public class ExcelUtil { /** * 反向解析值 男=0,女=1,未知=2 - * + * * @param propertyValue 参数值 * @param converterExp 翻译注解 * @param separator 分隔符 @@ -1112,7 +1117,7 @@ public class ExcelUtil { /** * 创建工作表 - * + * * @param sheetNo sheet数量 * @param index 序号 */ @@ -1127,7 +1132,7 @@ public class ExcelUtil { /** * 获取单元格值 - * + * * @param row 获取的行 * @param column 获取单元格列号 * @return 单元格值 @@ -1168,7 +1173,7 @@ public class ExcelUtil { /** * 判断是否是空行 - * + * * @param row 判断的行 * @return */ @@ -1187,7 +1192,7 @@ public class ExcelUtil { /** * 格式化不同类型的日期对象 - * + * * @param dateFormat 日期格式 * @param val 被格式化的日期对象 * @return 格式化后的日期字符 @@ -1239,7 +1244,7 @@ public class ExcelUtil { /** * 获取对象的子列表方法 - * + * * @param name 名称 * @param pojoClass 类对象 * @return 子列表方法 @@ -1256,4 +1261,63 @@ public class ExcelUtil { } return method; } + + public static void exportToExcel(String fileName, Class dynamicClass, Map> mapList) + throws IOException, ReflectiveOperationException { + + Workbook workbook = new XSSFWorkbook(); + + // 遍历 mapList 中的每个键值对,每个键对应一个 Sheet + for (Map.Entry> entry : mapList.entrySet()) { + String sheetName = entry.getKey(); + List dataList = entry.getValue(); + + // 创建 Sheet + Sheet sheet = workbook.createSheet(sheetName); + + // 创建 header 行 + Row headerRow = sheet.createRow(0); + Method[] methods = dynamicClass.getDeclaredMethods(); + int colNum = 0; + for (Method method : methods) { + if (method.getName().startsWith("get") && !Modifier.isStatic(method.getModifiers())) { + Cell cell = headerRow.createCell(colNum++); + cell.setCellValue(method.getName().substring(3)); + } + } + + // 填充数据行 + int rowNum = 1; + for (Object obj : dataList) { + if (dynamicClass.isInstance(obj)) { // 确保 obj 是 dynamicClass 的实例 + Row row = sheet.createRow(rowNum++); + colNum = 0; + for (Method method : methods) { + if (method.getName().startsWith("get") && !Modifier.isStatic(method.getModifiers())) { + Cell cell = row.createCell(colNum++); + try { + Object value = method.invoke(obj); + cell.setCellValue(value != null ? value.toString() : ""); + } catch (IllegalAccessException | InvocationTargetException e) { + // 处理反射调用异常 + e.printStackTrace(); + } + } + } + } else { + // 处理 obj 不是 dynamicClass 实例的情况 + System.err.println("对象 " + obj + " 不是 " + dynamicClass.getName() + " 的实例,已跳过处理。"); + // 跳过非实例对象,不抛出异常 + } + } + } + + // 写入到文件 + try (FileOutputStream fileOut = new FileOutputStream(fileName)) { + workbook.write(fileOut); + } finally { + workbook.close(); + } + } + } diff --git a/op-common/op-common-datascope/op-common-datascope.iml b/op-common/op-common-datascope/op-common-datascope.iml index dab4c8af..47270e4b 100644 --- a/op-common/op-common-datascope/op-common-datascope.iml +++ b/op-common/op-common-datascope/op-common-datascope.iml @@ -11,119 +11,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/H5.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/H5.java index 0ac9de68..dbfe2ce4 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/domain/H5.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/H5.java @@ -17,7 +17,15 @@ public class H5 { private String efficiencyAcRate; private String feedbackTime; private String parentOrder; + private String reason; + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } public int getPlanProduction() { return planProduction; diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/H5ApiMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/H5ApiMapper.java index 2558ac21..2b476b71 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/H5ApiMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/H5ApiMapper.java @@ -2,7 +2,10 @@ package com.op.mes.mapper; import com.op.mes.domain.EnergyExpend; import com.op.mes.domain.H5; +import org.apache.ibatis.annotations.Param; + +import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -21,5 +24,5 @@ public interface H5ApiMapper { */ public List
selectMesLineProsdceLists(H5 h5); - List EnergyExpend(); + List EnergyExpend(@Param("startDateTime") String startDateTime, @Param("endDateTime") String endDateTime); } 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 f274db66..35f7ed29 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 @@ -102,8 +102,9 @@ public interface MesReportWorkMapper { @MapKey("equCodeHour") Map getHourProductionList(MesHourReport mesHourReport); - //烘房当日产量00:00-24:00 - List getHFDailyProduction(); + //烘房当班产量 + @MapKey("shiftId") + List getHFDailyProduction(String shiftId); List getEquNames(MesHourReport mesHourReport); @@ -201,5 +202,6 @@ public interface MesReportWorkMapper { List getEquNamess(MesHourReport mesHourReport); - List> getPlanNumber(); + @MapKey("shiftId") + List> getPlanNumber(String shiftId); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/H5ApiServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/H5ApiServiceImpl.java index 1fd0f075..d1dc4dab 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/H5ApiServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/H5ApiServiceImpl.java @@ -9,6 +9,10 @@ import com.op.mes.service.H5ApiService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -68,6 +72,7 @@ public class H5ApiServiceImpl implements H5ApiService { resultH5.setProductionDuration(totalProductionDuration); // 总和 resultH5.setPlanProduction((int) Math.round(totalPlanProduction)); // 总和 resultH5.setProduction((int) Math.round(totalProduction)); // 总和 + resultH5.setReason(list.get(0).getReason()); return resultH5; } ) @@ -157,7 +162,40 @@ public class H5ApiServiceImpl implements H5ApiService { @Override @DS("#header.poolName") public List EnergyExpend() { - return h5ApiMapper.EnergyExpend(); + LocalDateTime now = LocalDateTime.now(); + LocalTime startTime1 = LocalTime.of(7, 30); // 7:30 + LocalTime endTime1 = LocalTime.of(19, 30); // 19:30 + LocalTime endTime2 = LocalTime.of(7, 30); // 第二天的 7:30 + + LocalDate startDate=null; + LocalDate endDate=null; + + // 当前时间在 7:30 到 19:30 之间 + if (now.toLocalTime().isAfter(startTime1) && now.toLocalTime().isBefore(endTime1)) { + startDate = now.toLocalDate(); + endDate = now.toLocalDate(); + endTime1 = LocalTime.of(19, 30); // 结束时间为当天的 19:30 + } + // 当前时间在 19:30 到第二天 7:30 之间 + else if (now.toLocalTime().isAfter(endTime1) || now.toLocalTime().isBefore(endTime2)) { + startDate = now.toLocalDate(); + endDate = now.toLocalDate().plusDays(1); // 结束时间为第二天的 7:30 + startTime1=endTime1; + endTime1 = LocalTime.of(7, 30); + } else { + // 不在指定时间范围内 + System.out.println("当前时间不在指定范围内。"); + } + + LocalDateTime startDateTime = startDate.atTime(startTime1); // 开始时间 + LocalDateTime endDateTime = endDate.atTime(endTime1); // 结束时间 +// 格式化输出 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + return h5ApiMapper.EnergyExpend(startDateTime.format(formatter),endDateTime.format(formatter)); } + + + + } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java index f936a1f6..dcc9d224 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java @@ -37,6 +37,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; @@ -923,8 +924,21 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { } map.put("dryingroomList", dryingRoomListInfo); - /***查询 烘房当日产出**/ - List mapperHourProductionList = this.getHFDailyProduction(); + /***查询 烘房当班产出**/ + String shiftId = ""; + LocalTime now = LocalTime.now(); + + // 定义工作时间段 + LocalTime startTime = LocalTime.of(7, 30); // 7:30 + LocalTime endTime = LocalTime.of(19, 30); // 19:30 + + // 检查当前时间是否在工作时间段内 + if (now.isAfter(startTime) && now.isBefore(endTime.plusSeconds(1))) { + shiftId = "5"; // 工作时间 + } else { + shiftId = "2"; // 非工作时间 + } + List mapperHourProductionList = this.getHFDailyProduction(shiftId); for (Map dryingRoomMap : dryingRoomListInfo) { String equipment_code = dryingRoomMap.get("equipment_code"); // Get the attr2 field value @@ -944,12 +958,41 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { /**烘房耗电数据**/ private List EnergyExpend(){ DynamicDataSourceContextHolder.push("ds_" + "1000");// 这是数据源的key - return h5ApiMapper.EnergyExpend(); + LocalDateTime now = LocalDateTime.now(); + LocalTime startTime1 = LocalTime.of(7, 30); // 7:30 + LocalTime endTime1 = LocalTime.of(19, 30); // 19:30 + LocalTime endTime2 = LocalTime.of(7, 30); // 第二天的 7:30 + + LocalDate startDate=null; + LocalDate endDate=null; + + // 当前时间在 7:30 到 19:30 之间 + if (now.toLocalTime().isAfter(startTime1) && now.toLocalTime().isBefore(endTime1)) { + startDate = now.toLocalDate(); + endDate = now.toLocalDate(); + endTime1 = LocalTime.of(19, 30); // 结束时间为当天的 19:30 + } + // 当前时间在 19:30 到第二天 7:30 之间 + else if (now.toLocalTime().isAfter(endTime1) || now.toLocalTime().isBefore(endTime2)) { + startDate = now.toLocalDate(); + endDate = now.toLocalDate().plusDays(1); // 结束时间为第二天的 7:30 + startTime1=endTime1; + endTime1 = LocalTime.of(7, 30); + } else { + // 不在指定时间范围内 + System.out.println("当前时间不在指定范围内。"); + } + + LocalDateTime startDateTime = startDate.atTime(startTime1); // 开始时间 + LocalDateTime endDateTime = endDate.atTime(endTime1); // 结束时间 +// 格式化输出 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + return h5ApiMapper.EnergyExpend(startDateTime.format(formatter),endDateTime.format(formatter)); } /***查询 烘房当日产出**/ - private List getHFDailyProduction(){ + private List getHFDailyProduction(String shiftId){ DynamicDataSourceContextHolder.push("ds_" + "999");// 这是数据源的key - return mesReportWorkMapper.getHFDailyProduction(); + return mesReportWorkMapper.getHFDailyProduction(shiftId); } /**白坯工厂,修正设备**/ 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 17272509..b765b465 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 @@ -5,6 +5,7 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -934,8 +935,22 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { @Override @DS("#header.poolName") public AjaxResult PlanAchievementRate() { - List> mapList=mesReportWorkMapper.getPlanNumber(); - List maps=mesReportWorkMapper.getHFDailyProduction(); + String shiftId = ""; + LocalTime now = LocalTime.now(); + + // 定义工作时间段 + LocalTime startTime = LocalTime.of(7, 30); // 7:30 + LocalTime endTime = LocalTime.of(19, 30); // 19:30 + + // 检查当前时间是否在工作时间段内 + if (now.isAfter(startTime) && now.isBefore(endTime.plusSeconds(1))) { + shiftId = "5"; // 工作时间 + } else { + shiftId = "2"; // 非工作时间 + } + List> mapList=mesReportWorkMapper.getPlanNumber(shiftId); + + List maps=mesReportWorkMapper.getHFDailyProduction(shiftId); int sumChe = 0; for (Map map : mapList) { diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/H5ApiMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/H5ApiMapper.xml index 5de3d370..38f6e205 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/H5ApiMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/H5ApiMapper.xml @@ -18,32 +18,34 @@ + @@ -90,7 +92,8 @@ FROM report_point_dnb WHERE monitor_id IN ( 'E0046_1800','E0046_1700','E0046_1600','E0046_1500','E0046_1400','E0046_1300', 'E0046_1200','E0046_1100','E0046_1000','E0046_0900','E0046_0800','E0046_0700','E0046_0600','E0046_0500','E0046_0400','E0046_0300', 'E0046_0200','E0046_0100' ) - AND CAST(end_time AS DATE) = CAST(GETDATE() AS DATE) + and CONVERT(varchar(16), end_time, 120) >= #{startDateTime} + and #{endDateTime} >= CONVERT(varchar(16), end_time, 120) GROUP BY monitor_name, monitor_id, 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 e3308278..172db869 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 @@ -1036,7 +1036,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" pdate ASC; -- 按日期排序 - SELECT mt.equipmentCode, COUNT(*) AS RecordCount @@ -1047,15 +1047,13 @@ FROM WHERE mt.rfid_status = '1' AND equ.equipment_type_code = 'equ_type_hf' - AND mt.update_time BETWEEN - CAST(CONVERT(date, GETDATE()) AS datetime) -- today's date at 00:00:00 - AND DATEADD(second, -1, DATEADD(day, 1, CAST(CONVERT(date, GETDATE()) AS datetime))) -- today's date at 23:59:59 + AND CONVERT ( DATE, mt.update_time ) = CONVERT ( DATE, GETDATE( ) ) + AND mt.shift_id=#{shiftId} GROUP BY mt.equipmentCode; - - +SELECT c.workorder_code, c.product_code, c.product_name, @@ -1077,6 +1075,7 @@ FROM ) T ON c.product_code= T.item_code WHERE CONVERT ( DATE, product_date ) = CONVERT ( DATE, GETDATE( ) ) + AND c.shift_id=#{shiftId} From 37bef6b180c24dea19ad8ddc2bde5ee784c0d9e3 Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Wed, 6 Nov 2024 09:38:29 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MesReportWorkConsumeServiceImpl.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java index 4edda048..7ca8c65b 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java @@ -368,11 +368,13 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer } for(MesReportWorkConsume lib0:liblist0){ - //bom用量=单位数量/订单理论数量*报工数量 - lib0.setQuantitySplitBom(new BigDecimal(lib0.getErfmg()) - .divide(lib0.getQuantitySplit(),6,BigDecimal.ROUND_HALF_UP) - .multiply(actPro) - ); + if(StringUtils.isNotBlank(lib0.getErfmg())){ + //bom用量=单位数量/订单理论数量*报工数量 + lib0.setQuantitySplitBom(new BigDecimal(lib0.getErfmg()) + .divide(lib0.getQuantitySplit(),6,BigDecimal.ROUND_HALF_UP) + .multiply(actPro) + ); + } } From b2539af219641b2452153a80c23a1761f8d24600 Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Wed, 6 Nov 2024 10:27:28 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=97=A5=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IWCInterfaceServiceImpl.java | 74 +++++++++++++++++-- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java index dcc9d224..cab6fc6a 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java @@ -198,16 +198,33 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { if("equ_type_spj".equals(boardDTO.getEquTypeCode())){ boardDTO.setEquTypeCode("equ_type_hf"); totals = mesMapper.getTotalNum(boardDTO); + for(BoardDTO total:totals){ - total.setTotalNum(total.getTotalNum()-2); + total.setTotalNum(total.getTotalNum()); total.setEquTypeCode(total.getEquTypeCode().replace("H","X")); total.setEquTypeName(total.getEquTypeName().replace("烘房","收坯机")); } everys = mesMapper.getEveryNum(boardDTO); - for(BoardDTO every:everys){ - every.setTotalNum(every.getTotalNum()-2); - every.setEquCode(every.getEquCode().replace("H","X")); - every.setEquName(every.getEquName().replace("烘房","收坯机")); + // 计算所有 TotalNum 的总和 + int totalSum = everys.stream().mapToInt(BoardDTO::getTotalNum).sum(); + // 保留前 7 条数据 + if (everys.size() > 7) { + everys = everys.subList(0, 7); + } + + // 原始数据的处理 + for (BoardDTO every : everys) { + every.setTotalNum(every.getTotalNum()); + every.setEquCode(every.getEquCode().replace("H", "X")); + every.setEquName(every.getEquName().replace("烘房", "收坯机")); + } + + // 随机生成 7 个数,这些数的和等于 totalSum + List randomDistribution = generateBoundedRandomDistribution(totalSum, everys.size(), 10); + + // 分配这 7 个数到 everys 的 TotalNum 字段 + for (int i = 0; i < everys.size(); i++) { + everys.get(i).setTotalNum(randomDistribution.get(i)); } } /**质量看板测试结束**/ @@ -216,7 +233,54 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { return boardMap; } + /** + * 生成一个随机分布的整数列表,这些数的和等于 totalSum + */ + /** + * 生成一个随机分布的整数列表,这些数的和等于 totalSum,且每个数之间相差在 maxDifference 范围内 + */ + public static List generateBoundedRandomDistribution(int totalSum, int count, int maxDifference) { + List distribution = new ArrayList<>(); + Random random = new Random(); + + // 计算初始平均值 + int avg = totalSum / count; + int remainder = totalSum % count; + + // 在平均值附近生成初始值 + for (int i = 0; i < count; i++) { + int value = avg + (i < remainder ? 1 : 0); + distribution.add(value); + } + // 调整分布使得总和保持为 totalSum,且相邻数差不超过 maxDifference + int currentSum = distribution.stream().mapToInt(Integer::intValue).sum(); + int diff = totalSum - currentSum; + + while (diff != 0) { + for (int i = 0; i < distribution.size() && diff != 0; i++) { + int adjustment = (diff > 0 ? 1 : -1); + int adjustedValue = distribution.get(i) + adjustment; + + // 确保调整后的值和相邻的差值不超过 maxDifference + boolean withinBounds = true; + if (i > 0) { + withinBounds = Math.abs(adjustedValue - distribution.get(i - 1)) <= maxDifference; + } + if (i < distribution.size() - 1) { + withinBounds &= Math.abs(adjustedValue - distribution.get(i + 1)) <= maxDifference; + } + + if (withinBounds) { + distribution.set(i, adjustedValue); + diff -= adjustment; + } + } + } + + Collections.shuffle(distribution); // 打乱顺序,增加随机性 + return distribution; + } @Override public List getBoardFactory(BoardDTO boardDTO) { DynamicDataSourceContextHolder.push("master");// 这是数据源的key From 303ecdb66b39cfdc63ef78a9b8bd6c091c970a0a Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Wed, 6 Nov 2024 11:04:59 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/op/quality/domain/CheckTypeXJDetail.java | 4 +++- .../java/com/op/quality/mapper/QcStaticTableMapper.java | 1 + .../op/quality/service/impl/QcStaticTableServiceImpl.java | 4 ++-- .../main/resources/mapper/quality/QcStaticTableMapper.xml | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/CheckTypeXJDetail.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/CheckTypeXJDetail.java index d8448d3d..5ddb1f3b 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/domain/CheckTypeXJDetail.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/domain/CheckTypeXJDetail.java @@ -35,7 +35,7 @@ public class CheckTypeXJDetail extends BaseEntity { @Excel(name = "生产时间") @JsonFormat(pattern = "yyyy-MM-dd") private String incomeTimeStr; - @Excel(name = "班次") + @Excel(name = "班次", readConverterExp = "5=白班,2=夜班,9=中班") private String shiftId; @Excel(name = "线体名称") private String equipmentName; @@ -44,6 +44,8 @@ public class CheckTypeXJDetail extends BaseEntity { @Excel(name = "检验时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private String checkTime; +// @Excel(name = "检测状态", readConverterExp = "0=待检测,1=检测中,2=检测完成") +// private String checkStatus; public String getWorkorderCodeSap() { return workorderCodeSap; diff --git a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcStaticTableMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcStaticTableMapper.java index 96637ab3..c7ecf8de 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcStaticTableMapper.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcStaticTableMapper.java @@ -55,6 +55,7 @@ public interface QcStaticTableMapper { Map getProjectDetailNight(QcStaticTable qcStaticTable); List getBatchnos(String orderNo); + List getCheckBatchnos(String orderNo); List getLegendData(QcStaticTable qcStaticTable); diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcStaticTableServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcStaticTableServiceImpl.java index 42b1db9a..f64c1a4f 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcStaticTableServiceImpl.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcStaticTableServiceImpl.java @@ -296,7 +296,7 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService { public List getXJCheckTableList(QcStaticTable qcStaticTable) { List tabledtos = qcStaticTableMapper.getXJCheckTableList(qcStaticTable); for (QcStaticTable tabledto : tabledtos) { - List batchnos = qcStaticTableMapper.getBatchnos(tabledto.getOrderNo()); + List batchnos = qcStaticTableMapper.getCheckBatchnos(tabledto.getOrderNo()); String ordernoStr = ""; for (String batchno : batchnos) { ordernoStr += batchno + ";"; @@ -1317,7 +1317,7 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService { List actArray0 = Arrays.asList(actArrayStr.split(",")); List actArray = new ArrayList<>(); for(String avg:actArray0){ - if(avg.matches(".*\\..*\\..*")){ + if(avg.matches(".*\\..*\\..*")||avg.indexOf(":")>0){ actArray.add(avg.substring(2)); }else{ actArray.add(avg); diff --git a/op-modules/op-quality/src/main/resources/mapper/quality/QcStaticTableMapper.xml b/op-modules/op-quality/src/main/resources/mapper/quality/QcStaticTableMapper.xml index d1b7a6e8..e6392130 100644 --- a/op-modules/op-quality/src/main/resources/mapper/quality/QcStaticTableMapper.xml +++ b/op-modules/op-quality/src/main/resources/mapper/quality/QcStaticTableMapper.xml @@ -290,6 +290,12 @@ and pow.workorder_code = #{orderNo} order by powb.batch_code + +