|
|
@ -1,7 +1,13 @@
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.exception.BusinessException;
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.ShiroUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitInfo;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.ruoyi.system.mapper.BaseSensorTypeMapper;
|
|
|
|
import com.ruoyi.system.mapper.BaseSensorTypeMapper;
|
|
|
@ -45,6 +51,62 @@ public class BaseSensorTypeServiceImpl implements IBaseSensorTypeService
|
|
|
|
return baseSensorTypeMapper.selectBaseSensorTypeList(baseSensorType);
|
|
|
|
return baseSensorTypeMapper.selectBaseSensorTypeList(baseSensorType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 导入传感器类型信息
|
|
|
|
|
|
|
|
* @author WenJY
|
|
|
|
|
|
|
|
* @date 2022/2/7 10:36
|
|
|
|
|
|
|
|
* @param baseSensorTypes
|
|
|
|
|
|
|
|
* @param updateSupport
|
|
|
|
|
|
|
|
* @return java.lang.String
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String importMould(List<BaseSensorType> baseSensorTypes, boolean updateSupport) {
|
|
|
|
|
|
|
|
if (StringUtils.isNull(baseSensorTypes) || baseSensorTypes.size() == 0) {
|
|
|
|
|
|
|
|
throw new BusinessException("导入标准数据不能为空!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int successNum = 0;
|
|
|
|
|
|
|
|
int failureNum = 0;
|
|
|
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
|
|
|
for (BaseSensorType baseSensorType : baseSensorTypes) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<BaseSensorType> baseSensorTypeList =
|
|
|
|
|
|
|
|
baseSensorTypeMapper.selectBaseSensorTypeList(new BaseSensorType(baseSensorType.getSensortypeId()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (baseSensorTypeList.size() == 0) {
|
|
|
|
|
|
|
|
baseSensorType.setCreateBy(ShiroUtils.getLoginName());
|
|
|
|
|
|
|
|
baseSensorType.setCreateTime(new Date());
|
|
|
|
|
|
|
|
baseSensorTypeMapper.insertBaseSensorType(baseSensorType);
|
|
|
|
|
|
|
|
successNum++;
|
|
|
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、 " + baseSensorType.getSensortypeName() + " 导入成功");
|
|
|
|
|
|
|
|
} else if (updateSupport) {
|
|
|
|
|
|
|
|
for (BaseSensorType sensorType : baseSensorTypeList) {
|
|
|
|
|
|
|
|
baseSensorType.setObjId(sensorType.getObjId());
|
|
|
|
|
|
|
|
baseSensorType.setUpdateBy(ShiroUtils.getLoginName());
|
|
|
|
|
|
|
|
baseSensorType.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
baseSensorTypeMapper.updateBaseSensorType(baseSensorType);
|
|
|
|
|
|
|
|
successNum++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、" + baseSensorType.getSensortypeName() + " 更新成功");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
failureNum++;
|
|
|
|
|
|
|
|
failureMsg.append("<br/>" + failureNum + "、" + baseSensorType.getSensortypeId() + "、" + baseSensorType.getSensortypeName() + " 已存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
failureNum++;
|
|
|
|
|
|
|
|
String msg = "<br/>" + failureNum + "、标准: " + baseSensorType.getSensortypeId() + "、" + baseSensorType.getSensortypeName() + " 导入失败:";
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 新增传感器类型
|
|
|
|
* 新增传感器类型
|
|
|
|
*
|
|
|
|
*
|
|
|
|