| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.ansteel.api.dao.MainProcessIndexDayDao; |
| | | import com.iailab.module.ansteel.api.dao.MainProcessIndexTeamDao; |
| | | import com.iailab.module.ansteel.api.dao.PowerRunStateDao; |
| | | import com.iailab.module.ansteel.api.dto.*; |
| | | import com.iailab.module.ansteel.api.service.DataApi; |
| | |
| | | @Autowired |
| | | private PowerRunStateDao powerRunStateDao; |
| | | |
| | | @Autowired |
| | | private MainProcessIndexDayDao mainProcessIndexDayDao; |
| | | |
| | | @Autowired |
| | | private MainProcessIndexTeamDao mainProcessIndexTeamDao; |
| | | |
| | | @Override |
| | | public List<PowerRunStateDTO> getPowerRunState() { |
| | | List<PowerRunStateDTO> list = ConvertUtils.sourceToTarget(powerRunStateDao.selectList(new QueryWrapper<>()), PowerRunStateDTO.class); |
| | |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<MainProcessIndexDTO> getIndexList(Map<String, Object> params) { |
| | | List<MainProcessIndexDTO> list = new ArrayList<>(); |
| | | if("day".equals(params.get("type"))) { |
| | | list = ConvertUtils.sourceToTarget(mainProcessIndexDayDao.selectList(new QueryWrapper<>()), MainProcessIndexDTO.class); |
| | | }else if("team".equals(params.get("type"))){ |
| | | list = ConvertUtils.sourceToTarget(mainProcessIndexTeamDao.selectList(new QueryWrapper<>()), MainProcessIndexDTO.class); |
| | | } |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | list.stream().map(item -> { |
| | | StringBuffer sb = new StringBuffer(); |
| | | sb.append(item.getHisAvg()); |
| | | sb.append(","); |
| | | sb.append(item.getTheory()); |
| | | sb.append(","); |
| | | sb.append(item.getActual()); |
| | | sb.append(","); |
| | | sb.append(item.getRealData()); |
| | | String[] arr = sb.toString().split(","); |
| | | Map<String, Object> adjValue = dataPointApi.queryPointsRealValue(Arrays.asList(arr)); |
| | | item.setHisAvg(ObjectUtils.isEmpty(adjValue.get(arr[0])) ? "0" : new BigDecimal(adjValue.get(arr[0]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | item.setTheory(ObjectUtils.isEmpty(adjValue.get(arr[1])) ? "0" : new BigDecimal(adjValue.get(arr[1]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | item.setActual(ObjectUtils.isEmpty(adjValue.get(arr[2])) ? "0" : new BigDecimal(adjValue.get(arr[2]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | item.setRealData(ObjectUtils.isEmpty(adjValue.get(arr[3])) ? "0" : new BigDecimal(adjValue.get(arr[3]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | |
| | | return item; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean useSuggest(StAlarmAndSuggestReqVO ReqVO) { |
| | | return mcsApi.useSuggest(ReqVO); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }); |
| | | preDataView.setTrendsDataL(newList); |
| | | } |
| | | MmItemOutputDTO outputDTO = mcsApi.getItemOutputByItemid(predictItem.getId(), resultStr, resultIndex); |
| | | |
| | | PreItemResultReqVO preItemResultReqVO = new PreItemResultReqVO(); |
| | | preItemResultReqVO.setOutputid(outputDTO.getId()); |
| | | preItemResultReqVO.setStartTime(startTime); |
| | | preItemResultReqVO.setEndTime(endTime); |
| | | preItemResultReqVO.setTimeFormat(timeFormat); |
| | | |
| | | preDataView.setPreData(resultOld.getDataView().getPreDataL()); |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | private Date[] calResultTime2(Date predictTimeReq,String startTimeReq, String endTimeReq, int lengthLeft, int lengthRight) { |
| | | Date[] result = new Date[2]; |
| | | Date predictTime = predictTimeReq; |
| | | Date startTime = new Date(); |
| | | if (startTimeReq == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictTime); |
| | | calendar.add(Calendar.SECOND, -1 * lengthLeft * 60); |
| | | startTime = calendar.getTime(); |
| | | } |
| | | Date endTime = new Date(); |
| | | if (endTimeReq == null) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(predictTime); |
| | | calendar.add(Calendar.SECOND, lengthRight * 60); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | if (endTime.getTime() <= startTime.getTime()) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | calendar.add(Calendar.SECOND, lengthRight * 60); |
| | | endTime = calendar.getTime(); |
| | | } |
| | | result[0] = startTime; |
| | | result[1] = endTime; |
| | | return result; |
| | | } |
| | | /** |
| | | * 查询原始计划、修正计划数据 |
| | | */ |
| | |
| | | list.forEach(item -> { |
| | | tMap.put(item.getParamCode(), item.getParamValue()); |
| | | }); |
| | | String planCode = tMap.get(CommonConstant.PLAN_CODE); |
| | | if (planCode == null) { |
| | | return null; |
| | | } |
| | | String itemCode = tMap.get(CommonConstant.ITEM_CODE); |
| | | if (itemCode == null) { |
| | | return null; |
| | | } |
| | | |
| | | PreDataSingleChartReqVO queryDto = new PreDataSingleChartReqVO(); |
| | | queryDto.setChartCode(reqVO.getChartCode()); |
| | | PreDataSingleChartRespVO chartData = mcsApi.getPreDataSingleChart(queryDto); |
| | | |
| | | Date predictTime = chartData.getPredictTime(); |
| | | int lengthLeft = new BigDecimal(tMap.get(CommonConstant.LENGTH_LEFT)).intValue(); |
| | | int lengthRight = reqVO.getLengthRight(); |
| | | |
| | | Date[] timeArray = calResultTime2(predictTime, reqVO.getStartTime(), reqVO.getEndTime(), lengthLeft, lengthRight); |
| | | Date startTime = timeArray[0]; |
| | | Date endTime = timeArray[1]; |
| | | Date startTime = chartData.getStartTime(); |
| | | Date endTime = chartData.getEndTime(); |
| | | |
| | | // 原始计划数据 |
| | | LinkedHashMap<String, List<String[]>> planData = getRealPlanData(planCode, startTime, endTime, predictTime); |
| | | LinkedHashMap<String, List<String[]>> planData = getRealPlanData(reqVO.getPlanCodes(), startTime, endTime, predictTime); |
| | | |
| | | // 修正计划数据 |
| | | LinkedHashMap<String, List<String[]>> predData = new LinkedHashMap<>(); |
| | | predData.put(reqVO.getChartCode(), getPrePlanData(reqVO.getChartCode(), predictTime, endTime)); |
| | | for (int i = 0; i < reqVO.getPlanCodes().size(); i++) { |
| | | predData.put(reqVO.getPlanCodes().get(i), getPrePlanData(reqVO.getPlanPreds().get(i), predictTime, endTime)); |
| | | } |
| | | result.put("planData", planData); |
| | | result.put("predData", predData); |
| | | return result; |
| | | } |
| | | |
| | | //原始计划 |
| | | public LinkedHashMap<String, List<String[]>> getRealPlanData(String planCode, Date startTime, Date endTime, Date predictTime) { |
| | | public LinkedHashMap<String, List<String[]>> getRealPlanData(List<String> planCodes, Date startTime, Date endTime, Date predictTime) { |
| | | LinkedHashMap<String, List<String[]>> result = new LinkedHashMap<>(); |
| | | ApiDataQueryDTO apiDataQueryDTO = new ApiDataQueryDTO(); |
| | | List<String> itemList = Arrays.asList(planCode.toString().split(",")); |
| | | apiDataQueryDTO.setItemNos(itemList); |
| | | apiDataQueryDTO.setItemNos(planCodes); |
| | | apiDataQueryDTO.setStart(startTime); |
| | | apiDataQueryDTO.setEnd(endTime); |
| | | LinkedHashMap<String, List<ApiPlanDataDTO>> planData = planItemApi.queryPlanItemRecordValue(apiDataQueryDTO); |