Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -42,7 +42,7 @@ public class AppRun implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
HeartClientServer heartServer = new HeartClientServer(new InetSocketAddress("192.168.8.218", 20889));
|
||||
HeartClientServer heartServer = new HeartClientServer(new InetSocketAddress("192.168.18.218", 20889));
|
||||
System.out.println("--------项目启动完成--------");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,492 @@
|
||||
package org.nl.common.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.Temporal;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class DateUtil extends org.apache.commons.lang3.time.DateUtils {
|
||||
public static String YYYY = "yyyy";
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
public static String YYYYMMDDHHMMSS_MS = "yyyyMMddHHmmssSS";
|
||||
public static final DateTimeFormatter DFY_MD_HMS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
public static final DateTimeFormatter DFY_MD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
* LocalDateTime 转时间戳
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public static Long getTimeStamp(LocalDateTime localDateTime) {
|
||||
return localDateTime.atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳转LocalDateTime
|
||||
*
|
||||
* @param timeStamp /
|
||||
* @return /
|
||||
*/
|
||||
public static LocalDateTime fromTimeStamp(Long timeStamp) {
|
||||
return LocalDateTime.ofEpochSecond(timeStamp, 0, OffsetDateTime.now().getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* LocalDateTime 转 Date
|
||||
* Jdk8 后 不推荐使用 {@link Date} Date
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public static Date toDate(LocalDateTime localDateTime) {
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* LocalDate 转 Date
|
||||
* Jdk8 后 不推荐使用 {@link Date} Date
|
||||
*
|
||||
* @param localDate /
|
||||
* @return /
|
||||
*/
|
||||
public static Date toDate(LocalDate localDate) {
|
||||
return toDate(localDate.atTime(LocalTime.now(ZoneId.systemDefault())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Date转 LocalDateTime
|
||||
* Jdk8 后 不推荐使用 {@link Date} Date
|
||||
*
|
||||
* @param date /
|
||||
* @return /
|
||||
*/
|
||||
public static LocalDateTime toLocalDateTime(Date date) {
|
||||
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期 格式化
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @param patten /
|
||||
* @return /
|
||||
*/
|
||||
public static String localDateTimeFormat(LocalDateTime localDateTime, String patten) {
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(patten);
|
||||
return df.format(localDateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期 格式化
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @param df /
|
||||
* @return /
|
||||
*/
|
||||
public static String localDateTimeFormat(LocalDateTime localDateTime, DateTimeFormatter df) {
|
||||
return df.format(localDateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期格式化 yyyy-MM-dd HH:mm:ss
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public static String localDateTimeFormatyMdHms(LocalDateTime localDateTime) {
|
||||
return DFY_MD_HMS.format(localDateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期格式化 yyyy-MM-dd
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public String localDateTimeFormatyMd(LocalDateTime localDateTime) {
|
||||
return DFY_MD.format(localDateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public static LocalDateTime parseLocalDateTimeFormat(String localDateTime, String pattern) {
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return LocalDateTime.from(dateTimeFormatter.parse(localDateTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public static LocalDateTime parseLocalDateTimeFormat(String localDateTime, DateTimeFormatter dateTimeFormatter) {
|
||||
return LocalDateTime.from(dateTimeFormatter.parse(localDateTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd HH:mm:ss
|
||||
*
|
||||
* @param localDateTime /
|
||||
* @return /
|
||||
*/
|
||||
public static LocalDateTime parseLocalDateTimeFormatyMdHms(String localDateTime) {
|
||||
return LocalDateTime.from(DFY_MD_HMS.parse(localDateTime));
|
||||
}
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取当前Date型日期
|
||||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate() {
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
public static final String getTime() {
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNowMs() {
|
||||
return dateTimeNow(YYYYMMDDHHMMSS_MS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow(final String format) {
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
public static final String dateTime(final Date date) {
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
public static final String parseDateToStr(final String format, final Date date) {
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
public static final Date dateTime(final String format, final String ts) {
|
||||
try {
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static final String datePath() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String year() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date parseDates(Object str, Integer index) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return parseDate(str.toString(), parsePatterns[index]);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器启动时间
|
||||
*/
|
||||
public static Date getServerStartDate() {
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间差
|
||||
*/
|
||||
public static String getDatePoor(Date endDate, Date nowDate) {
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime();
|
||||
// 计算差多少天
|
||||
long day = diff / nd;
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
// 计算差多少分钟
|
||||
long min = diff % nd % nh / nm;
|
||||
// 计算差多少秒//输出结果
|
||||
// long sec = diff % nd % nh % nm / ns;
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间差
|
||||
*/
|
||||
public static long getDatePoorHour(Date endDate, Date nowDate) {
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime();
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
return hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据年月日计算月份差
|
||||
*/
|
||||
public static long getDateDiff(Date startDateTime, Date endDateTime) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String startDate = df.format(startDateTime);
|
||||
String endTime = df.format(endDateTime);
|
||||
Temporal temporalNowDate = LocalDate.parse(startDate);
|
||||
Temporal temporalStartTime = LocalDate.parse(endTime);
|
||||
return ChronoUnit.MONTHS.between(temporalStartTime, temporalNowDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一个时间段计算另一段时间段的结束时间
|
||||
*/
|
||||
public static Date getDateEndFromInterval(String startDateTime, String endDateTime, Date startTime) {
|
||||
// 开始和结束时间
|
||||
LocalDateTime intervalStart = LocalDateTime.parse(startDateTime, DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
|
||||
LocalDateTime intervalEnd = LocalDateTime.parse(endDateTime, DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
|
||||
// 计算时间间隔时长
|
||||
long intervalDuration = ChronoUnit.SECONDS.between(intervalStart, intervalEnd);
|
||||
long interval2EndEpochSecond = startTime.toInstant().getEpochSecond() + intervalDuration;
|
||||
return Date.from(Instant.ofEpochSecond(interval2EndEpochSecond));
|
||||
}
|
||||
|
||||
|
||||
public static Date getTime(Date date, int amount) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
//把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天)
|
||||
calendar.add(Calendar.DATE, amount);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取过去第几天的日期
|
||||
*
|
||||
* @param past
|
||||
* @return
|
||||
*/
|
||||
public static String getPastDate(Date date, int past) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
|
||||
Date today = calendar.getTime();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String result = format.format(today);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Date getSameDayHourTime(Date date, int hourOfDay) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static String getStringDateMonthByDate(Date date) {
|
||||
return parseDateToStr(YYYY_MM, date);
|
||||
}
|
||||
|
||||
public static Date getDateMonthByString(String date) {
|
||||
return dateTime(YYYY_MM, date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 年、月 获取对应的月份 的 天数
|
||||
*/
|
||||
public static int getDaysByYearMonth(Date date) {
|
||||
Calendar a = Calendar.getInstance();
|
||||
a.setTime(date);
|
||||
a.set(Calendar.DATE, 1);
|
||||
a.roll(Calendar.DATE, -1);
|
||||
int maxDate = a.get(Calendar.DATE);
|
||||
return maxDate;
|
||||
}
|
||||
|
||||
public static int getDaysByYearMonth2(int year, int month) {
|
||||
Calendar a = Calendar.getInstance();
|
||||
a.set(Calendar.YEAR, year);
|
||||
a.set(Calendar.MONTH, month - 1);
|
||||
a.set(Calendar.DATE, 1);
|
||||
a.roll(Calendar.DATE, -1);
|
||||
int maxDate = a.get(Calendar.DATE);
|
||||
return maxDate;
|
||||
}
|
||||
|
||||
//获取年月yyyymm
|
||||
public static String getYearMonth() {
|
||||
String months = "";
|
||||
Calendar a = Calendar.getInstance();
|
||||
Integer year = a.get(Calendar.YEAR);
|
||||
Integer month = a.get(Calendar.MONTH);
|
||||
if (month <= 9) {
|
||||
months = "0" + month;
|
||||
} else {
|
||||
months = month.toString();
|
||||
}
|
||||
return year + months;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换为Date
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static Date toDateByStartTime(String startTime)
|
||||
throws ParseException {
|
||||
startTime = startTime + " 00:00:00";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date beginDate = dateFormat.parse(startTime);
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public static Date toDateByEndTime(String endTime)
|
||||
throws ParseException {
|
||||
endTime = endTime + " 23:59:59";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = dateFormat.parse(endTime);
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public static String getDate(Date date)
|
||||
throws ParseException {
|
||||
LocalDate time = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
String format = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
return format;
|
||||
}
|
||||
|
||||
public static String getDate1(Date date)
|
||||
throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDate time = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
String format = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
return format;
|
||||
}
|
||||
|
||||
public static String getDateStringYmd(String date) {
|
||||
if (StringUtils.isBlank(date)) {
|
||||
return "";
|
||||
}
|
||||
if (!date.contains(":")) {
|
||||
return date;
|
||||
}
|
||||
if (date.contains(".")) {
|
||||
int currentYear = cn.hutool.core.date.DateUtil.thisYear(); // 假设默认使用2023年份
|
||||
String[] dateParts = date.split("\\.");
|
||||
String month = dateParts[1];
|
||||
String day = dateParts[2];
|
||||
// 将提取的部分拼接成标准的日期格式"yyyy-MM-dd"
|
||||
return currentYear + "-" + month + "-" + day;
|
||||
}
|
||||
LocalDateTime dateTime = LocalDateTime.parse(date.replace("/", "-"), DFY_MD_HMS);
|
||||
return dateTime.format(DFY_MD);
|
||||
}
|
||||
|
||||
/**
|
||||
* date '2024/05/05 08:44:54'
|
||||
* type 1 yyyy/MM/dd HH:mm:ss,2 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static Date getDate(String date)
|
||||
throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(date.contains("-")?"yyyy-MM-dd HH:mm:ss":"yyyy/MM/dd HH:mm:ss");
|
||||
return dateFormat.parse(date);
|
||||
}
|
||||
|
||||
public static Date getDateFormat(String date)
|
||||
throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(date.contains("-")?"yyyy-MM-dd":"yyyy/MM/dd");
|
||||
return dateFormat.parse(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Date getDates(String date,String dateParseFormat )
|
||||
throws ParseException {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(dateParseFormat);
|
||||
Date format = dateFormat.parse(date);
|
||||
return format;
|
||||
}
|
||||
|
||||
|
||||
public static Date dateByEndTime(Date endTime)
|
||||
throws ParseException {
|
||||
String date = getDate(endTime);
|
||||
date = date + " 23:59:59";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = dateFormat.parse(date);
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public static Date dateByStartTime(Date startTime)
|
||||
throws ParseException {
|
||||
String date = getDate(startTime);
|
||||
date = date + " 00:00:00";
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = dateFormat.parse(date);
|
||||
return endDate;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.wms.base_manage.bsrealstorattr.service.impl.StIvtBsrealstorattrServiceImpl;
|
||||
import org.nl.wms.base_manage.customer.service.impl.BmCustomerServiceImpl;
|
||||
import org.nl.wms.base_manage.material.service.dao.MdMeMaterialbase;
|
||||
@@ -22,8 +21,6 @@ import org.nl.wms.base_manage.supplier.service.IBmSupplierService;
|
||||
import org.nl.wms.external_system.erp.dto.ErpQuery;
|
||||
import org.nl.wms.external_system.erp.dto.ErpSec;
|
||||
import org.nl.wms.sync_manage.service.form_mapping.dao.SyncFormMapping;
|
||||
import org.nl.wms.system_manage.service.dept.dao.SysDept;
|
||||
import org.nl.wms.system_manage.service.dept.impl.SysDeptServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -181,34 +178,48 @@ public class SyncErpService {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 回传测试
|
||||
*/
|
||||
public JSONObject process2(JSONObject from) {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
//todo 需要封装
|
||||
IdentifyInfo identifyInfo = new IdentifyInfo();
|
||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||
String results = cloudApi.push("PRD_INSTOCK", from.toJSONString());
|
||||
result.put("results", results);
|
||||
} catch (Exception ex) {
|
||||
Log.error(ex.getMessage());
|
||||
result.put("error", ex.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 回传测试
|
||||
*/
|
||||
public JSONObject process(JSONObject from) {
|
||||
String result ="";
|
||||
JSONObject result = new JSONObject();
|
||||
//执行回传
|
||||
String formType = from.getString("formid");
|
||||
try {
|
||||
//要回传的json数据
|
||||
JSONObject formData = from.getJSONObject("data");
|
||||
//todo 需要封装
|
||||
IdentifyInfo identifyInfo = new IdentifyInfo();
|
||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||
result = cloudApi.save(formType, formData.toJSONString());
|
||||
Integer sd =0;
|
||||
String results = cloudApi.save(formType, formData.toJSONString());
|
||||
result.put("results", results);
|
||||
} catch (Exception ex) {
|
||||
Log.error(ex.getMessage());
|
||||
String sd =result;
|
||||
result.put("error", ex.getMessage());
|
||||
}
|
||||
return from;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -220,11 +231,12 @@ public class SyncErpService {
|
||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
String filterString = "FBillNo ='MO102241101889'";
|
||||
//String filterString = "FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
|
||||
ErpQuery query = new ErpQuery();
|
||||
// query.setFilterString(filterString);
|
||||
query.setFilterString(filterString);
|
||||
//query.setFormId(syncFormMapping.getForm_type());
|
||||
query.setFormId("STK_InStock");
|
||||
query.setFormId("PRD_MO");
|
||||
query.setFieldKeys("FID");
|
||||
query.setLimit(1);
|
||||
String jsonString = JSON.toJSONString(query);
|
||||
@@ -244,7 +256,7 @@ public class SyncErpService {
|
||||
Map<String, String> error = new HashMap<>();
|
||||
for (String id : ids) {
|
||||
param.setId(id);
|
||||
OperatorResult view = cloudApi.view("STK_InStock", param);
|
||||
OperatorResult view = cloudApi.view("PRD_MO", param);
|
||||
RepoStatus status = view.getResult().getResponseStatus();
|
||||
if (status.isIsSuccess()) {
|
||||
result.add(view.getResult().getResult());
|
||||
|
||||
@@ -152,6 +152,10 @@ public class PdaIOService {
|
||||
JSONObject formJson = JSONObject.parseObject(form_data);
|
||||
JSONObject pFormJson = JSONObject.parseObject(pForm_data);
|
||||
if (ObjectUtils.isNotEmpty(formJson) && ObjectUtils.isNotEmpty(pFormJson)) {
|
||||
result.setBillNo(receiveBillData.getPCode());
|
||||
result.setMaterial_id(receiveBillData.getMaterial_id());
|
||||
result.setUnit_id(receiveBillData.getUnit_id());
|
||||
result.setPcsn(receiveBillData.getPcsn());
|
||||
result.setPrdOrgId(pFormJson.getString("PurOrgId_Id"));
|
||||
result.setStockOrgId(pFormJson.getString("DemandOrgId_Id"));
|
||||
result.setOwnerIdHead_Id(pFormJson.getString("OwnerIdHead_Id"));
|
||||
@@ -159,13 +163,11 @@ public class PdaIOService {
|
||||
result.setSupplierId(pFormJson.getString("SupplierId_Id"));
|
||||
result.setMoNumber(formJson.getString("OrderBillNo"));
|
||||
result.setQty(new BigDecimal(formJson.getString("ActReceiveQty")));
|
||||
result.setOwnerId_Id(StringUtils.isBlank(formJson.getString("OwnerId_Id"))?"750572":formJson.getString("OwnerId_Id"));
|
||||
result.setOwnerTypeId(formJson.getString("OwnerTypeId"));
|
||||
result.setRemainInStockUnitId(formJson.getString("PriceUnitId_Id"));
|
||||
result.setBillNo(receiveBillData.getPCode());
|
||||
result.setMaterial_id(receiveBillData.getMaterial_id());
|
||||
result.setUnit_id(receiveBillData.getUnit_id());
|
||||
result.setPcsn(receiveBillData.getPcsn());
|
||||
result.setOwnerIdHead_Id(StringUtils.isBlank(pFormJson.getString("OwnerIdHead_Id")) ? "750572" : pFormJson.getString("OwnerIdHead_Id"));
|
||||
result.setOwnerTypeIdHead(StringUtils.isBlank(pFormJson.getString("OwnerTypeIdHead")) ? "BD_OwnerOrg" : pFormJson.getString("OwnerTypeIdHead"));
|
||||
result.setOwnerId_Id(StringUtils.isBlank(formJson.getString("OwnerId_Id")) ? "750572" : formJson.getString("OwnerId_Id"));
|
||||
result.setOwnerTypeId(StringUtils.isBlank(formJson.getString("OwnerTypeId")) ? "BD_OwnerOrg" : formJson.getString("OwnerTypeId"));
|
||||
result.setRemainInStockUnitId(StringUtils.isBlank(formJson.getString("PriceUnitId_Id")) ? receiveBillData.getUnit_id() : formJson.getString("PriceUnitId_Id"));
|
||||
} else {
|
||||
throw new BadRequestException("合格证信息有误!");
|
||||
}
|
||||
@@ -224,7 +226,10 @@ public class PdaIOService {
|
||||
result.setProduct_area(dataList.get(10).toString());
|
||||
result.setMoNumber(dataList.get(11).toString());
|
||||
result.setMoEntrySeq(dataList.get(12).toString());
|
||||
result.setOwnerTypeId(dataList.get(13).toString());
|
||||
result.setOwnerTypeId(StringUtils.isBlank(dataList.get(13).toString()) ? "BD_OwnerOrg" : dataList.get(13).toString());
|
||||
result.setKeeperId("750572");
|
||||
result.setKeeperTypeId("BD_KeeperOrg");
|
||||
result.setStockStatusId("10000");
|
||||
//查询仓库信息
|
||||
String stockId = pmFormDataMapper.queryOrderStockId(result.getMoNumber(), result.getMoEntrySeq());
|
||||
result.setStockId(stockId);
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
package org.nl.wms.pm_manage.form_data.service.dao;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 表单信息表
|
||||
@@ -268,4 +264,27 @@ public class PmFormData implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String remainInStockUnitId;
|
||||
|
||||
|
||||
/**
|
||||
* 保管者类型
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String keeperTypeId;
|
||||
|
||||
|
||||
/**
|
||||
* 保管者
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String keeperId;
|
||||
|
||||
|
||||
/**
|
||||
* 库存状态
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String stockStatusId;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -92,8 +92,9 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
|
||||
// }else {
|
||||
// sourceData = JSONObject.parseObject(sourceString);
|
||||
// }
|
||||
JSONArray mappingJson = formMapping.getMapping_json();
|
||||
if (dtlSplit) {
|
||||
List<JSONObject> items_arr = mappingParseList(formMapping.getMapping_json(), one, sourceData);
|
||||
List<JSONObject> items_arr = mappingParseList(mappingJson, one, sourceData);
|
||||
for (int i = 0; i < items_arr.size(); i++) {
|
||||
JSONObject itemTarget = items_arr.get(i);
|
||||
itemTarget.put("id", IdUtil.getStringId());
|
||||
@@ -104,7 +105,7 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
|
||||
result.add(dtl);
|
||||
}
|
||||
} else {
|
||||
JSONObject target = mappingParse(formMapping.getMapping_json(), one, sourceData);
|
||||
JSONObject target = mappingParse(mappingJson, one, sourceData);
|
||||
Object items = target.remove("item");
|
||||
target.put("id",
|
||||
StringUtils.isEmpty(target.getString("biz_id"))
|
||||
|
||||
@@ -127,7 +127,7 @@ public class SyncFormMappingController {
|
||||
public ResponseEntity<Object> process(@RequestBody JSONObject form){
|
||||
//参数判读,参数解析,调用参数入库
|
||||
JSONObject result = syncErpService.process(form);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
return new ResponseEntity<>(result,HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,18 +2,16 @@ package org.nl.wms.system_manage.service.quartz.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.kingdee.bos.webapi.entity.*;
|
||||
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.BaseCode;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.config.lucene.LuceneAppender;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.external_system.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.external_system.erp.dto.ErpQuery;
|
||||
import org.nl.wms.external_system.erp.dto.ErpSec;
|
||||
import org.nl.wms.pm_manage.form_data.service.IPmFormDataService;
|
||||
@@ -26,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@@ -55,7 +54,7 @@ public class SyncErpBillsScheduleService {
|
||||
MDC.put("requestIp", "127.0.0.1");
|
||||
MDC.put("requestTime", DateUtil.now());
|
||||
LuceneAppender.traceIdTL.set(BaseCode.intToChars(IdUtil.getLongId()));
|
||||
List<SyncFormMapping> list = syncFormMappingServiceImpl.list();
|
||||
List<SyncFormMapping> list = syncFormMappingServiceImpl.list(new LambdaQueryWrapper<SyncFormMapping>().eq(SyncFormMapping::getForm_type, "PRD_MO"));
|
||||
list.forEach(this::syncData);
|
||||
} finally {
|
||||
LuceneAppender.traceIdTL.remove();
|
||||
@@ -75,7 +74,7 @@ public class SyncErpBillsScheduleService {
|
||||
BeanUtils.copyProperties(erpSec, identifyInfo);
|
||||
K3CloudApi cloudApi = new K3CloudApi(identifyInfo);
|
||||
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
String filterString = "FCreateDate >= '" + today + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
|
||||
String filterString = "FCreateDate >= '" + "2024-11-29" + " 00:00:00' and FCreateDate <= '" + today + " 23:59:59'";
|
||||
ErpQuery query = new ErpQuery();
|
||||
query.setFilterString(filterString);
|
||||
query.setFormId(syncFormMapping.getForm_type());
|
||||
@@ -112,11 +111,23 @@ public class SyncErpBillsScheduleService {
|
||||
if (!CollectionUtils.isEmpty(error)) {
|
||||
log.error("ERP单据同步同步失败:{}", error);
|
||||
}
|
||||
List<PmFormData> pmFormDataAll = new ArrayList<>();
|
||||
|
||||
for (Object r : result) {
|
||||
String syncMappingString = JSON.toJSONString(syncFormMapping);
|
||||
SyncFormMapping cloneMapping = JSON.parseObject(syncMappingString, SyncFormMapping.class);
|
||||
List<PmFormData> pmFormDatas = formDataService.syncAnalyse(cloneMapping, JSON.toJSONString(r));
|
||||
formDataService.saveBatch(pmFormDatas);
|
||||
List<PmFormData> pmFormData1 = formDataService.syncAnalyse(syncFormMapping, JSON.toJSONString(r));
|
||||
log.info(JSON.toJSONString(pmFormData1));
|
||||
pmFormDataAll.addAll(formDataService.syncAnalyse(syncFormMapping, JSON.toJSONString(r)));
|
||||
}
|
||||
//今天已同步单据
|
||||
List<PmFormData> existFormDataList = formDataService.list(
|
||||
new LambdaQueryWrapper<PmFormData>()
|
||||
.ge(PmFormData::getCreate_time, DateUtil.format(new Date(), "yyyy-MM-dd") + " 00:00:00")
|
||||
.le(PmFormData::getCreate_time, DateUtil.format(new Date(), "yyyy-MM-dd") + " 23:59:59")
|
||||
);
|
||||
Set<String> formDataIds = existFormDataList.stream().map(PmFormData::getId).collect(Collectors.toSet());
|
||||
List<PmFormData> insertBills = pmFormDataAll.stream().filter(bill -> !formDataIds.contains(bill.getId())).collect(Collectors.toList());
|
||||
if (ObjectUtils.isNotEmpty(insertBills)) {
|
||||
formDataService.saveBatch(insertBills);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
@@ -128,4 +139,35 @@ public class SyncErpBillsScheduleService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBills(List<PmFormData> OutInBillDetails, List<PmFormData> existingIds) {
|
||||
// 过滤出需要插入的新单据,并根据来源设置 ID
|
||||
// List<PmFormData> updateBills = OutInBillDetails.stream().filter(r -> r.getUpdate_time() != null).collect(Collectors.toList());
|
||||
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(OutInBillDetails)) {
|
||||
//比较insertBills与existingIds的修改时间进行按需更新
|
||||
for (PmFormData entity : OutInBillDetails) {
|
||||
PmFormData existing = existingIds.stream().filter(e -> {
|
||||
boolean isUpdate = false;
|
||||
try {
|
||||
if (e.getId().equals(entity.getId())) {
|
||||
if (e.getUnit_name() == null || org.nl.common.utils.DateUtil.getDate(entity.getUpdate_time()).after(org.nl.common.utils.DateUtil.getDate(e.getUpdate_time()))) {
|
||||
isUpdate = true;
|
||||
}
|
||||
}
|
||||
} catch (ParseException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return isUpdate;
|
||||
}).findFirst().orElse(null);
|
||||
if (existing != null) {
|
||||
PmFormData updateEntity = new PmFormData();
|
||||
//todo 补充需要修改的字段
|
||||
updateEntity.setForm_data(entity.getForm_data());
|
||||
formDataService.update(updateEntity, new QueryWrapper<PmFormData>().eq("id", entity.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user