add - SAP物料主数据定时任务

master
yinq 1 year ago
parent c2464c6e83
commit ac4efe9b12

@ -0,0 +1,46 @@
package com.aucma.api.task;
import com.aucma.api.domain.dto.SAPPortDto;
import com.aucma.api.domain.dto.WERKSDto;
import com.aucma.api.service.ISAPPortService;
import com.aucma.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @Author YinQ
* @create 2023-10-08 9:11
*/
@Component("SAPTask")
public class SAPTask {
@Autowired
private ISAPPortService portService;
/**
* SAP
*
* @param days
*/
public void SAPMaterialDataTask(String factoryCode, Long days) {
String startDate = DateUtils.convertDaysToDateString(days);
String endDate = DateUtils.getDate();
SAPPortDto sapPortDto = new SAPPortDto();
WERKSDto werksDto = new WERKSDto();
List<HashMap<String, String>> factoryList = new ArrayList<>();
HashMap<String, String> hashMap = new HashMap<>();
sapPortDto.setStartDate(startDate);
sapPortDto.setEndDate(endDate);
hashMap.put("WERKS", factoryCode);
factoryList.add(hashMap);
werksDto.setItem(factoryList);
sapPortDto.setFactoryCodes(werksDto);
portService.getSAPMaterialData(sapPortDto);
}
}

@ -8,6 +8,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
@ -188,4 +189,24 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault()); ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant()); return Date.from(zdt.toInstant());
} }
/**
* days
* @param days
* @return
*/
public static String convertDaysToDateString(Long days) {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 减去相应的天数
LocalDate targetDate = currentDate.minusDays(days);
// 创建DateTimeFormatter对象指定日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 格式化日期为字符串并返回
return targetDate.format(formatter);
}
} }

Loading…
Cancel
Save