|
@@ -1,12 +1,16 @@
|
|
|
package com.platform.service.remote.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.exception.BusinessException;
|
|
|
+import com.platform.common.util.BeanConverterUtil;
|
|
|
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.RemoteOpc;
|
|
|
import com.platform.dao.entity.remote.RemoteOpcLog;
|
|
|
import com.platform.dao.mapper.remote.RemoteOpcLogMapper;
|
|
|
import com.platform.dao.mapper.upms.SysDictMapper;
|
|
@@ -14,9 +18,12 @@ 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 com.platform.service.remote.RemoteOpcService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+import sun.swing.StringUIClientPropertyKey;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
|
|
@@ -36,6 +43,82 @@ import java.util.List;
|
|
|
@Service("remoteOpcLogService")
|
|
|
public class RemoteOpcLogServiceImpl extends BaseServiceImpl<RemoteOpcLogMapper, RemoteOpcLog, RemoteOpcLogDTO> implements RemoteOpcLogService {
|
|
|
|
|
|
+ private final RemoteOpcService remoteOpcService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RemoteOpcLogVO getVOById(String id) {
|
|
|
+ RemoteOpcLog log = mapper.selectByPrimaryKey(id);
|
|
|
+ RemoteOpc remoteOpc = remoteOpcService.selectByPositionNum(log.getPositionNum());
|
|
|
+ log.setSbId(remoteOpc.getId());
|
|
|
+ log.setSbName(remoteOpc.getSbName());
|
|
|
+ log.setUnit(remoteOpc.getUnit());
|
|
|
+ log.setRatio(remoteOpc.getRatio());
|
|
|
+ log.setType(remoteOpc.getType());
|
|
|
+ log.setDescription(remoteOpc.getDescription());
|
|
|
+ RemoteOpcLogVO vo = BeanConverterUtil.copyObjectProperties(log, RemoteOpcLogVO.class);
|
|
|
+ if(!StringUtils.isEmpty(log.getRemark())){
|
|
|
+ String[] remarks = log.getRemark().split(";");
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ for(String remark:remarks){
|
|
|
+ String[] data = remark.split(",");
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("time",data[0] );
|
|
|
+ object.put("value",data[1] + "");
|
|
|
+ array.add(object);
|
|
|
+ }
|
|
|
+ vo.setDataJsonStr(array.toJSONString());
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 默认查询当天
|
|
|
+ * *
|
|
|
+ * @param record
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public RemoteOpcLogVO getVOByDTO(RemoteOpcLogDTO record) {
|
|
|
+ if(record.getYear() == null){
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
+ record.setYear(localDateTime.getYear());
|
|
|
+ record.setMonth(localDateTime.getMonthValue());
|
|
|
+ record.setDay(localDateTime.getDayOfMonth());
|
|
|
+ }
|
|
|
+ Weekend<RemoteOpcLog> weekend = new Weekend<>(RemoteOpcLog.class);
|
|
|
+ WeekendCriteria<RemoteOpcLog, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(RemoteOpcLog::getPositionNum, record.getPositionNum())
|
|
|
+ .andEqualTo(RemoteOpcLog::getYear, record.getYear())
|
|
|
+ .andEqualTo(RemoteOpcLog::getMonth, record.getMonth())
|
|
|
+ .andEqualTo(RemoteOpcLog::getDay, record.getDay());
|
|
|
+ RemoteOpcLog log = mapper.selectOneByExample(weekend);
|
|
|
+ RemoteOpc remoteOpc = remoteOpcService.selectByPositionNum(record.getPositionNum());
|
|
|
+ if(log == null){
|
|
|
+ log = new RemoteOpcLog();
|
|
|
+ log.setPositionNum(record.getPositionNum());
|
|
|
+ }
|
|
|
+ log.setSbId(remoteOpc.getId());
|
|
|
+ log.setSbName(remoteOpc.getSbName());
|
|
|
+ log.setUnit(remoteOpc.getUnit());
|
|
|
+ log.setRatio(remoteOpc.getRatio());
|
|
|
+ log.setType(remoteOpc.getType());
|
|
|
+ log.setDescription(remoteOpc.getDescription());
|
|
|
+ RemoteOpcLogVO vo = BeanConverterUtil.copyObjectProperties(log, RemoteOpcLogVO.class);
|
|
|
+ if(!StringUtils.isEmpty(log.getRemark())){
|
|
|
+ String[] remarks = log.getRemark().split(";");
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
+ for(String remark:remarks){
|
|
|
+ String[] data = remark.split(",");
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("time",data[0] );
|
|
|
+ object.put("value",data[1] + "");
|
|
|
+ array.add(object);
|
|
|
+ }
|
|
|
+ vo.setDataJsonStr(array.toJSONString());
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
Weekend<RemoteOpcLog> weekend = new Weekend<>(RemoteOpcLog.class);
|