From b4bd03c5450f48968e1773ef46e51d0e6698961f Mon Sep 17 00:00:00 2001 From: zhangbaojian <1065122561@qq.com> Date: Wed, 19 Apr 2023 14:23:25 +0800 Subject: [PATCH] =?UTF-8?q?zbj//1.=E5=A4=A7=E5=B1=8F=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9A=82=E9=99=8D=E4=BA=8B=E4=BB=B6=E6=9C=80=E6=96=B050?= =?UTF-8?q?=E6=9D=A1=E6=95=B0=E6=8D=AEsql=E6=9B=B4=E6=94=B9=202.=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=AE=A1=E7=90=86=20=E5=88=A0=E9=99=A4=E8=B5=84?= =?UTF-8?q?=E6=BA=90/=E4=B8=8B=E8=BD=BD=E8=B5=84=E6=BA=90/=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../majornetwork/LargeScreenMapper.java | 4 +- .../mapping/LargeScreenMapper.xml | 35 +++++----- .../Impl/LargeScreenServiceImpl.java | 15 +--- .../system/pojo/po/ResinformationParam.java | 31 +++++++++ .../ResourceAdministrationController.java | 68 +++++++++++++++++-- .../mapper/ResourceAdministrationMapper.java | 4 ++ .../mapping/ResourceAdministrationMapper.xml | 5 ++ .../IResourceAdministrationService.java | 13 +++- .../ResourceAdministrationServiceImpl.java | 63 ++++++++++++++++- 9 files changed, 198 insertions(+), 40 deletions(-) create mode 100644 pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/ResinformationParam.java diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/LargeScreenMapper.java b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/LargeScreenMapper.java index 52cd46660..e2d0cd0ac 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/LargeScreenMapper.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/LargeScreenMapper.java @@ -6,6 +6,7 @@ import com.njcn.device.pq.pojo.vo.EventVO; import com.njcn.device.pq.pojo.vo.MiddleChildVO; import com.njcn.device.pq.pojo.vo.MiddleLimitRateVO; import com.njcn.harmonic.pojo.po.PQSComAssesPO; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -16,6 +17,7 @@ import java.util.Map; * @author: zbj * @date: 2023/03/31 */ +@Mapper public interface LargeScreenMapper { Map selectDownCount(@Param("lineIds") List lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime); @@ -24,7 +26,7 @@ public interface LargeScreenMapper { List> getTimeCount(@Param("lineIds") List lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime); - List> eventLists(@Param("startTime") String startTime, @Param("endTime") String endTime); + List eventLists(@Param("startTime") String startTime, @Param("endTime") String endTime); AllDataVO getFlagCount(@Param("lineIds") List lineIds); diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/LargeScreenMapper.xml b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/LargeScreenMapper.xml index a93710cfe..3e66e06f0 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/LargeScreenMapper.xml +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/LargeScreenMapper.xml @@ -54,25 +54,7 @@ group by day - + + diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/LargeScreenServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/LargeScreenServiceImpl.java index d76b49155..d8430d74f 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/LargeScreenServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/LargeScreenServiceImpl.java @@ -246,20 +246,7 @@ public class LargeScreenServiceImpl implements LargeScreenService { */ @Override public List eventLists(LargeScreenParam largeScreenParam) { - //创建返回VO - List result = new ArrayList<>(); - List> maps = largeScreenMapper.eventLists(largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime()); - for (Map map : maps) { - EventVO eventVO = new EventVO(); - eventVO.setTime(map.get("time").toString()); - eventVO.setName(map.get("name").toString()); - eventVO.setReason(map.get("reason").toString()); - eventVO.setType(map.get("type").toString()); - eventVO.setAmplitude(map.get("amplitude").toString()); - eventVO.setDuration(map.get("duration").toString()); - result.add(eventVO); - } - return result; + return largeScreenMapper.eventLists(largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime()); } /** diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/ResinformationParam.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/ResinformationParam.java new file mode 100644 index 000000000..e87e3d736 --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/po/ResinformationParam.java @@ -0,0 +1,31 @@ +package com.njcn.system.pojo.po; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author zbj + * @since 2023-04-18 + */ +@Data +public class ResinformationParam { + + @Excel(name = "资源名称", width = 20) + private String name; + + @Excel(name = "资源类目", width = 20) + private String type; + + @Excel(name = "资源描述", width = 20) + private String description; + + @Excel(name = "数据更新时间", format = "yyyy-MM-dd HH:mm:ss", width = 20) + private LocalDateTime time; + +} \ No newline at end of file diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/controller/ResourceAdministrationController.java b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/ResourceAdministrationController.java index c2d58e637..9d93c0272 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/controller/ResourceAdministrationController.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/ResourceAdministrationController.java @@ -16,6 +16,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; import java.util.List; @@ -39,10 +42,10 @@ public class ResourceAdministrationController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/uploadFile") @ApiOperation("上传资源") - public HttpResult uploadFile(@ApiParam(value = "文件", required = true)@RequestPart("multipartFile") MultipartFile multipartFile, - @ApiParam(value = "资源名称", required = true)String name, + public HttpResult uploadFile(@ApiParam(value = "文件", required = true) @RequestPart("multipartFile") MultipartFile multipartFile, + @ApiParam(value = "资源名称", required = true) String name, @ApiParam(value = "资源类型", required = true) String type, - @ApiParam(value = "资源描述", required = false)String describe, + @ApiParam(value = "资源描述", required = false) String describe, @ApiParam(value = "系统类型Guid", required = true) String systemType) { String methodDescribe = getMethodDescribe("uploadFile"); Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, name, type, describe, systemType); @@ -55,10 +58,65 @@ public class ResourceAdministrationController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryData") @ApiOperation("查询数据") - @ApiImplicitParam(name = "baseParam",value = "查询数据",required = true) + @ApiImplicitParam(name = "baseParam", value = "查询数据", required = true) public HttpResult> queryData(@RequestBody @Validated BaseParam baseParam) { String methodDescribe = getMethodDescribe("queryData"); - List result = iResourceAdministrationService.queryData(baseParam); + List result = iResourceAdministrationService.queryData(baseParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + + /** + * 修改资源 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/updateFile") + @ApiOperation("修改资源") + public HttpResult updateFile(@ApiParam(value = "文件", required = true) @RequestPart("multipartFile") MultipartFile multipartFile, + @ApiParam(value = "id", required = true) String id, + @ApiParam(value = "资源名称", required = true) String name, + @ApiParam(value = "资源类型", required = true) String type, + @ApiParam(value = "资源描述", required = false) String describe, + @ApiParam(value = "系统类型Guid", required = true) String systemType) { + String methodDescribe = getMethodDescribe("updateFile"); + Boolean flag = iResourceAdministrationService.updateFile(multipartFile, id, name, type, describe, systemType); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); + } + + /** + * 删除资源 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/deleteFile") + @ApiOperation("删除资源") + @ApiImplicitParam(name = "id",value = "id",required = true) + public HttpResult deleteFile(@RequestParam("id") String id) { + String methodDescribe = getMethodDescribe("deleteFile"); + Boolean flag = iResourceAdministrationService.deleteFile(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); + } + + /** + * 下载资源 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/downloadFile") + @ApiOperation("下载资源") + @ApiImplicitParam(name = "id",value = "id",required = true) + public HttpResult downloadFile(@RequestParam("id")String id,HttpServletResponse response) throws IOException { + String methodDescribe = getMethodDescribe("downloadFile"); + iResourceAdministrationService.downloadFile(id,response); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "下载成功", methodDescribe); + } + + /** + * 导出数据 + */ + /*@OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/exportData") + @ApiOperation("导出数据") + public HttpResult exportData() { + String methodDescribe = getMethodDescribe("exportData"); + iResourceAdministrationService.exportData(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "成功", methodDescribe); + }*/ } diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/ResourceAdministrationMapper.java b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/ResourceAdministrationMapper.java index e4495a0b6..f63fbafd1 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/ResourceAdministrationMapper.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/ResourceAdministrationMapper.java @@ -3,8 +3,11 @@ package com.njcn.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.njcn.system.pojo.po.Resinformation; +import com.njcn.system.pojo.po.ResinformationParam; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * @version 1.0.0 * @author: zbj @@ -12,4 +15,5 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ResourceAdministrationMapper extends BaseMapper { + List listAll(); } diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/ResourceAdministrationMapper.xml b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/ResourceAdministrationMapper.xml index b6301e2f5..07f4d0b9c 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/ResourceAdministrationMapper.xml +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/mapper/mapping/ResourceAdministrationMapper.xml @@ -2,4 +2,9 @@ + diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/IResourceAdministrationService.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/IResourceAdministrationService.java index bce4ed65b..4c0a75c7d 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/IResourceAdministrationService.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/IResourceAdministrationService.java @@ -6,6 +6,9 @@ import com.njcn.system.pojo.po.Resinformation; import com.njcn.web.pojo.param.BaseParam; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; import java.util.List; /** @@ -15,7 +18,15 @@ import java.util.List; */ public interface IResourceAdministrationService extends IService { - Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe,String systemType); + Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe, String systemType); List queryData(BaseParam baseParam); + + Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String describe, String systemType); + + Boolean deleteFile(String id); + + void downloadFile(String id,HttpServletResponse response) throws IOException; + + void exportData(); } diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ResourceAdministrationServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ResourceAdministrationServiceImpl.java index fa6e826b9..6ef63e261 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ResourceAdministrationServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/ResourceAdministrationServiceImpl.java @@ -3,11 +3,15 @@ package com.njcn.system.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.common.config.GeneralInfo; import com.njcn.oss.constant.OssPath; import com.njcn.oss.utils.FileStorageUtil; +import com.njcn.poi.excel.ExcelUtil; import com.njcn.system.mapper.ResourceAdministrationMapper; import com.njcn.system.pojo.po.Resinformation; +import com.njcn.system.pojo.po.ResinformationParam; import com.njcn.system.service.IResourceAdministrationService; +import com.njcn.user.pojo.dto.excel.UserExcel; import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; @@ -16,6 +20,10 @@ import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @@ -34,6 +42,8 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl(baseParam.getPageNum(), baseParam.getPageSize())).getRecords(); } } + + @Override + public Boolean updateFile(MultipartFile multipartFile, String id, String name, String type, String describe, String systemType) { + Resinformation resinformation = resourceAdministrationMapper.selectById(id); + //删除文件 + fileStorageUtil.deleteFile(resinformation.getUrl()); + //获取路径 + String url = fileStorageUtil.uploadMultipart(multipartFile, OssPath.RESOURCEADMINISTRATION); + resinformation.setUrl(url); + resinformation.setName(name); + if (StringUtils.isNotBlank(describe)) { + resinformation.setDescription(describe); + } + //获取用户id + //String userIndex = RequestUtil.getUserIndex(); + String userIndex = "123456"; + resinformation.setUpdateUser(userIndex); + resinformation.setUpdateTime(LocalDateTime.now()); + resinformation.setState(1); + resinformation.setSystemType(systemType); + resinformation.setType(type); + int i = resourceAdministrationMapper.updateById(resinformation); + return i > 0; + } + + @Override + public Boolean deleteFile(String id) { + Resinformation resinformation = resourceAdministrationMapper.selectById(id); + //删除文件 + fileStorageUtil.deleteFile(resinformation.getUrl()); + //删除数据 + int i = resourceAdministrationMapper.deleteById(id); + return i > 0; + } + + @Override + public void downloadFile(String id,HttpServletResponse response) throws IOException { + Resinformation resinformation = resourceAdministrationMapper.selectById(id); + //下载文件 + fileStorageUtil.downloadStream(response,resinformation.getUrl()); + } + + @Override + public void exportData() { + String fileName = "资源列表.csv"; + //String targetDir = generalInfo.getBusinessTempPath() + File.separator + RequestUtil.getUserIndex(); + String targetDir = "C:\\Users\\User\\Desktop\\1"; + File excel = new File(targetDir, fileName); + List list = resourceAdministrationMapper.listAll(); + ExcelUtil.exportExcelWithTargetFile(excel, ResinformationParam.class, list); + } }