parent
1a978f7a8a
commit
014ea0ba3b
@ -0,0 +1,15 @@
|
||||
package com.mudu.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mudu.entity.ASafeWgcy;
|
||||
|
||||
/**
|
||||
* (ASafeWgcy)表数据库访问层
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-08-24 18:14:06
|
||||
*/
|
||||
public interface ASafeWgcyMapper extends BaseMapper<ASafeWgcy> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
package com.mudu.quartz;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.mudu.entity.ASafeQyjcxx;
|
||||
import com.mudu.entity.ASafeWgcy;
|
||||
import com.mudu.service.ASafeQyjcxxService;
|
||||
import com.mudu.service.ASafeWgcyService;
|
||||
import com.mudu.service.impl.LoginService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 获取木渎新增企业定时任务
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024/8/24 18:11
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class EntQuartz {
|
||||
|
||||
@Resource
|
||||
private ASafeQyjcxxService qyjcxxService;
|
||||
|
||||
@Resource
|
||||
private ASafeWgcyService wgcyService;
|
||||
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
|
||||
@Value("${addEntUrl}")
|
||||
private String addEntUrl;
|
||||
|
||||
@Value("${findEntDelUrl}")
|
||||
private String findEntDelUrl;
|
||||
|
||||
|
||||
private String getToken() {
|
||||
return "Bearer " + loginService.getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增昨天木渎新增的企业
|
||||
*/
|
||||
@Scheduled(cron = "0 30 12 * * ? ")
|
||||
public void addqyjcxxAndWgcy() {
|
||||
// 获取token
|
||||
String token = getToken();
|
||||
// 获取所有信息
|
||||
String res = HttpRequest.get(addEntUrl)
|
||||
.contentType("application/x-www-form-urlencoded;charset=UTF-8")
|
||||
.header("Authorization", token)
|
||||
.execute().body();
|
||||
JSONObject resObj = JSON.parseObject(res);
|
||||
String dataList = resObj.getString("data");
|
||||
if (StrUtil.isEmpty(dataList)) {
|
||||
return;
|
||||
}
|
||||
List<ASafeQyjcxx> qyjcxxList = JSON.parseArray(dataList, ASafeQyjcxx.class);
|
||||
qyjcxxService.saveBatch(qyjcxxList);
|
||||
List<ASafeWgcy> wgcyList = qyjcxxList.stream().map(ASafeQyjcxx::getASafeWgcy).collect(Collectors.toList());
|
||||
wgcyService.saveBatch(wgcyList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除昨天木渎删除的企业
|
||||
*/
|
||||
@Scheduled(cron = "0 30 12 * * ? ")
|
||||
public void findEntDel() {
|
||||
// 获取token
|
||||
String token = getToken();
|
||||
// 获取所有信息
|
||||
String res = HttpRequest.get(findEntDelUrl)
|
||||
.contentType("application/x-www-form-urlencoded;charset=UTF-8")
|
||||
.header("Authorization", token)
|
||||
.execute().body();
|
||||
JSONObject resObj = JSON.parseObject(res);
|
||||
String dataList = resObj.getString("data");
|
||||
if (StrUtil.isEmpty(dataList)) {
|
||||
return;
|
||||
}
|
||||
List<String> tyshxybmList = JSON.parseArray(dataList, String.class);
|
||||
qyjcxxService.updateByTyshxybm(tyshxybmList);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.mudu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mudu.entity.ASafeWgcy;
|
||||
|
||||
/**
|
||||
* (ASafeWgcy)表服务接口
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-08-24 18:14:06
|
||||
*/
|
||||
public interface ASafeWgcyService extends IService<ASafeWgcy> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.mudu.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mudu.entity.ASafeWgcy;
|
||||
import com.mudu.mapper.ASafeWgcyMapper;
|
||||
import com.mudu.service.ASafeWgcyService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* (ASafeWgcy)表服务实现类
|
||||
*
|
||||
* @author wu
|
||||
* @since 2024-08-24 18:14:07
|
||||
*/
|
||||
@Service("aSafeWgcyService")
|
||||
public class ASafeWgcyServiceImpl extends ServiceImpl<ASafeWgcyMapper, ASafeWgcy> implements ASafeWgcyService {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue