刘力
3 years ago
16 changed files with 378 additions and 512 deletions
-
67storeroom/src/main/java/com/storeroom/modules/device/controller/CameraController.java
-
3storeroom/src/main/java/com/storeroom/modules/device/controller/DeseCabinetController.java
-
53storeroom/src/main/java/com/storeroom/modules/device/controller/InsideDevicesController.java
-
47storeroom/src/main/java/com/storeroom/modules/device/controller/RotaryCabinetController.java
-
13storeroom/src/main/java/com/storeroom/modules/device/domain/DeviceInfo.java
-
23storeroom/src/main/java/com/storeroom/modules/device/repository/DeseCabinetRepository.java
-
35storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceInfoRepository.java
-
31storeroom/src/main/java/com/storeroom/modules/device/service/DeseCabinetService.java
-
45storeroom/src/main/java/com/storeroom/modules/device/service/DeviceService.java
-
23storeroom/src/main/java/com/storeroom/modules/device/service/RotaryCabinetService.java
-
57storeroom/src/main/java/com/storeroom/modules/device/service/dto/DeseCabinetDto.java
-
8storeroom/src/main/java/com/storeroom/modules/device/service/dto/DeviceInfoDto.java
-
174storeroom/src/main/java/com/storeroom/modules/device/service/impl/DenseCabinetImpl.java
-
144storeroom/src/main/java/com/storeroom/modules/device/service/impl/DeviceImpl.java
-
156storeroom/src/main/java/com/storeroom/modules/device/service/impl/RotaryCabinetImpl.java
-
11storeroom/src/main/java/com/storeroom/modules/device/service/mapstruct/DeseCabinetMapper.java
@ -0,0 +1,67 @@ |
|||
package com.storeroom.modules.device.controller; |
|||
|
|||
|
|||
import com.storeroom.annotaion.rest.AnonymousPostMapping; |
|||
import com.storeroom.annotaion.rest.AnonymousPutMapping; |
|||
import com.storeroom.exception.BaseException; |
|||
import com.storeroom.modules.device.service.DeviceService; |
|||
import com.storeroom.modules.device.service.dto.DeviceInfoDto; |
|||
import com.storeroom.utils.ApiResponse; |
|||
import com.storeroom.utils.StringUtils; |
|||
import com.storeroom.utils.enums.ResponseStatus; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "摄像机管理") |
|||
@RequestMapping("/api/camera/") |
|||
public class CameraController { |
|||
|
|||
|
|||
private final DeviceService deviceService; |
|||
|
|||
|
|||
@ApiOperation("创建摄像机") |
|||
@AnonymousPostMapping("create") |
|||
public ApiResponse<Object> create(@RequestBody DeviceInfoDto deviceInfoDto) { |
|||
if (!StringUtils.isEmpty(deviceInfoDto.getId())) { |
|||
throw new BaseException("id不为空"); |
|||
} |
|||
verifyValues(deviceInfoDto); |
|||
deviceService.createCamera(deviceInfoDto); |
|||
return ApiResponse.success(ResponseStatus.SUCCESS); |
|||
} |
|||
|
|||
@ApiOperation("修改摄像机") |
|||
@AnonymousPutMapping("update") |
|||
public ApiResponse<Object> update(@RequestBody DeviceInfoDto deviceInfoDto){ |
|||
if (StringUtils.isEmpty(deviceInfoDto.getId())) { |
|||
throw new BaseException("id不能为空"); |
|||
} |
|||
verifyValues(deviceInfoDto); |
|||
deviceService.updateCamera(deviceInfoDto); |
|||
return ApiResponse.success(ResponseStatus.SUCCESS); |
|||
} |
|||
|
|||
/** |
|||
* 验证必填值 |
|||
* |
|||
* @param deviceInfoDto |
|||
*/ |
|||
private void verifyValues(DeviceInfoDto deviceInfoDto) { |
|||
if (StringUtils.isEmpty(deviceInfoDto.getDeviceName()) && |
|||
StringUtils.isEmpty(deviceInfoDto.getDeviceIp()) && |
|||
deviceInfoDto.getDevicePort() != null && |
|||
StringUtils.isEmpty(deviceInfoDto.getDeviceAccount()) && |
|||
StringUtils.isEmpty(deviceInfoDto.getDevicePassword())) { |
|||
throw new BaseException("必填字段不能为空"); |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,53 @@ |
|||
package com.storeroom.modules.device.controller; |
|||
|
|||
|
|||
import com.storeroom.annotaion.rest.AnonymousPostMapping; |
|||
import com.storeroom.exception.BaseException; |
|||
import com.storeroom.modules.device.service.DeviceService; |
|||
import com.storeroom.modules.device.service.dto.DeviceInfoDto; |
|||
import com.storeroom.utils.ApiResponse; |
|||
import com.storeroom.utils.StringUtils; |
|||
import com.storeroom.utils.enums.ResponseStatus; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "环控设备管理") |
|||
@RequestMapping("/api/insidedevices/") |
|||
public class InsideDevicesController { |
|||
|
|||
private final DeviceService deviceService; |
|||
|
|||
|
|||
@ApiOperation("新增环控设备") |
|||
@AnonymousPostMapping("create") |
|||
public ApiResponse<Object> create(@RequestBody DeviceInfoDto deviceInfoDto) { |
|||
if (!StringUtils.isEmpty(deviceInfoDto.getId())) { |
|||
throw new BaseException("id不为空"); |
|||
} |
|||
verifyValues(deviceInfoDto); |
|||
deviceService.createInsideDevices(deviceInfoDto); |
|||
return ApiResponse.success(ResponseStatus.SUCCESS); |
|||
} |
|||
|
|||
/** |
|||
* 验证必填值 |
|||
* |
|||
* @param deviceInfoDto |
|||
*/ |
|||
private void verifyValues(DeviceInfoDto deviceInfoDto) { |
|||
if (StringUtils.isEmpty(deviceInfoDto.getDeviceName()) && |
|||
StringUtils.isEmpty(deviceInfoDto.getDeviceIp()) && |
|||
deviceInfoDto.getDevicePort() != null && |
|||
StringUtils.isEmpty(deviceInfoDto.getDeviceId()) && |
|||
deviceInfoDto.getDeviceTypeId() != null) { |
|||
throw new BaseException("必填字段不能为空"); |
|||
|
|||
} |
|||
} |
|||
} |
@ -1,23 +0,0 @@ |
|||
package com.storeroom.modules.device.repository; |
|||
|
|||
import com.storeroom.modules.device.domain.DeseCabinet; |
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface DeseCabinetRepository extends JpaRepository<DeseCabinet, String>, JpaSpecificationExecutor<DeseCabinet> { |
|||
|
|||
|
|||
/** |
|||
* 区号,ip 端口号查询 |
|||
* |
|||
* @param areaNo 区号 |
|||
* @param ip ip |
|||
* @param port 端口号 |
|||
* @return 返回列表 |
|||
*/ |
|||
@Query(value = "SELECT * FROM dese_cabinet a JOIN device_info b ON a.device_info_id=b.id WHERE a.area_No=?1 AND b.device_ip=?2 AND b.device_port=?3", nativeQuery = true) |
|||
List<DeseCabinet> findIpAndPortAndAreaNo(Integer areaNo, String ip, Integer port); |
|||
} |
@ -1,31 +0,0 @@ |
|||
package com.storeroom.modules.device.service; |
|||
|
|||
import com.storeroom.modules.device.domain.DeseCabinet; |
|||
import com.storeroom.modules.device.service.dto.DeseCabinetDto; |
|||
|
|||
|
|||
public interface DeseCabinetService { |
|||
|
|||
/** |
|||
* 设备新增 |
|||
*/ |
|||
void create(DeseCabinet deseCabinet); |
|||
|
|||
/** |
|||
* 设备修改 |
|||
*/ |
|||
void update(DeseCabinet deseCabinet); |
|||
|
|||
/** |
|||
* 删除 |
|||
*/ |
|||
void delete(String id); |
|||
|
|||
|
|||
|
|||
/** |
|||
* 获取状态 |
|||
* @return / |
|||
*/ |
|||
Boolean getState(); |
|||
} |
@ -1,23 +0,0 @@ |
|||
package com.storeroom.modules.device.service; |
|||
|
|||
import com.storeroom.modules.device.domain.RotaryCabinet; |
|||
|
|||
/** |
|||
* 回转柜 |
|||
*/ |
|||
public interface RotaryCabinetService { |
|||
|
|||
|
|||
/** |
|||
* 创建回转柜 |
|||
* @param rotaryCabinet / |
|||
*/ |
|||
void create(RotaryCabinet rotaryCabinet); |
|||
|
|||
|
|||
/** |
|||
* 修改回转柜 |
|||
* @param rotaryCabinet / |
|||
*/ |
|||
void update(RotaryCabinet rotaryCabinet); |
|||
} |
@ -1,57 +0,0 @@ |
|||
package com.storeroom.modules.device.service.dto; |
|||
|
|||
import com.storeroom.base.BaseDTO; |
|||
import com.storeroom.modules.device.domain.DeviceInfo; |
|||
import com.storeroom.modules.device.domain.OperatingState; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Objects; |
|||
|
|||
|
|||
/** |
|||
* 密集架DTO |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
public class DeseCabinetDto extends BaseDTO implements Serializable { |
|||
|
|||
private String id; |
|||
|
|||
private DeviceInfoDto deviceInfo; |
|||
|
|||
private String storeroomCode; |
|||
|
|||
private String deviceId; |
|||
|
|||
private Integer rowNo; |
|||
|
|||
private Integer areaNo; |
|||
|
|||
private Integer sumColumnNo; |
|||
|
|||
private Integer firstColumnNo; |
|||
|
|||
private Integer partNo; |
|||
|
|||
private Integer isNotice; |
|||
|
|||
private OperatingStateDto isLinkage; |
|||
|
|||
private OperatingStateDto isCallback; |
|||
|
|||
|
|||
@Override |
|||
public boolean equals(Object o) { |
|||
if (this == o) return true; |
|||
if (o == null || getClass() != o.getClass()) return false; |
|||
DeseCabinetDto that = (DeseCabinetDto) o; |
|||
return Objects.equals(id, that.id) && Objects.equals(deviceInfo, that.deviceInfo) && Objects.equals(storeroomCode, that.storeroomCode) && Objects.equals(deviceId, that.deviceId) && Objects.equals(rowNo, that.rowNo) && Objects.equals(areaNo, that.areaNo) && Objects.equals(sumColumnNo, that.sumColumnNo) && Objects.equals(firstColumnNo, that.firstColumnNo) && Objects.equals(partNo, that.partNo) && Objects.equals(isNotice, that.isNotice) && Objects.equals(isLinkage, that.isLinkage) && Objects.equals(isCallback, that.isCallback); |
|||
} |
|||
|
|||
@Override |
|||
public int hashCode() { |
|||
return Objects.hash(id, deviceInfo, storeroomCode, deviceId, rowNo, areaNo, sumColumnNo, firstColumnNo, partNo, isNotice, isLinkage, isCallback); |
|||
} |
|||
} |
@ -1,174 +0,0 @@ |
|||
package com.storeroom.modules.device.service.impl; |
|||
|
|||
import com.storeroom.exception.BaseException; |
|||
import com.storeroom.modules.device.domain.DeseCabinet; |
|||
import com.storeroom.modules.device.domain.DeviceArchivesTag; |
|||
import com.storeroom.modules.device.domain.OperatingState; |
|||
import com.storeroom.modules.device.repository.DeseCabinetRepository; |
|||
import com.storeroom.modules.device.repository.DeviceArchivesTagRepository; |
|||
import com.storeroom.modules.device.repository.DeviceInfoRepository; |
|||
import com.storeroom.modules.device.repository.OperatingStateRepository; |
|||
import com.storeroom.modules.device.service.DeseCabinetService; |
|||
import com.storeroom.utils.NanoIdUtils; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.ObjectUtils; |
|||
|
|||
import java.util.List; |
|||
import java.util.concurrent.ThreadLocalRandom; |
|||
|
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DenseCabinetImpl implements DeseCabinetService { |
|||
|
|||
private final DeseCabinetRepository deseCabinetRepository; |
|||
private final DeviceArchivesTagRepository deviceArchivesTagRepository; |
|||
private final OperatingStateRepository operatingStateRepository; |
|||
|
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void create(DeseCabinet deseCabinet) { |
|||
|
|||
//根据IP和端口号查询设备 |
|||
List<DeseCabinet> deseCabinet1 = deseCabinetRepository.findIpAndPortAndAreaNo(deseCabinet.getAreaNo(), deseCabinet.getDeviceInfo().getDeviceIp(), deseCabinet.getDeviceInfo().getDevicePort()); |
|||
//判断设备同一IP和端口下是否重复 |
|||
if (!ObjectUtils.isEmpty(deseCabinet1)) { |
|||
throw new BaseException("区号IP端口不能重复添加设备"); |
|||
} |
|||
//创建密集架id |
|||
deseCabinet.setId(NanoIdUtils.randomNanoId()); |
|||
//创建设备信息id |
|||
deseCabinet.getDeviceInfo().setId(NanoIdUtils.randomNanoId()); |
|||
//生成架位 |
|||
String position = deseCabinet.getAreaNo() + |
|||
"-" + |
|||
deseCabinet.getFirstColumnNo() + |
|||
"-" + |
|||
deseCabinet.getPartNo() + |
|||
"-" + |
|||
deseCabinet.getRowNo() + |
|||
"-" + |
|||
GenerateNum(); |
|||
String leftOrRight; |
|||
if (GenerateNum().equals("1")) { |
|||
leftOrRight = "左"; |
|||
} else { |
|||
leftOrRight = "右"; |
|||
} |
|||
String positionName = deseCabinet.getAreaNo() + |
|||
"区" + |
|||
deseCabinet.getFirstColumnNo() + |
|||
"列" + |
|||
deseCabinet.getPartNo() + |
|||
"节" + |
|||
deseCabinet.getRowNo() + |
|||
"层" + |
|||
leftOrRight; |
|||
|
|||
|
|||
DeviceArchivesTag deviceArchivesTag = new DeviceArchivesTag(); |
|||
//生成架位标签表id |
|||
deviceArchivesTag.setId(NanoIdUtils.randomNanoId()); |
|||
deviceArchivesTag.setPosition(position); |
|||
deviceArchivesTag.setDeviceInfoId(deseCabinet.getDeviceInfo().getId()); |
|||
deviceArchivesTag.setPosition_name(positionName); |
|||
//创建联动操作状态对象 |
|||
IsLinkageState(deseCabinet); |
|||
IsCallbackState(deseCabinet); |
|||
//保存架位标签 |
|||
deviceArchivesTagRepository.save(deviceArchivesTag); |
|||
//保存密集架 |
|||
deseCabinetRepository.save(deseCabinet); |
|||
} |
|||
|
|||
/** |
|||
* 保存联动操作状态 |
|||
* |
|||
* @param deseCabinet / |
|||
*/ |
|||
private void IsLinkageState(DeseCabinet deseCabinet) { |
|||
OperatingState operatingState = new OperatingState(); |
|||
operatingState.setId(NanoIdUtils.randomNanoId()); |
|||
operatingState.setDeviceId(deseCabinet.getId()); |
|||
operatingState.setBorrow(deseCabinet.getIsLinkage().getBorrow()); |
|||
operatingState.setInBound(deseCabinet.getIsLinkage().getInBound()); |
|||
operatingState.setOutBound(deseCabinet.getIsLinkage().getOutBound()); |
|||
operatingState.setLend(deseCabinet.getIsLinkage().getLend()); |
|||
operatingState.setStateType(deseCabinet.getIsLinkage().getStateType()); |
|||
operatingStateRepository.save(operatingState); |
|||
} |
|||
|
|||
/** |
|||
* 保存回调操作状态 |
|||
* @param deseCabinet / |
|||
*/ |
|||
private void IsCallbackState(DeseCabinet deseCabinet) { |
|||
OperatingState operatingState = new OperatingState(); |
|||
operatingState.setId(NanoIdUtils.randomNanoId()); |
|||
operatingState.setDeviceId(deseCabinet.getId()); |
|||
operatingState.setBorrow(deseCabinet.getIsCallback().getBorrow()); |
|||
operatingState.setInBound(deseCabinet.getIsCallback().getInBound()); |
|||
operatingState.setOutBound(deseCabinet.getIsCallback().getOutBound()); |
|||
operatingState.setLend(deseCabinet.getIsCallback().getLend()); |
|||
operatingState.setStateType(deseCabinet.getIsCallback().getStateType()); |
|||
operatingStateRepository.save(operatingState); |
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 生成架位左右位置 |
|||
* |
|||
* @return |
|||
*/ |
|||
private String GenerateNum() { |
|||
ThreadLocalRandom tlr = ThreadLocalRandom.current(); |
|||
return String.valueOf(tlr.nextInt(1, 2)); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(DeseCabinet deseCabinet) { |
|||
|
|||
List<DeseCabinet> deseCabinet1 = deseCabinetRepository.findIpAndPortAndAreaNo(deseCabinet.getAreaNo(), deseCabinet.getDeviceInfo().getDeviceIp(), deseCabinet.getDeviceInfo().getDevicePort()); |
|||
if (!ObjectUtils.isEmpty(deseCabinet1)) { |
|||
throw new BaseException("区号IP端口不能重复添加设备"); |
|||
} |
|||
|
|||
DeseCabinet deseCabinet2 = deseCabinetRepository.findById(deseCabinet.getId()).orElseGet(DeseCabinet::new); |
|||
if (ObjectUtils.isEmpty(deseCabinet2)) { |
|||
throw new BaseException("数据不存在"); |
|||
} |
|||
|
|||
deseCabinet2.getDeviceInfo().setDeviceName(deseCabinet.getDeviceInfo().getDeviceName()); |
|||
deseCabinet2.getDeviceInfo().setDeviceIp(deseCabinet.getDeviceInfo().getDeviceIp()); |
|||
deseCabinet2.getDeviceInfo().setDevicePort(deseCabinet.getDeviceInfo().getDevicePort()); |
|||
deseCabinet2.setStoreroomCode(deseCabinet.getStoreroomCode()); |
|||
OperatingState operatingState = operatingStateRepository.findById(deseCabinet.getIsLinkage().getId()).orElseGet(OperatingState::new); |
|||
OperatingState operatingState1 = operatingStateRepository.findById(deseCabinet.getIsCallback().getId()).orElseGet(OperatingState::new); |
|||
operatingStateRepository.save(operatingState); |
|||
operatingStateRepository.save(operatingState1); |
|||
deseCabinetRepository.save(deseCabinet2); |
|||
} |
|||
|
|||
@Override |
|||
public void delete(String id) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Boolean getState() { |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 生成层位 |
|||
*/ |
|||
public void createLayer() { |
|||
|
|||
} |
|||
} |
@ -1,156 +0,0 @@ |
|||
package com.storeroom.modules.device.service.impl; |
|||
|
|||
import com.storeroom.exception.BaseException; |
|||
import com.storeroom.modules.device.domain.DeviceArchivesTag; |
|||
import com.storeroom.modules.device.domain.OperatingState; |
|||
import com.storeroom.modules.device.domain.RotaryCabinet; |
|||
import com.storeroom.modules.device.repository.DeviceArchivesTagRepository; |
|||
import com.storeroom.modules.device.repository.OperatingStateRepository; |
|||
import com.storeroom.modules.device.repository.RotaryCabinetRepository; |
|||
import com.storeroom.modules.device.service.RotaryCabinetService; |
|||
import com.storeroom.utils.NanoIdUtils; |
|||
import com.storeroom.utils.StringUtils; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.ObjectUtils; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class RotaryCabinetImpl implements RotaryCabinetService { |
|||
|
|||
private final RotaryCabinetRepository rotaryCabinetRepository; |
|||
private final OperatingStateRepository operatingStateRepository; |
|||
private final DeviceArchivesTagRepository deviceArchivesTagRepository; |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void create(RotaryCabinet rotaryCabinet) { |
|||
List<RotaryCabinet> rotaryCabinetList = rotaryCabinetRepository.findIpAndPortAndAreaNo(rotaryCabinet.getCupboardNo(), rotaryCabinet.getDeviceInfo().getDeviceIp(), rotaryCabinet.getDeviceInfo().getDevicePort()); |
|||
|
|||
if (!ObjectUtils.isEmpty(rotaryCabinetList)) { |
|||
throw new BaseException("同一IP和端口号下不能重复添加设备"); |
|||
} |
|||
rotaryCabinet.setId(NanoIdUtils.randomNanoId()); |
|||
rotaryCabinet.getDeviceInfo().setId(NanoIdUtils.randomNanoId()); |
|||
|
|||
String position = rotaryCabinet.getCupboardNo() + |
|||
"-" + |
|||
rotaryCabinet.getRowNo() + |
|||
"-" + |
|||
rotaryCabinet.getRowNo() + |
|||
"-" + |
|||
rotaryCabinet.getColumnRowNo(); |
|||
|
|||
String positionName = rotaryCabinet.getCupboardNo() + |
|||
"柜" + |
|||
rotaryCabinet.getRowNo() + |
|||
"层" + |
|||
rotaryCabinet.getColumnRowNo() + |
|||
"列"; |
|||
|
|||
DeviceArchivesTag deviceArchivesTag = new DeviceArchivesTag(); |
|||
|
|||
deviceArchivesTag.setId(NanoIdUtils.randomNanoId()); |
|||
deviceArchivesTag.setPosition(position); |
|||
deviceArchivesTag.setPosition_name(positionName); |
|||
deviceArchivesTag.setDeviceInfoId(rotaryCabinet.getDeviceInfo().getId()); |
|||
//创建联动操作状态对象 |
|||
IsLinkageState(rotaryCabinet); |
|||
IsCallbackState(rotaryCabinet); |
|||
|
|||
deviceArchivesTagRepository.save(deviceArchivesTag); |
|||
|
|||
rotaryCabinetRepository.save(rotaryCabinet); |
|||
|
|||
|
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(RotaryCabinet rotaryCabinet) { |
|||
List<RotaryCabinet> rotaryCabinetList = rotaryCabinetRepository.findIpAndPortAndAreaNo(rotaryCabinet.getCupboardNo(), rotaryCabinet.getDeviceInfo().getDeviceIp(), rotaryCabinet.getDeviceInfo().getDevicePort()); |
|||
if (!ObjectUtils.isEmpty(rotaryCabinetList)) { |
|||
throw new BaseException("同一IP和端口号下不能重复添加设备"); |
|||
} |
|||
RotaryCabinet rotaryCabinet1 = rotaryCabinetRepository.findById(rotaryCabinet.getId()).orElseGet(RotaryCabinet::new); |
|||
if (ObjectUtils.isEmpty(rotaryCabinet1)) { |
|||
throw new BaseException("数据不存在"); |
|||
} |
|||
|
|||
rotaryCabinet1.setDeviceAccount(rotaryCabinet.getDeviceAccount()); |
|||
rotaryCabinet1.setDevicePassword(rotaryCabinet.getDevicePassword()); |
|||
rotaryCabinet1.getDeviceInfo().setDeviceName(rotaryCabinet.getDeviceInfo().getDeviceName()); |
|||
rotaryCabinet1.getDeviceInfo().setDeviceIp(rotaryCabinet.getDeviceInfo().getDeviceIp()); |
|||
rotaryCabinet1.getDeviceInfo().setDevicePort(rotaryCabinet.getDeviceInfo().getDevicePort()); |
|||
rotaryCabinet1.setStoreroomCode(rotaryCabinet.getStoreroomCode()); |
|||
IsLinkageState(rotaryCabinet); |
|||
IsCallbackState(rotaryCabinet); |
|||
rotaryCabinetRepository.save(rotaryCabinet1); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 保存联动操作状态 |
|||
* |
|||
* @param rotaryCabinet / |
|||
*/ |
|||
private void IsLinkageState(RotaryCabinet rotaryCabinet) { |
|||
|
|||
if (StringUtils.isEmpty(rotaryCabinet.getIsLinkage().getId())){ |
|||
OperatingState operatingState = new OperatingState(); |
|||
operatingState.setId(NanoIdUtils.randomNanoId()); |
|||
operatingState.setDeviceId(rotaryCabinet.getId()); |
|||
operatingState.setBorrow(rotaryCabinet.getIsLinkage().getBorrow()); |
|||
operatingState.setInBound(rotaryCabinet.getIsLinkage().getInBound()); |
|||
operatingState.setOutBound(rotaryCabinet.getIsLinkage().getOutBound()); |
|||
operatingState.setLend(rotaryCabinet.getIsLinkage().getLend()); |
|||
operatingState.setStateType(rotaryCabinet.getIsLinkage().getStateType()); |
|||
operatingStateRepository.save(operatingState); |
|||
}else { |
|||
OperatingState operatingState1 = operatingStateRepository.findById(rotaryCabinet.getIsLinkage().getId()).orElseGet(OperatingState::new); |
|||
operatingState1.setDeviceId(rotaryCabinet.getId()); |
|||
operatingState1.setBorrow(rotaryCabinet.getIsLinkage().getBorrow()); |
|||
operatingState1.setInBound(rotaryCabinet.getIsLinkage().getInBound()); |
|||
operatingState1.setOutBound(rotaryCabinet.getIsLinkage().getOutBound()); |
|||
operatingState1.setLend(rotaryCabinet.getIsLinkage().getLend()); |
|||
operatingState1.setStateType(rotaryCabinet.getIsLinkage().getStateType()); |
|||
operatingStateRepository.save(operatingState1); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 保存回调操作状态 |
|||
* |
|||
* @param rotaryCabinet / |
|||
*/ |
|||
private void IsCallbackState(RotaryCabinet rotaryCabinet) { |
|||
|
|||
if (StringUtils.isEmpty(rotaryCabinet.getIsCallback().getId())){ |
|||
OperatingState operatingState = new OperatingState(); |
|||
operatingState.setId(NanoIdUtils.randomNanoId()); |
|||
operatingState.setDeviceId(rotaryCabinet.getId()); |
|||
operatingState.setBorrow(rotaryCabinet.getIsCallback().getBorrow()); |
|||
operatingState.setInBound(rotaryCabinet.getIsCallback().getInBound()); |
|||
operatingState.setOutBound(rotaryCabinet.getIsCallback().getOutBound()); |
|||
operatingState.setLend(rotaryCabinet.getIsCallback().getLend()); |
|||
operatingState.setStateType(rotaryCabinet.getIsCallback().getStateType()); |
|||
operatingStateRepository.save(operatingState); |
|||
}else { |
|||
OperatingState operatingState1 = operatingStateRepository.findById(rotaryCabinet.getIsLinkage().getId()).orElseGet(OperatingState::new); |
|||
operatingState1.setDeviceId(rotaryCabinet.getId()); |
|||
operatingState1.setBorrow(rotaryCabinet.getIsCallback().getBorrow()); |
|||
operatingState1.setInBound(rotaryCabinet.getIsCallback().getInBound()); |
|||
operatingState1.setOutBound(rotaryCabinet.getIsCallback().getOutBound()); |
|||
operatingState1.setLend(rotaryCabinet.getIsCallback().getLend()); |
|||
operatingState1.setStateType(rotaryCabinet.getIsCallback().getStateType()); |
|||
operatingStateRepository.save(operatingState1); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
@ -1,11 +0,0 @@ |
|||
package com.storeroom.modules.device.service.mapstruct; |
|||
|
|||
import com.storeroom.base.BaseMapper; |
|||
import com.storeroom.modules.device.domain.DeseCabinet; |
|||
import com.storeroom.modules.device.service.dto.DeseCabinetDto; |
|||
import org.mapstruct.Mapper; |
|||
import org.mapstruct.ReportingPolicy; |
|||
|
|||
//@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
|||
//public interface DeseCabinetMapper extends BaseMapper<DeseCabinetDto, DeseCabinet> { |
|||
//} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue