1.添加手动数据同步接口

master
x_z 3 years ago
parent a5ba3eb62c
commit b5d940d15d

@ -0,0 +1,178 @@
package com.glxp.api.admin.controller.basic;
import cn.hutool.core.collection.CollUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.api.admin.constant.BasicProcessStatus;
import com.glxp.api.admin.entity.basic.BasicExportStatusEntity;
import com.glxp.api.admin.entity.basic.BasicExportStatusTimeEntity;
import com.glxp.api.admin.req.basic.BasicExportStatusRequest;
import com.glxp.api.admin.req.basic.BasicExportTimeRequest;
import com.glxp.api.admin.req.info.DeleteRequest;
import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.service.basic.BasicExportService;
import com.glxp.api.admin.service.basic.BasicExportTimeService;
import com.glxp.api.admin.util.CustomUtil;
import com.glxp.api.admin.util.RedisUtil;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RestController
public class SpsSyncExportStatusController {
@Resource
BasicExportService basicExportService;
@Resource
BasicExportTimeService basicExportTimeService;
@Resource
RedisUtil redisUtil;
@GetMapping("/spssync/basic/udiinfo/getStatus")
public BaseResponse getStatus(BasicExportStatusRequest basicExportStatusRequest) {
List<BasicExportStatusEntity> basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest);
return ResultVOUtils.success(basicExportStatusEntities);
}
@GetMapping("/spssync/basic/udiinfo/filter")
public BaseResponse filterStatus(BasicExportStatusRequest basicExportStatusRequest) {
List<BasicExportStatusEntity> basicExportStatusEntities = basicExportService.filterExportStatus(basicExportStatusRequest);
PageInfo<BasicExportStatusEntity> pageInfo;
pageInfo = new PageInfo<>(basicExportStatusEntities);
PageSimpleResponse<BasicExportStatusEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(basicExportStatusEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("/spssync/basic/udiinfo/deleteByStatus")
public BaseResponse deleteByStatus(@RequestBody DeleteRequest deleteRequest) {
boolean b = basicExportService.deleteById(deleteRequest.getId());
redisUtil.del(deleteRequest.getId());
if (b)
return ResultVOUtils.success("删除成功!");
else
return ResultVOUtils.error(500, "删除失败!");
}
@PostMapping("/spssync/basic/udiinfo/updateStatus")
public BaseResponse updateStatus(@RequestBody BasicExportStatusEntity basicExportStatusEntity) {
basicExportStatusEntity.setEndTime(new Date());
basicExportStatusEntity.setUpdateTime(new Date());
boolean b = basicExportService.updateExportStatus(basicExportStatusEntity);
if (b)
return ResultVOUtils.success("更新成功!");
else
return ResultVOUtils.error(500, "更新成功!");
}
@GetMapping("/spssync/basic/schedule/lastTime")
public BaseResponse getLastUpdateTime(BasicExportTimeRequest basicExportTimeRequest) {
List<BasicExportStatusTimeEntity> basicExportStatusEntities = basicExportTimeService.filterExportStatus(basicExportTimeRequest);
if (CollUtil.isNotEmpty(basicExportStatusEntities)) {
return ResultVOUtils.success(basicExportStatusEntities.get(0).getLastUpdateTime());
} else {
return ResultVOUtils.success("1949-01-01 00:00:00");
}
}
@PostMapping("/spssync/basic/schedule/updateLastTime")
public BaseResponse updateLastTime(@RequestBody BasicExportStatusTimeEntity basicExportStatusTimeEntity) {
boolean b = basicExportTimeService.insertExportStatus(basicExportStatusTimeEntity);
if (b)
return ResultVOUtils.success("更新成功!");
else
return ResultVOUtils.error(500, "更新失败!");
}
@PostMapping("/spssync/basic/schedule/create")
public BaseResponse createSchedule(@RequestBody BasicExportStatusRequest basicExportStatusRequest) {
if (basicExportStatusRequest.getCreateType() == 1) {
//自动创建要求被下载已完成单据任务
BasicExportStatusEntity basicExportStatusEntity1 = basicExportService.findByData("AutoDownloadOrder", 0);
if (basicExportStatusEntity1 == null) {
BasicExportStatusEntity orderStatusEntity = new BasicExportStatusEntity();
orderStatusEntity.setId(CustomUtil.getId());
orderStatusEntity.setIdDatas("AutoDownloadOrder");
orderStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
orderStatusEntity.setUpdateTime(new Date());
orderStatusEntity.setStatus(0);
orderStatusEntity.setStartTime(new Date());
orderStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicExportService.insertExportStatus(orderStatusEntity);
}else {
return ResultVOUtils.error(501,"任务已存在!");
}
} else if (basicExportStatusRequest.getCreateType() == 2) {
//自动创建要求被下载单据类型任务
BasicExportStatusEntity basicExportStatusEntity2 = basicExportService.findByData("AutoDownloadBusType", 0);
if (basicExportStatusEntity2 == null) {
BasicExportStatusEntity busTypetatusEntity = new BasicExportStatusEntity();
busTypetatusEntity.setId(CustomUtil.getId());
busTypetatusEntity.setIdDatas("AutoDownloadBusType");
busTypetatusEntity.setType(BasicProcessStatus.NEW_ALL_BUS);
busTypetatusEntity.setUpdateTime(new Date());
busTypetatusEntity.setStatus(0);
busTypetatusEntity.setStartTime(new Date());
busTypetatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicExportService.insertExportStatus(busTypetatusEntity);
}else {
return ResultVOUtils.error(501,"任务已存在!");
}
} else if (basicExportStatusRequest.getCreateType() == 3) {
//自动创建要求被下载基础信息任务
BasicExportStatusEntity basicExportStatusEntity3 = basicExportService.findByData("AutoDownloadAllData", 0);
if (basicExportStatusEntity3 == null) {
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
basicExportStatusEntity.setId(CustomUtil.getId());
basicExportStatusEntity.setIdDatas("AutoDownloadAllData");
basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStatus(0);
basicExportStatusEntity.setStartTime(new Date());
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicExportService.insertExportStatus(basicExportStatusEntity);
}else {
return ResultVOUtils.error(501,"任务已存在!");
}
} else if (basicExportStatusRequest.getCreateType() == 4) {
//自动创建要求被下载同步库DI信息
BasicExportStatusEntity basicExportStatusEntity4 = basicExportService.findByData("AutoDownloadDiProducts", 0);
if (basicExportStatusEntity4 == null) {
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
basicExportStatusEntity.setId(CustomUtil.getId());
basicExportStatusEntity.setIdDatas("AutoDownloadDiProducts");
basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_DI);
basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStatus(0);
basicExportStatusEntity.setStartTime(new Date());
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicExportService.insertExportStatus(basicExportStatusEntity);
}else {
return ResultVOUtils.error(501,"任务已存在!");
}
}
return ResultVOUtils.success("创建成功!");
}
}

@ -10,4 +10,5 @@ public class BasicExportStatusRequest extends ListPageRequest {
private Integer type;
private String idDatas;
private Integer scheduleType;
public Integer createType;
}

@ -0,0 +1,12 @@
package com.glxp.api.admin.req.info;
import lombok.Data;
import java.util.List;
@Data
public class DeleteRequest {
String id;
List<String> ids;
}
Loading…
Cancel
Save