更新
This commit is contained in:
@@ -165,7 +165,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
message = null;
|
||||
if (move == 0 ) {
|
||||
inst_message = null;
|
||||
// this.clearWrite();
|
||||
this.clearWrite();
|
||||
}
|
||||
if(move == 0 && last_move == 1 ){
|
||||
last_vehicle_code = vehicle_code;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
|
||||
package org.nl.acs.udw.rest;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.DriverTypeEnum;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.OpcPlcDto;
|
||||
import org.nl.acs.device.service.DeviceExtraService;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.dto.DeviceDto;
|
||||
import org.nl.acs.udw.service.UdwManageService;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "内存点位管理")
|
||||
@RequestMapping("/api/udw")
|
||||
@Slf4j
|
||||
public class UdwManagerController {
|
||||
|
||||
private final UdwManageService udwManageService;
|
||||
|
||||
// @GetMapping
|
||||
// @Log("查询内存点位")
|
||||
// @ApiOperation("查询内存点位")
|
||||
// @SaIgnore
|
||||
// public ResponseEntity<Object> query(@RequestParam JSONObject whereJson) {
|
||||
// return new ResponseEntity<>(udwManageService.queryByConditions(whereJson), HttpStatus.OK);
|
||||
// }
|
||||
|
||||
@GetMapping
|
||||
@Log("查询内存点位")
|
||||
@ApiOperation("查询内存点位")
|
||||
@SaIgnore
|
||||
//@PreAuthorize("@el.check('device:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(udwManageService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package org.nl.acs.udw.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.udw.dto.UdwDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UdwManageService {
|
||||
/**
|
||||
@@ -13,4 +15,14 @@ public interface UdwManageService {
|
||||
* @return
|
||||
*/
|
||||
List<UdwDto> queryByConditions(JSONObject where);
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,157 @@
|
||||
package org.nl.acs.udw.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.acs.udw.UnifiedData;
|
||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||
import org.nl.acs.udw.dto.UdwDto;
|
||||
import org.nl.acs.udw.service.UdwManageService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class UdwManagerServiceImpl implements UdwManageService {
|
||||
|
||||
public UdwManagerServiceImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UdwDto> queryByConditions(JSONObject where) {
|
||||
return null;
|
||||
String unified_key = null;
|
||||
String keys = null;
|
||||
|
||||
UnifiedDataUnit unifiedDataUnit = UnifiedDataAccessorFactory.getUnifiedDataAppService().getUnifiedDataUnit(unified_key);
|
||||
if (unifiedDataUnit == null) {
|
||||
return null;
|
||||
} else {
|
||||
String key;
|
||||
UdwDto udwDto;
|
||||
Map storage;
|
||||
ArrayList udwDtos;
|
||||
Iterator var14;
|
||||
if (keys != null) {
|
||||
storage = unifiedDataUnit.getStorage();
|
||||
udwDtos = new ArrayList();
|
||||
var14 = storage.keySet().iterator();
|
||||
|
||||
while(var14.hasNext()) {
|
||||
key = (String)var14.next();
|
||||
if (key.indexOf(keys) != -1) {
|
||||
udwDto = new UdwDto();
|
||||
udwDto.setUnified_key(unified_key);
|
||||
udwDto.setKey(key);
|
||||
udwDto.setValue(((UnifiedData)storage.get(key)).getValue());
|
||||
udwDtos.add(udwDto);
|
||||
}
|
||||
}
|
||||
|
||||
return udwDtos;
|
||||
} else {
|
||||
storage = unifiedDataUnit.getStorage();
|
||||
udwDtos = new ArrayList();
|
||||
var14 = storage.keySet().iterator();
|
||||
|
||||
while(var14.hasNext()) {
|
||||
key = (String)var14.next();
|
||||
udwDto = new UdwDto();
|
||||
udwDto.setUnified_key(unified_key);
|
||||
udwDto.setKey(key);
|
||||
udwDto.setValue(((UnifiedData)storage.get(key)).getValue());
|
||||
udwDtos.add(udwDto);
|
||||
}
|
||||
|
||||
return udwDtos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
|
||||
String unified_key = (String) whereJson.get("unified_key");
|
||||
String keys = (String) whereJson.get("code");
|
||||
if(StrUtil.isEmpty(unified_key))
|
||||
{
|
||||
unified_key = "opc_value";
|
||||
}
|
||||
// String unified_key = (String) whereJson.get("unified_key");
|
||||
// String code = (String) whereJson.get("code");
|
||||
|
||||
// unified_key = whereJson.get("key").toString();
|
||||
// keys = whereJson.get("value").toString();
|
||||
|
||||
|
||||
//[[{"column":"unified_key","value":"cached","compareType":"equals","columnType":"object"}]]
|
||||
UnifiedDataUnit unifiedDataUnit = UnifiedDataAccessorFactory.getUnifiedDataAppService().getUnifiedDataUnit(unified_key);
|
||||
if (unifiedDataUnit == null) {
|
||||
return null;
|
||||
} else {
|
||||
String key;
|
||||
UdwDto udwDto;
|
||||
Map storage;
|
||||
ArrayList udwDtos;
|
||||
Iterator var14;
|
||||
if (keys != null) {
|
||||
storage = unifiedDataUnit.getStorage();
|
||||
udwDtos = new ArrayList();
|
||||
var14 = storage.keySet().iterator();
|
||||
|
||||
while(var14.hasNext()) {
|
||||
key = (String)var14.next();
|
||||
if (key.indexOf(keys) != -1) {
|
||||
udwDto = new UdwDto();
|
||||
udwDto.setUnified_key(unified_key);
|
||||
udwDto.setKey(key);
|
||||
udwDto.setValue(((UnifiedData)storage.get(key)).getValue());
|
||||
udwDtos.add(udwDto);
|
||||
}
|
||||
}
|
||||
|
||||
Integer currentPageNumber = page.getPageNumber() + 1;
|
||||
Integer pageMaxSize = page.getPageSize();
|
||||
|
||||
List orderbyDtoList = (List) udwDtos.stream().skip((currentPageNumber - 1) * pageMaxSize)
|
||||
.limit(pageMaxSize)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("content", orderbyDtoList);
|
||||
jo.put("totalElements", udwDtos.size());
|
||||
|
||||
return jo;
|
||||
} else {
|
||||
storage = unifiedDataUnit.getStorage();
|
||||
udwDtos = new ArrayList();
|
||||
var14 = storage.keySet().iterator();
|
||||
|
||||
while(var14.hasNext()) {
|
||||
key = (String)var14.next();
|
||||
udwDto = new UdwDto();
|
||||
udwDto.setUnified_key(unified_key);
|
||||
udwDto.setKey(key);
|
||||
udwDto.setValue(((UnifiedData)storage.get(key)).getValue());
|
||||
udwDtos.add(udwDto);
|
||||
}
|
||||
Integer currentPageNumber = page.getPageNumber() + 1;
|
||||
Integer pageMaxSize = page.getPageSize();
|
||||
|
||||
List orderbyDtoList = (List) udwDtos.stream().skip((currentPageNumber - 1) * pageMaxSize)
|
||||
.limit(pageMaxSize)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("content", orderbyDtoList);
|
||||
jo.put("totalElements", udwDtos.size());
|
||||
|
||||
return jo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user