栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

延期业务员script

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

延期业务员script

1.HealthCheckController
@Resource
    private ExpiryYwyGradeChangFlowScript expiryYwyGradeChangFlowScript;

    @GetMapping("/expiry-ywy-grade-chang-flow")
    private BaseResponse expiryYwyGradeChangFlow(@RequestParam Long latterGradeId, @RequestParam int relegationPeriod,
                                                 @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date expiryTime){
        if (StringUtils.isEmpty(latterGradeId) || StringUtils.isEmpty(relegationPeriod) || expiryTime == null){
            return BaseResponse.fail("缺少必要的参数");
        }
        try {
            expiryYwyGradeChangFlowScript.expiryYwyGradeChangFlow(latterGradeId, relegationPeriod, expiryTime);
            return BaseResponse.success();
        } catch (Exception e) {
            log.info("HealthCheckController.expiryYwyGradeChangFlow发生异常:{}", ExceptionUtils.getStackTrace(e));
            return BaseResponse.fail();
        }
    }
	
2.	GradeChangeFlowMapper

    List selectByLatterGradeId(@Param("latterGradeId")Long latterGradeId, @Param("expiryTime")Date expiryTime);

    
    Integer expiryGradeChangeFlowBatch(List list);

3.	ExpiryYwyGradeChangFlowScript

@Component
@Slf4j
public class ExpiryYwyGradeChangFlowScript {

    @Resource
    private GradeChangeFlowMapper gradeChangeFlowMapper;


    public void expiryYwyGradeChangFlow(Long latterGradeId, int relegationPeriod, Date expiryTime) {

        log.info("延期业务员成长流水job开始执行,latterGradeId:{},relegationPeriod:{},expiryTime:{}",
                latterGradeId, relegationPeriod, expiryTime);
        //循环次数
        int cycle = 0;
        //总量
        int count = 0;

        while (true){
            List gradeChangeFlows = gradeChangeFlowMapper.selectByLatterGradeId(latterGradeId, expiryTime);

            //当流水表查询不到数据后者循环执行超过一定次数时,结束本次循环
            if (CollectionUtils.isEmpty(gradeChangeFlows) || cycle > 400){
                log.info("延期业务员成长流水job执行完成,cycle:{},count:{}", cycle, count);
                break;
            }
            List updateBatch = new ArrayList<>();
            gradeChangeFlows.stream().forEach(e -> {
                GradeChangeFlow flow = new GradeChangeFlow();
                flow.setId(e.getId());
                //当前日期,延期一个保级周期的时长
                flow.setExpiryTime(DateUtil.dateAddDayEnd(new Date(), relegationPeriod));
                updateBatch.add(flow);
            });
            gradeChangeFlowMapper.expiryGradeChangeFlowBatch(updateBatch);
            cycle++;
            count = count + gradeChangeFlows.size();
        }

    }



}

4.GradeChangeFlowMapper
  

  
    update grade_change_flow
    
      
        
          
            when id = #{item.id} then #{item.expiryTime}
          
        
      
      where id in
      
        
          #{item.id}
        
      
    
  
  
 5. 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/970446.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号