Kaynağa Gözat

定时任务前 先删除所有数据

tags/24080901
PoffyZhang 1 yıl önce
ebeveyn
işleme
c1c0fb9745
10 değiştirilmiş dosya ile 91 ekleme ve 15 silme
  1. +19
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java
  2. +4
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java
  3. +1
    -1
      pmapi/src/main/resources/application-dev.yml
  4. +1
    -0
      pmapi/src/main/resources/application-pre.yml
  5. +1
    -0
      pmapi/src/main/resources/application-prod.yml
  6. +1
    -1
      pmapi/src/test/resources/application-dev.yml
  7. +1
    -0
      pmapi/src/test/resources/application-pre.yml
  8. +1
    -0
      pmapi/src/test/resources/application-prod.yml
  9. +6
    -1
      syn-data-task/src/main/java/com/ningdatech/syndataapi/open/controller/ProjectReceiveController.java
  10. +56
    -11
      syn-data-task/src/main/java/com/ningdatech/syndataapi/open/manage/ProjectReceiveManage.java

+ 19
- 0
pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java Dosyayı Görüntüle

@@ -75,6 +75,9 @@ public class GovProjectCollectionManage {
@Value("${project.no-effective-url}")
private String noEffectiveUrl;

@Value("${project.delete-all-url}")
private String deleteAllUrl;

public List<GovProjectDictionaryVO> dictionary(String type) {

List<GovProjectDictionary> dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class)
@@ -472,4 +475,20 @@ public class GovProjectCollectionManage {
log.info("推送失败,{}",e.getMessage());
}
}

public void deleteAll() {
String url = deleteAllUrl;
try{
log.info("推送删除数据url {}",url);
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<String> formEntity = new HttpEntity<String>(null, headers);
ResponseEntity<String> response = restTemplate.postForEntity(url, formEntity, String.class);
log.info("推送删除结果 :{}",response);
}catch (Exception e){
log.info("推送删除失败,{}",e.getMessage());
}
}
}

+ 4
- 1
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java Dosyayı Görüntüle

@@ -55,10 +55,13 @@ public class SynProjectCollectionTask {
log.info("预发环境不用同步!");
return;
}
log.info("数据同步任务开始");
StopWatch stopWatch = new StopWatch();
stopWatch.start();

log.info("数据同步任务开始之前 先删除前置机上的所有数据");
collectionManage.deleteAll();

//取昨天1点 到今天1点的 项目归集
ProjectListReq req = new ProjectListReq();
req.setCreateOnMax(DateUtil.convertDateToLocal(DateUtil.getTodayTime(TASK_HOUR_TODAY)));


+ 1
- 1
pmapi/src/main/resources/application-dev.yml Dosyayı Görüntüle

@@ -233,7 +233,7 @@ hostname: iZbp13nwyvib53j4j1p2xoZ
project:
push-url: http://120.26.44.207:38088/open/api/v1/project-receive/save
no-effective-url: http://120.26.44.207:38088/open/api/v1/project-receive/not-effective
delete-all-url: http://120.26.44.207:38088/open/api/v1/project-receive/delete-all
login:
phone-verify-code:
skip: true


+ 1
- 0
pmapi/src/main/resources/application-pre.yml Dosyayı Görüntüle

@@ -236,6 +236,7 @@ hostname: iZ6mx01asxnsmennpzoxooZ
project:
push-url: http://10.53.168.41:38088/open/api/v1/project-receive/save
no-effective-url: http://10.53.168.41:38088/open/api/v1/project-receive/not-effective
delete-all-url: http://10.53.168.41:38088/open/api/v1/project-receive/delete-all
login:
phone-verify-code:
skip: true


+ 1
- 0
pmapi/src/main/resources/application-prod.yml Dosyayı Görüntüle

@@ -236,6 +236,7 @@ hostname: iZ6mx01gyeodd80imxd2gbZ
project:
push-url: http://10.53.168.41:38088/open/api/v1/project-receive/save
no-effective-url: http://10.53.168.41:38088/open/api/v1/project-receive/not-effective
delete-all-url: http://10.53.168.41:38088/open/api/v1/project-receive/delete-all
login:
phone-verify-code:
skip: true


+ 1
- 1
pmapi/src/test/resources/application-dev.yml Dosyayı Görüntüle

@@ -233,7 +233,7 @@ hostname: iZbp13nwyvib53j4j1p2xoZ
project:
push-url: http://120.26.44.207:38088/open/api/v1/project-receive/save
no-effective-url: http://120.26.44.207:38088/open/api/v1/project-receive/not-effective
delete-all-url: http://120.26.44.207:38088/open/api/v1/project-receive/delete-all
login:
phone-verify-code:
skip: true


+ 1
- 0
pmapi/src/test/resources/application-pre.yml Dosyayı Görüntüle

@@ -236,6 +236,7 @@ hostname: iZ6mx01asxnsmennpzoxooZ
project:
push-url: http://10.53.168.41:38088/open/api/v1/project-receive/save
no-effective-url: http://10.53.168.41:38088/open/api/v1/project-receive/not-effective
delete-all-url: http://10.53.168.41:38088/open/api/v1/project-receive/delete-all
login:
phone-verify-code:
skip: true


+ 1
- 0
pmapi/src/test/resources/application-prod.yml Dosyayı Görüntüle

@@ -236,6 +236,7 @@ hostname: iZ6mx01gyeodd80imxd2gbZ
project:
push-url: http://10.53.168.41:38088/open/api/v1/project-receive/save
no-effective-url: http://10.53.168.41:38088/open/api/v1/project-receive/not-effective
delete-all-url: http://10.53.168.41:38088/open/api/v1/project-receive/delete-all
login:
phone-verify-code:
skip: true


+ 6
- 1
syn-data-task/src/main/java/com/ningdatech/syndataapi/open/controller/ProjectReceiveController.java Dosyayı Görüntüle

@@ -4,7 +4,6 @@ import com.ningdatech.basic.model.ApiResponse;
import com.ningdatech.syndataapi.open.manage.ProjectReceiveManage;
import com.ningdatech.syndataapi.scheduler.model.dto.ProjectBaseInfoDTO;
import com.ningdatech.syndataapi.scheduler.model.dto.ProjectSaveDTO;
import com.ningdatech.syndataapi.scheduler.model.entity.ProjectBaseInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@@ -37,4 +36,10 @@ public class ProjectReceiveController {
public ApiResponse<String> notEffective(@Valid @RequestBody ProjectBaseInfoDTO baseinfo) {
return ApiResponse.ofSuccess(receiveManage.notEffective(baseinfo));
}

@PostMapping("/delete-all")
@ApiOperation("清空当前表数据")
public ApiResponse<String> deleteAll() {
return ApiResponse.ofSuccess(receiveManage.deleteAll());
}
}

+ 56
- 11
syn-data-task/src/main/java/com/ningdatech/syndataapi/open/manage/ProjectReceiveManage.java Dosyayı Görüntüle

@@ -1,7 +1,6 @@
package com.ningdatech.syndataapi.open.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.syndataapi.common.constant.BizConst;
@@ -59,10 +58,16 @@ public class ProjectReceiveManage {
.last(BizConst.LIMIT_1));
ProjectBaseInfo saveBase = BeanUtil.copyProperties(baseInfo,ProjectBaseInfo.class);
if(Objects.isNull(oldBaseInfo)){
saveBase.setOp(BizConst.OP_INSERT);
//如果当前 数据不存在 但是我们平台操作是修改 说明之前数据被推送过了那么 可以置为修改update
if(StringUtils.isNotBlank(baseInfo.getOp()) && BizConst.OP_UPDATE.equals(baseInfo.getOp())){
saveBase.setOp(BizConst.OP_UPDATE);
}else{
saveBase.setOp(BizConst.OP_INSERT);
}
saveBase.setTongTime(LocalDateTime.now());
}else {
saveBase.setOp(BizConst.OP_UPDATE);
saveBase.setOp(BizConst.OP_INSERT);
saveBase.setTongID(oldBaseInfo.getTongID());
}
saveBase.setBizTime(LocalDateTime.now());
baseInfoService.saveOrUpdate(saveBase);
@@ -77,11 +82,18 @@ public class ProjectReceiveManage {
ProjectApply saveApply = BeanUtil.copyProperties(apply,ProjectApply.class);
saveApply.setBaseProjId(baseProjId);
if(Objects.isNull(oldApply)){
saveApply.setOp(BizConst.OP_INSERT);
//如果当前 数据不存在 但是我们平台操作是修改 说明之前数据被推送过了那么 可以置为修改update
if(StringUtils.isNotBlank(apply.getOp()) && BizConst.OP_UPDATE.equals(apply.getOp())){
saveApply.setOp(BizConst.OP_UPDATE);
}else{
saveApply.setOp(BizConst.OP_INSERT);
}
saveApply.setTongTime(LocalDateTime.now());
}else{
saveApply.setOp(BizConst.OP_UPDATE);
saveApply.setOp(BizConst.OP_INSERT);
saveApply.setTongID(oldApply.getTongID());
}

saveApply.setBizTime(LocalDateTime.now());
applyService.saveOrUpdate(saveApply);

@@ -95,10 +107,16 @@ public class ProjectReceiveManage {
ProjectApprove saveApprove = BeanUtil.copyProperties(approve,ProjectApprove.class);
saveApprove.setBaseProjId(baseProjId);
if(Objects.isNull(oldApprove)){
saveApprove.setOp(BizConst.OP_INSERT);
//如果当前 数据不存在 但是我们平台操作是修改 说明之前数据被推送过了那么 可以置为修改update
if(StringUtils.isNotBlank(approve.getOp()) && BizConst.OP_UPDATE.equals(approve.getOp())){
saveApprove.setOp(BizConst.OP_UPDATE);
}else{
saveApprove.setOp(BizConst.OP_INSERT);
}
saveApprove.setTongTime(LocalDateTime.now());
}else{
saveApprove.setOp(BizConst.OP_UPDATE);
saveApprove.setOp(BizConst.OP_INSERT);
saveApprove.setTongID(oldApprove.getTongID());
}
saveApprove.setBizTime(LocalDateTime.now());
approveService.saveOrUpdate(saveApprove);
@@ -114,10 +132,16 @@ public class ProjectReceiveManage {
ProjectCimplement saveCimplement = BeanUtil.copyProperties(cimplement,ProjectCimplement.class);
saveCimplement.setBaseProjId(baseProjId);
if(Objects.isNull(oldCimplement)){
saveCimplement.setOp(BizConst.OP_INSERT);
//如果当前 数据不存在 但是我们平台操作是修改 说明之前数据被推送过了那么 可以置为修改update
if(StringUtils.isNotBlank(cimplement.getOp()) && BizConst.OP_UPDATE.equals(cimplement.getOp())){
saveCimplement.setOp(BizConst.OP_UPDATE);
}else{
saveCimplement.setOp(BizConst.OP_INSERT);
}
saveCimplement.setTongTime(LocalDateTime.now());
}else{
saveCimplement.setOp(BizConst.OP_UPDATE);
saveCimplement.setOp(BizConst.OP_INSERT);
saveCimplement.setTongID(oldCimplement.getTongID());
}
saveCimplement.setBizTime(LocalDateTime.now());
cimplementService.saveOrUpdate(saveCimplement);
@@ -133,10 +157,16 @@ public class ProjectReceiveManage {
ProjectMimplement saveMimplement = BeanUtil.copyProperties(mimplement,ProjectMimplement.class);
saveMimplement.setBaseProjId(baseProjId);
if(Objects.isNull(oldMimplement)){
saveMimplement.setOp(BizConst.OP_INSERT);
//如果当前 数据不存在 但是我们平台操作是修改 说明之前数据被推送过了那么 可以置为修改update
if(StringUtils.isNotBlank(mimplement.getOp()) && BizConst.OP_UPDATE.equals(mimplement.getOp())){
saveMimplement.setOp(BizConst.OP_UPDATE);
}else{
saveMimplement.setOp(BizConst.OP_INSERT);
}
saveMimplement.setTongTime(LocalDateTime.now());
}else{
saveMimplement.setOp(BizConst.OP_UPDATE);
saveMimplement.setOp(BizConst.OP_INSERT);
saveMimplement.setTongID(oldMimplement.getTongID());
}
saveMimplement.setBizTime(LocalDateTime.now());
mimplementService.saveOrUpdate(saveMimplement);
@@ -191,4 +221,19 @@ public class ProjectReceiveManage {

return BizConst.OP_SUCCESS;
}

/**
* 删除表里的所有数据
* @return
*/
public String deleteAll() {
baseInfoService.remove(Wrappers.lambdaQuery(ProjectBaseInfo.class));
applyService.remove(Wrappers.lambdaQuery(ProjectApply.class));
approveService.remove(Wrappers.lambdaQuery(ProjectApprove.class));
cimplementService.remove(Wrappers.lambdaQuery(ProjectCimplement.class));
mimplementService.remove(Wrappers.lambdaQuery(ProjectMimplement.class));
procureService.remove(Wrappers.lambdaQuery(ProjectProcure.class));
log.info("删除所有前置表数据成功");
return BizConst.OP_SUCCESS;
}
}

Yükleniyor…
İptal
Kaydet