SAP订单组件修改接口、来料接口、成品备货单接口

master
Yangwl 1 year ago
parent 54a0e76ed1
commit 6db6289d4d

@ -338,6 +338,16 @@ public class SapController extends BaseController {
return sapOrderService.shopUpdateSync(sapProOrder); return sapOrderService.shopUpdateSync(sapProOrder);
} }
/**
*
*/
@PostMapping("/shopOrderBomUpdate")
@Log(title = "生产订单组件修改", businessType = BusinessType.SAP)
public R shopOrderBomUpdate(@RequestBody(required = false) List<Map<String, Object>> mapList) {
return sapOrderService.shopOrderBomUpdate(mapList);
}
/** /**
* *
@ -476,4 +486,27 @@ public class SapController extends BaseController {
return sapWmsService.sapProductWarehousing(mapList); return sapWmsService.sapProductWarehousing(mapList);
} }
/**
*
*
* @param mapList
* @return
*/
@PostMapping("/inComingCheck")
@Log(title = "来料检验", businessType = BusinessType.SAP)
public R inComingCheck(@RequestBody(required = false) Map<String, Object> mapList) {
return sapItemSyncService.inComingCheck(mapList);
}
/**
*
*/
@PostMapping("/FPinventory")
@Log(title = "来料检验", businessType = BusinessType.SAP)
public R FPinventory(@RequestBody(required = false) Map<String, Object> mapList) {
return sapItemSyncService.FPinventory(mapList);
}
} }

@ -31,4 +31,7 @@ public interface SapItemSyncService {
R sapBackflushMP(List<SapBackflushMPQuery> sapBackflushMPQueryList); R sapBackflushMP(List<SapBackflushMPQuery> sapBackflushMPQueryList);
R inComingCheck(Map<String, Object> mapList);
R FPinventory(Map<String, Object> mapList);
} }

@ -58,4 +58,6 @@ public interface SapOrderService {
R sapPOrderGoodsReceipt(List<Map<String, Object>> mapList); R sapPOrderGoodsReceipt(List<Map<String, Object>> mapList);
R shopOrderBomUpdate(List<Map<String, Object>> mapList);
} }

@ -9,6 +9,7 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.bean.BeanValidators; import com.op.common.core.utils.bean.BeanValidators;
import com.op.common.security.utils.SecurityUtils; import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.domain.quality.QcCheckTaskIncomeDTO;
import com.op.system.api.domain.sap.SapBackflushMPQuery; import com.op.system.api.domain.sap.SapBackflushMPQuery;
import com.op.sap.domain.vo.SapItemQuery; import com.op.sap.domain.vo.SapItemQuery;
import com.op.system.api.domain.sap.SapMaterialPosting; import com.op.system.api.domain.sap.SapMaterialPosting;
@ -68,7 +69,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
S_MATKL S_MATKL
S_ERSDA S_ERSDA
S_LAEDA */ S_LAEDA */
sapItemQuery.setMatnr("000000040000005209");
if (!StringUtils.isNull(sapItemQuery.getMatnr())) { if (!StringUtils.isNull(sapItemQuery.getMatnr())) {
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR"); JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow(); S_MATNR.appendRow();
@ -93,14 +94,14 @@ public class SapItemSyncImpl implements SapItemSyncService {
S_ERSDA.setValue(Constants.LOW, sapItemQuery.getErsda()); S_ERSDA.setValue(Constants.LOW, sapItemQuery.getErsda());
S_ERSDA.setValue("HIGH", END_DATE); S_ERSDA.setValue("HIGH", END_DATE);
} }
if (!StringUtils.isNull(sapItemQuery.getLaeda())) { // if (!StringUtils.isNull(sapItemQuery.getLaeda())) {
JCoTable S_LAEDA = func.getTableParameterList().getTable("S_LAEDA"); // JCoTable S_LAEDA = func.getTableParameterList().getTable("S_LAEDA");
S_LAEDA.appendRow(); // S_LAEDA.appendRow();
S_LAEDA.setValue(Constants.SIGN, "I"); // S_LAEDA.setValue(Constants.SIGN, "I");
S_LAEDA.setValue(Constants.OPTION, "BT"); // S_LAEDA.setValue(Constants.OPTION, "BT");
S_LAEDA.setValue(Constants.LOW, sapItemQuery.getLaeda()); // S_LAEDA.setValue(Constants.LOW, sapItemQuery.getLaeda());
S_LAEDA.setValue("HIGH", END_DATE); // S_LAEDA.setValue("HIGH", END_DATE);
} // }
// 获取调用 RFC 函数对象 // 获取调用 RFC 函数对象
func.execute(dest); func.execute(dest);
@ -213,6 +214,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
baseProduct.setVolume(VOLUM); baseProduct.setVolume(VOLUM);
baseProduct.setDelFlag("0"); baseProduct.setDelFlag("0");
baseProduct.setActiveFlag("1"); baseProduct.setActiveFlag("1");
baseProduct.setCreateBy(SecurityUtils.getUsername()); baseProduct.setCreateBy(SecurityUtils.getUsername());
baseProduct.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ERSDA)); baseProduct.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ERSDA));
baseProduct.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", LAEDA)); baseProduct.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", LAEDA));
@ -352,6 +354,8 @@ public class SapItemSyncImpl implements SapItemSyncService {
} }
public String importProducts(List<SapBaseProduct> sapBaseProductList) { public String importProducts(List<SapBaseProduct> sapBaseProductList) {
if (StringUtils.isNull(sapBaseProductList) || sapBaseProductList.size() == 0) { if (StringUtils.isNull(sapBaseProductList) || sapBaseProductList.size() == 0) {
throw new ServiceException("同步物料数据为空!"); throw new ServiceException("同步物料数据为空!");
@ -394,4 +398,71 @@ public class SapItemSyncImpl implements SapItemSyncService {
} }
return successMsg.toString(); return successMsg.toString();
} }
@Override
public R inComingCheck(Map<String, Object> mapList) {
try {
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_MSEG_MKPF");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
log.info("来料检验-------" + mapList.toString());
func.execute(dest);//执行调用函数
JCoTable maraTable = func.getTableParameterList().getTable("LT_LLZJ");
System.out.println(maraTable);
List<QcCheckTaskIncomeDTO> qcCheckTaskIncomeDTOList=new ArrayList<>();
for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i);
QcCheckTaskIncomeDTO qcCheckTaskIncomeDTO=new QcCheckTaskIncomeDTO();
qcCheckTaskIncomeDTO.setOrderNo(maraTable.getString("EBELN"));
qcCheckTaskIncomeDTO.setMaterialCode(maraTable.getString("MATNR"));
qcCheckTaskIncomeDTO.setMaterialName(maraTable.getString("MAKTX"));
System.out.println(maraTable);
qcCheckTaskIncomeDTOList.add(qcCheckTaskIncomeDTO);
}
return R.ok();
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
@Override
public R FPinventory(Map<String, Object> mapList) {
try {
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_ZSDR29");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
log.info("成品备货单参数-------" + mapList.toString());
JCoTable S_TDDAT = func.getTableParameterList().getTable("S_TDDAT");
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_TDDAT.appendRow();
S_TDDAT.setValue(Constants.SIGN, "I");
S_TDDAT.setValue(Constants.OPTION, "BT");
S_TDDAT.setValue(Constants.LOW, "20231201");
S_TDDAT.setValue("HIGH", END_DATE);
System.out.println(S_TDDAT);
System.out.println(S_MATNR);
func.execute(dest);//执行调用函数
JCoTable maraTable = func.getTableParameterList().getTable("LT_CP");
System.out.println(maraTable);
// List<QcCheckTaskIncomeDTO> qcCheckTaskIncomeDTOList=new ArrayList<>();
// for (int i = 0; i < maraTable.getNumRows(); i++) {
// maraTable.setRow(i);
// QcCheckTaskIncomeDTO qcCheckTaskIncomeDTO=new QcCheckTaskIncomeDTO();
// qcCheckTaskIncomeDTO.setOrderNo(maraTable.getString("EBELN"));
// qcCheckTaskIncomeDTO.setMaterialCode(maraTable.getString("MATNR"));
// qcCheckTaskIncomeDTO.setMaterialName(maraTable.getString("MAKTX"));
// System.out.println(maraTable);
// qcCheckTaskIncomeDTOList.add(qcCheckTaskIncomeDTO);
// }
return R.ok();
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
} }

@ -1,8 +1,10 @@
package com.op.sap.service.impl; package com.op.sap.service.impl;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import com.op.common.core.constant.Constants; import com.op.common.core.constant.Constants;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;
import com.op.common.core.exception.ServiceException;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.utils.uuid.IdUtils;
@ -92,9 +94,6 @@ public class SapOrderServiceImpl implements SapOrderService {
} }
func.execute(dest);//执行调用函数 func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO // 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO"); JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO");
@ -451,12 +450,10 @@ public class SapOrderServiceImpl implements SapOrderService {
if (func == null) { if (func == null) {
throw new RuntimeException("Function does not exist in SAP"); throw new RuntimeException("Function does not exist in SAP");
} }
if (StringUtils.isEmpty(sapProOrder.getAufnr())) if (StringUtils.isEmpty(sapProOrder.getAufnr())) {
{
return R.fail("订单号为空!"); return R.fail("订单号为空!");
} }
if (StringUtils.isEmpty(sapProOrder.getQuantity())) if (StringUtils.isEmpty(sapProOrder.getQuantity())) {
{
return R.fail("数量为空!"); return R.fail("数量为空!");
} }
@ -596,6 +593,55 @@ public class SapOrderServiceImpl implements SapOrderService {
} }
} }
@Override
public R shopOrderBomUpdate(List<Map<String, Object>> mapList) {
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
try {
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_AUFNR_CHANGE");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
log.info("生产订单组件修改-------" + mapList.toString());
JCoParameterList jCoParameterList = func.getImportParameterList();
for (Map m : mapList) {
jCoParameterList.setValue("P_AUFNR", m.get("P_AUFNR"));
jCoParameterList.setValue("P_MATNR", m.get("P_MATNR"));
jCoParameterList.setValue("P_GMEIN", m.get("P_GMEIN"));
jCoParameterList.setValue("P_WERKS", m.get("P_WERKS"));
jCoParameterList.setValue("P_LGORT", m.get("P_LGORT"));
func.execute(dest);//执行调用函数
//获取结果
String L_MSG = func.getExportParameterList().getString("MSG");
String RETCODE = func.getExportParameterList().getString("RETCODE");
if (Constants.SUCCESS.equals(Integer.parseInt(RETCODE))){
successNum++;
successMsg.append("<br/>" + successNum + "、物料:"+m.get("P_MATNR")+L_MSG);
}else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、物料 " +m.get("P_MATNR")+L_MSG);
}
}
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉添加SAP组件失败共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
// return R.fail(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您添加SAP组件成功共 " + successNum + " 条,数据如下:");
}
return R.ok(successMsg);
}
} }

Loading…
Cancel
Save