From 112aceeb646c45a89003738ed66bee8a728aba21 Mon Sep 17 00:00:00 2001 From: huangrenya Date: Tue, 5 Mar 2024 18:15:50 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=9B=91=E7=9D=A3=E6=A3=80?= =?UTF-8?q?=E6=9F=A5-=E6=B7=BB=E5=8A=A0=E6=B0=B4=E9=97=B8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=90=AF=E7=94=A8=E6=80=A7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yxgh/base/enums/SuperviseWayStatus.java | 25 ++++ .../controller/SzSuperviseWayController.java | 2 +- .../sz/service/SzSuperviseWayService.java | 140 ++++++++++-------- 3 files changed, 108 insertions(+), 59 deletions(-) create mode 100644 shuili-system/src/main/java/com/kms/yxgh/base/enums/SuperviseWayStatus.java diff --git a/shuili-system/src/main/java/com/kms/yxgh/base/enums/SuperviseWayStatus.java b/shuili-system/src/main/java/com/kms/yxgh/base/enums/SuperviseWayStatus.java new file mode 100644 index 00000000..65027698 --- /dev/null +++ b/shuili-system/src/main/java/com/kms/yxgh/base/enums/SuperviseWayStatus.java @@ -0,0 +1,25 @@ +package com.kms.yxgh.base.enums; + +import lombok.Getter; + +/** + * 监督检查办法状态 + * @author hry + * @date 2024/3/4 18:57 + */ +@Getter +public enum SuperviseWayStatus { + + ENABLE("启用", "0"), + STOP("停用", "1"), + ; + + private final String value; + private final String name; + + SuperviseWayStatus(String name, String value) { + this.name = name; + this.value = value; + } + +} diff --git a/shuili-system/src/main/java/com/kms/yxgh/sz/controller/SzSuperviseWayController.java b/shuili-system/src/main/java/com/kms/yxgh/sz/controller/SzSuperviseWayController.java index 9c3d278c..f434cbe9 100644 --- a/shuili-system/src/main/java/com/kms/yxgh/sz/controller/SzSuperviseWayController.java +++ b/shuili-system/src/main/java/com/kms/yxgh/sz/controller/SzSuperviseWayController.java @@ -67,7 +67,7 @@ public class SzSuperviseWayController extends BaseController { @ApiOperation("水闸监督检查办法复制") @Log(title = "水闸监督检查办法复制", businessType = BusinessType.INSERT) @PostMapping("/copy/{id}") - public Response copyInfo(@PathVariable String id) throws IOException { + public Response copyInfo(@PathVariable String id) { return Response.ok(superviseWayService.copyInfo(id)); } diff --git a/shuili-system/src/main/java/com/kms/yxgh/sz/service/SzSuperviseWayService.java b/shuili-system/src/main/java/com/kms/yxgh/sz/service/SzSuperviseWayService.java index cc6f9802..5733bee8 100644 --- a/shuili-system/src/main/java/com/kms/yxgh/sz/service/SzSuperviseWayService.java +++ b/shuili-system/src/main/java/com/kms/yxgh/sz/service/SzSuperviseWayService.java @@ -4,8 +4,8 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.kms.framework.config.ServerConfig; import com.kms.yxgh.base.DfException; +import com.kms.yxgh.base.enums.SuperviseWayStatus; import com.kms.yxgh.sz.domain.SzSuperviseWay; import com.kms.yxgh.sz.domain.SzSuperviseWayProject; import com.kms.yxgh.sz.domain.SzSuperviseWayProjectItem; @@ -21,7 +21,6 @@ import com.shuili.common.config.ShuiliConfig; import com.shuili.common.constant.Constants; import com.shuili.common.core.service.BaseService; import com.shuili.common.utils.DateUtils; -import com.shuili.common.utils.FastDfsUtil; import com.shuili.common.utils.file.FileDownloadUtils; import com.shuili.common.utils.uuid.IdUtils; import lombok.AllArgsConstructor; @@ -42,10 +41,8 @@ import java.util.stream.Collectors; @AllArgsConstructor public class SzSuperviseWayService extends BaseService { - private final SzSuperviseWayProjectMapper wayProjectService; + private final SzSuperviseWayProjectMapper wayProjectMapper; private final SzSuperviseWayProjectItemMapper projectItemMapper; - private final ServerConfig serverConfig; - private final FastDfsUtil fastDfsUtil; @Transactional(rollbackFor = Exception.class) public SzSuperviseWayDto addOrModify(SzSuperviseWayDto dto) { @@ -53,10 +50,37 @@ public class SzSuperviseWayService extends BaseServicelambdaQuery().eq(SzSuperviseWay::getStatus, SuperviseWayStatus.ENABLE.getValue())); + } + public SzSuperviseWayDto getDetailById(String id) { SzSuperviseWay superviseWay = this.getById(id); return BeanCopyUtils.copy(superviseWay, SzSuperviseWayDto.class); @@ -64,57 +88,57 @@ public class SzSuperviseWayService extends BaseService projectList = listData(superviseWay.getId()); - superviseWay.setId(null); - this.saveOrUpdate(superviseWay); - if (projectList.isEmpty()) { + // 1.3 查询水闸监督检查办法项目 + List projectList = listData(id); + if (projectList.isEmpty()) { + return true; + } + List list = BeanCopyUtils.copyList(projectList, SzSuperviseWayProject.class); + list.forEach(v -> { + List listItem = projectItemMapper.selectList( + Wrappers.lambdaQuery().eq(SzSuperviseWayProjectItem::getProjectId, v.getId())); + // 新增项目 + v.setId(null); + v.setWayId(superviseWay.getId()); + wayProjectMapper.insert(v); + + // 1.4 新增水闸监督检查办法项目内容 + if (!listItem.isEmpty()) { + listItem.forEach(val -> { + val.setId(null); + val.setProjectId(v.getId()); + projectItemMapper.insert(val); + }); + } + }); return true; } - List list = BeanCopyUtils.copyList(projectList, SzSuperviseWayProject.class); - list.forEach(v -> { - List listItem = projectItemMapper.selectList( - Wrappers.lambdaQuery().eq(SzSuperviseWayProjectItem::getProjectId, v.getId())); - - // 新增项目 - v.setId(null); - v.setWayId(superviseWayNew.getId()); - wayProjectService.insert(v); - - // 1.4 新增水闸监督检查办法项目内容 - if (!listItem.isEmpty()) { - listItem.forEach(val -> { - val.setId(null); - val.setProjectId(v.getId()); - projectItemMapper.insert(val); - }); + + private void copyFile(String checkWayFile, SzSuperviseWay superviseWayNew) { + String localPath = ShuiliConfig.getProfile(); + try { + String suffix = checkWayFile.substring(checkWayFile.lastIndexOf(".")); + String serverUrl = checkWayFile.substring(0, checkWayFile.lastIndexOf("/profile")); + // 文件名地址 + String pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + suffix; + // 复制文件 + FileDownloadUtils.downloadFile(checkWayFile, localPath, localPath + Constants.RESOURCE_PREFIX + pathName); + superviseWayNew.setSuperviseCheckWay(serverUrl + Constants.RESOURCE_PREFIX + "/" + pathName); + } catch (Exception e) { + e.printStackTrace(); } - }); -}catch (Exception e){ - e.printStackTrace(); -} - return true; } @@ -126,33 +150,33 @@ try { public SzSuperviseWayProjectDto getDataById(String dataId) { - SzSuperviseWayProject superviseWayData = wayProjectService.selectById(dataId); + SzSuperviseWayProject superviseWayData = wayProjectMapper.selectById(dataId); return BeanCopyUtils.copy(superviseWayData, SzSuperviseWayProjectDto.class); } @Transactional(rollbackFor = Exception.class) public SzSuperviseWayProjectDto addData(SzSuperviseWayProjectDto dataDto) { SzSuperviseWayProject superviseWayData = BeanCopyUtils.copy(dataDto, SzSuperviseWayProject.class); - wayProjectService.insert(BeanCopyUtils.copy(dataDto, superviseWayData)); + wayProjectMapper.insert(BeanCopyUtils.copy(dataDto, superviseWayData)); return BeanCopyUtils.copy(superviseWayData, SzSuperviseWayProjectDto.class); } @Transactional(rollbackFor = Exception.class) public SzSuperviseWayProjectDto updateData(SzSuperviseWayProjectDto dataDto) { SzSuperviseWayProject dataEntity = BeanCopyUtils.copy(dataDto, SzSuperviseWayProject.class); - wayProjectService.updateById(dataEntity); + wayProjectMapper.updateById(dataEntity); return dataDto; } @Transactional(rollbackFor = Exception.class) public boolean deleteByDataId(String id) { - wayProjectService.deleteById(id); + wayProjectMapper.deleteById(id); return true; } public List listData(String wayId) { - List list = wayProjectService.selectList( + List list = wayProjectMapper.selectList( Wrappers.lambdaQuery().eq(SzSuperviseWayProject::getWayId, wayId)); return BeanCopyUtils.copyList(list, SzSuperviseWayProjectDto.class); } @@ -173,7 +197,7 @@ try { public SzSuperviseWayProjectItemDto getDataItemById(String id) { SzSuperviseWayProjectItem projectItem = projectItemMapper.selectById(id); return BeanCopyUtils.copy(projectItem, SzSuperviseWayProjectItemDto.class); - } + } @Transactional(rollbackFor = Exception.class) public SzSuperviseWayProjectItemDto addDataItem(SzSuperviseWayProjectItemDto dto) { @@ -199,7 +223,7 @@ try { public SzSuperviseWayOtherDto getEnableSuperviseWay() { SzSuperviseWayOtherDto superviseWayOtherDto = new SzSuperviseWayOtherDto(); // 1.1 查询启用的水闸监督检查办法 - SzSuperviseWay enable = this.getOne(Wrappers.lambdaQuery().eq(SzSuperviseWay::getStatus, "0")); + SzSuperviseWay enable = getEnableWay(); if (enable == null) { return superviseWayOtherDto; }