From 8390f355a8a0c21c04422a73fe38feeaf1290819 Mon Sep 17 00:00:00 2001 From: hello-hao <923453645@qq.com> Date: Fri, 29 Oct 2021 18:25:53 +0800 Subject: [PATCH] =?UTF-8?q?:art:=E5=AE=8C=E5=96=84=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/hellohao/dao/ImgMapper.java | 2 + .../java/cn/hellohao/quartz/FirstJob.java | 20 --- .../hellohao/quartz/QuartzConfigration.java | 88 ---------- .../hellohao/quartz/QuartzConfiguration.java | 49 ++++++ .../cn/hellohao/quartz/SchedulerTask.java | 134 ---------------- .../java/cn/hellohao/quartz/SecondJob.java | 16 -- .../java/cn/hellohao/quartz/SpringUtil.java | 40 ----- .../java/cn/hellohao/quartz/TempImgTask.java | 150 ------------------ .../java/cn/hellohao/quartz/job/FirstJob.java | 95 +++++++++++ .../java/cn/hellohao/quartz/job/ThirdJob.java | 18 +++ .../java/cn/hellohao/service/ImgService.java | 2 + .../hellohao/service/impl/ImgServiceImpl.java | 4 + .../service/impl/KODOImageupload.java | 1 - src/main/resources/mapper/ImgMapper.xml | 3 + 14 files changed, 173 insertions(+), 449 deletions(-) delete mode 100644 src/main/java/cn/hellohao/quartz/FirstJob.java delete mode 100644 src/main/java/cn/hellohao/quartz/QuartzConfigration.java create mode 100644 src/main/java/cn/hellohao/quartz/QuartzConfiguration.java delete mode 100644 src/main/java/cn/hellohao/quartz/SchedulerTask.java delete mode 100644 src/main/java/cn/hellohao/quartz/SecondJob.java delete mode 100644 src/main/java/cn/hellohao/quartz/SpringUtil.java delete mode 100644 src/main/java/cn/hellohao/quartz/TempImgTask.java create mode 100644 src/main/java/cn/hellohao/quartz/job/FirstJob.java create mode 100644 src/main/java/cn/hellohao/quartz/job/ThirdJob.java diff --git a/src/main/java/cn/hellohao/dao/ImgMapper.java b/src/main/java/cn/hellohao/dao/ImgMapper.java index 214e9e6..e40c25e 100644 --- a/src/main/java/cn/hellohao/dao/ImgMapper.java +++ b/src/main/java/cn/hellohao/dao/ImgMapper.java @@ -17,6 +17,8 @@ public interface ImgMapper { Integer deleimg(@Param("id") Integer id); + Integer deleimgForImgUid(@Param("imguid") String imguid); + Images selectByPrimaryKey(@Param("id") Integer id); Integer counts(@Param("userid") Integer userid); diff --git a/src/main/java/cn/hellohao/quartz/FirstJob.java b/src/main/java/cn/hellohao/quartz/FirstJob.java deleted file mode 100644 index cccd063..0000000 --- a/src/main/java/cn/hellohao/quartz/FirstJob.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.hellohao.quartz; - -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.stereotype.Component; - - -@EnableScheduling -@Component -public class FirstJob{ - - public void task(){ - //System.out.println("任务1执行...."); - TempImgTask tempImgTask = new TempImgTask(); - try { - tempImgTask.start(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/quartz/QuartzConfigration.java b/src/main/java/cn/hellohao/quartz/QuartzConfigration.java deleted file mode 100644 index 56ee8ab..0000000 --- a/src/main/java/cn/hellohao/quartz/QuartzConfigration.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.hellohao.quartz; - -import cn.hellohao.quartz.FirstJob; -import cn.hellohao.quartz.SecondJob; -import cn.hellohao.quartz.SpringUtil; -import org.quartz.JobDetail; -import org.quartz.Trigger; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.quartz.CronTriggerFactoryBean; -import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean; - - -@Configuration -public class QuartzConfigration { - //直接读取properties文件的值 -// @Value("${Expression}") - private String Expression = "0 0 1 1 * ?"; - - - - // 配置触发器1 - @Bean(name = "firstTrigger") - public SimpleTriggerFactoryBean firstTrigger(JobDetail firstJobDetail) { - SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean(); - trigger.setJobDetail(firstJobDetail); - // 设置任务启动延迟 - trigger.setStartDelay(0); - // 每5秒执行一次 - trigger.setRepeatInterval(3600000);//一小时 - return trigger; - } - - // 配置定时任务1 - @Bean(name = "firstJobDetail") - public MethodInvokingJobDetailFactoryBean firstJobDetail() { - FirstJob firstJob = (FirstJob) SpringUtil.getBean(FirstJob.class); - MethodInvokingJobDetailFactoryBean jobDetail = new MethodInvokingJobDetailFactoryBean(); - // 是否并发执行 - jobDetail.setConcurrent(false); - // 为需要执行的实体类对应的对象 - jobDetail.setTargetObject(firstJob); - // 需要执行的方法 - jobDetail.setTargetMethod("task"); - return jobDetail; - } - - // 配置触发器2 - @Bean(name = "secondTrigger") - public CronTriggerFactoryBean secondTrigger(JobDetail secondJobDetail) { - CronTriggerFactoryBean trigger = new CronTriggerFactoryBean(); - trigger.setJobDetail(secondJobDetail); - // cron表达式 - trigger.setCronExpression(Expression); - //trigger.setCronExpression("0 0/1 * * * ?"); - return trigger; - } - - // 配置定时任务2 - @Bean(name = "secondJobDetail") - public MethodInvokingJobDetailFactoryBean secondJobDetail() { - - SecondJob secondJob = (SecondJob) SpringUtil.getBean(SecondJob.class); - MethodInvokingJobDetailFactoryBean jobDetail = new MethodInvokingJobDetailFactoryBean(); - // 是否并发执行 - jobDetail.setConcurrent(false); - // 为需要执行的实体类对应的对象 - jobDetail.setTargetObject(secondJob); - // 需要执行的方法 - jobDetail.setTargetMethod("task"); - return jobDetail; - } - - // 配置Scheduler - @Bean(name = "scheduler") - public SchedulerFactoryBean schedulerFactory(Trigger firstTrigger, Trigger secondTrigger) { - SchedulerFactoryBean bean = new SchedulerFactoryBean(); - // 延时启动,应用启动1秒后 - bean.setStartupDelay(1); - // 注册触发器 - bean.setTriggers(firstTrigger, secondTrigger); - return bean; - } - -} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/quartz/QuartzConfiguration.java b/src/main/java/cn/hellohao/quartz/QuartzConfiguration.java new file mode 100644 index 0000000..23d482e --- /dev/null +++ b/src/main/java/cn/hellohao/quartz/QuartzConfiguration.java @@ -0,0 +1,49 @@ +package cn.hellohao.quartz; + +import cn.hellohao.quartz.job.FirstJob; +import org.quartz.JobDetail; +import org.quartz.Trigger; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean; + +@Configuration +public class QuartzConfiguration { + + // 配置定时任务1 + @Bean(name = "firstJobDetail") + public MethodInvokingJobDetailFactoryBean firstJobDetail(FirstJob firstJob) { + MethodInvokingJobDetailFactoryBean jobDetail = new MethodInvokingJobDetailFactoryBean(); + // 是否并发执行 + jobDetail.setConcurrent(true); + // 为需要执行的实体类对应的对象 + jobDetail.setTargetObject(firstJob); + // 需要执行的方法 + jobDetail.setTargetMethod("task"); + return jobDetail; + } + + // 配置触发器1 + @Bean(name = "firstTrigger") + public SimpleTriggerFactoryBean firstTrigger(JobDetail firstJobDetail) { + SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean(); + trigger.setJobDetail(firstJobDetail); + // 设置任务启动延迟 + trigger.setStartDelay(0); + // 单位毫秒 60000是一分钟 + trigger.setRepeatInterval(60000); + return trigger; + } + + @Bean(name = "scheduler") + public SchedulerFactoryBean schedulerFactory(Trigger firstTrigger, Trigger secondTrigger) { + SchedulerFactoryBean bean = new SchedulerFactoryBean(); + // 延时启动,应用启动5秒后 + bean.setStartupDelay(5); + // 注册触发器 + bean.setTriggers(firstTrigger, secondTrigger); + return bean; + } +} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/quartz/SchedulerTask.java b/src/main/java/cn/hellohao/quartz/SchedulerTask.java deleted file mode 100644 index 14ee7d7..0000000 --- a/src/main/java/cn/hellohao/quartz/SchedulerTask.java +++ /dev/null @@ -1,134 +0,0 @@ -package cn.hellohao.quartz; - -import cn.hellohao.pojo.Images; -import cn.hellohao.pojo.Imgreview; -import cn.hellohao.pojo.Keys; -import cn.hellohao.service.impl.ImgServiceImpl; -import cn.hellohao.service.impl.ImgreviewServiceImpl; -import cn.hellohao.service.impl.KeysServiceImpl; -import cn.hellohao.service.impl.NOSImageupload; -import cn.hellohao.utils.LocUpdateImg; -import cn.hellohao.utils.SpringContextHolder; -import com.alibaba.fastjson.JSON; -import com.baidu.aip.contentcensor.AipContentCensor; -import com.baidu.aip.contentcensor.EImgType; -import org.json.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -/* -单任务执行,并且通过控制器的接口实现时间间隔的动态修改 -任务类 -* */ -//@Configuration - -@Component - -public class SchedulerTask { - - @Autowired - private ImgServiceImpl imgService; - @Autowired - private ImgreviewServiceImpl imgreviewService; - @Autowired - private KeysServiceImpl keysService; - - private static AipContentCensor client; - - private static SchedulerTask schedulerTask; - - - @PostConstruct - public void init() { - schedulerTask = this; } - - - private static void Initializes(Imgreview imgreview) { - client = new AipContentCensor(imgreview.getAppId(), imgreview.getApiKey(), imgreview.getSecretKey()); - client.setConnectionTimeoutInMillis(2000); - client.setSocketTimeoutInMillis(60000); - } - - public void start(){ - //查询鉴黄key - Imgreview imgreview = schedulerTask.imgreviewService.selectByPrimaryKey(1); - if(imgreview.getUsing()==1){ - //初始化鉴黄 - SchedulerTask.Initializes(imgreview); - //计算出昨天的日期 - Date d = new Date(); - SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd"); - String oldtime = df.format(new Date(d.getTime() - 1 * 24 * 60 * 60 * 1000)); - //服务器获取出这个时间段的值然后遍历 - List imglist= schedulerTask.imgService.gettimeimg(oldtime); - for (Images images : imglist) { - String imgurl = images.getImgurl(); - System.err.println("正在鉴定的图片:" + imgurl); - JSONObject res = client.antiPorn(imgurl); - res = client.imageCensorUserDefined(imgurl, EImgType.URL, null); - System.err.println("返回的鉴黄json:"+res.toString()); - com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray("[" + res.toString() + "]"); - for (Object o : jsonArray) { - com.alibaba.fastjson.JSONObject jsonObject = (com.alibaba.fastjson.JSONObject) o; - com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data"); - Integer conclusionType = jsonObject.getInteger("conclusionType"); - if (conclusionType == 2) { - for (Object datum : data) { - com.alibaba.fastjson.JSONObject imgdata = (com.alibaba.fastjson.JSONObject) datum; - if (imgdata.getInteger("type") == 1) { - //标记图片 - Integer ret = schedulerTask.imgService.deleimgname(images.getImgname()); //删除数据库图片信息 - //Imgreview imgreview1 =imgreviewService.selectByPrimaryKey(1); - Imgreview imgreview1 = new Imgreview(); - imgreview1.setId(1); - Integer count = imgreview.getCount(); - System.out.println("违法图片总数:" + count); - imgreview1.setCount(count + 1); - schedulerTask.imgreviewService.updateByPrimaryKeySelective(imgreview1); - Keys key =null; - if(images.getSource()==1){ - key =schedulerTask.keysService.selectKeys(images.getSource()); - schedulerTask.imgService.delect(key, images.getImgname()); - }else if (images.getSource()==2){ - key = schedulerTask.keysService.selectKeys(images.getSource()); - schedulerTask.imgService.delectOSS(key, images.getImgname()); - }else if(images.getSource()==3){ - key = schedulerTask.keysService.selectKeys(images.getSource()); - schedulerTask.imgService.delectUSS(key, images.getImgname()); - }else if(images.getSource()==4){ - key = schedulerTask.keysService.selectKeys(images.getSource()); - schedulerTask.imgService.delectKODO(key, images.getImgname()); - }else if(images.getSource()==5){ - LocUpdateImg.deleteLOCImg(images.getImgname()); - }else if(images.getSource()==6){ - key = schedulerTask.keysService.selectKeys(images.getSource()); - schedulerTask.imgService.delectCOS(key, images.getImgname()); - }else if(images.getSource()==7){ - key = schedulerTask.keysService.selectKeys(images.getSource()); - schedulerTask.imgService.delectFTP(key, images.getImgname()); - }else if(images.getSource()==8){ - key = schedulerTask.keysService.selectKeys(images.getSource()); - schedulerTask.imgService.delectUFile(key, images.getImgname()); - }else{ - System.err.println("未获取到对象存储参数,上传失败。"); - } - if (ret == 1) { - System.err.println("存在色情图片,删除成功。"); - } else { - System.err.println("存在色情图片,删除失败"); - } - } - } - } - } - } - } - } - - -} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/quartz/SecondJob.java b/src/main/java/cn/hellohao/quartz/SecondJob.java deleted file mode 100644 index 9999042..0000000 --- a/src/main/java/cn/hellohao/quartz/SecondJob.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.hellohao.quartz; - -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.stereotype.Component; - - -@EnableScheduling -@Component -public class SecondJob{ - - public void task() { - //System.out.println("任务2执行...."); - SchedulerTask schedulerTask = new SchedulerTask(); - schedulerTask.start(); - } -} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/quartz/SpringUtil.java b/src/main/java/cn/hellohao/quartz/SpringUtil.java deleted file mode 100644 index a2b0797..0000000 --- a/src/main/java/cn/hellohao/quartz/SpringUtil.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.hellohao.quartz; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -@Component -public class SpringUtil implements ApplicationContextAware { - - private static ApplicationContext applicationContext; - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - if (SpringUtil.applicationContext == null) { - SpringUtil.applicationContext = applicationContext; - } - } - - //获取applicationContext - public static ApplicationContext getApplicationContext() { - return applicationContext; - } - - //通过name获取 Bean. - public static Object getBean(String name) { - return getApplicationContext().getBean(name); - } - - //通过class获取Bean. - public static T getBean(Class clazz) { - return getApplicationContext().getBean(clazz); - } - - //通过name,以及Clazz返回指定的Bean - public static T getBean(String name, Class clazz) { - return getApplicationContext().getBean(name, clazz); - } - -} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/quartz/TempImgTask.java b/src/main/java/cn/hellohao/quartz/TempImgTask.java deleted file mode 100644 index 4fb41aa..0000000 --- a/src/main/java/cn/hellohao/quartz/TempImgTask.java +++ /dev/null @@ -1,150 +0,0 @@ -package cn.hellohao.quartz; - -import cn.hellohao.pojo.FixedResources; -import cn.hellohao.pojo.Keys; -import cn.hellohao.service.impl.ImgServiceImpl; -import cn.hellohao.service.impl.KeysServiceImpl; -import cn.hellohao.utils.DeleImg; -import cn.hellohao.utils.LocUpdateImg; -import cn.hellohao.utils.Print; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.io.*; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/* -单任务执行,并且通过控制器的接口实现时间间隔的动态修改 -任务类 -* */ -//@Configuration - -@Component -public class TempImgTask { - - @Autowired - private ImgServiceImpl imgService; - @Autowired - private KeysServiceImpl keysService; - - private static TempImgTask tempImgTask; - - - @PostConstruct - public void init() { - tempImgTask = this; - tempImgTask.imgService = this.imgService; - tempImgTask.keysService = this.keysService; - } - - - public void start() throws InterruptedException { - File f = new File(FixedResources.LOCPATH); - if (!f.exists()) { - f.mkdirs(); - } - List list = new ArrayList<>(); - File file = new File(File.separator + "HellohaoData"+File.separator+"img.ini"); - //判断文件是否存在 - if (file.exists()) { - StringBuilder result = new StringBuilder(); - try { - BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));//构造一个BufferedReader类来读取文件 - String s = null; - while ((s = br.readLine()) != null) {//使用readLine方法,一次读一行 - result.append(System.lineSeparator() + s); - String str = s; - String[] strArr = str.split("\\|"); - System.out.println(strArr.length); //这里输出3 - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date sd1=new Date();//大时间 当前时间 - Date sd2=df.parse(strArr[1]);//小时间 - if(sd1.after(sd2)){//等于false时说明图片时间大于或者等于当前时间 - Integer ret = tempImgTask.imgService.deleimgname(strArr[0]);//删除库里图片数据 - Keys key =null; - if(Integer.parseInt(strArr[2])==1){ - key = tempImgTask.keysService.selectKeys(Integer.parseInt(strArr[2])); - tempImgTask.imgService.delect(key,strArr[0]); - }else if (Integer.parseInt(strArr[2])==2){ - key = tempImgTask.keysService.selectKeys(Integer.parseInt(strArr[2])); - tempImgTask.imgService.delectOSS(key, strArr[0]); - }else if(Integer.parseInt(strArr[2])==3){ - key = tempImgTask.keysService.selectKeys(Integer.parseInt(strArr[2])); - tempImgTask.imgService.delectUSS(key, strArr[0]); - }else if(Integer.parseInt(strArr[2])==4){ - key = tempImgTask.keysService.selectKeys(Integer.parseInt(strArr[2])); - tempImgTask.imgService.delectKODO(key, strArr[0]); - }else if(Integer.parseInt(strArr[2])==5){ - LocUpdateImg.deleteLOCImg(strArr[0]); - }else if(Integer.parseInt(strArr[2])==6){ - key = tempImgTask.keysService.selectKeys(Integer.parseInt(strArr[2])); - tempImgTask.imgService.delectCOS(key,strArr[0]); - }else if(Integer.parseInt(strArr[2])==7){ - key = tempImgTask.keysService.selectKeys(Integer.parseInt(strArr[2])); - tempImgTask.imgService.delectFTP(key, strArr[0]); - }else{ - System.err.println("未获取到对象存储参数,上传失败。"); - } - }else{ - //没有过期的临时图片 - list.add(s); - } - } - br.close(); - } catch (Exception e) { - e.printStackTrace(); - } - //return result.toString(); - textcr(list); - } else { - //Print.warning("file not exists, 不进行暂存扫描处理"); - try { - file.createNewFile(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - public static void main(String[] args) throws Exception { - clearInfoForFile(File.separator + "HellohaoData"+File.separator+"img.ini"); - } - - - /** - * 清空文件内容 - * @param fileName - */ - public static void clearInfoForFile(String fileName) { - //Print.Normal("清空原ini文件"); - File file =new File(fileName); - try { - if(!file.exists()) { - file.createNewFile(); - } - FileWriter fileWriter =new FileWriter(file); - fileWriter.write(""); - fileWriter.flush(); - fileWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - - - //遍历没有过期的list文本,依次插入 - public static void textcr(List list){ - clearInfoForFile(File.separator + "HellohaoData"+File.separator+"img.ini"); - //Print.Normal("开始重新插入没有过期的文本"); - for (String s : list) { - DeleImg.charu(s); - } - } - -} \ No newline at end of file diff --git a/src/main/java/cn/hellohao/quartz/job/FirstJob.java b/src/main/java/cn/hellohao/quartz/job/FirstJob.java new file mode 100644 index 0000000..5567876 --- /dev/null +++ b/src/main/java/cn/hellohao/quartz/job/FirstJob.java @@ -0,0 +1,95 @@ +package cn.hellohao.quartz.job; + +import cn.hellohao.pojo.Images; +import cn.hellohao.pojo.Keys; +import cn.hellohao.service.ImgTempService; +import cn.hellohao.service.KeysService; +import cn.hellohao.service.impl.*; +import cn.hellohao.utils.LocUpdateImg; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +@Component +@EnableScheduling +public class FirstJob { + + @Autowired + private ImgServiceImpl imgService; + @Autowired + private NOSImageupload nosImageupload; + @Autowired + private OSSImageupload ossImageupload; + @Autowired + private COSImageupload cosImageupload; + @Autowired + private KODOImageupload kodoImageupload; + @Autowired + private USSImageupload ussImageupload; + @Autowired + private UFileImageupload uFileImageupload; + @Autowired + private FTPImageupload ftpImageupload; + @Autowired + ImgTempService imgTempService; + @Autowired + KeysService keysService; + + private static FirstJob firstJob; + + @PostConstruct + public void init() { + firstJob = this; + } + + //调用的任务主体 + public void task() { +// System.out.println("定时任务.//开始"); + try{ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String currdate = format.format(new Date()); + List imagesList = imgTempService.selectDelImgUidList(currdate); + if(imagesList.size()==0){ +// System.out.println("定时任务.//没有期限图片"); + return; + } + for (Images images : imagesList) { + imgTempService.delImgAndExp(images.getImguid()); + imgService.deleimgForImgUid(images.getImguid()); + Keys keys = keysService.selectKeys(images.getSource()); + if(keys.getStorageType()==1){ + firstJob.nosImageupload.delNOS(keys.getId(),images.getImgname()); + }else if (keys.getStorageType()==2){ + firstJob.ossImageupload.delOSS(keys.getId(), images.getImgname()); + }else if(keys.getStorageType()==3){ + firstJob.ussImageupload.delUSS(keys.getId(), images.getImgname()); + }else if(keys.getStorageType()==4){ + firstJob.kodoImageupload.delKODO(keys.getId(), images.getImgname()); + }else if(keys.getStorageType()==5){ + LocUpdateImg.deleteLOCImg(images.getImgname()); + }else if(keys.getStorageType()==6){ + firstJob.cosImageupload.delCOS(keys.getId(),images.getImgname()); + }else if(keys.getStorageType()==7){ + firstJob.ftpImageupload.delFTP(keys.getId(), images.getImgname()); + }else if(keys.getStorageType()==8){ + firstJob.uFileImageupload.delUFile(keys.getId(), images.getImgname()); + }else{ + System.err.println("未获取到对象存储参数,上传失败。"); + } + } + }catch (Exception e){ + System.err.println("任务查询期限图像发生错误"); + e.printStackTrace(); + } + + + } + + + +} diff --git a/src/main/java/cn/hellohao/quartz/job/ThirdJob.java b/src/main/java/cn/hellohao/quartz/job/ThirdJob.java new file mode 100644 index 0000000..5eba892 --- /dev/null +++ b/src/main/java/cn/hellohao/quartz/job/ThirdJob.java @@ -0,0 +1,18 @@ +package cn.hellohao.quartz.job; + +import java.text.SimpleDateFormat; +import java.util.Date; + +//@Component +//@EnableScheduling +public class ThirdJob { + + public void task() { + System.out.println("任务3执行....当前时间为" + dateFormat().format(new Date())); + } + + private SimpleDateFormat dateFormat() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss"); + return simpleDateFormat; + } +} diff --git a/src/main/java/cn/hellohao/service/ImgService.java b/src/main/java/cn/hellohao/service/ImgService.java index 4693f47..dcf4a9f 100644 --- a/src/main/java/cn/hellohao/service/ImgService.java +++ b/src/main/java/cn/hellohao/service/ImgService.java @@ -15,6 +15,8 @@ public interface ImgService { Integer deleimg(Integer id); + Integer deleimgForImgUid(String imguid); + Integer countimg(Integer userid); Images selectByPrimaryKey(Integer id); diff --git a/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java b/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java index 6ea6390..94652be 100644 --- a/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java +++ b/src/main/java/cn/hellohao/service/impl/ImgServiceImpl.java @@ -57,6 +57,10 @@ public class ImgServiceImpl implements ImgService { return imgMapper.deleimg(id); } + @Override + public Integer deleimgForImgUid(String imguid) { + return imgMapper.deleimgForImgUid(imguid); + } public Images selectByPrimaryKey(Integer id) { return imgMapper.selectByPrimaryKey(id); diff --git a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java index 18cb70d..08b855c 100644 --- a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java +++ b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java @@ -76,7 +76,6 @@ public class KODOImageupload { returnImage.setCode("500"); } return returnImage; - } public static Integer Initialize(Keys k) { diff --git a/src/main/resources/mapper/ImgMapper.xml b/src/main/resources/mapper/ImgMapper.xml index 0438c41..de1e9e3 100644 --- a/src/main/resources/mapper/ImgMapper.xml +++ b/src/main/resources/mapper/ImgMapper.xml @@ -63,6 +63,9 @@ DELETE FROM imgdata WHERE id=#{id} + + DELETE FROM imgdata WHERE imguid = #{imguid} +