Browse Source

fit:定时任

master
pengwei 1 month ago
parent
commit
bef523fdec
  1. 2
      src/main/java/com/biutag/supervision/config/InterceptorConfig.java
  2. 12
      src/main/java/com/biutag/supervision/controller/data/DataMailBoxController.java
  3. 4
      src/main/java/com/biutag/supervision/job/Job.java
  4. 9
      src/main/java/com/biutag/supervision/service/BusinessDepartService.java

2
src/main/java/com/biutag/supervision/config/InterceptorConfig.java

@ -47,7 +47,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
.excludePathPatterns("/common/**") .excludePathPatterns("/common/**")
.excludePathPatterns("/app/**") .excludePathPatterns("/app/**")
// excel导出 // excel导出
.excludePathPatterns("/data/petitionComplaint12337/export/result","/err","/sampling/export/samplingPoling", "/negative/books/export/**","/data/petitionComplaint/export/**","/confinement/export","/books/dataThread/export") .excludePathPatterns("/data/mailbox/updateBaseData","/data/petitionComplaint12337/export/result","/err","/sampling/export/samplingPoling", "/negative/books/export/**","/data/petitionComplaint/export/**","/confinement/export","/books/dataThread/export")
.excludePathPatterns(List.of("/doc.html", "/webjars/**", "/favicon.ico", "/v3/api-docs/**")); .excludePathPatterns(List.of("/doc.html", "/webjars/**", "/favicon.ico", "/v3/api-docs/**"));
registry.addInterceptor(new ApiInterceptor()) registry.addInterceptor(new ApiInterceptor())
.addPathPatterns("/api/jwdc/**"); .addPathPatterns("/api/jwdc/**");

12
src/main/java/com/biutag/supervision/controller/data/DataMailBoxController.java

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.constants.enums.ProblemSourcesEnum; import com.biutag.supervision.constants.enums.ProblemSourcesEnum;
import com.biutag.supervision.job.Job;
import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.dto.DataPetitionComplaintReplenishDto; import com.biutag.supervision.pojo.dto.DataPetitionComplaintReplenishDto;
import com.biutag.supervision.pojo.entity.DataMailbox; import com.biutag.supervision.pojo.entity.DataMailbox;
@ -22,6 +23,7 @@ import com.biutag.supervision.service.NegativeService;
import com.biutag.supervision.service.SupDictDataService; import com.biutag.supervision.service.SupDictDataService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -43,6 +45,9 @@ public class DataMailBoxController {
private final DataMailboxService dataMailboxService; private final DataMailboxService dataMailboxService;
private final SupDictDataService dictDataService; private final SupDictDataService dictDataService;
private final Job job;
@GetMapping @GetMapping
public Result<Page<DataMailbox>> list(NegativeQueryParam param) { public Result<Page<DataMailbox>> list(NegativeQueryParam param) {
LambdaQueryWrapper<DataMailbox> queryWrapper = new LambdaQueryWrapper<DataMailbox>() LambdaQueryWrapper<DataMailbox> queryWrapper = new LambdaQueryWrapper<DataMailbox>()
@ -101,4 +106,11 @@ public class DataMailBoxController {
}).sheet(0).headRowNumber(1).doRead(); }).sheet(0).headRowNumber(1).doRead();
return Result.success(); return Result.success();
} }
@GetMapping("/updateBaseData")
public Result updateBaseData(){
job.updateBaseData();
return Result.success();
}
} }

4
src/main/java/com/biutag/supervision/job/Job.java

@ -62,10 +62,10 @@ public class Job {
} }
// 每日04:00更新基础数据 // 每日04:00更新基础数据
@Scheduled(cron = "0 0 3 * * ?") @Scheduled(cron = "0 0 23 * * ?")
public void updateBaseData() { public void updateBaseData() {
// 0秒 // 0秒
log.info("获取数据-------updateBaseData-----------");
//LocalDateTime.now().minusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0).atZone(ZoneId.systemDefault()).toInstant() //LocalDateTime.now().minusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0).atZone(ZoneId.systemDefault()).toInstant()
//LocalDateTime.now().minusDays(1).withHour(23).withMinute(59).withSecond(59).atZone(ZoneId.systemDefault()).toInstant() //LocalDateTime.now().minusDays(1).withHour(23).withMinute(59).withSecond(59).atZone(ZoneId.systemDefault()).toInstant()
LocalDateTime firstDay = LocalDate.now() LocalDateTime firstDay = LocalDate.now()

9
src/main/java/com/biutag/supervision/service/BusinessDepartService.java

@ -143,6 +143,7 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
// 分组ID的映射:xxx(内部ID)——长沙县局ID // 分组ID的映射:xxx(内部ID)——长沙县局ID
Map<String, Long> resultMap = resultList.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId"))); Map<String, Long> resultMap = resultList.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId")));
List<Long> groupIds = new ArrayList<>(); List<Long> groupIds = new ArrayList<>();
log.info("映射成是我们单位的数据");
// 映射成是我们单位的数据 // 映射成是我们单位的数据
generateBusinessDepartList(happenTime, gBaseJJDSList, resultMap, resultMap2, resultMap3, groupIds, businessDepartList, gBaseAJJBXXListSA, gBaseAJJBXXListLA, gBaseAJJBXXListPA); generateBusinessDepartList(happenTime, gBaseJJDSList, resultMap, resultMap2, resultMap3, groupIds, businessDepartList, gBaseAJJBXXListSA, gBaseAJJBXXListLA, gBaseAJJBXXListPA);
List<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds); List<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds);
@ -160,7 +161,7 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
private static void generateBusinessDepartList(List<Date> happenTime, List<GBaseJJD> gBaseJJDSList, Map<String, Long> resultMap, Map<String, String> resultMap2, Map<String, String> resultMap3, List<Long> groupIds, List<BusinessDepart> businessDepartList, List<GBaseAJJBXX> gBaseAJJBXXListSA, List<GBaseAJJBXX> gBaseAJJBXXListLA, List<GBaseAJJBXX> gBaseAJJBXXListPA) { private static void generateBusinessDepartList(List<Date> happenTime, List<GBaseJJD> gBaseJJDSList, Map<String, Long> resultMap, Map<String, String> resultMap2, Map<String, String> resultMap3, List<Long> groupIds, List<BusinessDepart> businessDepartList, List<GBaseAJJBXX> gBaseAJJBXXListSA, List<GBaseAJJBXX> gBaseAJJBXXListLA, List<GBaseAJJBXX> gBaseAJJBXXListPA) {
for (GBaseJJD gBaseJJD : gBaseJJDSList) { for (GBaseJJD gBaseJJD : gBaseJJDSList) {
Long groupId = Long.valueOf(resultMap2.get(gBaseJJD.getGxdwdm())); Long groupId = resultMap.get(resultMap2.get(gBaseJJD.getGxdwdm()));
if (groupId == null) { if (groupId == null) {
continue; continue;
} }
@ -169,7 +170,7 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
businessDepartList.add(businessDepart); businessDepartList.add(businessDepart);
} }
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListSA) { for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListSA) {
Long groupId = Long.valueOf(resultMap2.get(gBaseAJJBXX.getBADWIDdm())); Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) { if (groupId == null) {
continue; continue;
} }
@ -178,7 +179,7 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
businessDepartList.add(businessDepart); businessDepartList.add(businessDepart);
} }
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListLA) { for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListLA) {
Long groupId = Long.valueOf(resultMap2.get(gBaseAJJBXX.getBADWIDdm())); Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) { if (groupId == null) {
continue; continue;
} }
@ -187,7 +188,7 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
businessDepartList.add(businessDepart); businessDepartList.add(businessDepart);
} }
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListPA) { for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListPA) {
Long groupId = Long.valueOf(resultMap2.get(gBaseAJJBXX.getBADWIDdm())); Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) { if (groupId == null) {
continue; continue;
} }

Loading…
Cancel
Save