IntelligentRecognition/ah-jjsp-service/.svn/pristine/fb/fba115a0fb706050617f72b2662...

163 lines
4.5 KiB
Plaintext

package com.sercurityControl.proteam.service.impl;
import com.securityControl.common.core.utils.StringUtils;
import com.sercurityControl.proteam.domain.vo.DeviceTypeVo;
import com.sercurityControl.proteam.domain.vo.ReturnCodeEntity;
import com.sercurityControl.proteam.mapper.DeviceTypeMapper;
import com.sercurityControl.proteam.service.DeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 设备类型实现类
*/
@Service
public class DeviceTypeServiceImpl implements DeviceTypeService {
@Autowired
private DeviceTypeMapper mapper;
/**
* 查询全部设备类型
* @param deviceTypeVo
* @return
*/
@Override
public List<DeviceTypeVo> getTypeList(DeviceTypeVo deviceTypeVo) {
return mapper.getTypeList(deviceTypeVo);
}
/**
* 查询p节点下拉选
* @param param
* @return
*/
@Override
public List<DeviceTypeVo> getPTypeSelected(String param) {
return mapper.getPTypeSelected(param);
}
/**
* 设备类型添加
* @param typeVo
* @return
*/
@Override
public ReturnCodeEntity addDeviceType(DeviceTypeVo typeVo) {
ReturnCodeEntity entity=new ReturnCodeEntity();
try{
if(StringUtils.isEmpty(typeVo.getpId())){//父节点
typeVo.setpId("0");
}
int num=mapper.getNumByType(typeVo);
if(num>0){
entity.setCode("201");
entity.setMsg("类型名称已存在");
return entity;
}
int num2=mapper.getNumByCode(typeVo);
if(num2>0){
entity.setCode("201");
entity.setMsg("类型编码已存在");
return entity;
}
int num3=mapper.addDeviceType(typeVo);
if(num3>0){
entity.setMsg("添加成功");
entity.setCode("200");
}else{
entity.setMsg("添加失败,请联系管理员");
entity.setCode("202");
}
}catch (Exception e){
entity.setCode("202");
entity.setMsg("网络异常,请联系管理员");
}
return entity;
}
@Override
public DeviceTypeVo getDeviceTypeDetail(String keyId) {
return mapper.getDeviceTypeDetail(keyId);
}
/**
* 修改设备类型
* @param typeVo
* @return
*/
@Override
public ReturnCodeEntity updateDeviceType(DeviceTypeVo typeVo) {
ReturnCodeEntity entity=new ReturnCodeEntity();
try{
if(StringUtils.isEmpty(typeVo.getpId())){//父节点
typeVo.setpId("0");
}
int num=mapper.getNumByType(typeVo);
if(num>0){
entity.setCode("201");
entity.setMsg("类型名称已存在");
return entity;
}
int num2=mapper.getNumByCode(typeVo);
if(num2>0){
entity.setCode("201");
entity.setMsg("类型编码已存在");
return entity;
}
int num3=mapper.updateDeviceType(typeVo);
if(num3>0){
entity.setMsg("修改成功");
entity.setCode("200");
}else{
entity.setMsg("修改失败,请联系管理员");
entity.setCode("202");
}
}catch (Exception e){
entity.setCode("202");
entity.setMsg("网络异常,请联系管理员");
}
return entity;
}
/**
* 设备类型
* @param keyId
* @return
*/
@Override
public ReturnCodeEntity deleteType(String keyId) {
ReturnCodeEntity entity=new ReturnCodeEntity();
try {
int num=mapper.getNumByPId(keyId);
if(num>0) {
entity.setCode("201");
entity.setMsg("请先删除子节点");
return entity;
}
int num2=mapper.deleteType(keyId);
if(num2>0){
entity.setMsg("删除成功");
entity.setCode("200");
}else{
entity.setMsg("删除成功,请联系管理员");
entity.setCode("202");
}
}catch (Exception e){
entity.setCode("202");
entity.setMsg("网络异常,请联系管理员");
}
return entity;
}
}