一些优化
This commit is contained in:
parent
75af7a687b
commit
b1765b65a0
|
|
@ -852,7 +852,6 @@ public class StructuralPackageOrderController extends BaseController {
|
||||||
public void saveInventory(WmsInTaskItem item,BigDecimal total){
|
public void saveInventory(WmsInTaskItem item,BigDecimal total){
|
||||||
WmsInventory inventory = inventoryService.lambdaQuery()
|
WmsInventory inventory = inventoryService.lambdaQuery()
|
||||||
.eq(WmsInventory::getMaterialNo, item.getItemCode())
|
.eq(WmsInventory::getMaterialNo, item.getItemCode())
|
||||||
.eq(WmsInventory::getExternalOrderNo, item.getPoNum())
|
|
||||||
.eq(WmsInventory::getBatchNumber, item.getBatchNumber())
|
.eq(WmsInventory::getBatchNumber, item.getBatchNumber())
|
||||||
.one();
|
.one();
|
||||||
if (Objects.isNull(inventory)) {
|
if (Objects.isNull(inventory)) {
|
||||||
|
|
@ -861,9 +860,6 @@ public class StructuralPackageOrderController extends BaseController {
|
||||||
.setNum(total)
|
.setNum(total)
|
||||||
.setFactoryNo(item.getFactory())
|
.setFactoryNo(item.getFactory())
|
||||||
.setWarehouseNo(item.getReceivedWarehouse())
|
.setWarehouseNo(item.getReceivedWarehouse())
|
||||||
.setBinNos(item.getStorageLocation())
|
|
||||||
.setExternalOrderNo(item.getPoNum())
|
|
||||||
.setRowNo(item.getPoLineNumber())
|
|
||||||
.setCreateBy(UserUtil.getUserName())
|
.setCreateBy(UserUtil.getUserName())
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setCreateTime(LocalDateTime.now());
|
||||||
inventoryService.save(inventory);
|
inventoryService.save(inventory);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import cn.hutool.json.JSONUtil;
|
||||||
import com.nflg.wms.admin.pojo.dto.SAPMaterialInfoInOrderDTO;
|
import com.nflg.wms.admin.pojo.dto.SAPMaterialInfoInOrderDTO;
|
||||||
import com.nflg.wms.admin.pojo.dto.ZIM003105DTO;
|
import com.nflg.wms.admin.pojo.dto.ZIM003105DTO;
|
||||||
import com.nflg.wms.admin.pojo.dto.ZIM003DTO;
|
import com.nflg.wms.admin.pojo.dto.ZIM003DTO;
|
||||||
|
import com.nflg.wms.common.constant.Constant;
|
||||||
import com.nflg.wms.common.constant.STATE;
|
import com.nflg.wms.common.constant.STATE;
|
||||||
import com.nflg.wms.common.exception.NflgException;
|
import com.nflg.wms.common.exception.NflgException;
|
||||||
import com.nflg.wms.common.pojo.dto.*;
|
import com.nflg.wms.common.pojo.dto.*;
|
||||||
|
|
@ -18,6 +19,7 @@ import com.nflg.wms.common.util.VUtil;
|
||||||
import com.sap.conn.jco.*;
|
import com.sap.conn.jco.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.slf4j.MDC;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
@ -43,53 +45,48 @@ public class SapService {
|
||||||
parameters.put("EBELN", orderNo);
|
parameters.put("EBELN", orderNo);
|
||||||
|
|
||||||
Zim001QueryResultDTO result=new Zim001QueryResultDTO();
|
Zim001QueryResultDTO result=new Zim001QueryResultDTO();
|
||||||
try {
|
JCoFunction function = exec("ZIM_001_QUERY", parameters, null);
|
||||||
JCoFunction function = exec("ZIM_001_QUERY", parameters, null);
|
|
||||||
|
|
||||||
JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT");
|
JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT");
|
||||||
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
|
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
|
||||||
.throwMessage("SAP错误:" + structure.getString("MSG"));
|
.throwMessage("SAP错误:" + structure.getString("MSG"));
|
||||||
|
|
||||||
JCoTable ot1 = function.getTableParameterList().getTable("OUTPUT1");
|
JCoTable ot1 = function.getTableParameterList().getTable("OUTPUT1");
|
||||||
List<Zim001QueryResultItem1DTO> items1 = new ArrayList<>();
|
List<Zim001QueryResultItem1DTO> items1 = new ArrayList<>();
|
||||||
for (int i = 0; i < ot1.getNumRows(); i++) {
|
for (int i = 0; i < ot1.getNumRows(); i++) {
|
||||||
ot1.setRow(i);
|
ot1.setRow(i);
|
||||||
items1.add(new Zim001QueryResultItem1DTO()
|
items1.add(new Zim001QueryResultItem1DTO()
|
||||||
.setEBELN(ot1.getString("EBELN"))
|
.setEBELN(ot1.getString("EBELN"))
|
||||||
.setEBELP(ot1.getString("EBELP"))
|
.setEBELP(ot1.getString("EBELP"))
|
||||||
.setMATNR(ot1.getString("MATNR"))
|
.setMATNR(ot1.getString("MATNR"))
|
||||||
.setMAKTX(ot1.getString("MAKTX"))
|
.setMAKTX(ot1.getString("MAKTX"))
|
||||||
.setMEINS(ot1.getString("MEINS"))
|
.setMEINS(ot1.getString("MEINS"))
|
||||||
.setCHARG(ot1.getString("CHARG"))
|
.setCHARG(ot1.getString("CHARG"))
|
||||||
.setWERKS(ot1.getString("WERKS"))
|
.setWERKS(ot1.getString("WERKS"))
|
||||||
.setLGORT(ot1.getString("LGORT"))
|
.setLGORT(ot1.getString("LGORT"))
|
||||||
.setLFBJA(ot1.getString("LFBJA"))
|
.setLFBJA(ot1.getString("LFBJA"))
|
||||||
.setLFBNR(ot1.getString("LFBNR"))
|
.setLFBNR(ot1.getString("LFBNR"))
|
||||||
.setLFPOS(ot1.getString("LFPOS"))
|
.setLFPOS(ot1.getString("LFPOS"))
|
||||||
);
|
);
|
||||||
}
|
|
||||||
result.setItem1(items1);
|
|
||||||
|
|
||||||
JCoTable ot2 = function.getTableParameterList().getTable("OUTPUT2");
|
|
||||||
List<Zim001QueryResultItem2DTO> items2 = new ArrayList<>();
|
|
||||||
for (int i = 0; i < ot2.getNumRows(); i++) {
|
|
||||||
ot2.setRow(i);
|
|
||||||
items2.add(new Zim001QueryResultItem2DTO()
|
|
||||||
.setEBELN(ot2.getString("EBELN"))
|
|
||||||
.setEBELP(ot2.getString("EBELP"))
|
|
||||||
.setSERNR(ot2.getString("SERNR"))
|
|
||||||
.setLFBJA(ot2.getString("LFBJA"))
|
|
||||||
.setLFBNR(ot2.getString("LFBNR"))
|
|
||||||
.setLFPOS(ot2.getString("LFPOS"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
result.setItem2(items2);
|
|
||||||
|
|
||||||
log.debug("数据:{}", JSONUtil.toJsonStr(result));
|
|
||||||
} catch (JCoException e) {
|
|
||||||
log.error("SAP错误", e);
|
|
||||||
VUtil.trueThrowBusinessError(true).throwMessage("SAP错误:" + e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
result.setItem1(items1);
|
||||||
|
|
||||||
|
JCoTable ot2 = function.getTableParameterList().getTable("OUTPUT2");
|
||||||
|
List<Zim001QueryResultItem2DTO> items2 = new ArrayList<>();
|
||||||
|
for (int i = 0; i < ot2.getNumRows(); i++) {
|
||||||
|
ot2.setRow(i);
|
||||||
|
items2.add(new Zim001QueryResultItem2DTO()
|
||||||
|
.setEBELN(ot2.getString("EBELN"))
|
||||||
|
.setEBELP(ot2.getString("EBELP"))
|
||||||
|
.setSERNR(ot2.getString("SERNR"))
|
||||||
|
.setLFBJA(ot2.getString("LFBJA"))
|
||||||
|
.setLFBNR(ot2.getString("LFBNR"))
|
||||||
|
.setLFPOS(ot2.getString("LFPOS"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
result.setItem2(items2);
|
||||||
|
|
||||||
|
log.debug("数据:{}", JSONUtil.toJsonStr(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -372,7 +369,7 @@ public class SapService {
|
||||||
* @param resebRsNum 退库单号
|
* @param resebRsNum 退库单号
|
||||||
* @return 预留单号
|
* @return 预留单号
|
||||||
*/
|
*/
|
||||||
public List<C_MaterialReturnQueryDTO> zwm00_MB017(String resebRsNum) throws JCoException {
|
public List<C_MaterialReturnQueryDTO> zwm00_MB017(String resebRsNum) {
|
||||||
Map<String, Object> parameters = new HashMap<>();
|
Map<String, Object> parameters = new HashMap<>();
|
||||||
parameters.put("I_RSNUM", resebRsNum);
|
parameters.put("I_RSNUM", resebRsNum);
|
||||||
JCoFunction function = exec("ZWM00_MB017", parameters, null);
|
JCoFunction function = exec("ZWM00_MB017", parameters, null);
|
||||||
|
|
@ -396,7 +393,7 @@ public class SapService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 成本中心退库确认
|
// 成本中心退库确认
|
||||||
public C_MaterialReturnDTO zwm00_MB112(C_MaterialReturnQO request) throws JCoException {
|
public C_MaterialReturnDTO zwm00_MB112(C_MaterialReturnQO request) {
|
||||||
Map<String, Object> parameters = new HashMap<>();
|
Map<String, Object> parameters = new HashMap<>();
|
||||||
parameters.put("I_RSNUM", request.getResbRsNum());
|
parameters.put("I_RSNUM", request.getResbRsNum());
|
||||||
parameters.put("I_USNAM", UserUtil.getUserName());
|
parameters.put("I_USNAM", UserUtil.getUserName());
|
||||||
|
|
@ -447,12 +444,12 @@ public class SapService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//成本中心领料查询
|
//成本中心领料查询
|
||||||
public C_MaterialOutboundQueryDTO zwm00_MB026(String resebRsNum) throws JCoException {
|
public C_MaterialOutboundQueryDTO zwm00_MB026(String resebRsNum) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public C_MaterialOutboundDTO ZWM00_MB115(C_MaterialOutboundQO request) throws JCoException {
|
public C_MaterialOutboundDTO ZWM00_MB115(C_MaterialOutboundQO request) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -468,53 +465,48 @@ public class SapService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private JCoTable execReturnTable(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables, String outName) {
|
private JCoTable execReturnTable(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables, String outName) {
|
||||||
try {
|
JCoFunction function = exec(functionName, parameters, tables);
|
||||||
JCoFunction function = exec(functionName, parameters, tables);
|
JCoTable out = function.getTableParameterList().getTable(outName);
|
||||||
JCoTable out = function.getTableParameterList().getTable(outName);
|
log.info("SAP返回: {}", out);
|
||||||
log.info("SAP返回: {}", out);
|
return out;
|
||||||
return out;
|
|
||||||
} catch (JCoException ex) {
|
|
||||||
log.error("SAP错误", ex);
|
|
||||||
throw new NflgException(STATE.BusinessError, "SAP错误");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JCoParameterList execReturnParameter(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) {
|
private JCoParameterList execReturnParameter(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) {
|
||||||
try {
|
JCoFunction function = exec(functionName, parameters, tables);
|
||||||
JCoFunction function = exec(functionName, parameters, tables);
|
JCoParameterList out = function.getExportParameterList();
|
||||||
JCoParameterList out = function.getExportParameterList();
|
log.info("SAP返回: {}", out);
|
||||||
log.info("SAP返回: {}", out);
|
return out;
|
||||||
return out;
|
|
||||||
} catch (JCoException ex) {
|
|
||||||
log.error("SAP错误", ex);
|
|
||||||
throw new NflgException(STATE.BusinessError, "SAP错误");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JCoFunction exec(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) throws JCoException {
|
private JCoFunction exec(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) {
|
||||||
functionName=functionName.toUpperCase();
|
try {
|
||||||
log.info("SAP functionName:{}", functionName);
|
functionName=functionName.toUpperCase();
|
||||||
JCoFunction function = repository.getFunction(functionName);
|
log.info("SAP functionName:{}", functionName);
|
||||||
|
JCoFunction function = repository.getFunction(functionName);
|
||||||
|
|
||||||
log.info("SAP ImportParameter:{}", JSONUtil.toJsonStr(parameters));
|
log.info("SAP ImportParameter:{}", JSONUtil.toJsonStr(parameters));
|
||||||
log.info("---{}", function.getImportParameterList().getListMetaData());
|
log.info("---{}", function.getImportParameterList().getListMetaData());
|
||||||
|
|
||||||
if (CollectionUtil.isNotEmpty(parameters)) {
|
if (CollectionUtil.isNotEmpty(parameters)) {
|
||||||
parameters.forEach((name, value) -> function.getImportParameterList().setValue(name, value));
|
parameters.forEach((name, value) -> function.getImportParameterList().setValue(name, value));
|
||||||
}
|
}
|
||||||
if (CollectionUtil.isNotEmpty(tables)) {
|
if (CollectionUtil.isNotEmpty(tables)) {
|
||||||
tables.forEach((tableName, list) -> {
|
tables.forEach((tableName, list) -> {
|
||||||
log.info("SAP TableParameter:{}", tableName);
|
log.info("SAP TableParameter:{}", tableName);
|
||||||
log.info(JSONUtil.toJsonStr(list));
|
log.info(JSONUtil.toJsonStr(list));
|
||||||
JCoTable jt = function.getTableParameterList().getTable(tableName);
|
JCoTable jt = function.getTableParameterList().getTable(tableName);
|
||||||
list.forEach(vl -> {
|
list.forEach(vl -> {
|
||||||
jt.appendRow();
|
jt.appendRow();
|
||||||
vl.forEach(jt::setValue);
|
vl.forEach(jt::setValue);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
function.execute(destination);
|
||||||
|
return function;
|
||||||
|
} catch (JCoException e) {
|
||||||
|
log.error("SAP调用异常", e);
|
||||||
|
throw new NflgException(STATE.BusinessError, "SAP调用异常:" + MDC.get(Constant.TRACE_ID));
|
||||||
}
|
}
|
||||||
function.execute(destination);
|
|
||||||
return function;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printMeta(String functionName) throws JCoException {
|
public void printMeta(String functionName) throws JCoException {
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,6 @@ public class WmsInventory implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String warehouseNo;
|
private String warehouseNo;
|
||||||
|
|
||||||
/**
|
|
||||||
* 储位编号,逗号分隔
|
|
||||||
*/
|
|
||||||
private String binNos;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数量
|
* 数量
|
||||||
*/
|
*/
|
||||||
|
|
@ -78,16 +73,6 @@ public class WmsInventory implements Serializable {
|
||||||
*/
|
*/
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 采购单订单号
|
|
||||||
*/
|
|
||||||
private String externalOrderNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 采购单订单行号
|
|
||||||
*/
|
|
||||||
private String rowNo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批次号
|
* 批次号
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue