src/main/java/com/whyc/controller/DeviceSpareController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/web_site/DeviceSpareLog.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/schedule/AlarmInspectionSchedule.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/DeviceSpareLogService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/DeviceSpareService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/DeviceSpareController.java
@@ -62,6 +62,12 @@ return service.update(spare); } @PostMapping("andOrChangePicture") @ApiOperation("新增或者替换图片") public Response andOrChangePicture(@RequestParam Integer id,@RequestParam MultipartFile file) throws IOException { return service.andOrChangePicture(id,file); } @PostMapping("delete") @ApiOperation("删除") public Response delete(@RequestParam Integer id) { src/main/java/com/whyc/pojo/web_site/DeviceSpareLog.java
@@ -25,4 +25,13 @@ private Date createTime; public DeviceSpareLog(Integer deviceSpareId, Integer operationType, String operationDetail, Date createTime) { this.deviceSpareId = deviceSpareId; this.operationType = operationType; this.operationDetail = operationDetail; this.createTime = createTime; } public DeviceSpareLog() { } } src/main/java/com/whyc/schedule/AlarmInspectionSchedule.java
@@ -17,7 +17,7 @@ /** * 有两个定时任务:1.告警产生,加入到巡检实时表,2.告警是否消失,同步到巡检实时表 */ @EnableScheduling //@EnableScheduling @Component public class AlarmInspectionSchedule { src/main/java/com/whyc/service/DeviceSpareLogService.java
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; @Service @@ -21,6 +22,11 @@ mapper.insert(deviceSpareLog); } public void add(Integer deviceSpareId, Integer operationType, String operationDetail, Date createTime) { DeviceSpareLog deviceSpareLog = new DeviceSpareLog(deviceSpareId, operationType, operationDetail, createTime); mapper.insert(deviceSpareLog); } public Response<List<DeviceSpareLog>> getList(int deviceSpareId) { QueryWrapper<DeviceSpareLog> query = Wrappers.query(); query.eq("device_spare_id",deviceSpareId); src/main/java/com/whyc/service/DeviceSpareService.java
@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -347,4 +348,32 @@ } } public Response andOrChangePicture(Integer id, MultipartFile file) throws IOException { DeviceSpare spare = mapper.selectById(id); //对存储路径进行定义 Date now = new Date(); String timeFormat = ThreadLocalUtil.format(ThreadLocalUtil.TIME_YYYY_MM_DD_HH_MM_SS_UNION, now); String dirMonth = ThreadLocalUtil.format(ThreadLocalUtil.TIME_YYYY_MM, now); String fileDirPath = CommonUtil.getRootFile() + "deviceSpare" + File.separator + dirMonth; File fileDir = new File(fileDirPath); //如果文件夹不存在则创建 if (!fileDir.exists()) { fileDir.mkdirs(); } String filePath = fileDirPath + File.separator + spare.getName()+"_"+spare.getModel()+"_"+spare.getVersion() + "_"+ timeFormat+".png"; // 保存图片到本地 file.transferTo(new File(filePath)); String split = "pis_file"+File.separator+"deviceSpare"; String picUrl = File.separator + filePath.substring(filePath.indexOf(split)); //更新图片 UpdateWrapper<DeviceSpare> update = Wrappers.update(); update.eq("id",id); update.set("picture_url",picUrl); mapper.update((DeviceSpare) CommonUtil.nullObject,update); //记录变更 deviceSpareLogService.add(id,2,"更换图片",now); return new Response().setII(1,"新增或者替换图片完成"); } }