lxzn-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java
@@ -598,4 +598,11 @@ Integer AUTO_FLAG_Y = 1; Integer AUTO_FLAG_N = 2; /** * 停机类型 1(计划停机) 2 (非计划停机) */ String CLOSE_TYPE_1 = "1"; String CLOSE_TYPE_2 = "2"; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
@@ -13,7 +13,6 @@ import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mdc.dto.MdcEquipmentDto; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; import org.jeecg.modules.mdc.model.MdcEquipmentTree; @@ -74,7 +73,6 @@ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { //QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, req.getParameterMap()); Page<MdcEquipment> page = new Page<MdcEquipment>(pageNo, pageSize); IPage<MdcEquipment> pageList = mdcEquipmentService.pageList(page, mdcEquipment, req); @@ -428,7 +426,6 @@ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, MdcEquipmentVo mdcEquipment) { // Step.1 组装查询条件 //QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<MdcEquipment> pageList = mdcEquipmentService.exportXlsList(mdcEquipment); @@ -445,7 +442,6 @@ mv.addObject(NormalExcelConstants.CLASS, MdcEquipment.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); ExportParams exportParams = new ExportParams("设备列表数据", "导出人:" + user.getRealname(), "导出信息"); // exportParams.setImageBasePath(upLoadPath); mv.addObject(NormalExcelConstants.PARAMS, exportParams); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentWorklineMapper.java
@@ -24,19 +24,15 @@ List<MdcEquipmentDto> getMacingDataList(@Param("tableName") String tableName); @InterceptorIgnore(tenantLine = "1") @Select("select Sequencenumber,CollectTime from [${tableName}] " + @Select("select Sequencenumber,CollectTime from ${tableName} " + " where CollectTime > #{startTime} and CollectTime <= #{endTime} and Sequencenumber is not null" + " order by CollectTime desc ") List<Map<String, Object>> getEquipmentSequenceNumber(@Param("tableName") String tableName, @Param("startTime") Date startTime, @Param("endTime") Date endTime); @InterceptorIgnore(tenantLine = "1") @Select("select CollectTime ${columns} from [${tableName}] where CollectTime > #{startTime} and CollectTime <= #{endTime} order by CollectTime asc") @Select("select CollectTime ${columns} from ${tableName} where CollectTime > #{startTime} and CollectTime <= #{endTime} order by CollectTime asc") List<Map<String, Object>> getWorkLineList(Map<String, Object> param); @InterceptorIgnore(tenantLine = "1") @Select("SELECT COUNT(*) FROM SysObjects WHERE XType='U' AND name = '${tableName}'") Integer isTableExist(@Param("tableName") String tableName); @InterceptorIgnore(tenantLine = "1") List<String> findRunningData(@Param("tableName") String saveTableName, @Param("startTime") Date startTime, @Param("endTime") Date endTime); lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalInfoMapper.java
@@ -16,4 +16,13 @@ * 获取设备最新日期的运行数据 */ MdcEquipmentStatisticalInfo getMaxStaticsData(@Param("equipmentId") String equipmentId); /** * 查询设备运行时间 * * @param equipmentId * @param validDate * @return */ Integer selectProcessLong(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPartProcessInfoMapper.java
@@ -22,4 +22,31 @@ * @return */ IPage<MdcPartProcessInfo> pageList(Page<MdcPartProcessInfo> page, @Param("mdcPartProcessInfo") MdcPartProcessInfoVo mdcPartProcessInfo); /** * 查询设备某天总加工时间 * * @param equipmentId * @param validDate * @return */ Integer selectTotalProcessLong(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate); /** * 查询设备某天总加工数量 * * @param equipmentId * @param validDate * @return */ Integer selectTotalProcessCount(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate); /** * 查询设备某天总加工合格数量 * * @param equipmentId * @param validDate * @return */ Integer selectTotalPassCount(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPlanCloseMapper.java
@@ -24,4 +24,14 @@ * @return */ IPage<MdcPlanClose> pageList(Page<MdcPlanClose> page, @Param("mdcPlanClose") MdcPlanCloseVo mdcPlanClose); /** * 计算 计划/非计划停机当天总时长 * * @param equipmentId * @param validDate * @param closeType * @return */ Integer findPlanTimeDuration(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate, @Param("closeType") String closeType); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
@@ -7,4 +7,9 @@ <select id="getMaxStaticsData" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> SELECT TOP 1 * FROM mdc_equipment_statistical_info WHERE equipment_id = #{equipmentId} ORDER BY the_date DESC </select> <!--查询设备运行时间--> <select id="selectProcessLong" resultType="java.lang.Integer"> SELECT TOP 1 process_long FROM mdc_equipment_statistical_info WHERE equipment_id = #{equipmentId} AND the_date = #{validDate} </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPartProcessInfoMapper.xml
@@ -33,4 +33,19 @@ ORDER BY the_date DESC, equipment_id ASC </select> <!--查询设备某天总加工时间--> <select id="selectTotalProcessLong" resultType="java.lang.Integer"> SELECT sum(total_process_long) FROM mdc_part_process_info WHERE equipment_id = #{equipmentId} AND the_date = #{validDate} </select> <!--查询设备某天总加工数量--> <select id="selectTotalProcessCount" resultType="java.lang.Integer"> SELECT sum(process_count) FROM mdc_part_process_info WHERE equipment_id = #{equipmentId} AND the_date = #{validDate} </select> <!--查询设备某天总加工合格数量--> <select id="selectTotalPassCount" resultType="java.lang.Integer"> SELECT sum(pass_count) FROM mdc_part_process_info WHERE equipment_id = #{equipmentId} AND the_date = #{validDate} </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPlanCloseMapper.xml
@@ -33,4 +33,16 @@ </where> ORDER BY the_date DESC, equipment_id ASC </select> <!--计算 计划/非计划停机当天总时长--> <select id="findPlanTimeDuration" resultType="java.lang.Integer"> SELECT sum(plan_close_time_long) FROM mdc_plan_close WHERE equipment_id = #{equipmentId} AND the_date = #{validDate} AND close_type = #{closeType} </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentWorkLineService.java
@@ -23,11 +23,6 @@ List<EquipmentMachingDto> getEquipmentSequencenumber(String tableName, Date startTime, Date endTime); /** * 判断表是否存在 */ Boolean isTableExist(String tableName); /** * 查询一段时间内的数据 */ List<String> findRunningData(String tableName, Date startTime, Date endTime); lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
@@ -17,4 +17,13 @@ * @param dateTime */ void runningAllEquipmentStatisticalProcess(String dateTime); /** * 查询设备运行时间 * * @param equipmentId * @param validDate * @return */ Integer selectProcessLong(String equipmentId, String validDate); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPartProcessInfoService.java
@@ -44,4 +44,30 @@ */ ModelAndView exportXls(String userId, MdcPartProcessInfoVo mdcPartProcessInfo); /** * 查询设备某天总加工时间 * * @param equipmentId * @param validDate * @return */ Integer selectTotalProcessLong(String equipmentId, String validDate); /** * 查询设备某天总加工数量 * * @param equipmentId * @param validDate * @return */ Integer selectTotalProcessCount(String equipmentId, String validDate); /** * 查询设备某天总加工合格数量 * * @param equipmentId * @param validDate * @return */ Integer selectTotalPassCount(String equipmentId, String validDate); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPlanCloseService.java
@@ -18,7 +18,15 @@ */ public interface IMdcPlanCloseService extends IService<MdcPlanClose> { BigDecimal findPlanTimeDuration(BigDecimal actualWorkDayCount, String planCloseType); /** * 计算 计划/非计划停机当天总时长 * * @param equipmentId * @param validDate * @param closeType * @return */ Integer findPlanTimeDuration(String equipmentId, String validDate, String closeType); /** * 分页查询 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentWorkLineServiceImpl.java
@@ -44,12 +44,6 @@ } @Override public Boolean isTableExist(String tableName) { Integer count = equipmentWorkLineMapper.isTableExist(tableName); return count != 0; } @Override public List<String> findRunningData(String tableName, Date startTime, Date endTime) { return equipmentWorkLineMapper.findRunningData(tableName, startTime, endTime); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
@@ -67,17 +67,17 @@ if (!running.isEmpty()) { MdcEquipmentRunningSectionDto dto; String tableName = ""; Boolean isTableExist = false; String backupTableName = ""; if (equip != null) { if (StringUtils.isNotBlank(equip.getDrivetype())) { tableName = equip.getDrivetype() + "_" + equip.getEquipmentid(); isTableExist = equipmentWorkLineService.isTableExist(tableName); backupTableName = equipmentService.checkTableExists(tableName); } } for (MdcEquipmentRunningSection entity : running) { dto = new MdcEquipmentRunningSectionDto(); BeanUtils.copyProperties(entity, dto); if (entity.getStatus() == 3 && StringUtils.isBlank(entity.getSequenceNumber()) && isTableExist && !"ZUOLAN".equals(equip.getDrivetype())) { if (entity.getStatus() == 3 && StringUtils.isBlank(entity.getSequenceNumber()) && StringUtils.isNotBlank(backupTableName) && !"ZUOLAN".equals(equip.getDrivetype())) { List<EquipmentMachingDto> esList = equipmentWorkLineService.getEquipmentSequencenumber(tableName, entity.getStartTime(), entity.getEndTime()); if (esList != null && esList.size() > 1) { dto.setSequenceNumber(esList.get(0).getSequencenumber()); lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -438,16 +438,16 @@ } map.put("value", value); runData.add(map); if ("spindlebeilv".equals(englishName)) { if ("spindlebeilv".equals(englishName) && !"".equals(value)) { result.put("spindlebeilv", value); } if ("feedbeilv".equals(englishName)) { if ("feedbeilv".equals(englishName) && !"".equals(value)) { result.put("feedbeilv", value); } if ("spindleload".equals(englishName)) { if ("spindleload".equals(englishName) && !"".equals(value)) { result.put("spindleload", value); } if ("rapidfeed".equals(englishName)) { if ("rapidfeed".equals(englishName) && !"".equals(value)) { result.put("rapidfeed", value); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import io.swagger.models.auth.In; import org.apache.commons.lang.StringUtils; import org.jeecg.common.system.vo.DictModel; import org.jeecg.modules.mdc.entity.*; @@ -14,6 +15,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; /** @@ -75,6 +77,23 @@ } } /** * 查询设备运行时间 * * @param equipmentId * @param validDate * @return */ @Override public Integer selectProcessLong(String equipmentId, String validDate) { Integer processLong = this.baseMapper.selectProcessLong(equipmentId, validDate); if (processLong == null) { return 0; } else { return Integer.parseInt(new BigDecimal(processLong).divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP).toString()); } } private List<EquipmentStatisticalInfo> dataHandle(List<MdcEquipmentStatisticalInfo> list) { List<EquipmentStatisticalInfo> result = new ArrayList<>(); list.forEach(item -> { lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOeeInfoServiceImpl.java
@@ -6,20 +6,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcOeeInfo; import org.jeecg.modules.mdc.mapper.MdcOeeInfoMapper; import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.mdc.service.IMdcOeeInfoService; import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.vo.MdcOeeInfoVo; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -34,6 +40,15 @@ @Resource private IMdcEquipmentService mdcEquipmentService; @Resource private IMdcPlanCloseService mdcPlanCloseService; @Resource private IMdcPartProcessInfoService mdcPartProcessInfoService; @Resource private IMdcEquipmentStatisticalInfoService mdcEquipmentStatisticalInfoService; /** * 分页列表 @@ -140,10 +155,84 @@ /** * 计算oee * @param dateTime * @param dateTime 参数 */ @Override @Transactional(rollbackFor = Exception.class) public void runningComputeOee(String dateTime) { List<MdcOeeInfo> result = new ArrayList<>(); // 获取有效日期 格式 yyyy-MM-dd String validDate = LocalDate.now().minusDays(1).toString(); if (StringUtils.isNotBlank(dateTime)) { validDate = DateUtils.format(DateUtils.toDate(dateTime, DateUtils.STRDATE), DateUtils.STR_DATE); } try { this.remove(new LambdaQueryWrapper<MdcOeeInfo>().eq(MdcOeeInfo::getTheDate, validDate)); } catch (Exception e) { log.error("参数格式不对", e); } //获取设备列表 List<MdcEquipment> equipmentList = mdcEquipmentService.list(); for (MdcEquipment mdcEquipment : equipmentList) { String equipmentId = mdcEquipment.getEquipmentId(); MdcOeeInfo mdcOeeInfo = new MdcOeeInfo(); // 设备编号 mdcOeeInfo.setEquipmentId(equipmentId); // 计算日期 mdcOeeInfo.setTheDate(validDate); // 工作日历时间(min) --- 按每天24小时算 mdcOeeInfo.setCalendarLong(1440); // 计划停机时间(min) --- 按维护数据统计当天总时长 Integer planCloseLong = mdcPlanCloseService.findPlanTimeDuration(equipmentId, validDate, CommonConstant.CLOSE_TYPE_1); mdcOeeInfo.setPlanCloseLong(planCloseLong); // 负荷时间(min) --- 日历工作时间-计划停机时间 Integer loadLong = mdcOeeInfo.getCalendarLong() - planCloseLong; mdcOeeInfo.setLoadLong(loadLong); // 非计划停机时间(min) --- 按维护数据统计当天总时长 Integer noPlanCloseLong = mdcPlanCloseService.findPlanTimeDuration(equipmentId, validDate, CommonConstant.CLOSE_TYPE_2); mdcOeeInfo.setNoplanCloseLong(noPlanCloseLong); // 开动时间(min) --- 负荷时间-非计划停机时间 int actuateLong = loadLong - noPlanCloseLong; mdcOeeInfo.setActuateLong(actuateLong); // 时间开动率 --- 开动时间/负荷时间 BigDecimal timeActuationRate = new BigDecimal(actuateLong).divide(new BigDecimal(loadLong), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); mdcOeeInfo.setTimeActuationRate(timeActuationRate); // 有效运行时间 --- 按需求维护零件加工总时长||系统主轴负载时间 Integer effectiveRunLong = 0; Integer totalProcessLong = mdcPartProcessInfoService.selectTotalProcessLong(equipmentId, validDate); if (totalProcessLong == 0) { //查询设备运行时间 effectiveRunLong = mdcEquipmentStatisticalInfoService.selectProcessLong(equipmentId, validDate.replace("-", "")); } else { effectiveRunLong = totalProcessLong; } mdcOeeInfo.setEffectiveRunLong(effectiveRunLong); // 性能开动率 --- 有效运行时间/开动时间 BigDecimal performanceRate = BigDecimal.ZERO; if (effectiveRunLong != 0 && actuateLong != 0) { performanceRate = new BigDecimal(effectiveRunLong).divide(new BigDecimal(actuateLong), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); } mdcOeeInfo.setPerformanceRate(performanceRate); // 加工零件数量 --- 按维护数据统计当天 Integer processCount = mdcPartProcessInfoService.selectTotalProcessCount(equipmentId, validDate); mdcOeeInfo.setProcessCount(processCount); // 合格零件数量 --- 按维护数据统计当天 Integer passCount = mdcPartProcessInfoService.selectTotalPassCount(equipmentId, validDate); mdcOeeInfo.setPassCount(passCount); // 合格率 --- 合格数/加工数 BigDecimal passRate = BigDecimal.ZERO; if (processCount != 0 && passCount != 0) { passRate = new BigDecimal(passCount).divide(new BigDecimal(processCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); } mdcOeeInfo.setPassRate(passRate); // OEE --- 时间开动率 * 性能开动率 * 一次合格率 BigDecimal oee = BigDecimal.ZERO; if (!timeActuationRate.equals(BigDecimal.ZERO) && !performanceRate.equals(BigDecimal.ZERO) && !passRate.equals(BigDecimal.ZERO)) { oee = timeActuationRate.multiply(performanceRate).multiply(passRate).divide(new BigDecimal("10000"), 4, RoundingMode.HALF_UP); } mdcOeeInfo.setOee(oee); result.add(mdcOeeInfo); } super.saveBatch(result); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java
@@ -127,33 +127,33 @@ // 月度实际班产总时间(分钟) mdcOverallEquipmentEfficiency.setMonthActualWorkDayTimeCount(mdcOverallEquipmentEfficiency.getShiftTimeCount().multiply(actualWorkDayCount).multiply(new BigDecimal("60")).add(overtime)); // 故障停机时长统计(分钟) BigDecimal breakdownDownDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.BREAKDOWN_DOWN); mdcOverallEquipmentEfficiency.setBreakdownDownDuration(breakdownDownDuration); // 换型调试时长统计(分钟) BigDecimal conversionDebugDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.CONVERSION_DEBUG); mdcOverallEquipmentEfficiency.setConversionDebugDuration(conversionDebugDuration); // 物料短缺时长统计(分钟) BigDecimal materialShortageDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.MATERIAL_SHORTAGE); mdcOverallEquipmentEfficiency.setMaterialShortageDuration(materialShortageDuration); // 计划等任务时长统计(分钟) BigDecimal plannedTaskDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.PLANNED_TASK); mdcOverallEquipmentEfficiency.setPlannedTaskDuration(plannedTaskDuration); // 检验时长统计(分钟) BigDecimal inspectDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.INSPECT); mdcOverallEquipmentEfficiency.setInspectDuration(inspectDuration); // 其他时长统计(分钟) BigDecimal otherDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.OTHER); mdcOverallEquipmentEfficiency.setOtherDuration(otherDuration); // 计划保养时长统计(分钟) BigDecimal plannedMaintenanceDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.PLANNED_MAINTENANCE); mdcOverallEquipmentEfficiency.setPlannedMaintenanceDuration(plannedMaintenanceDuration); // 会议/培训时长统计(分钟) BigDecimal conferenceTrainingDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.CONFERENCE_TRAINING); mdcOverallEquipmentEfficiency.setConferenceTrainingDuration(conferenceTrainingDuration); // 其它休息时长统计(分钟) BigDecimal otherRestDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.OTHER_REST); mdcOverallEquipmentEfficiency.setOtherRestDuration(otherRestDuration); // // 故障停机时长统计(分钟) // BigDecimal breakdownDownDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.BREAKDOWN_DOWN); // mdcOverallEquipmentEfficiency.setBreakdownDownDuration(breakdownDownDuration); // // 换型调试时长统计(分钟) // BigDecimal conversionDebugDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.CONVERSION_DEBUG); // mdcOverallEquipmentEfficiency.setConversionDebugDuration(conversionDebugDuration); // // 物料短缺时长统计(分钟) // BigDecimal materialShortageDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.MATERIAL_SHORTAGE); // mdcOverallEquipmentEfficiency.setMaterialShortageDuration(materialShortageDuration); // // 计划等任务时长统计(分钟) // BigDecimal plannedTaskDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.PLANNED_TASK); // mdcOverallEquipmentEfficiency.setPlannedTaskDuration(plannedTaskDuration); // // 检验时长统计(分钟) // BigDecimal inspectDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.INSPECT); // mdcOverallEquipmentEfficiency.setInspectDuration(inspectDuration); // // 其他时长统计(分钟) // BigDecimal otherDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.OTHER); // mdcOverallEquipmentEfficiency.setOtherDuration(otherDuration); // // 计划保养时长统计(分钟) // BigDecimal plannedMaintenanceDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.PLANNED_MAINTENANCE); // mdcOverallEquipmentEfficiency.setPlannedMaintenanceDuration(plannedMaintenanceDuration); // // 会议/培训时长统计(分钟) // BigDecimal conferenceTrainingDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.CONFERENCE_TRAINING); // mdcOverallEquipmentEfficiency.setConferenceTrainingDuration(conferenceTrainingDuration); // // 其它休息时长统计(分钟) // BigDecimal otherRestDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.OTHER_REST); // mdcOverallEquipmentEfficiency.setOtherRestDuration(otherRestDuration); /* 负荷时间(小时) = 工作日历时间 - 计划停机时间 工作日历时间 = 日历时间 - 法定假日 - 双休日 + 加班时间 @@ -161,78 +161,78 @@ */ // mdcOverallEquipmentEfficiency.getShiftTimeCount() - plannedMaintenanceDuration - conferenceTrainingDuration - otherRestDuration // 负荷时间(分钟) BigDecimal loadTime = mdcOverallEquipmentEfficiency.getMonthActualWorkDayTimeCount().subtract(plannedMaintenanceDuration).subtract(conferenceTrainingDuration).subtract(otherRestDuration); if (loadTime.compareTo(BigDecimal.ZERO) < 0) { loadTime = BigDecimal.ZERO; } mdcOverallEquipmentEfficiency.setLoadTime(loadTime.divide(new BigDecimal("60"), 1, RoundingMode.HALF_UP)); // BigDecimal loadTime = mdcOverallEquipmentEfficiency.getMonthActualWorkDayTimeCount().subtract(plannedMaintenanceDuration).subtract(conferenceTrainingDuration).subtract(otherRestDuration); // if (loadTime.compareTo(BigDecimal.ZERO) < 0) { // loadTime = BigDecimal.ZERO; // } // mdcOverallEquipmentEfficiency.setLoadTime(loadTime.divide(new BigDecimal("60"), 1, RoundingMode.HALF_UP)); // 时间开动率 = 主轴运行时间/负荷时间 // 查询主轴运行时间(分钟) BigDecimal spindleRunDuration = mdcEquipmentStatisticalShiftInfoService.findSpindleRunDuration(equipmentId, validDate); BigDecimal timeActuationRate = BigDecimal.ZERO; if (loadTime.compareTo(BigDecimal.ZERO) == 0) { mdcOverallEquipmentEfficiency.setTimeActuationRate(BigDecimal.ZERO); } else { timeActuationRate = spindleRunDuration.divide(loadTime, 4, RoundingMode.HALF_UP); mdcOverallEquipmentEfficiency.setTimeActuationRate(timeActuationRate); } // BigDecimal spindleRunDuration = mdcEquipmentStatisticalShiftInfoService.findSpindleRunDuration(equipmentId, validDate); // BigDecimal timeActuationRate = BigDecimal.ZERO; // if (loadTime.compareTo(BigDecimal.ZERO) == 0) { // mdcOverallEquipmentEfficiency.setTimeActuationRate(BigDecimal.ZERO); // } else { // timeActuationRate = spindleRunDuration.divide(loadTime, 4, RoundingMode.HALF_UP); // mdcOverallEquipmentEfficiency.setTimeActuationRate(timeActuationRate); // } BigDecimal processQuantity; // 加工零件数(件) processQuantity if ("FANUC".equals(mdcEquipment.getDriveType())) { processQuantity = processCountService.findCount(equipmentId, validDate); } else { processQuantity = mdcPassRateService.findProcessQuantity(equipmentId, validDate); } mdcOverallEquipmentEfficiency.setProcessQuantity(processQuantity); // BigDecimal processQuantity; // // 加工零件数(件) processQuantity // if ("FANUC".equals(mdcEquipment.getDriveType())) { // processQuantity = processCountService.findCount(equipmentId, validDate); // } else { // processQuantity = mdcPassRateService.findProcessQuantity(equipmentId, validDate); // } // mdcOverallEquipmentEfficiency.setProcessQuantity(processQuantity); // // // 标准加工时间(分钟) // MdcStandardProcessDuration mdcStandardProcessDuration = mdcStandardProcessDurationService.getOne(new LambdaQueryWrapper<MdcStandardProcessDuration>().eq(MdcStandardProcessDuration::getEquipmentId, equipmentId)); // if (mdcStandardProcessDuration != null) { // mdcOverallEquipmentEfficiency.setStandardProcessDuration(new BigDecimal(mdcStandardProcessDuration.getDuration()).multiply(processQuantity)); // } else { // mdcOverallEquipmentEfficiency.setStandardProcessDuration(BigDecimal.ZERO); // } // 标准加工时间(分钟) MdcStandardProcessDuration mdcStandardProcessDuration = mdcStandardProcessDurationService.getOne(new LambdaQueryWrapper<MdcStandardProcessDuration>().eq(MdcStandardProcessDuration::getEquipmentId, equipmentId)); if (mdcStandardProcessDuration != null) { mdcOverallEquipmentEfficiency.setStandardProcessDuration(new BigDecimal(mdcStandardProcessDuration.getDuration()).multiply(processQuantity)); } else { mdcOverallEquipmentEfficiency.setStandardProcessDuration(BigDecimal.ZERO); } if ("FANUC".equals(mdcEquipment.getDriveType())) { // (新)性能开动率 = 理论标准加工时长 * 件数 /(主轴运行时间) // 查询法兰克设备标准加工时长(秒) BigDecimal duration = processCountService.findDuration(mdcEquipment.getEquipmentId(), validDate); if (spindleRunDuration.compareTo(BigDecimal.ZERO) != 0 && duration.compareTo(BigDecimal.ZERO) != 0) { mdcOverallEquipmentEfficiency.setStandardProcessDuration(duration.divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP)); BigDecimal performanceRate = duration.divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP).divide(spindleRunDuration, 4, RoundingMode.HALF_UP); if (performanceRate.compareTo(BigDecimal.ONE) == 1) { performanceRate = new BigDecimal("0.95").add(BigDecimal.valueOf(Math.random() * 5).divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP)); } mdcOverallEquipmentEfficiency.setPerformanceRate(performanceRate); } else { mdcOverallEquipmentEfficiency.setPerformanceRate(BigDecimal.ZERO); } } else { // (旧)性能开动率 = 主轴运行时间/负荷时间 if (loadTime.compareTo(BigDecimal.ZERO) != 0) { mdcOverallEquipmentEfficiency.setPerformanceRate(spindleRunDuration.divide(loadTime, 4, RoundingMode.HALF_UP)); } else { mdcOverallEquipmentEfficiency.setPerformanceRate(BigDecimal.ZERO); } } // if ("FANUC".equals(mdcEquipment.getDriveType())) { // // (新)性能开动率 = 理论标准加工时长 * 件数 /(主轴运行时间) // // 查询法兰克设备标准加工时长(秒) // BigDecimal duration = processCountService.findDuration(mdcEquipment.getEquipmentId(), validDate); // if (spindleRunDuration.compareTo(BigDecimal.ZERO) != 0 && duration.compareTo(BigDecimal.ZERO) != 0) { // mdcOverallEquipmentEfficiency.setStandardProcessDuration(duration.divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP)); // BigDecimal performanceRate = duration.divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP).divide(spindleRunDuration, 4, RoundingMode.HALF_UP); // if (performanceRate.compareTo(BigDecimal.ONE) == 1) { // performanceRate = new BigDecimal("0.95").add(BigDecimal.valueOf(Math.random() * 5).divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP)); // } // mdcOverallEquipmentEfficiency.setPerformanceRate(performanceRate); // } else { // mdcOverallEquipmentEfficiency.setPerformanceRate(BigDecimal.ZERO); // } // } else { // // (旧)性能开动率 = 主轴运行时间/负荷时间 // if (loadTime.compareTo(BigDecimal.ZERO) != 0) { // mdcOverallEquipmentEfficiency.setPerformanceRate(spindleRunDuration.divide(loadTime, 4, RoundingMode.HALF_UP)); // } else { // mdcOverallEquipmentEfficiency.setPerformanceRate(BigDecimal.ZERO); // } // } // 废品数 unqualifiedQuantity BigDecimal unqualifiedQuantity = mdcPassRateService.findUnqualifiedQuantity(equipmentId, validDate); mdcOverallEquipmentEfficiency.setUnqualifiedQuantity(unqualifiedQuantity); // 合格率 if (processQuantity.compareTo(BigDecimal.ZERO) == 0) { mdcOverallEquipmentEfficiency.setPassRate(BigDecimal.ONE); } else { mdcOverallEquipmentEfficiency.setPassRate((processQuantity.subtract(unqualifiedQuantity)).divide(processQuantity, 4, RoundingMode.HALF_UP)); } // 设备综合效率 = 时间开动率 × 性能开动率 × 合格品率 mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(timeActuationRate.multiply(mdcOverallEquipmentEfficiency.getPerformanceRate()).multiply(mdcOverallEquipmentEfficiency.getPassRate()).setScale(4, RoundingMode.HALF_UP)); if (mdcOverallEquipmentEfficiency.getOverallEquipmentEfficiency().compareTo(BigDecimal.ZERO) == 0) { mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(BigDecimal.ZERO); } // BigDecimal unqualifiedQuantity = mdcPassRateService.findUnqualifiedQuantity(equipmentId, validDate); // mdcOverallEquipmentEfficiency.setUnqualifiedQuantity(unqualifiedQuantity); // // 合格率 // if (processQuantity.compareTo(BigDecimal.ZERO) == 0) { // mdcOverallEquipmentEfficiency.setPassRate(BigDecimal.ONE); // } else { // mdcOverallEquipmentEfficiency.setPassRate((processQuantity.subtract(unqualifiedQuantity)).divide(processQuantity, 4, RoundingMode.HALF_UP)); // } // // // 设备综合效率 = 时间开动率 × 性能开动率 × 合格品率 // mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(timeActuationRate.multiply(mdcOverallEquipmentEfficiency.getPerformanceRate()).multiply(mdcOverallEquipmentEfficiency.getPassRate()).setScale(4, RoundingMode.HALF_UP)); // if (mdcOverallEquipmentEfficiency.getOverallEquipmentEfficiency().compareTo(BigDecimal.ZERO) == 0) { // mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(BigDecimal.ZERO); // } result.add(mdcOverallEquipmentEfficiency); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPartProcessInfoServiceImpl.java
@@ -142,7 +142,7 @@ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<MdcPartProcessInfo> mdcPartProcessInfos = this.baseMapper.selectList(queryWrapper); // 导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "零件加工数据列表"); mv.addObject(NormalExcelConstants.FILE_NAME, "零件加工数据列表"); mv.addObject(NormalExcelConstants.CLASS, MdcPartProcessInfo.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("零件加工数据列表数据", "导出人:" + user.getRealname(), "零件加工数据")); @@ -150,4 +150,55 @@ mv.addObject(NormalExcelConstants.DATA_LIST, mdcPartProcessInfos); return mv; } /** * 查询设备某天总加工时间 * * @param equipmentId * @param validDate * @return */ @Override public Integer selectTotalProcessLong(String equipmentId, String validDate) { Integer totalProcessLong = this.baseMapper.selectTotalProcessLong(equipmentId, validDate); if (totalProcessLong == null) { return 0; } else { return totalProcessLong; } } /** * 查询设备某天总加工数量 * * @param equipmentId * @param validDate * @return */ @Override public Integer selectTotalProcessCount(String equipmentId, String validDate) { Integer totalProcessCount = this.baseMapper.selectTotalProcessCount(equipmentId, validDate); if (totalProcessCount == null) { return 0; } else { return totalProcessCount; } } /** * 查询设备某天总加工合格数量 * * @param equipmentId * @param validDate * @return */ @Override public Integer selectTotalPassCount(String equipmentId, String validDate) { Integer totalPassCount = this.baseMapper.selectTotalPassCount(equipmentId, validDate); if (totalPassCount == null) { return 0; } else { return totalPassCount; } } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java
@@ -165,28 +165,21 @@ return mv; } /** * 计算 计划/非计划停机当天总时长 * @param equipmentId * @param validDate * @param closeType * @return */ @Override public BigDecimal findPlanTimeDuration(BigDecimal actualWorkDayCount, String planCloseType) { BigDecimal result = new BigDecimal("0"); // List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(new LambdaQueryWrapper<MdcPlanClose>().in(MdcPlanClose::getPlanCloseType, Arrays.asList(planCloseType.split(",")))); // if (mdcPlanCloses != null && !mdcPlanCloses.isEmpty()) { // for (MdcPlanClose mdcPlanClose : mdcPlanCloses) { // switch (mdcPlanClose.getPlanCloseTimeType()) { // case MdcConstant.DAY: // result = result.add(actualWorkDayCount.multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()))); // break; // case MdcConstant.WEEK: // result = result.add(new BigDecimal("4").multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()))); // break; // case MdcConstant.MONTH: // result = result.add(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())); // break; // default: // break; // } // } // } return result; public Integer findPlanTimeDuration(String equipmentId, String validDate, String closeType) { Integer planTimeDuration = this.baseMapper.findPlanTimeDuration(equipmentId, validDate, closeType); if (planTimeDuration == null) { return 0; } else { return planTimeDuration; } } }