From e8ed1a91c77ab62a924f12acd55777f227bacd7e Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期五, 21 十一月 2025 17:15:17 +0800
Subject: [PATCH] 工位组删除后,其下工位移动到默认组
---
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/ProcessParameterServiceImpl.java | 420 +++++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 332 insertions(+), 88 deletions(-)
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/ProcessParameterServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/ProcessParameterServiceImpl.java
index df5260f..d832ade 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/ProcessParameterServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/ProcessParameterServiceImpl.java
@@ -1,13 +1,7 @@
package com.qianwen.smartman.modules.mdc.service.impl;
-import cn.hutool.core.lang.Tuple;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -21,8 +15,29 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.qianwen.core.log.exception.ServiceException;
+import com.qianwen.core.mp.support.Query;
+import com.qianwen.core.oss.model.BladeFile;
+import com.qianwen.core.tool.jackson.JsonUtil;
+import com.qianwen.core.tool.utils.DateUtil;
+import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.common.cache.cps.TimeSliceCache;
import com.qianwen.smartman.common.cache.cps.WorkstationCache;
import com.qianwen.smartman.common.constant.DateConstant;
@@ -31,21 +46,18 @@
import com.qianwen.smartman.common.enums.WcsDataTypeEnums;
import com.qianwen.smartman.common.utils.ListUtils;
import com.qianwen.smartman.common.utils.MessageUtils;
-import com.qianwen.core.log.exception.ServiceException;
-import com.qianwen.core.mp.support.Query;
-import com.qianwen.core.oss.model.BladeFile;
-import com.qianwen.core.tool.jackson.JsonUtil;
-import com.qianwen.core.tool.utils.DateUtil;
-import com.qianwen.core.tool.utils.Func;
-import com.qianwen.smartman.modules.cps.dto.CalendarShiftDTO;
-import com.qianwen.smartman.modules.cps.dto.CalendarShiftTimeSlicesDTO;
-import com.qianwen.smartman.modules.cps.dto.WorkstationWcsDmpDTO;
-import com.qianwen.smartman.modules.cps.entity.GlobalWcs;
-import com.qianwen.smartman.modules.cps.entity.Workstation;
-import com.qianwen.smartman.modules.cps.service.ICalendarService;
-import com.qianwen.smartman.modules.cps.service.IWorkstationService;
-import com.qianwen.smartman.modules.cps.utils.ThrowFun;
-import com.qianwen.smartman.modules.cps.vo.ShiftTimeDetailVO;
+import com.qianwen.smartman.modules.smis.dto.CalendarShiftDTO;
+import com.qianwen.smartman.modules.smis.dto.CalendarShiftTimeSlicesDTO;
+import com.qianwen.smartman.modules.smis.dto.WorkstationWcsDmpDTO;
+import com.qianwen.smartman.modules.smis.entity.GlobalWcs;
+import com.qianwen.smartman.modules.smis.entity.Workstation;
+import com.qianwen.smartman.modules.smis.service.ICalendarService;
+import com.qianwen.smartman.modules.smis.service.IWorkstationService;
+import com.qianwen.smartman.modules.smis.service.WorkstationDatapointsService;
+import com.qianwen.smartman.modules.smis.utils.ThrowFun;
+import com.qianwen.smartman.modules.smis.vo.ShiftTimeDetailVO;
+import com.qianwen.smartman.modules.smis.vo.WorkstationDatapointsVO;
+import com.qianwen.smartman.modules.mdc.dto.DatapointDTO;
import com.qianwen.smartman.modules.mdc.dto.GroupWorkDTO;
import com.qianwen.smartman.modules.mdc.dto.NewParamDTO;
import com.qianwen.smartman.modules.mdc.dto.ParamDTO;
@@ -54,12 +66,12 @@
import com.qianwen.smartman.modules.mdc.dto.ProcessParameterVO;
import com.qianwen.smartman.modules.mdc.dto.ProcessWcsDTO;
import com.qianwen.smartman.modules.mdc.dto.StatusDTO;
-import com.qianwen.smartman.modules.mdc.entity.LastProcessParam;
import com.qianwen.smartman.modules.mdc.entity.WorkstationCollectData;
import com.qianwen.smartman.modules.mdc.enums.ProcessParamEnum;
-import com.qianwen.smartman.modules.mdc.mapper.SuperCollectJsonMapper;
+//import com.qianwen.smartman.modules.mdc.mapper.SuperCollectJsonMapper;
import com.qianwen.smartman.modules.mdc.mapper.SuperProcessParameterMapper;
import com.qianwen.smartman.modules.mdc.service.IProcessParameterService;
+import com.qianwen.smartman.modules.mdc.service.ProcessParameterHelperService;
import com.qianwen.smartman.modules.mdc.utils.ExcelStrategyUtil;
import com.qianwen.smartman.modules.mdc.vo.AllShiftTimeDetail;
import com.qianwen.smartman.modules.mdc.vo.CollectParamResVO;
@@ -72,26 +84,31 @@
import com.qianwen.smartman.modules.mdc.vo.WorkstationShiftSearchVO;
import com.qianwen.smartman.modules.mdc.vo.excel.ProcessParamExcelVO;
import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
+
+import cn.hutool.core.lang.Tuple;
+import cn.hutool.core.util.ObjectUtil;
@Service
public class ProcessParameterServiceImpl implements IProcessParameterService {
private static final Logger log = LoggerFactory.getLogger(ProcessParameterServiceImpl.class);
- private final SuperCollectJsonMapper collectJsonMapper;
- private final IWorkstationService workstationService;
- private final OssBuilder ossBuilder;
- private final SuperProcessParameterMapper parameterMapper;
- private final ICalendarService calendarService;
-
- public ProcessParameterServiceImpl(final SuperCollectJsonMapper collectJsonMapper, final IWorkstationService workstationService, final OssBuilder ossBuilder, final SuperProcessParameterMapper parameterMapper, final ICalendarService calendarService) {
- this.collectJsonMapper = collectJsonMapper;
- this.workstationService = workstationService;
- this.ossBuilder = ossBuilder;
- this.parameterMapper = parameterMapper;
- this.calendarService = calendarService;
- }
-
+ //@Autowired
+ //private SuperCollectJsonMapper collectJsonMapper;
+ @Autowired
+ private IWorkstationService workstationService;
+ @Autowired
+ private OssBuilder ossBuilder;
+ @Autowired
+ private SuperProcessParameterMapper parameterMapper;
+ @Autowired
+ private ICalendarService calendarService;
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
+ @Autowired
+ private WorkstationDatapointsService dpService;
+
+ @Autowired
+ private ProcessParameterHelperService helperService;
+
@Override
public ProcessParameterResVO queryProcessParameterChart(ProcessParameterSearchVO vo) {
ProcessParamEnum methodEnum = vo.getMethodEnum();
@@ -116,6 +133,7 @@
int current = query.getCurrent().intValue();
long startTime = vo.getStartTime().getTime();
long endTime = vo.getEndTime().getTime();
+
String workstationId = vo.getWorkstationId();
Integer flag = vo.getFlag();
String item = vo.getItem();
@@ -124,7 +142,8 @@
if (total == 0) {
return page;
}
- List<ProcessParameterVO> res = this.parameterMapper.pageProcessParameter(Integer.valueOf(size), Integer.valueOf((current - 1) * size), Long.valueOf(startTime), Long.valueOf(endTime), item, workstationId);
+
+ List<ProcessParameterVO> res = this.parameterMapper.pageProcessParameter(size,(current - 1) * size, startTime, endTime, item, workstationId);
Map<String, String> map = getWcsMap();
List<ProcessParameterRealVO> collect = res.stream().map(c -> {
String value;
@@ -138,18 +157,71 @@
page.setRecords(collect);
return page;
}
-
+ /*
@Override
public List<WorkstationWcsDmpDTO> processParam(String workstationId) {
- List<WorkstationWcsDmpDTO> vos =WorkstationCache.getWorkstationWcsList(workstationId).stream().filter((v0) -> {
- return v0.getProcessParameter();
- }).collect(Collectors.toList());
- if (Func.isEmpty(vos)) {
- return Lists.newArrayList();
+
+
+ //鑾峰彇灞曠ず鍦ㄨ繃绋嬪弬鏁颁腑鐨勫彉閲�
+ List<WorkstationWcsDmpDTO> dps = new ArrayList<>();
+ if(ObjectUtil.isEmpty(workstationId)) {
+ return Collections.emptyList();
}
- return vos;
+ WorkstationDatapointsVO dpVo = dpService.getDatapoints(Long.parseLong(workstationId));
+ if(ObjectUtil.isEmpty(dpVo.getDpConfig())) {
+ return Collections.emptyList();
+ }
+
+ JSONArray dpArrJson = JSONArray.parseArray(dpVo.getDpConfig());
+
+ String dpName;
+ JSONObject dp;
+ for(int i=0; i<dpArrJson.size();i++) {
+ dp = dpArrJson.getJSONObject(i);
+
+
+ Boolean isProcessParam = false;
+ if(dp.containsKey("isProcessParam")) {
+ isProcessParam = dp.getBoolean("isProcessParam");
+ }
+ if(!isProcessParam) {
+ //涓嶆槸杩囩▼鍙傛暟鏄剧ず鐨�,璺宠繃
+ continue;
+ }
+ WorkstationWcsDmpDTO dto = new WorkstationWcsDmpDTO();
+ dto.setDescription(dp.getString("dpLabel"));
+
+ dpName = dp.getString("dpName");
+ dto.setName(dpName);
+
+ if("DeviceStatus".equals(dpName)) {
+ dto.setWcsDataType(WcsDataTypeEnums.WcsDataType.STATE.getCode());
+ }else if("Output".equals(dpName)) {
+ dto.setWcsDataType(WcsDataTypeEnums.WcsDataType.YIELD.getCode());
+ }
+ dps.add(dto);
+ }
+ return dps;
}
-
+ */
+ @Override
+ public List<DatapointDTO> processParams(String workstationId) {
+ //鑾峰彇灞曠ず鍦ㄨ繃绋嬪弬鏁颁腑鐨勫彉閲�
+ if(ObjectUtil.isEmpty(workstationId)) {
+ return Collections.emptyList();
+ }
+ WorkstationDatapointsVO dpVo = dpService.getDatapoints(Long.parseLong(workstationId));
+ if(ObjectUtil.isEmpty(dpVo.getDpConfig())) {
+ return Collections.emptyList();
+ }
+
+ //JSONArray dpArrJson = JSONArray.parseArray(dpVo.getDpConfig());
+ List<DatapointDTO> list = JSONObject.parseArray(dpVo.getDpConfig(),DatapointDTO.class);
+
+ return list.stream().filter(dp -> dp.getIsProcessParam()!=null && dp.getIsProcessParam()).collect(Collectors.toList());
+
+ }
+ /*
@Override
public ProParamSheetVO queryProcessParameterSheet(ProcessParameterSearchVO vo, Boolean isFilterProcessParameter) {
ProcessParamEnum methodEnum = vo.getMethodEnum();
@@ -161,8 +233,8 @@
default:
return new ProParamSheetVO();
}
- }
-
+ }*/
+ /*
@Override
public BladeFile exportProcessParam(ProcessParamExcelVO vo) {
try {
@@ -172,13 +244,13 @@
throw new RuntimeException(e);
}
}
-
+ */
@Override
public ShiftTimeVO getShiftTime(ProcessParameterSearchVO vo) {
String workstationId = vo.getWorkstationId();
LocalDate queryTime = vo.getQueryTime();
Integer shift = vo.getShift();
- Workstation workstation = (Workstation) this.workstationService.getById(Long.valueOf(Func.toLong(workstationId)));
+ Workstation workstation = (Workstation) this.workstationService.getById(Func.toLong(workstationId));
return (ShiftTimeVO) Optional.ofNullable(workstation).map(w -> {
CalendarShiftTimeSlicesDTO timeSliceShift = TimeSliceCache.getTimeSliceShift(workstation.getCalendarCode(), queryTime, shift);
return (ShiftTimeVO) Optional.ofNullable(timeSliceShift).map(time -> {
@@ -198,13 +270,16 @@
if (startTime.after(now)) {
return new CollectParamResVO<>();
}
- String workstationId = vo.getWorkstationId();
- List<ProcessParameterVO> processParameterList = getProcessParameterList(startTime, endTime, workstationId, vo.getDmpDTO());
- return getCollectParamResVO(vo.getDmpDTO(), processParameterList);
+
+ Long workstationId = Long.parseLong(vo.getWorkstationId());
+ List<ProcessParameterVO> processParameterList = getProcessParameterList(startTime, endTime, workstationId, vo.getDpDTO());
+ return getCollectParamResVO(vo.getDpDTO(), processParameterList);
}
- private CollectParamResVO<?> getCollectParamResVO(WorkstationWcsDmpDTO dmpDTO, List<ProcessParameterVO> processParameterList) {
- if (WcsDataTypeEnums.WcsDataType.STATE.getCode().equals(dmpDTO.getWcsDataType())) {
+ private CollectParamResVO<?> getCollectParamResVO(DatapointDTO dpDTO, List<ProcessParameterVO> processParameterList) {//WorkstationWcsDmpDTO dmpDTO
+ //鐘舵�佺壒娈婂鐞嗭紵
+ //if (WcsDataTypeEnums.WcsDataType.STATE.getCode().equals(dmpDTO.getWcsDataType())) {//yys
+ if ("DeviceStatus".equals(dpDTO.getDpName())) {//鐘舵�侊紝闇�瑕佺壒娈婂鐞�
Map<String, String> colorMap = Maps.newHashMap();
Map<String, String> nameMap = Maps.newHashMap();
Set<String> codes = Sets.newHashSet();
@@ -217,24 +292,26 @@
return StatusDTO.builder().time(DateUtil.formatDateTime(DateUtil.fromMilliseconds(param.getRealTime().longValue()))).name((String) nameMap.get(param.getValue())).color((String) colorMap.get(param.getValue())).value(param.getValue()).build();
}).collect(Collectors.toList());*/
return CollectParamResVO.<StatusDTO>builder()
- .collectItem(dmpDTO.getDescription())
- .collectRealItem(dmpDTO.getName())
+ .collectItem(dpDTO.getDpLabel())
+ .collectRealItem(dpDTO.getDpName())
.data(list)
.build();
//return CollectParamResVO.builder().collectItem(dmpDTO.getDescription()).collectRealItem(dmpDTO.getName()).data(list).build();
}
+ //绌烘寚閽�
List<ParamDTO> collect = processParameterList.stream().map(param -> ParamDTO.builder().time(DateUtil.formatDateTime(DateUtil.fromMilliseconds(param.getRealTime().longValue()))).value(param.getValue()).build()).collect(Collectors.toList());
+ /*
return CollectParamResVO.<ParamDTO>builder()
.collectItem(dmpDTO.getDescription())
.collectRealItem(dmpDTO.getName())
.data(collect)
.build();
- /*
- List<ParamDTO> collect2 = (List) processParameterList.stream().map(param2 -> {
- return ParamDTO.builder().time(DateUtil.formatDateTime(DateUtil.fromMilliseconds(param2.getRealTime().longValue()))).value(param2.getValue()).build();
- }).collect(Collectors.toList());
- return CollectParamResVO.builder().collectItem(dmpDTO.getDescription()).collectRealItem(dmpDTO.getName()).data(collect2).build();
- */
+ */
+ return CollectParamResVO.<ParamDTO>builder()
+ .collectItem(dpDTO.getDpLabel())
+ .collectRealItem(dpDTO.getDpName())
+ .data(collect)
+ .build();
}
private void buildWcsMap(Map<String, String> colorMap, Map<String, String> nameMap, Set<String> codes) {
@@ -246,13 +323,22 @@
}
}
- private List<ProcessParameterVO> getProcessParameterList(Date startTime, Date endTime, String workstationId, WorkstationWcsDmpDTO dmpDTO) {
- ProcessParameterVO firstStatue = oldFirstStatue(startTime, dmpDTO.getName(), workstationId);
- ProcessParameterVO endStatue = oldLastStatue(endTime, dmpDTO.getName(), workstationId);
- List<ProcessParameterVO> processParameterList = oldOneCollectList(startTime, endTime, dmpDTO.getName(), workstationId);
+ /**
+ * 鑾峰彇杩囩▼鍙傛暟鍒楄〃
+ * @param startTime
+ * @param endTime
+ * @param workstationId
+ * @param dmpDTO
+ * @return
+ */
+ private List<ProcessParameterVO> getProcessParameterList(Date startTime, Date endTime, Long workstationId, DatapointDTO dpDTO) {//WorkstationWcsDmpDTO dmpDTO
+ ProcessParameterVO firstStatue = oldFirstStatue(startTime, dpDTO.getDpName(), workstationId);
+ ProcessParameterVO endStatue = oldLastStatue(endTime, dpDTO.getDpName(), workstationId);
+
+ List<ProcessParameterVO> processParameterList = oldOneCollectList(startTime, endTime, dpDTO.getDpName(), workstationId);
if (Func.isNotEmpty(processParameterList)) {
- if (Func.notNull(firstStatue) && !firstStatue.getRealTime().equals(Long.valueOf(startTime.getTime()))) {
- firstStatue.setRealTime(Long.valueOf(startTime.getTime()));
+ if (Func.notNull(firstStatue) && !firstStatue.getRealTime().equals(startTime.getTime())) {
+ firstStatue.setRealTime(startTime.getTime());
processParameterList.add(0, firstStatue);
}
if (Func.notNull(endStatue) && !endStatue.getRealTime().equals(Long.valueOf(endTime.getTime()))) {
@@ -370,7 +456,7 @@
return entityVO(parameterList, wcs, collectItemMap);
}).orElse(new ProcessParameterResVO());
}
-
+ /*
private ProParamSheetVO buildProcessHourSheet(ProcessParameterSearchVO vo, Boolean isFilterProcessParameter) {
Date startTime = vo.getStartTime();
Date endTime = vo.getEndTime();
@@ -397,8 +483,8 @@
return new ProParamSheetVO();
}
return buildSheetVO(vos, dtoList, wcs, getWcsMap());
- }
-
+ }*/
+ /*
private ProParamSheetVO buildProcessShiftSheet(ProcessParameterSearchVO vo, Boolean isFilterProcessParameter) {
Integer shift = vo.getShift();
LocalDate queryTime = vo.getQueryTime();
@@ -424,8 +510,8 @@
return new ProParamSheetVO();
}
return buildSheetVO(vos, dtoList, wcs, getWcsMap());
- }
-
+ }*/
+ /*
private BladeFile exportByHour(ProcessParamExcelVO vo) throws Exception {
Date startTime = vo.getStartTime();
Date endTime = vo.getEndTime();
@@ -438,7 +524,8 @@
MultipartFile multipartFile = ExcelStrategyUtil.customerStyleExport(fileName, ExcelConstant.SHEET, head, content);
return this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile);
}
-
+ */
+ /*
private List<List<Object>> buildExcelContentByHour(Long workstationId, List<WorkstationWcsDmpDTO> collectItem, Date startTime, Date endTime) {
Workstation workstation = (Workstation) this.workstationService.getById(workstationId);
Map<Long, GroupWorkDTO> groupWorkMap = this.workstationService.queryGroupWorkStation(Lists.newArrayList(new Long[]{workstation.getId()}));
@@ -453,7 +540,7 @@
return Lists.newArrayList();
}
return buildExcelContentByHour(collectItem, parameterList, wcs, workstation, groupName, timeShiftAll);
- }
+ }*/
private List<List<Object>> buildExcelContentByHour(List<WorkstationWcsDmpDTO> collectItem, List<NewParamDTO> parameterList, WorkstationWcsDmpDTO wcs, Workstation workstation, String groupName, List<CalendarShiftDTO> timeShiftAll) {
List<Tuple> times = timeShiftAll.stream().map(calendarShiftDTO -> {
@@ -497,33 +584,52 @@
}
return head;
}
-
+ /*
private List<NewParamDTO> processParameterList(Date startTime, Date endTime, String workstationId) {
return this.collectJsonMapper.queryProcessParameter(workstationId, Long.valueOf(startTime.getTime()), Long.valueOf(endTime.getTime()));
}
-
+ */
private List<ProcessParameterVO> oldProcessParameterList(Date startTime, Date endTime, List<String> collectItems, String workstationId) {
return this.parameterMapper.queryProcessParameter(workstationId, collectItems, Long.valueOf(startTime.getTime()), Long.valueOf(endTime.getTime()));
}
- private ProcessParameterVO oldFirstStatue(Date startTime, String item, String workstationId) {
- ProcessParameterVO vo = this.parameterMapper.oldFirstStatue(workstationId, item, Long.valueOf(startTime.getTime()));
+ private ProcessParameterVO oldFirstStatue(Date startTime, String item, Long workstationId) {
+ //ProcessParameterVO vo = this.parameterMapper.oldFirstStatue(workstationId, item, Long.valueOf(startTime.getTime()));
+ ProcessParameterVO vo = helperService.queryLastParameterLessThenTime(workstationId, item, startTime.getTime());
if (Func.notNull(vo)) {
vo.setCollectItem(item);
}
return vo;
}
- private ProcessParameterVO oldLastStatue(Date endTime, String item, String workstationId) {
- ProcessParameterVO vo = this.parameterMapper.oldLastStatue(workstationId, item, Long.valueOf(endTime.getTime()));
+ /**
+ *
+ * @param endTime
+ * @param item 鏁版嵁鐐瑰悕绉�,濡侽utput
+ * @param workstationId
+ * @return
+ */
+ private ProcessParameterVO oldLastStatue(Date endTime, String item, Long workstationId) {
+ //ProcessParameterVO vo = this.parameterMapper.oldLastStatue(workstationId, item, Long.valueOf(endTime.getTime()));
+ ProcessParameterVO vo = helperService.getLastParameterGreaterThenTime(workstationId, item, endTime.getTime());
if (Func.notNull(vo)) {
vo.setCollectItem(item);
}
return vo;
}
- private List<ProcessParameterVO> oldOneCollectList(Date startTime, Date endTime, String item, String workstationId) {
- return this.parameterMapper.oldOneCollectList(workstationId, item, Long.valueOf(startTime.getTime()), Long.valueOf(endTime.getTime()));
+ /**
+ *
+ * @param startTime
+ * @param endTime
+ * @param item 鏁版嵁鐐瑰悕绉帮紝濡侽utput
+ * @param workstationId
+ * @return
+ */
+ private List<ProcessParameterVO> oldOneCollectList(Date startTime, Date endTime, String item, Long workstationId) {
+ List<ProcessParameterVO> list = this.parameterMapper.oldOneCollectList(workstationId, item, startTime.getTime(), endTime.getTime());
+ list.forEach(p -> {p.setRealTime(p.getTime().getTime());});
+ return list;
}
private ProcessParameterResVO entityVO(List<ProcessParameterVO> dtoList, WorkstationWcsDmpDTO wcs, Map<String, WorkstationWcsDmpDTO> collectItemMap) {
@@ -639,6 +745,7 @@
return vos;
}
+ /*
@Override
public List<WorkstationCollectData> lastParameter(long workstationId) {
//yys
@@ -659,5 +766,142 @@
});
return result;
+ }*/
+
+ /**
+ * 鑾峰彇宸ヤ綅鏈�鏂板弬鏁板��
+ * @param workstationId 宸ヤ綅id
+ * @param item 鍙傛暟鍚嶇О,濡侱eviceStatus/Output
+ * @param time 鏃堕棿锛屽弬鏁板簲灏忎簬璇ユ椂闂�
+ * @return
+ */
+ /*
+ public ProcessParameterVO getLastParameterLessThanTimeOld_notuse(long workstationId,String item,Long time) {
+ //yys
+ LastProcessParam lp = this.parameterMapper.lastParameterLessThanTime(workstationId,item,time);
+ if(lp == null) {
+ return null;
+ }
+ ProcessParameterVO vo = new ProcessParameterVO();
+ //瑙f瀽json涓哄璞″垪琛�
+ JSONObject paramsObj = JSONObject.parseObject(lp.getParamJson());
+
+ if(paramsObj.containsKey(item)) {
+ JSONObject itemObj = paramsObj.getJSONObject(item);
+
+ Long lastTime = itemObj.getLong("time");
+ vo.setTime(new Timestamp(lastTime));
+ vo.setRealTime(lastTime);
+ vo.setValueCollect(itemObj.getString("value"));
+ }
+
+ return vo;
+ }*/
+ @DS("iotdb")
+ public ProcessParameterVO queryLastParameterLessThenTime1(long workstationId,String item,Long time) {
+ /**
+ *tdengine瀹炵幇锛歰ldFirstStatue
+ * select last(ts) as realTime,
+ last(v) as value_collect
+ from iot_data.super_collect_data
+ where n = #{item}
+ and ts < #{startTime}
+ and workstation_id = #{workstationId}
+ */
+ ProcessParameterVO vo = null;
+ String sql ="select max_time(n) as ts,last_value(n) as n,last_value(v) as v,last_value(workstation_id) as workstationId from root.f2.process_param_"+workstationId+"_"+item+" where time<"+time+" align by device limit 1";
+ List<ProcessParameterVO> list = jdbcTemplate.query(sql, new RowMapper<ProcessParameterVO>() {
+
+ @Override
+ public ProcessParameterVO mapRow(ResultSet rs, int rowNum) throws SQLException {
+ ProcessParameterVO p = new ProcessParameterVO();
+ p.setRealTime(rs.getLong("ts"));
+ p.setValueCollect(rs.getString("v"));
+
+ return p;
+ }
+
+ });
+ if(!list.isEmpty()) {
+ vo = list.get(0);
+ }
+ return vo;
+ }
+
+ /**
+ * 鑾峰彇宸ヤ綅鏈�鏂板弬鏁板��(閲囬泦鏃堕棿搴斿ぇ浜庢寚瀹氭椂闂�)
+ * @param workstationId
+ * @param item 鍙傛暟鍚嶇О,濡侱eviceStatus/Output
+ * @param time 鎸囧畾鐨勬椂闂�
+ * @return
+ */
+ @DS("iotdb")
+ public ProcessParameterVO getLastParameterGreaterThenTime1(long workstationId,String item,Long time) {
+ /*
+ oldLastStatue
+ select last(ts) as realTime,
+ last(v) as value_collect
+ from iot_data.super_collect_data
+ where n = #{item}
+ and ts > #{endTime}
+ and workstation_id = #{workstationId}
+ * */
+ /*
+ LastProcessParam lp = this.parameterMapper.lastParameterGreaterThanTime(workstationId,item,time);
+ if(lp == null) {
+ return null;
+ }
+ ProcessParameterVO vo = new ProcessParameterVO();
+ //瑙f瀽json涓哄璞″垪琛�
+ JSONObject paramsObj = JSONObject.parseObject(lp.getParamJson());
+
+ if(paramsObj.containsKey(item)) {
+ JSONObject itemObj = paramsObj.getJSONObject(item);
+
+ Long lastTime = itemObj.getLong("time");
+ vo.setTime(new Timestamp(lastTime));
+ vo.setRealTime(lastTime);
+ vo.setValueCollect(itemObj.getString("value"));
+ }
+
+ return vo;*/
+
+ ProcessParameterVO vo = null;
+ String sql ="select max_time(n) as ts,last_value(n) as n,last_value(v) as v,last_value(workstation_id) as workstationId from root.f2.process_param_"+workstationId+"_"+item+" where time>"+time+" align by device limit 1";
+ List<ProcessParameterVO> list = jdbcTemplate.query(sql, new RowMapper<ProcessParameterVO>() {
+
+ @Override
+ public ProcessParameterVO mapRow(ResultSet rs, int rowNum) throws SQLException {
+ ProcessParameterVO p = new ProcessParameterVO();
+ p.setRealTime(rs.getLong("ts"));
+ p.setValueCollect(rs.getString("v"));
+
+ return p;
+ }
+
+ });
+ if(!list.isEmpty()) {
+ vo = list.get(0);
+ }
+ return vo;
+
+
+ }
+
+ @DS("iotdb")
+ @Override
+ public List<WorkstationCollectData> queryLastParameter(long workstationId) {
+ String sql ="select max_time(n) as ts,last_value(n) as n,last_value(v) as v,last_value(workstation_id) as workstationId from root.f2.process_param_"+workstationId+"_* align by device";
+ List<WorkstationCollectData> list = jdbcTemplate.query(sql, new RowMapper<WorkstationCollectData>() {
+
+ @Override
+ public WorkstationCollectData mapRow(ResultSet rs, int rowNum) throws SQLException {
+ WorkstationCollectData data = WorkstationCollectData.builder().ts(rs.getLong("ts")).n(rs.getString("n")).v(rs.getString("v")).workstationId(workstationId).build();
+
+ return data;
+ }
+
+ });
+ return list;
}
}
--
Gitblit v1.9.3