|
@@ -2,22 +2,28 @@ package com.platform.service.remote.impl;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.common.exception.BusinessException;
|
|
|
+import com.platform.common.util.DateUtils;
|
|
|
import com.platform.common.util.IdGeneratorUtils;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
import com.platform.dao.dto.remote.RemoteOpcLogDTO;
|
|
|
import com.platform.dao.entity.remote.RemoteOpcLog;
|
|
|
import com.platform.dao.mapper.remote.RemoteOpcLogMapper;
|
|
|
import com.platform.dao.mapper.upms.SysDictMapper;
|
|
|
+import com.platform.dao.vo.query.remote.RemoteOpcLogHistoryVO;
|
|
|
import com.platform.dao.vo.query.remote.RemoteOpcLogVO;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import com.platform.service.remote.RemoteOpcLogService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -67,11 +73,64 @@ public class RemoteOpcLogServiceImpl extends BaseServiceImpl<RemoteOpcLogMapper,
|
|
|
LocalDateTime createdTimeStart = createdTimeEnd.plusMinutes(-10);
|
|
|
record.setCreatedTimeStart(createdTimeStart);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return mapper.selectList(record);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<RemoteOpcLogHistoryVO> selectListHistory(RemoteOpcLogDTO remoteOpcLogDTO) {
|
|
|
+ List<RemoteOpcLogHistoryVO> voList = new ArrayList<>();
|
|
|
+ LocalDateTime createdTimeEnd = remoteOpcLogDTO.getCreatedTimeEnd();
|
|
|
+ String timeA = DateUtils.dateToString(createdTimeEnd);
|
|
|
+ int year = createdTimeEnd.getYear();
|
|
|
+ int month = createdTimeEnd.getMonthValue();
|
|
|
+ int day = createdTimeEnd.getDayOfMonth();
|
|
|
+ remoteOpcLogDTO.setYear(year);
|
|
|
+ remoteOpcLogDTO.setMonth(month);
|
|
|
+ remoteOpcLogDTO.setDay(day);
|
|
|
+ remoteOpcLogDTO.setCreatedTimeEnd(null);
|
|
|
+ List<RemoteOpcLogVO> remoteOpcLogList = mapper.selectList(remoteOpcLogDTO);
|
|
|
+ if (!CollectionUtils.isEmpty(remoteOpcLogList)) {
|
|
|
+ if (remoteOpcLogList.size() > 1) {
|
|
|
+ throw new BusinessException("存在重复数据,请联系技术人员: " + year + "," + month + "," + day + "," + remoteOpcLogDTO.getPositionNum());
|
|
|
+ }
|
|
|
+ String timeB = null;
|
|
|
+ if (remoteOpcLogDTO.getSearchType() == 1) {// 1小时
|
|
|
+ LocalDateTime createdTimeStart = createdTimeEnd.plusHours(-1);
|
|
|
+ timeB = DateUtils.dateToString(createdTimeStart);
|
|
|
+ } else if (remoteOpcLogDTO.getSearchType() == 2) {// 2小时
|
|
|
+ LocalDateTime createdTimeStart = createdTimeEnd.plusHours(-2);
|
|
|
+ timeB = DateUtils.dateToString(createdTimeStart);
|
|
|
+ } else if (remoteOpcLogDTO.getSearchType() == 3) {// 3小时
|
|
|
+ LocalDateTime createdTimeStart = createdTimeEnd.plusHours(-3);
|
|
|
+ timeB = DateUtils.dateToString(createdTimeStart);
|
|
|
+ } else {// 1小时 默认
|
|
|
+ LocalDateTime createdTimeStart = createdTimeEnd.plusHours(-1);
|
|
|
+ timeB = DateUtils.dateToString(createdTimeStart);
|
|
|
+ }
|
|
|
+ RemoteOpcLogVO vo = remoteOpcLogList.get(0);
|
|
|
+ String result = vo.getRemark();
|
|
|
+ String[] resultArr = result.split(";");
|
|
|
+ for (String str : resultArr) {
|
|
|
+ String[] item = str.split(",");
|
|
|
+ String time = item[0];
|
|
|
+ if (time.compareTo(timeB) >= 0 && time.compareTo(timeA) <= 0) {
|
|
|
+ RemoteOpcLogHistoryVO remoteOpcLogHistoryVO = new RemoteOpcLogHistoryVO();
|
|
|
+ remoteOpcLogHistoryVO.setCreatedTime(item[0]);
|
|
|
+ remoteOpcLogHistoryVO.setResult(item[1]);
|
|
|
+ voList.add(remoteOpcLogHistoryVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String ss = "2022-12-11 12:00:01";
|
|
|
+ String s1 = "2022-12-11 12:00:01";
|
|
|
+ System.out.println(ss.compareTo(s1));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public AbstractPageResultBean<RemoteOpcLog> selectPageInfo(RemoteOpcLogDTO record, int pageNum, int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|