首页 > 编程语言 >java xxljob 根据参数运行业务

java xxljob 根据参数运行业务

时间:2023-04-04 14:34:43浏览次数:52  
标签:xxljob java String distributorName param 参数 yyyyMM null tempName

配置定时任务不启动,手动执行 根据传入的参数完成既定的业务


	/**
	 * 自定义增删除平台酒体数据
	 * 参数:startDate,endDate [yyyy-MM-dd)
	 *
	 * @return {@link * @return: com.xxl.job.core.biz.model.ReturnT<java.lang.String>}
	 * @author: xxx
	 * @date 2023/3/12
	 **/
	@XxlJob("wineMonthCustomHandler")
	public ReturnT<String> wineMonthCustomHandler() throws Exception {
		String param = XxlJobHelper.getJobParam();
		XxlJobHelper.log("========= wineMonthCustomHandler param = {} ===============", param);
		if (StringUtils.isEmpty(param)) {
			XxlJobHelper.log("========= 参数不能为空 ===============");
			return ReturnT.FAIL;
		}
		String s = null;
		try {
			s = wineMonthService.wineMonthCustom(param);
		}catch (Exception e) {
			XxlJobHelper.log("========= wineMonthCustomHandler {} ===============", e.getMessage());
		}

		XxlJobHelper.log("========= wineMonthCustomHandler end [{}] ===============", s);
		return ReturnT.SUCCESS;
	}
        @Override
	public String wineMonthCustom(String param) {
		String[] split = param.split(";|,|;|,|\\|");
		if (split.length != 3) {
			throw new BusinessException("参数不能多于或少于3个 格式:202302,平台名称,删除/开启");
		}
		String yyyyMM = null;
		String distributorName = null;
		Integer status = null;
		String tempName = null;

		List<String> temp = Arrays.asList(split);
		List<String> open = Arrays.asList("开","启", "Y","y","增", "加");
		List<String> close = Arrays.asList("关","闭", "N","n","删","除");

		Iterator it = temp.iterator();
		while(it.hasNext()){
			if (ObjectUtil.isNotEmpty(tempName)) {
				distributorName = tempName;
			}
			tempName = (String) it.next();
			try{
				yyyyMM = DateUtil.format(DateUtil.parse(tempName, "yyyyMM"), "yyyyMM");
				tempName = null;
			} catch (Exception e) {
			}
			if (checkExist(tempName, open)){
				status = TourDistributorNew.IS_DELETED_0;
				tempName = null;
			}
			if (checkExist(tempName, close)){
				status = TourDistributorNew.IS_DELETED_1;
				tempName = null;
			}
		}
		if (ObjectUtil.isNotEmpty(tempName) && ObjectUtil.isEmpty(distributorName)) {
			distributorName = tempName;
		}
		if (ObjectUtil.isEmpty(yyyyMM)) {
			throw new BusinessException("日期没有");
		}
		if (ObjectUtil.isEmpty(status)) {
			throw new BusinessException("状态没有");
		}
		if (ObjectUtil.isEmpty(distributorName)) {
			throw new BusinessException("平台名称没有");
		}
		WineMonth wineMonth = new WineMonth();
		wineMonth.setMonth(yyyyMM);
		wineMonth.setDistributorName(distributorName);
		wineMonth.setIsDeleted(status);
		WineMonthMaster wineMonthMaster = new WineMonthMaster();
		BeanUtil.copyProperties(wineMonth, wineMonthMaster);
		Long aLong = wineMonthMapper.selectAllCount(wineMonth);
		long count = iuGoodsWineService.count(Wrappers.<UGoodsWine>lambdaQuery().eq(UGoodsWine::getShow, 1));
		if (count < aLong && TourDistributorNew.IS_DELETED_0.equals(status)) {
			throw new BusinessException("酒体数据数量{" + aLong + "} 小于当前执行恢复删除数量 {" + count + "}");
		}
		int update1 = wineMonthMapper.updateNative(wineMonth);
		boolean update2 = iWineMonthMasterService.updateNative(wineMonthMaster);
		String format = String.format("平台名称 {%s} 日期 {%s} 状态 {%s} 总计查询到 {%s} 条数据 WineMonth表更新状态 {%s} WineMonthMaster表更新状态 {%s}",distributorName,yyyyMM,status, (ObjectUtil.isEmpty(aLong) ? 0 : aLong.toString()), update1, update2);
		log.info(format);
		return format;
	}

标签:xxljob,java,String,distributorName,param,参数,yyyyMM,null,tempName
From: https://www.cnblogs.com/fuqian/p/17286316.html

相关文章

  • 深入理解 Java 中 SPI 机制
    vivo互联网技术微信公众号 作者:姜柱SPI(ServiceProviderInterface),是JDK内置的一种服务提供发现机制,本文由浅入深地介绍了JavaSPI机制。一、简介SPI(ServiceProviderInterface),是JDK内置的一种服务提供发现机制,可以用来启用框架扩展和替换组件,主要是被框架的开发人员使用,比如j......
  • 为什么 JavaScript 中 0.1 0.2 不等于 0.3 ?
    vivo互联网技术微信公众号 作者:刘洋在js中进行数学的运算时,会出现0.1+0.2=0.300000000000000004的结果,一开始认为是浮点数的二进制存储导致的精度问题,但这似乎不能很好的解释为什么在同样的存储方式下0.3+0.4=0.7可以得到正确的结果。本文主要通过浮点数的二进制存储及运算,和......
  • UI跳转WE DYNPRO带参数
    同事今天在做一个需求,需要把UI上的业务角色,传递给挂在UI上的DYNPRO程序。然后我们就研究了一下,发现挺好玩的。1,设置URL参数2.定义URL的参数3.找到链接对应的类,把参数传上4.WEBDYNPRO里把参数设置到application上5.然后在默认的windows里加入入参,获取参数 ......
  • Kotlin 协程真的比 Java 线程更高效吗?
    vivo互联网技术微信公众号 作者:吴越网上几乎全部介绍Kotlin的文章都会说Kotlin的协程是多么的高效,比线程性能好很多,然而事情的真相真是如此么?协程的概念本身并不新鲜,使用C++加上内嵌汇编,一个基本的协程模型50行代码之内就可以完全搞出来。早在2013年国内就有团队开源了号称支持......
  • python基础六(函数基础及参数使用)
    一、函数定义1、什么是函数函数就相当于具备某一功能的工具函数的使用必须遵循一个原则:先定义后调用2、为何要用函数代码冗余,程序的组织结构不清晰,可读性差可维护性、扩展性差3、如何用函数#定义函数#定义的语法def函数名(参数1,参数2,........
  • CSDN粘贴图片自动上传到服务器(Java版)
    ​ 如何做到ueditor批量上传word图片?1、前端引用代码<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>......
  • selenium Java基础一
      1、下载相应的浏览器驱动包//设置环境变量SystemsetProperty("webdriver.firefox.marionete","D:\\geckodriver.exe");//初始化driverWebDriver driver=newFirefoxDriver();/请求地址driver.get("http://www.baidu.com"); 2、定位元素By.tagName()   ......
  • 155.最小栈 Java
    155.最小栈设计一个支持push,pop,top操作,并能在常数时间内检索到最小元素的栈。实现MinStack类:MinStack()初始化堆栈对象。voidpush(intval)将元素val推入堆栈。voidpop()删除堆栈顶部的元素。inttop()获取堆栈顶部的元素。intgetMin()获取堆栈中的最小元素......
  • java lambda List 查找 anyMatch() allMatch() noneMatch()
    packagelambda.list;importcn.hutool.core.util.ObjectUtil;importlombok.extern.slf4j.Slf4j;importorg.junit.Test;importpojo.Dome;importjava.util.ArrayList;importjava.util.List;/***@Author:xxx*@date2021/5/14**/@Slf4jpublicclassSe......
  • java lambda List 分组 Collectors.groupingBy
    packagelambda.list;importlombok.extern.slf4j.Slf4j;importorg.junit.Test;importpojo.Dome;importjava.util.ArrayList;importjava.util.List;importjava.util.Map;importjava.util.stream.Collectors;/***@Author:xxx*@date2021/5/14**/@Sl......