|
|
|
@ -1,7 +1,12 @@
|
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.exception.BusinessException;
|
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
import com.ruoyi.common.utils.ShiroUtils;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.ruoyi.system.mapper.BaseMonitorunitTypeMapper;
|
|
|
|
@ -55,6 +60,62 @@ public class BaseMonitorunitTypeServiceImpl implements IBaseMonitorunitTypeServi
|
|
|
|
|
return baseMonitorunitTypeMapper.selectBaseMonitorunitTypeList(baseMonitorunitType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入监控单元类型
|
|
|
|
|
* @author WenJY
|
|
|
|
|
* @date 2022/2/7 9:27
|
|
|
|
|
* @param baseMonitorunitTypes
|
|
|
|
|
* @param updateSupport
|
|
|
|
|
* @return java.lang.String
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String importMould(List<BaseMonitorunitType> baseMonitorunitTypes, boolean updateSupport) {
|
|
|
|
|
if (StringUtils.isNull(baseMonitorunitTypes) || baseMonitorunitTypes.size() == 0) {
|
|
|
|
|
throw new BusinessException("导入标准数据不能为空!");
|
|
|
|
|
}
|
|
|
|
|
int successNum = 0;
|
|
|
|
|
int failureNum = 0;
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
for (BaseMonitorunitType baseMonitorunitType : baseMonitorunitTypes) {
|
|
|
|
|
try {
|
|
|
|
|
List<BaseMonitorunitType> baseMonitorunitTypeList =
|
|
|
|
|
baseMonitorunitTypeMapper.selectBaseMonitorunitTypeList(new BaseMonitorunitType(baseMonitorunitType.getMonitorunittypeId()));
|
|
|
|
|
|
|
|
|
|
if (baseMonitorunitTypeList.size() == 0) {
|
|
|
|
|
baseMonitorunitType.setCreateBy(ShiroUtils.getLoginName());
|
|
|
|
|
baseMonitorunitType.setCreateTime(new Date());
|
|
|
|
|
baseMonitorunitTypeMapper.insertBaseMonitorunitType(baseMonitorunitType);
|
|
|
|
|
successNum++;
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、 " + baseMonitorunitType.getMonitorunittypeName() + " 导入成功");
|
|
|
|
|
} else if (updateSupport) {
|
|
|
|
|
for (BaseMonitorunitType unitType : baseMonitorunitTypeList) {
|
|
|
|
|
baseMonitorunitType.setObjId(unitType.getObjId());
|
|
|
|
|
baseMonitorunitType.setUpdateBy(ShiroUtils.getLoginName());
|
|
|
|
|
baseMonitorunitType.setUpdateTime(new Date());
|
|
|
|
|
baseMonitorunitTypeMapper.updateBaseMonitorunitType(baseMonitorunitType);
|
|
|
|
|
successNum++;
|
|
|
|
|
}
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、" + baseMonitorunitType.getMonitorunittypeName() + " 更新成功");
|
|
|
|
|
} else {
|
|
|
|
|
failureNum++;
|
|
|
|
|
failureMsg.append("<br/>" + failureNum + "、" + baseMonitorunitType.getMonitorunittypeId() + "、" + baseMonitorunitType.getMonitorunittypeName() + " 已存在");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
failureNum++;
|
|
|
|
|
String msg = "<br/>" + failureNum + "、标准: " + baseMonitorunitType.getMonitorunittypeId() + "、" + baseMonitorunitType.getMonitorunittypeName() + " 导入失败:";
|
|
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (failureNum > 0) {
|
|
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
|
throw new BusinessException(failureMsg.toString());
|
|
|
|
|
} else {
|
|
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
|
}
|
|
|
|
|
return successMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增监控单元类型
|
|
|
|
|
*
|
|
|
|
|