|
|
|
@ -19,177 +19,187 @@ import com.ruoyi.common.core.text.Convert;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 监控单元信息Service业务层处理
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @author wenjy
|
|
|
|
|
* @date 2022-01-27
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoService
|
|
|
|
|
{
|
|
|
|
|
@Autowired
|
|
|
|
|
private BaseMonitorunitInfoMapper baseMonitorunitInfoMapper;
|
|
|
|
|
public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoService {
|
|
|
|
|
@Autowired private BaseMonitorunitInfoMapper baseMonitorunitInfoMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param ObjId 监控单元信息主键
|
|
|
|
|
* @return 监控单元信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public BaseMonitorunitInfo selectBaseMonitorunitInfoByObjId(Long ObjId)
|
|
|
|
|
{
|
|
|
|
|
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoByObjId(ObjId);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param ObjId 监控单元信息主键
|
|
|
|
|
* @return 监控单元信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public BaseMonitorunitInfo selectBaseMonitorunitInfoByObjId(Long ObjId) {
|
|
|
|
|
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoByObjId(ObjId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息列表
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 监控单元信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BaseMonitorunitInfo> selectBaseMonitorunitInfoList(BaseMonitorunitInfo baseMonitorunitInfo)
|
|
|
|
|
{
|
|
|
|
|
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(baseMonitorunitInfo);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息列表
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 监控单元信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BaseMonitorunitInfo> selectBaseMonitorunitInfoList(
|
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo) {
|
|
|
|
|
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(baseMonitorunitInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息列表
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 监控单元信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoList(BaseMonitorunitInfo baseMonitorunitInfo)
|
|
|
|
|
{
|
|
|
|
|
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息列表
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 监控单元信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoList(
|
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo) {
|
|
|
|
|
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入监控单元信息
|
|
|
|
|
* @author WenJY
|
|
|
|
|
* @date 2022/2/7 9:53
|
|
|
|
|
* @param baseMonitorunitInfos
|
|
|
|
|
* @param updateSupport
|
|
|
|
|
* @return java.lang.String
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String importMould(List<BaseMonitorunitInfo> baseMonitorunitInfos, boolean updateSupport) {
|
|
|
|
|
if (StringUtils.isNull(baseMonitorunitInfos) || baseMonitorunitInfos.size() == 0) {
|
|
|
|
|
throw new BusinessException("导入标准数据不能为空!");
|
|
|
|
|
}
|
|
|
|
|
int successNum = 0;
|
|
|
|
|
int failureNum = 0;
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
for (BaseMonitorunitInfo baseMonitorunitInfo : baseMonitorunitInfos) {
|
|
|
|
|
try {
|
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfoList =
|
|
|
|
|
baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo(baseMonitorunitInfo.getMonitorunitId()));
|
|
|
|
|
/**
|
|
|
|
|
* 导入监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @author WenJY
|
|
|
|
|
* @date 2022/2/7 9:53
|
|
|
|
|
* @param baseMonitorunitInfos
|
|
|
|
|
* @param updateSupport
|
|
|
|
|
* @return java.lang.String
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String importMould(List<BaseMonitorunitInfo> baseMonitorunitInfos, boolean updateSupport) {
|
|
|
|
|
if (StringUtils.isNull(baseMonitorunitInfos) || baseMonitorunitInfos.size() == 0) {
|
|
|
|
|
throw new BusinessException("导入标准数据不能为空!");
|
|
|
|
|
}
|
|
|
|
|
int successNum = 0;
|
|
|
|
|
int failureNum = 0;
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
for (BaseMonitorunitInfo baseMonitorunitInfo : baseMonitorunitInfos) {
|
|
|
|
|
try {
|
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfoList =
|
|
|
|
|
baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(
|
|
|
|
|
new BaseMonitorunitInfo(baseMonitorunitInfo.getMonitorunitId()));
|
|
|
|
|
|
|
|
|
|
if (baseMonitorunitInfoList.size() == 0) {
|
|
|
|
|
baseMonitorunitInfo.setCreateBy(ShiroUtils.getLoginName());
|
|
|
|
|
baseMonitorunitInfo.setCreateTime(new Date());
|
|
|
|
|
baseMonitorunitInfoMapper.insertBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
successNum++;
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、 " + baseMonitorunitInfo.getMonitorunitName() + " 导入成功");
|
|
|
|
|
} else if (updateSupport) {
|
|
|
|
|
for (BaseMonitorunitInfo unitInfo : baseMonitorunitInfoList) {
|
|
|
|
|
baseMonitorunitInfo.setObjId(unitInfo.getObjId());
|
|
|
|
|
baseMonitorunitInfo.setUpdateBy(ShiroUtils.getLoginName());
|
|
|
|
|
baseMonitorunitInfo.setUpdateTime(new Date());
|
|
|
|
|
baseMonitorunitInfoMapper.updateBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
successNum++;
|
|
|
|
|
}
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、" + baseMonitorunitInfo.getMonitorunitName() + " 更新成功");
|
|
|
|
|
} else {
|
|
|
|
|
failureNum++;
|
|
|
|
|
failureMsg.append("<br/>" + failureNum + "、" + baseMonitorunitInfo.getMonitorunitId() + "、" + baseMonitorunitInfo.getMonitorunitName() + " 已存在");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
failureNum++;
|
|
|
|
|
String msg = "<br/>" + failureNum + "、标准: " + baseMonitorunitInfo.getMonitorunitId() + "、" + baseMonitorunitInfo.getMonitorunitName() + " 导入失败:";
|
|
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (failureNum > 0) {
|
|
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
|
throw new BusinessException(failureMsg.toString());
|
|
|
|
|
if (baseMonitorunitInfoList.size() == 0) {
|
|
|
|
|
baseMonitorunitInfo.setCreateBy(ShiroUtils.getLoginName());
|
|
|
|
|
baseMonitorunitInfo.setCreateTime(new Date());
|
|
|
|
|
baseMonitorunitInfoMapper.insertBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
successNum++;
|
|
|
|
|
successMsg.append(
|
|
|
|
|
"<br/>" + successNum + "、 " + baseMonitorunitInfo.getMonitorunitName() + " 导入成功");
|
|
|
|
|
} else if (updateSupport) {
|
|
|
|
|
for (BaseMonitorunitInfo unitInfo : baseMonitorunitInfoList) {
|
|
|
|
|
baseMonitorunitInfo.setObjId(unitInfo.getObjId());
|
|
|
|
|
baseMonitorunitInfo.setUpdateBy(ShiroUtils.getLoginName());
|
|
|
|
|
baseMonitorunitInfo.setUpdateTime(new Date());
|
|
|
|
|
baseMonitorunitInfoMapper.updateBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
successNum++;
|
|
|
|
|
}
|
|
|
|
|
successMsg.append(
|
|
|
|
|
"<br/>" + successNum + "、" + baseMonitorunitInfo.getMonitorunitName() + " 更新成功");
|
|
|
|
|
} else {
|
|
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
|
failureNum++;
|
|
|
|
|
failureMsg.append(
|
|
|
|
|
"<br/>"
|
|
|
|
|
+ failureNum
|
|
|
|
|
+ "、"
|
|
|
|
|
+ baseMonitorunitInfo.getMonitorunitId()
|
|
|
|
|
+ "、"
|
|
|
|
|
+ baseMonitorunitInfo.getMonitorunitName()
|
|
|
|
|
+ " 已存在");
|
|
|
|
|
}
|
|
|
|
|
return successMsg.toString();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
failureNum++;
|
|
|
|
|
String msg =
|
|
|
|
|
"<br/>"
|
|
|
|
|
+ failureNum
|
|
|
|
|
+ "、标准: "
|
|
|
|
|
+ baseMonitorunitInfo.getMonitorunitId()
|
|
|
|
|
+ "、"
|
|
|
|
|
+ baseMonitorunitInfo.getMonitorunitName()
|
|
|
|
|
+ " 导入失败:";
|
|
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int insertBaseMonitorunitInfo(BaseMonitorunitInfo baseMonitorunitInfo)
|
|
|
|
|
{
|
|
|
|
|
baseMonitorunitInfo.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
return baseMonitorunitInfoMapper.insertBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
if (failureNum > 0) {
|
|
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
|
throw new BusinessException(failureMsg.toString());
|
|
|
|
|
} else {
|
|
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
|
}
|
|
|
|
|
return successMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int updateBaseMonitorunitInfo(BaseMonitorunitInfo baseMonitorunitInfo)
|
|
|
|
|
{
|
|
|
|
|
baseMonitorunitInfo.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
return baseMonitorunitInfoMapper.updateBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 新增监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int insertBaseMonitorunitInfo(BaseMonitorunitInfo baseMonitorunitInfo) {
|
|
|
|
|
baseMonitorunitInfo.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
return baseMonitorunitInfoMapper.insertBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param ObjIds 需要删除的监控单元信息主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteBaseMonitorunitInfoByObjIds(String ObjIds)
|
|
|
|
|
{
|
|
|
|
|
return baseMonitorunitInfoMapper.deleteBaseMonitorunitInfoByObjIds(Convert.toStrArray(ObjIds));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 修改监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param baseMonitorunitInfo 监控单元信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int updateBaseMonitorunitInfo(BaseMonitorunitInfo baseMonitorunitInfo) {
|
|
|
|
|
baseMonitorunitInfo.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
return baseMonitorunitInfoMapper.updateBaseMonitorunitInfo(baseMonitorunitInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除监控单元信息信息
|
|
|
|
|
*
|
|
|
|
|
* @param ObjId 监控单元信息主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteBaseMonitorunitInfoByObjId(Long ObjId)
|
|
|
|
|
{
|
|
|
|
|
return baseMonitorunitInfoMapper.deleteBaseMonitorunitInfoByObjId(ObjId);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除监控单元信息
|
|
|
|
|
*
|
|
|
|
|
* @param ObjIds 需要删除的监控单元信息主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteBaseMonitorunitInfoByObjIds(String ObjIds) {
|
|
|
|
|
return baseMonitorunitInfoMapper.deleteBaseMonitorunitInfoByObjIds(Convert.toStrArray(ObjIds));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息树列表
|
|
|
|
|
*
|
|
|
|
|
* @return 所有监控单元信息信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Ztree> selectBaseMonitorunitInfoTree()
|
|
|
|
|
{
|
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfoList = baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
|
|
|
|
|
List<Ztree> ztrees = new ArrayList<Ztree>();
|
|
|
|
|
for (BaseMonitorunitInfo baseMonitorunitInfo : baseMonitorunitInfoList)
|
|
|
|
|
{
|
|
|
|
|
Ztree ztree = new Ztree();
|
|
|
|
|
ztree.setId(baseMonitorunitInfo.getMonitorunitId());
|
|
|
|
|
ztree.setpId(baseMonitorunitInfo.getParentId());
|
|
|
|
|
ztree.setName(baseMonitorunitInfo.getMonitorunitName());
|
|
|
|
|
ztree.setTitle(baseMonitorunitInfo.getMonitorunitName());
|
|
|
|
|
ztrees.add(ztree);
|
|
|
|
|
}
|
|
|
|
|
return ztrees;
|
|
|
|
|
/**
|
|
|
|
|
* 删除监控单元信息信息
|
|
|
|
|
*
|
|
|
|
|
* @param ObjId 监控单元信息主键
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteBaseMonitorunitInfoByObjId(Long ObjId) {
|
|
|
|
|
return baseMonitorunitInfoMapper.deleteBaseMonitorunitInfoByObjId(ObjId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询监控单元信息树列表
|
|
|
|
|
*
|
|
|
|
|
* @return 所有监控单元信息信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Ztree> selectBaseMonitorunitInfoTree() {
|
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfoList =
|
|
|
|
|
baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
|
|
|
|
|
List<Ztree> ztrees = new ArrayList<Ztree>();
|
|
|
|
|
for (BaseMonitorunitInfo baseMonitorunitInfo : baseMonitorunitInfoList) {
|
|
|
|
|
Ztree ztree = new Ztree();
|
|
|
|
|
ztree.setId(baseMonitorunitInfo.getMonitorunitId());
|
|
|
|
|
ztree.setpId(baseMonitorunitInfo.getParentId());
|
|
|
|
|
ztree.setName(baseMonitorunitInfo.getMonitorunitName());
|
|
|
|
|
ztree.setTitle(baseMonitorunitInfo.getMonitorunitName());
|
|
|
|
|
ztrees.add(ztree);
|
|
|
|
|
}
|
|
|
|
|
return ztrees;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|