|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.bellmann.common.base.BasePageQuery; |
|
|
|
|
import com.bellmann.common.base.IBaseEnum; |
|
|
|
|
import com.bellmann.common.enums.DevTypeVerStatusEnum; |
|
|
|
|
import com.bellmann.common.exception.BusinessException; |
|
|
|
|
import com.bellmann.common.model.Option; |
|
|
|
|
import com.bellmann.common.result.Result; |
|
|
|
|
import com.bellmann.common.result.ResultCode; |
|
|
|
@ -14,6 +15,7 @@ import com.bellmann.mapper.DeviceTypeVerMapper; |
|
|
|
|
import com.bellmann.model.bo.DeviceTypePageBO; |
|
|
|
|
import com.bellmann.model.entity.DeviceType; |
|
|
|
|
import com.bellmann.model.entity.DeviceTypeVer; |
|
|
|
|
import com.bellmann.model.form.DeviceTypeForm; |
|
|
|
|
import com.bellmann.model.query.DeviceTypeQuery; |
|
|
|
|
import com.bellmann.model.query.Tr069BindingPageQuery; |
|
|
|
|
import com.bellmann.model.vo.DeviceTypePageVO; |
|
|
|
@ -21,6 +23,10 @@ import com.bellmann.model.vo.DeviceTypeVO; |
|
|
|
|
import com.bellmann.model.vo.Tr069BindingVO; |
|
|
|
|
import com.bellmann.security.util.SecurityUtils; |
|
|
|
|
import com.bellmann.service.DeviceTypeService; |
|
|
|
|
import com.zznode.itms.api.InventoryManager; |
|
|
|
|
import com.zznode.itms.idl.resourcedefinition.RDevTypeStruct; |
|
|
|
|
import com.zznode.itms.idl.resourcedefinition.RDevTypeStructHolder; |
|
|
|
|
import com.zznode.itms.idl.resourcedefinition.RStringListHolder; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -165,4 +171,44 @@ public class DeviceTypeServiceImpl implements DeviceTypeService { |
|
|
|
|
tr069BindingVOPage.setRecords(collect); |
|
|
|
|
return tr069BindingVOPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addDeviceType(DeviceTypeForm form) { |
|
|
|
|
RDevTypeStruct rDevTypeStruct = new RDevTypeStruct(); |
|
|
|
|
rDevTypeStruct.devTypeName = form.getDevTypeName(); |
|
|
|
|
rDevTypeStruct.devVendorName = form.getDevVendorName(); |
|
|
|
|
String sql = "SELECT DEV_VENDOR_OUI FROM ITMS_DEVICE_TYPE WHERE 1=1 AND DEV_VENDOR_NAME =" + "'" + form.getDevVendorName() + "' "; |
|
|
|
|
RStringListHolder queryHolder = new RStringListHolder(); |
|
|
|
|
int result = InventoryManager.getDistinctStrings(sql, queryHolder); |
|
|
|
|
if (result != 0){ |
|
|
|
|
throw new BusinessException(ResultCode.DATA_NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
if(queryHolder.value.length>0&&queryHolder.value[0].equals(form.getDevVendorOui())){ |
|
|
|
|
rDevTypeStruct.devVendorOUI = form.getDevVendorOui(); |
|
|
|
|
}else if(queryHolder.value.length>0&&(!queryHolder.value[0].equals(form.getDevVendorOui()))){ |
|
|
|
|
throw new BusinessException(ResultCode.THE_SUPPLIER_OUI_CANNOT_BE_MODIFIED); |
|
|
|
|
}else { |
|
|
|
|
if(form.getDevVendorOui().isEmpty()){ |
|
|
|
|
String sql2 = "SELECT DEV_VENDOR_OUI FROM ITMS_DEVICE_TYPE WHERE 1=1 AND DEV_VENDOR_OUI=" + "'" + form.getDevVendorOui() + "'"; |
|
|
|
|
RStringListHolder queryHolder2 = new RStringListHolder(); |
|
|
|
|
result = InventoryManager.getDistinctStrings(sql2, queryHolder2); |
|
|
|
|
if (result != 0){ |
|
|
|
|
throw new BusinessException(ResultCode.DATA_NOT_FOUND); |
|
|
|
|
} |
|
|
|
|
if(queryHolder2.value.length>0){ |
|
|
|
|
throw new BusinessException(ResultCode.THE_VENDOR_OUI_ALREADY_EXISTS); |
|
|
|
|
} |
|
|
|
|
rDevTypeStruct.devVendorOUI = form.getDevVendorOui(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
rDevTypeStruct.devHardVer = form.getDevHardVer(); |
|
|
|
|
rDevTypeStruct.devTypeDesc = form.getDevTypeDesc(); |
|
|
|
|
// 设备类型插入的时候报错,由于productType为null
|
|
|
|
|
rDevTypeStruct.productType = ""; |
|
|
|
|
RDevTypeStructHolder holder = new RDevTypeStructHolder(rDevTypeStruct); |
|
|
|
|
int returnValue = InventoryManager.addDevType(holder); |
|
|
|
|
if (returnValue != 0){ |
|
|
|
|
throw new BusinessException(ResultCode.ADD_DEVICE_TYPE_FAIL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|