psh 7 months ago
parent
commit
641e61ab74
  1. 29
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java
  2. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/MobileAuthorizationController.java
  3. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/HandServiceImpl.java

29
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java

@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alicp.jetcache.anno.method.SpringCacheContext; import com.alicp.jetcache.anno.method.SpringCacheContext;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.bag.SynchronizedSortedBag;
import org.nl.acs.opc.service.dto.OpcServerManageDto; import org.nl.acs.opc.service.dto.OpcServerManageDto;
import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessor;
import org.nl.acs.udw.UnifiedDataAccessorFactory; import org.nl.acs.udw.UnifiedDataAccessorFactory;
@ -16,7 +17,9 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
/**
* @author 20220102CG\noblelift
*/
@Slf4j @Slf4j
@Service @Service
public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener { public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener {
@ -103,7 +106,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
log.trace("清理server..."); log.trace("清理server...");
} }
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService.class); OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService.class);
group =opcServerService.getServer(this.getOpcServer().getOpc_code()); group = opcServerService.getServer(this.getOpcServer().getOpc_code());
// this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); // this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
// this.server.addStateListener(this); // this.server.addStateListener(this);
// group = this.server.addGroup(); // group = this.server.addGroup();
@ -204,7 +207,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
if (true) { if (true) {
this.logItemChanged(itemId, accessor_value, value, itemDto); this.logItemChanged(itemId, accessor_value, value, itemDto);
} }
if(!ObjectUtil.isEmpty(value)){ if (!ObjectUtil.isEmpty(value)) {
accessor_value.setValue(itemId, value); accessor_value.setValue(itemId, value);
} }
} }
@ -227,17 +230,17 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
random *= 1000; random *= 1000;
if (this.all_null < 3) { if (this.all_null < 3) {
if (log.isWarnEnabled()) { if (log.isWarnEnabled()) {
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,5000 + random); log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 5000 + random);
} }
ThreadUtl.sleep((long) (5000 + random)); ThreadUtl.sleep((long) (5000 + random));
} else if (this.all_null < 6) { } else if (this.all_null < 6) {
if (log.isWarnEnabled()) { if (log.isWarnEnabled()) {
log.warn(tag + "重新创建server"); log.warn(tag + "重新创建server");
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,30000 + random); log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 30000 + random);
} }
// ThreadUtl.sleep((long) (30000 + random)); // ThreadUtl.sleep((long) (30000 + random));
ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 1000); ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 1000);
break start; break start;
} else if (this.all_null < 12) { } else if (this.all_null < 12) {
if (log.isWarnEnabled()) { if (log.isWarnEnabled()) {
@ -358,6 +361,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
} }
@Override
public void connectionStateChanged(boolean connected) { public void connectionStateChanged(boolean connected) {
if (!connected) { if (!connected) {
this.server = null; this.server = null;
@ -380,6 +384,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
} }
@Override
public void changed(Item item, ItemState itemState) { public void changed(Item item, ItemState itemState) {
String itemId = item.getId(); String itemId = item.getId();
@ -424,7 +429,17 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value, sb}); log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value, sb});
// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{};信号快照:{}", new Object[]{itemId, his, value, sb}); // this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{};信号快照:{}", new Object[]{itemId, his, value, sb});
} else { } else {
log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value}); if(his instanceof int[]){
if(!Arrays.equals((long[]) his, (long[]) value)){
log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value});
}
} else if(his instanceof String){
if(!StrUtil.equals((CharSequence) his, (CharSequence) value)){
log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value});
}
} else {
log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value});
}
// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{}", new Object[]{itemId, his, value}); // this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{}", new Object[]{itemId, his, value});
} }
} }

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/hand/rest/MobileAuthorizationController.java

@ -34,14 +34,14 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/api/pda") @RequestMapping("/mobile/auth")
public class MobileAuthorizationController { public class MobileAuthorizationController {
@Autowired @Autowired
private ISysUserService userService; private ISysUserService userService;
@Autowired @Autowired
private ISysRoleService roleService; private ISysRoleService roleService;
@PostMapping(value = "/handlogin") @PostMapping(value = "/login")
@SaIgnore @SaIgnore
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception { public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
// 密码解密 - 前端的加密规则: encrypt(根据实际更改) // 密码解密 - 前端的加密规则: encrypt(根据实际更改)

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/hand/service/impl/HandServiceImpl.java

@ -229,13 +229,14 @@ public class HandServiceImpl implements HandService {
List<InstructionMybatis> list; List<InstructionMybatis> list;
if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){ if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){
list = instructionService.lambdaQuery() list = instructionService.lambdaQuery()
.le(InstructionMybatis::getInstruction_status,"1")
.orderByDesc(InstructionMybatis::getCreate_time) .orderByDesc(InstructionMybatis::getCreate_time)
.list(); .list();
}else { }else {
list = instructionService.lambdaQuery() list = instructionService.lambdaQuery()
.like(InstructionMybatis::getStart_device_code, start_point) .like(InstructionMybatis::getStart_device_code, start_point)
.like(InstructionMybatis::getNext_device_code, next_point) .like(InstructionMybatis::getNext_device_code, next_point)
.ne(InstructionMybatis::getInstruction_status, "2") .le(InstructionMybatis::getInstruction_status, "1")
.eq(InstructionMybatis::getInstruction_code, key) .eq(InstructionMybatis::getInstruction_code, key)
.or() .or()
.eq(InstructionMybatis::getCarno, key) .eq(InstructionMybatis::getCarno, key)
@ -339,6 +340,7 @@ public class HandServiceImpl implements HandService {
if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){ if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){
list = taskserver.lambdaQuery() list = taskserver.lambdaQuery()
.orderByDesc(Task::getCreate_time) .orderByDesc(Task::getCreate_time)
.lt(Task::getTask_status, "2")
.list(); .list();
}else { }else {
list = taskserver.lambdaQuery() list = taskserver.lambdaQuery()

Loading…
Cancel
Save