| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.mdc.constant.MdcConstant; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; |
| | |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.MdcOverallEquipmentEfficiencyVo; |
| | | import org.jeecg.modules.mdc.vo.OeeStatisticsChartVo; |
| | | import org.jeecg.modules.mdc.vo.OeeStatisticsVo; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.YearMonth; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author: LiuS |
| | |
| | | return mdcOverallEquipmentEfficiencyIPage; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param date |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<OeeStatisticsVo> oeeStatisticsList(String date) { |
| | | List<OeeStatisticsVo> result = new ArrayList<>(); |
| | | if (StringUtils.isEmpty(date)) { |
| | | date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1)); |
| | | } |
| | | List<MdcProduction> mdcProductionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, 2).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0)); |
| | | if (mdcProductionList != null && !mdcProductionList.isEmpty()) { |
| | | for (MdcProduction mdcProduction : mdcProductionList) { |
| | | OeeStatisticsVo oeeStatisticsVo = new OeeStatisticsVo(); |
| | | oeeStatisticsVo.setProductionName(mdcProduction.getProductionName()); |
| | | List<MdcOverallEquipmentEfficiency> mdcOverallEquipmentEfficiencyList = this.baseMapper.findOeeByDate(date, mdcProduction.getId()); |
| | | if (mdcOverallEquipmentEfficiencyList != null && !mdcOverallEquipmentEfficiencyList.isEmpty()) { |
| | | for (MdcOverallEquipmentEfficiency mdcOverallEquipmentEfficiency : mdcOverallEquipmentEfficiencyList) { |
| | | int oee = mdcOverallEquipmentEfficiency.getOverallEquipmentEfficiency().multiply(new BigDecimal("10000")).intValue(); |
| | | if (oee < 500) { |
| | | oeeStatisticsVo.setLevel1(oeeStatisticsVo.getLevel1() + 1); |
| | | } else if (oee >= 500 && oee < 1000) { |
| | | oeeStatisticsVo.setLevel2(oeeStatisticsVo.getLevel2() + 1); |
| | | } else if (oee >= 1000 && oee < 3000) { |
| | | oeeStatisticsVo.setLevel3(oeeStatisticsVo.getLevel3() + 1); |
| | | } else if (oee >= 3000 && oee < 6000) { |
| | | oeeStatisticsVo.setLevel4(oeeStatisticsVo.getLevel4() + 1); |
| | | } else if (oee >= 6000) { |
| | | oeeStatisticsVo.setLevel5(oeeStatisticsVo.getLevel5() + 1); |
| | | } |
| | | } |
| | | } |
| | | result.add(oeeStatisticsVo); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param date |
| | | * @param equipmentType |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<OeeStatisticsChartVo> oeeStatisticsChart(String date, String equipmentType) { |
| | | List<OeeStatisticsChartVo> result = new ArrayList<>(); |
| | | if (StringUtils.isEmpty(date)) { |
| | | date = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDate.now().plusMonths(-1)); |
| | | } |
| | | List<MdcProduction> mdcProductionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, 2).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0)); |
| | | if (mdcProductionList != null && !mdcProductionList.isEmpty()) { |
| | | for (MdcProduction mdcProduction : mdcProductionList) { |
| | | OeeStatisticsChartVo oeeStatisticsChartVo = new OeeStatisticsChartVo(); |
| | | oeeStatisticsChartVo.setKey(mdcProduction.getProductionName()); |
| | | BigDecimal oee = this.baseMapper.findAvgOee(date, equipmentType, mdcProduction.getId()); |
| | | if (oee != null) { |
| | | oeeStatisticsChartVo.setValue(oee); |
| | | } |
| | | result.add(oeeStatisticsChartVo); |
| | | } |
| | | } |
| | | if (!result.isEmpty()) { |
| | | result = result.stream().sorted(Comparator.comparing(OeeStatisticsChartVo::getValue)).collect(Collectors.toList()); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 递归查询设备车间名称 |