调拨出库回传接口开发

This commit is contained in:
2023-04-06 15:38:11 +08:00
parent 90d4f6b670
commit 9dc7492132
7 changed files with 199 additions and 3 deletions

View File

@@ -36,4 +36,11 @@ public class LmsToSapController {
return new ResponseEntity<>(LmsToSapService.returnMoveDtl(jo), HttpStatus.OK);
}
@PostMapping("/returnOutDtl")
@Log("LMS调拨出库接口回传")
@ApiOperation("LMS调拨出库接口回传")
public ResponseEntity<Object> returnOutDtl(@RequestBody JSONObject jo) {
return new ResponseEntity<>(LmsToSapService.returnOutDtl(jo), HttpStatus.OK);
}
}

View File

@@ -48,4 +48,12 @@ public class SapToLmsController {
return new ResponseEntity<>(sapToLmsService.getReturnDeliveryInfo(jo), HttpStatus.OK);
}
@SaIgnore
@PostMapping("/getCannibalize")
@Log("SAP给LMS推送调拨出库单")
@ApiOperation("SAP给LMS推送调拨出库单")
public ResponseEntity<Object> getCannibalize(@RequestBody JSONObject jo) {
return new ResponseEntity<>(sapToLmsService.getCannibalize(jo), HttpStatus.OK);
}
}

View File

@@ -40,4 +40,16 @@ public interface LmsToSapService {
KDPOS 销售订单行项目
* */
JSONObject returnMoveDtl(JSONObject jo);
/*
* ZDBSQD 调拨单号
* VBELN 销售订单及行号
* MATNR 物料号
* LGORT1 移出仓库
* LGORT2 移入仓库
* ZHL02 幅宽
* ZZWLHD 厚度
* KALAB 重量
*/
JSONObject returnOutDtl(JSONObject jo);
}

View File

@@ -16,4 +16,9 @@ public interface SapToLmsService {
* 获取退货交货单信息
* */
JSONObject getReturnDeliveryInfo(JSONObject jo);
/*
* SAP给LMS推送调拨出库单
* */
JSONObject getCannibalize(JSONObject jo);
}

View File

@@ -138,4 +138,46 @@ public class LmsToSapServiceImpl implements LmsToSapService {
return result;
}
}
@Override
public JSONObject returnOutDtl(JSONObject jo) {
{
log.info("returnOutDtl接口输入参数为-------------------" + jo.toString());
JSONObject result = new JSONObject();
String isConnect = "1";
if (StrUtil.equals("0", isConnect)) {
result.put("status", HttpStatus.OK.value());
result.put("message", "下发成功但未连接MES!");
result.put("data", new JSONObject());
return result;
}
JSONArray list = new JSONArray();
// String url = acsUrl + api;
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("SAP_URL").getValue();
String token = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("SAP_TOKEN").getValue();
String sap_client = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("SAP_CLIENT").getValue();
String api = "/sap/center/wms/007";
url = url + api;
try {
String resultMsg = HttpRequest.post(url).header("TOKEN", token)
.header("sap-client", sap_client)
.body(String.valueOf(jo))
.execute().body();
result = JSONObject.parseObject(resultMsg);
log.info("returnOutDtl接口输出参数为-------------------" + result.toString());
String type = result.getString("TYPE");
if (StrUtil.equals(type, "E")) {
throw new BadRequestException(result.getString("MESSAGE"));
}
} catch (Exception e) {
throw new BadRequestException("SAP提示错误" + e.getMessage());
}
return result;
}
}
}

View File

@@ -214,7 +214,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
}
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("sap_pcsn = '" + sap_pcsn + "'").uniqueResult(0);
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("container_name = '" + sap_pcsn + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(sub_jo)) {
//为空新增一条
sub_jo = new JSONObject();
@@ -247,6 +247,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
sub_jo.put("width", width);
sub_jo.put("length", length);
sub_jo.put("status", "0");
sub_jo.put("net_weight", json.getString("LFIMG")); // 变更为真实退货数量
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").update(sub_jo);
}
@@ -348,4 +349,82 @@ public class SapToLmsServiceImpl implements SapToLmsService {
return result;
}
@Override
public JSONObject getCannibalize(JSONObject jo) {
log.info("getCannibalize的输入参数为------------------------" + jo.toString());
JSONObject result = new JSONObject();
WQLObject storTab = WQLObject.getWQLObject("st_ivt_bsrealstorattr"); // 仓库表
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase"); // 物料表
WQLObject unitTab = WQLObject.getWQLObject("md_pb_measureunit"); // 基础单位表
// 校验调入仓库和调出仓库是否存在
String lgort_out = jo.getString("LGORT1"); // 调出仓库
String lgort_in = jo.getString("LGORT2"); // 调入仓库
JSONObject jsonStorOut = storTab.query("stor_code = '" + lgort_out + "' and is_used = '1' and is_delete = '0'").uniqueResult(0);
JSONObject jsonStorIn = storTab.query("stor_code = '" + lgort_in + "' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonStorOut) || ObjectUtil.isEmpty(jsonStorIn)) {
result.put("RTYPE", "E");
result.put("RTMSG", "操作失败!,调入仓库或调出仓库有误,请检查!");
result.put("RTOAL", 1);
result.put("RTDAT", null);
return result;
}
try {
// 创建调拨出库单
// 主表
JSONObject jsonMst = new JSONObject();
jsonMst.put("io_type", "1");
jsonMst.put("buss_type", "1004");
jsonMst.put("bill_type", "1004");
jsonMst.put("source_id", jo.getLongValue("ZDBSQD"));
jsonMst.put("source_name", "调拨单");
jsonMst.put("stor_id", jsonStorOut.getString("stor_id"));
jsonMst.put("stor_code", jsonStorOut.getString("stor_code"));
jsonMst.put("stor_name", jsonStorOut.getString("stor_name"));
jsonMst.put("out_stor_id", jsonStorIn.getString("stor_id"));
jsonMst.put("detail_count", 1);
jsonMst.put("bill_status", "10");
jsonMst.put("create_mode", "03");
jsonMst.put("biz_date", DateUtil.now());
jsonMst.put("user", "sap");
// 明细
JSONArray tableData = new JSONArray();
JSONObject jsonDtl = new JSONObject();
JSONObject jsonMater = materTab.query("material_code = '" + jo.getString("MATNR") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonMater)) throw new BadRequestException("此物料不存在" + jo.getString("MATNR"));
JSONObject jsonUnit = unitTab.query("measure_unit_id = '" + jsonMater.getString("base_unit_id") + "'").uniqueResult(0);
jsonDtl.put("material_id", jsonMater.getString("material_id"));
jsonDtl.put("qty_unit_id", jsonMater.getLongValue("base_unit_id"));
jsonDtl.put("qty_unit_name", jsonUnit.getString("unit_name"));
jsonDtl.put("plan_qty", jo.getDoubleValue("KALAB"));
jsonDtl.put("source_bill_code", jo.getString("VBELN"));
jsonDtl.put("vbeln", jo.getString("ZDBSQD")); // 来源交货单
// jsonDtl.put("posnr", json.getString("POSNR")); // 来源交货单行
jsonDtl.put("width", jo.getString("ZHL02")); // 幅宽
tableData.add(jsonDtl);
jsonMst.put("tableData", tableData);
// 调用出库新增
checkOutBillService.insertDtl2(jsonMst);
} catch (Exception e) {
result.put("RTYPE", "E");
result.put("RTMSG", "操作失败!" + e.getMessage());
result.put("RTOAL", 1);
result.put("RTDAT", null);
log.info("getDeliveryInfo的输出参数为------------------------" + result.toString());
return result;
}
result.put("RTYPE", "S");
result.put("RTMSG", "操作成功!");
result.put("RTOAL", 1);
result.put("RTDAT", null);
log.info("getCannibalize的输出参数为------------------------" + result.toString());
return result;
}
}

View File

@@ -251,7 +251,7 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
paramMesMst.put("item", paramArr);
// 调用接口回传
new LmsToMesServiceImpl().childRollFGOutboundComplete(paramMesMst);
// new LmsToMesServiceImpl().childRollFGOutboundComplete(paramMesMst);
jo_mst.put("upload_mes", "1");
jo_mst.put("is_upload", "1");
@@ -523,6 +523,49 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(jo_mst);
}
// 调拨出库
if (StrUtil.equals(bill_type, "1004")) {
// 回传sap
JSONArray paramSapMstArr = new JSONArray();
JSONArray disArr = wo_dis.query("iostorinv_id = '" + jo_mst.getString("iostorinv_id") + "'").getResultJSONArray(0);
JSONObject jsonDtl = wo_dtl.query("iostorinv_id = '" + jo_mst.getString("iostorinv_id") + "'").uniqueResult(0);
for (int j = 0; j < disArr.size(); j++) {
JSONObject jsonDis = disArr.getJSONObject(j);
JSONObject paramDis = new JSONObject();
paramDis.put("ZDBSQD", jsonDtl.getString("vbeln"));
paramDis.put("VBELN", jsonDtl.getString("source_bill_code"));
JSONObject jsonMater = materTab.query("material_id = '" + jsonDis.getString("material_id") + "'").uniqueResult(0);
paramDis.put("MATNR", jsonMater.getString("material_code"));
paramDis.put("LGORT1", jo_mst.getString("stor_code"));
JSONObject jsonStorOut = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id = '" + jo_mst.getString("out_stor_id") + "'").uniqueResult(0);
paramDis.put("LGORT2", jsonStorOut.getString("stor_code"));
JSONObject jsonSub = subTab.query("container_name = '" + jsonDis.getString("pcsn") + "'").uniqueResult(0);
paramDis.put("ZHL02", jsonSub.getString("width"));
paramDis.put("ZZWLHD", jsonSub.getString("thickness"));
paramDis.put("CHARG", jsonDis.getString("pcsn"));
paramDis.put("KALAB", jsonDis.getString("plan_qty"));
paramDis.put("WERKS", "2460");
paramSapMstArr.add(paramDis);
}
JSONObject param = new JSONObject();
param.put("HEAD", paramSapMstArr);
System.out.println(param.toString());
// 调用接口回传
new LmsToSapServiceImpl().returnOutDtl(param);
jo_mst.put("upload_sap", "1");
jo_mst.put("is_upload", "1");
jo_mst.put("upload_optid", SecurityUtils.getCurrentUserId());
jo_mst.put("upload_time", DateUtil.now());
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(jo_mst);
}
// 改切出库
if (StrUtil.equals(bill_type, "1003")) {
JSONObject paramMst = new JSONObject();
@@ -1175,7 +1218,7 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
System.out.println(param.toString());
// 调用接口回传
new LmsToSapServiceImpl().returnDelivery(param);
new LmsToSapServiceImpl().returnOutDtl(param);
jo_mst.put("upload_sap", "1");
jo_mst.put("is_upload", "1");