From fbb42c700dc47e0e448871dd0624dcdafa502842 Mon Sep 17 00:00:00 2001 From: wenjy Date: Mon, 7 Feb 2022 10:32:59 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E7=9B=91=E6=8E=A7=E5=8D=95?= =?UTF-8?q?=E5=85=83=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/pom.xml | 9 + .../base/BaseMonitorunitInfoController.java | 39 +++- .../base/monitorUnitInfo/monitorUnitInfo.html | 215 ++++++++++-------- .../ruoyi/common/core/domain/TreeEntity.java | 3 + ruoyi-system/pom.xml | 4 + .../system/domain/BaseMonitorunitInfo.java | 7 + .../domain/dto/BaseMonitorunitInfoDto.java | 18 ++ .../mapper/BaseMonitorunitInfoMapper.java | 10 + .../service/IBaseMonitorunitInfoService.java | 19 ++ .../impl/BaseMonitorunitInfoServiceImpl.java | 74 ++++++ .../system/BaseMonitorunitInfoMapper.xml | 35 +++ 11 files changed, 338 insertions(+), 95 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 343b780..a5d041d 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -67,6 +67,15 @@ ruoyi-generator + + + org.projectlombok + lombok + 1.18.20 + provided + + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java index 61d2d95..7e8c8de 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.List; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -22,6 +23,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.core.domain.Ztree; +import org.springframework.web.multipart.MultipartFile; /** * 监控单元信息Controller @@ -51,12 +53,45 @@ public class BaseMonitorunitInfoController extends BaseController @RequiresPermissions("base:monitorUnitInfo:list") @PostMapping("/list") @ResponseBody - public List list(BaseMonitorunitInfo baseMonitorunitInfo) + public List list(BaseMonitorunitInfo baseMonitorunitInfo) { - List list = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(baseMonitorunitInfo); + List list = baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); return list; } + /** + * 获取导入模板 + * @author WenJY + * @date 2022/2/7 9:57 + * @return com.ruoyi.common.core.domain.AjaxResult + */ + @RequiresPermissions("base:monitorUnitInfo:importTemplate") + @GetMapping("/importTemplate") + @ResponseBody + public AjaxResult importTemplate() { + ExcelUtil util = new ExcelUtil(BaseMonitorunitInfo.class); + return util.importTemplateExcel("监控单元信息"); + } + + /** + * 导入监控单元信息 + * @author WenJY + * @date 2022/2/7 9:58 + * @param file + * @param updateSupport + * @return com.ruoyi.common.core.domain.AjaxResult + */ + @RequiresPermissions("base:monitorUnitInfo:importData") + @PostMapping("/importData") + @ResponseBody + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { + ExcelUtil util = new ExcelUtil(BaseMonitorunitInfo.class); + //读取file文件将文件内容转为list集合 + List baseMonitorunitInfoList = util.importExcel(file.getInputStream()); + String message = baseMonitorunitInfoService.importMould(baseMonitorunitInfoList,updateSupport); + return AjaxResult.success(message); + } + /** * 导出监控单元信息列表 */ diff --git a/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html b/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html index eb866d7..858d9f7 100644 --- a/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html +++ b/ruoyi-admin/src/main/resources/templates/base/monitorUnitInfo/monitorUnitInfo.html @@ -1,97 +1,110 @@ - + -
-
-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
  • -  搜索 -  重置 -
  • -
-
-
-
+
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
- -
-
-
+ +
+
- - + }; + $.treeTable.init(options); + }); + + + \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java index 1e21460..cc91f04 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java @@ -1,5 +1,7 @@ package com.ruoyi.common.core.domain; +import com.ruoyi.common.annotation.Excel; + /** * Tree基类 * @@ -13,6 +15,7 @@ public class TreeEntity extends BaseEntity private String parentName; /** 父菜单ID */ + @Excel(name = "父级编号") private String parentId; /** 显示顺序 */ diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index bad780f..ec2518b 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -22,6 +22,10 @@ com.ruoyi ruoyi-common + + org.projectlombok + lombok + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java index 2620911..1e58509 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java @@ -15,6 +15,13 @@ public class BaseMonitorunitInfo extends TreeEntity { private static final long serialVersionUID = 1L; + public BaseMonitorunitInfo() { + } + + public BaseMonitorunitInfo(String monitorunitId) { + this.monitorunitId = monitorunitId; + } + /** 主键标识 */ private Long objId; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java new file mode 100644 index 0000000..adca0b2 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java @@ -0,0 +1,18 @@ +package com.ruoyi.system.domain.dto; + +import com.ruoyi.system.domain.BaseMonitorunitInfo; +import lombok.Data; + +/** + * @author WenJY + * @date 2022年02月07日 10:12 + */ +@Data +public class BaseMonitorunitInfoDto extends BaseMonitorunitInfo { + + private String monitorunitTypeName; + + private String substationName; + + private String parentName; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java index cdf3ce8..ea21529 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.BaseMonitorunitInfo; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; /** * 监控单元信息Mapper接口 @@ -27,6 +28,15 @@ public interface BaseMonitorunitInfoMapper */ public List selectBaseMonitorunitInfoList(BaseMonitorunitInfo baseMonitorunitInfo); + /** + * 查询监控单元信息列表 + * @author WenJY + * @date 2022/2/7 10:23 + * @param baseMonitorunitInfo + * @return java.util.List + */ + public List selectBaseMonitorunitInfoDtoList(BaseMonitorunitInfo baseMonitorunitInfo); + /** * 新增监控单元信息 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java index 9472d61..5d533a0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java @@ -3,6 +3,7 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.BaseMonitorunitInfo; import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; /** * 监控单元信息Service接口 @@ -28,6 +29,24 @@ public interface IBaseMonitorunitInfoService */ public List selectBaseMonitorunitInfoList(BaseMonitorunitInfo baseMonitorunitInfo); + /** + * 查询监控单元信息列表 + * + * @param baseMonitorunitInfo 监控单元信息 + * @return 监控单元信息集合 + */ + public List selectBaseMonitorunitInfoDtoList(BaseMonitorunitInfo baseMonitorunitInfo); + + /** + * 导入监控单元信息 + * @author WenJY + * @date 2022/2/7 9:53 + * @param baseMonitorunitInfos + * @param updateSupport + * @return java.lang.String + */ + public String importMould(List baseMonitorunitInfos, boolean updateSupport); + /** * 新增监控单元信息 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java index 4870f90..26f1ff8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java @@ -1,9 +1,15 @@ package com.ruoyi.system.service.impl; +import java.util.Date; import java.util.List; import java.util.ArrayList; import com.ruoyi.common.core.domain.Ztree; +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 com.ruoyi.system.domain.BaseMonitorunitType; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.BaseMonitorunitInfoMapper; @@ -47,6 +53,74 @@ public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoServi return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(baseMonitorunitInfo); } + /** + * 查询监控单元信息列表 + * + * @param baseMonitorunitInfo 监控单元信息 + * @return 监控单元信息 + */ + @Override + public List 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 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 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("
" + 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("
" + successNum + "、" + baseMonitorunitInfo.getMonitorunitName() + " 更新成功"); + } else { + failureNum++; + failureMsg.append("
" + failureNum + "、" + baseMonitorunitInfo.getMonitorunitId() + "、" + baseMonitorunitInfo.getMonitorunitName() + " 已存在"); + } + } catch (Exception e) { + failureNum++; + String msg = "
" + failureNum + "、标准: " + baseMonitorunitInfo.getMonitorunitId() + "、" + baseMonitorunitInfo.getMonitorunitName() + " 导入失败:"; + 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(); + } + /** * 新增监控单元信息 * diff --git a/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml index b3a4b3e..9105a28 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml @@ -19,6 +19,23 @@ + + + + + + + + + + + + + + + + + select ObjId, MonitorUnit_Id, MonitorUnit_Name, Parent_Id, MonitorUnit_Type, Substation_Id, Enable_Flag, Create_By, Create_Time, Update_By, Update_Time from base_monitorunit_info @@ -36,6 +53,24 @@ order by Parent_Id + +