Browse Source

充电重复点击优化

master
psh 10 months ago
parent
commit
67bb286790
  1. 2
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
  2. 2
      acs/nladmin-system/src/main/java/org/nl/hand/amb/rest/HFHandController.java
  3. 8
      acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java
  4. 2
      acs/nladmin-system/src/main/java/org/nl/modules/common/aspect/LimitAspect.java
  5. 12
      acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java

2
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java

@ -86,4 +86,6 @@ public class AgvDto implements Serializable {
*/ */
private String type = "AGV"; private String type = "AGV";
private Boolean chargingFlag=false;
} }

2
acs/nladmin-system/src/main/java/org/nl/hand/amb/rest/HFHandController.java

@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.hand.amb.service.HFHandService; import org.nl.hand.amb.service.HFHandService;
import org.nl.modules.common.annotation.Limit;
import org.nl.modules.logging.annotation.Log; import org.nl.modules.logging.annotation.Log;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -169,6 +170,7 @@ public class HFHandController {
@Log("创建充电任务") @Log("创建充电任务")
@ApiOperation("创建充电任务") @ApiOperation("创建充电任务")
@SaIgnore @SaIgnore
@Limit(period = 2, count = 1)
//@PreAuthorize("@el.check('sect:list')") //@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createChargingTask(@RequestBody Map<String, String> whereJson) { public ResponseEntity<Object> createChargingTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.createChargingTask(whereJson), HttpStatus.OK); return new ResponseEntity<>(HandService.createChargingTask(whereJson), HttpStatus.OK);

8
acs/nladmin-system/src/main/java/org/nl/hand/amb/service/impl/HFHandServiceImpl.java

@ -13,6 +13,7 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.XianGongAgvService; import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.agv.server.dto.AgvDto;
import org.nl.acs.agv.server.impl.NDCAgvServiceImpl; import org.nl.acs.agv.server.impl.NDCAgvServiceImpl;
import org.nl.acs.auto.run.AutoRunService; import org.nl.acs.auto.run.AutoRunService;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
@ -59,6 +60,7 @@ public class HFHandServiceImpl implements HFHandService {
private final UserService userService; private final UserService userService;
private final DeviceService deviceService; private final DeviceService deviceService;
private final DeviceAppService deviceAppService; private final DeviceAppService deviceAppService;
private final NDCAgvService ndcAgvService;
InstructionService instructionService = null; InstructionService instructionService = null;
@ -772,6 +774,12 @@ public class HFHandServiceImpl implements HFHandService {
} }
String type = whereJson.get("carno"); String type = whereJson.get("carno");
AgvDto agv = ndcAgvService.findByCarNumber(type);
if(agv.getChargingFlag()){
jo.put("code", "0");
jo.put("desc", "该车已在充电!");
return jo;
}
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
try { try {
agvService.createChargingTaskToNDC(type); agvService.createChargingTaskToNDC(type);

2
acs/nladmin-system/src/main/java/org/nl/modules/common/aspect/LimitAspect.java

@ -81,7 +81,7 @@ public class LimitAspect {
log.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name()); log.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name());
return joinPoint.proceed(); return joinPoint.proceed();
} else { } else {
throw new BadRequestException("访问次数受限制"); throw new BadRequestException("请不要重复点击!");
} }
} }

12
acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java

@ -970,6 +970,18 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
// 状态 // 状态
AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19])); AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19]));
agv.setState(String.valueOf(ikey)); agv.setState(String.valueOf(ikey));
}else if (phase == 0x40) {
// 状态
AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19]));
agv.setChargingFlag(true);
}else if (phase == 0x41) {
// 状态
AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19]));
agv.setChargingFlag(false);
}else if (phase == 0x42) {
// 状态
AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19]));
agv.setChargingFlag(false);
} }
if (!ObjectUtil.isEmpty(data)) { if (!ObjectUtil.isEmpty(data)) {
write(data); write(data);

Loading…
Cancel
Save