一些优化
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){
|
||||
WmsInventory inventory = inventoryService.lambdaQuery()
|
||||
.eq(WmsInventory::getMaterialNo, item.getItemCode())
|
||||
.eq(WmsInventory::getExternalOrderNo, item.getPoNum())
|
||||
.eq(WmsInventory::getBatchNumber, item.getBatchNumber())
|
||||
.one();
|
||||
if (Objects.isNull(inventory)) {
|
||||
|
|
@ -861,9 +860,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|||
.setNum(total)
|
||||
.setFactoryNo(item.getFactory())
|
||||
.setWarehouseNo(item.getReceivedWarehouse())
|
||||
.setBinNos(item.getStorageLocation())
|
||||
.setExternalOrderNo(item.getPoNum())
|
||||
.setRowNo(item.getPoLineNumber())
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
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.ZIM003105DTO;
|
||||
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.exception.NflgException;
|
||||
import com.nflg.wms.common.pojo.dto.*;
|
||||
|
|
@ -18,6 +19,7 @@ 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;
|
||||
|
|
@ -43,53 +45,48 @@ public class SapService {
|
|||
parameters.put("EBELN", orderNo);
|
||||
|
||||
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");
|
||||
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
|
||||
.throwMessage("SAP错误:" + structure.getString("MSG"));
|
||||
JCoStructure structure = function.getExportParameterList().getStructure("OUTPUT");
|
||||
VUtil.trueThrowBusinessError(!StrUtil.equals(structure.getString("TYPE"), "S"))
|
||||
.throwMessage("SAP错误:" + structure.getString("MSG"));
|
||||
|
||||
JCoTable ot1 = function.getTableParameterList().getTable("OUTPUT1");
|
||||
List<Zim001QueryResultItem1DTO> items1 = new ArrayList<>();
|
||||
for (int i = 0; i < ot1.getNumRows(); i++) {
|
||||
ot1.setRow(i);
|
||||
items1.add(new Zim001QueryResultItem1DTO()
|
||||
.setEBELN(ot1.getString("EBELN"))
|
||||
.setEBELP(ot1.getString("EBELP"))
|
||||
.setMATNR(ot1.getString("MATNR"))
|
||||
.setMAKTX(ot1.getString("MAKTX"))
|
||||
.setMEINS(ot1.getString("MEINS"))
|
||||
.setCHARG(ot1.getString("CHARG"))
|
||||
.setWERKS(ot1.getString("WERKS"))
|
||||
.setLGORT(ot1.getString("LGORT"))
|
||||
.setLFBJA(ot1.getString("LFBJA"))
|
||||
.setLFBNR(ot1.getString("LFBNR"))
|
||||
.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());
|
||||
JCoTable ot1 = function.getTableParameterList().getTable("OUTPUT1");
|
||||
List<Zim001QueryResultItem1DTO> items1 = new ArrayList<>();
|
||||
for (int i = 0; i < ot1.getNumRows(); i++) {
|
||||
ot1.setRow(i);
|
||||
items1.add(new Zim001QueryResultItem1DTO()
|
||||
.setEBELN(ot1.getString("EBELN"))
|
||||
.setEBELP(ot1.getString("EBELP"))
|
||||
.setMATNR(ot1.getString("MATNR"))
|
||||
.setMAKTX(ot1.getString("MAKTX"))
|
||||
.setMEINS(ot1.getString("MEINS"))
|
||||
.setCHARG(ot1.getString("CHARG"))
|
||||
.setWERKS(ot1.getString("WERKS"))
|
||||
.setLGORT(ot1.getString("LGORT"))
|
||||
.setLFBJA(ot1.getString("LFBJA"))
|
||||
.setLFBNR(ot1.getString("LFBNR"))
|
||||
.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));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +369,7 @@ public class SapService {
|
|||
* @param resebRsNum 退库单号
|
||||
* @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<>();
|
||||
parameters.put("I_RSNUM", resebRsNum);
|
||||
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<>();
|
||||
parameters.put("I_RSNUM", request.getResbRsNum());
|
||||
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;
|
||||
}
|
||||
|
||||
public C_MaterialOutboundDTO ZWM00_MB115(C_MaterialOutboundQO request) throws JCoException {
|
||||
public C_MaterialOutboundDTO ZWM00_MB115(C_MaterialOutboundQO request) {
|
||||
|
||||
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) {
|
||||
try {
|
||||
JCoFunction function = exec(functionName, parameters, tables);
|
||||
JCoTable out = function.getTableParameterList().getTable(outName);
|
||||
log.info("SAP返回: {}", out);
|
||||
return out;
|
||||
} catch (JCoException ex) {
|
||||
log.error("SAP错误", ex);
|
||||
throw new NflgException(STATE.BusinessError, "SAP错误");
|
||||
}
|
||||
JCoFunction function = exec(functionName, parameters, tables);
|
||||
JCoTable out = function.getTableParameterList().getTable(outName);
|
||||
log.info("SAP返回: {}", out);
|
||||
return out;
|
||||
}
|
||||
|
||||
private JCoParameterList execReturnParameter(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) {
|
||||
try {
|
||||
JCoFunction function = exec(functionName, parameters, tables);
|
||||
JCoParameterList out = function.getExportParameterList();
|
||||
log.info("SAP返回: {}", out);
|
||||
return out;
|
||||
} catch (JCoException ex) {
|
||||
log.error("SAP错误", ex);
|
||||
throw new NflgException(STATE.BusinessError, "SAP错误");
|
||||
}
|
||||
JCoFunction function = exec(functionName, parameters, tables);
|
||||
JCoParameterList out = function.getExportParameterList();
|
||||
log.info("SAP返回: {}", out);
|
||||
return out;
|
||||
}
|
||||
|
||||
private JCoFunction exec(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) throws JCoException {
|
||||
functionName=functionName.toUpperCase();
|
||||
log.info("SAP functionName:{}", functionName);
|
||||
JCoFunction function = repository.getFunction(functionName);
|
||||
private JCoFunction exec(String functionName, Map<String, Object> parameters, Map<String, List<Map<String, Object>>> tables) {
|
||||
try {
|
||||
functionName=functionName.toUpperCase();
|
||||
log.info("SAP functionName:{}", functionName);
|
||||
JCoFunction function = repository.getFunction(functionName);
|
||||
|
||||
log.info("SAP ImportParameter:{}", JSONUtil.toJsonStr(parameters));
|
||||
log.info("---{}", function.getImportParameterList().getListMetaData());
|
||||
log.info("SAP ImportParameter:{}", JSONUtil.toJsonStr(parameters));
|
||||
log.info("---{}", function.getImportParameterList().getListMetaData());
|
||||
|
||||
if (CollectionUtil.isNotEmpty(parameters)) {
|
||||
parameters.forEach((name, value) -> function.getImportParameterList().setValue(name, value));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(tables)) {
|
||||
tables.forEach((tableName, list) -> {
|
||||
log.info("SAP TableParameter:{}", tableName);
|
||||
log.info(JSONUtil.toJsonStr(list));
|
||||
JCoTable jt = function.getTableParameterList().getTable(tableName);
|
||||
list.forEach(vl -> {
|
||||
jt.appendRow();
|
||||
vl.forEach(jt::setValue);
|
||||
if (CollectionUtil.isNotEmpty(parameters)) {
|
||||
parameters.forEach((name, value) -> function.getImportParameterList().setValue(name, value));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(tables)) {
|
||||
tables.forEach((tableName, list) -> {
|
||||
log.info("SAP TableParameter:{}", tableName);
|
||||
log.info(JSONUtil.toJsonStr(list));
|
||||
JCoTable jt = function.getTableParameterList().getTable(tableName);
|
||||
list.forEach(vl -> {
|
||||
jt.appendRow();
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -48,11 +48,6 @@ public class WmsInventory implements Serializable {
|
|||
*/
|
||||
private String warehouseNo;
|
||||
|
||||
/**
|
||||
* 储位编号,逗号分隔
|
||||
*/
|
||||
private String binNos;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
|
|
@ -78,16 +73,6 @@ public class WmsInventory implements Serializable {
|
|||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 采购单订单号
|
||||
*/
|
||||
private String externalOrderNo;
|
||||
|
||||
/**
|
||||
* 采购单订单行号
|
||||
*/
|
||||
private String rowNo;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue