feat: bug-789 成本中心领料(退料)单据新增,搜索条件添加【单号】
This commit is contained in:
parent
6226770de9
commit
555b4792ba
|
|
@ -10,9 +10,7 @@ import com.nflg.wms.admin.pojo.dto.SAPMaterialInfoInOrderDTO;
|
|||
import com.nflg.wms.admin.pojo.dto.ZWM3A17DTO;
|
||||
import com.nflg.wms.admin.pojo.dto.ZWM3A18DTO;
|
||||
import com.nflg.wms.admin.util.JCoUtil;
|
||||
import com.nflg.wms.common.constant.Constant;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.exception.SAPException;
|
||||
import com.nflg.wms.common.pojo.dto.*;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.*;
|
||||
|
|
@ -22,11 +20,11 @@ import com.nflg.wms.common.util.VUtil;
|
|||
import com.sap.conn.jco.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
|
|
@ -1016,8 +1014,24 @@ public class SapService {
|
|||
parameters.put("S_DATE", DateTimeUtil.format(query.getStartDate(), "yyyyMMdd"));
|
||||
parameters.put("E_DATE", DateTimeUtil.format(query.getEndDate(), "yyyyMMdd"));
|
||||
|
||||
Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
if (CollectionUtil.isNotEmpty(query.getKostl())) {
|
||||
tables.put("S_KOSTL", query.getKostl().stream().map(kostl -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("KOSTL", kostl);
|
||||
return map;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(query.getRsnum())) {
|
||||
tables.put("S_RSNUM", query.getRsnum().stream().map(rsnum -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("RSNUM", rsnum);
|
||||
return map;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
// 调用 SAP RFC 函数 ZWM00_MB112
|
||||
JCoFunction function = exec("ZWM3A13", parameters, null);
|
||||
JCoFunction function = exec("ZWM3A13", parameters, tables);
|
||||
|
||||
// 处理返回表 T_RETURN,判断执行是否成功
|
||||
JCoParameterList exportParam = function.getExportParameterList();
|
||||
|
|
@ -1050,8 +1064,25 @@ public class SapService {
|
|||
parameters.put("I_WERKS", query.getWerks());
|
||||
parameters.put("S_DATE", DateTimeUtil.format(query.getStartDate(), "yyyyMMdd"));
|
||||
parameters.put("E_DATE", DateTimeUtil.format(query.getEndDate(), "yyyyMMdd"));
|
||||
|
||||
Map<String, List<Map<String, Object>>> tables = new HashMap<>();
|
||||
if (CollectionUtil.isNotEmpty(query.getKostl())) {
|
||||
tables.put("S_KOSTL", query.getKostl().stream().map(kostl -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("KOSTL", kostl);
|
||||
return map;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(query.getRsnum())) {
|
||||
tables.put("S_RSNUM", query.getRsnum().stream().map(rsnum -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("RSNUM", rsnum);
|
||||
return map;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
// 调用 SAP RFC 函数 ZWM00_MB112
|
||||
JCoFunction function = exec("ZWM3A14", parameters, null);
|
||||
JCoFunction function = exec("ZWM3A14", parameters, tables);
|
||||
// 处理返回表 T_RETURN,判断执行是否成功
|
||||
JCoParameterList exportParam = function.getExportParameterList();
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(exportParam)).throwMessage("无法获取到有效的物料凭证信息");
|
||||
|
|
@ -1110,7 +1141,7 @@ public class SapService {
|
|||
JCoTable returnTable = function.getTableParameterList().getTable("T_RETURN");
|
||||
log.info("SAP返回: {}", returnTable);
|
||||
returnTable.setRow(0);
|
||||
throw new NflgException(STATE.BusinessError, "SAP错误:" + returnTable.getString("MESSAGE"));
|
||||
throw new SAPException(returnTable.getString("MESSAGE"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1322,7 +1353,7 @@ public class SapService {
|
|||
return function;
|
||||
} catch (JCoException e) {
|
||||
log.error("SAP调用异常", e);
|
||||
throw new NflgException(STATE.BusinessError, "SAP调用异常:" + MDC.get(Constant.TRACE_ID));
|
||||
throw new SAPException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ public enum STATE {
|
|||
BusinessError(115, "业务异常"),
|
||||
RequestMethodError(116, "请求方式错误"),
|
||||
InconsistentDataError(117, "需要用户确认"),
|
||||
NoOrderData(118, "订单不存在");
|
||||
NoOrderData(118, "订单不存在"),
|
||||
SAPErr(119, "SAP错误");
|
||||
|
||||
@Getter
|
||||
private final Integer state;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nflg.wms.common.exception;
|
||||
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SAPException extends RuntimeException {
|
||||
|
||||
public final STATE state;
|
||||
private final String msg;
|
||||
|
||||
public SAPException(String msg) {
|
||||
super(msg);
|
||||
this.state = STATE.SAPErr;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import lombok.Data;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
|
|
@ -67,4 +68,14 @@ public class DepartmentMaterialRequisitionQO {
|
|||
}
|
||||
return endDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预留/相关需求的编号
|
||||
*/
|
||||
private List<String> rsnum;
|
||||
|
||||
/**
|
||||
* 成本中心
|
||||
*/
|
||||
private List<String> kostl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import lombok.Data;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
|
|
@ -34,4 +35,14 @@ public class DepartmentMaterialReturnSlipQO {
|
|||
}
|
||||
return endDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预留/相关需求的编号
|
||||
*/
|
||||
private List<String> rsnum;
|
||||
|
||||
/**
|
||||
* 成本中心
|
||||
*/
|
||||
private List<String> kostl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.nflg.wms.common.constant.Constant;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.exception.SAPException;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
|
@ -74,4 +75,10 @@ public class GlobalRestControllerAdvice {
|
|||
log.error("请求的地址无效: ", ex);
|
||||
return ApiResult.error(STATE.BusinessError, "请求的地址无效:" + ex.getResourcePath());
|
||||
}
|
||||
|
||||
@ExceptionHandler(SAPException.class)
|
||||
public ApiResult<Void> handleSAPException(SAPException ex) {
|
||||
log.error("SAP错误: ", ex);
|
||||
return ApiResult.error(ex.getState(), "SAP错误:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue