修改
This commit is contained in:
@@ -28,8 +28,8 @@ public class SapToLmsController {
|
||||
@PostMapping("/getMaterialInfo")
|
||||
@Log("SAP给LMS推送物料信息")
|
||||
@ApiOperation("SAP给LMS推送物料信息")
|
||||
public ResponseEntity<Object> getMaterialInfo(@RequestBody JSONArray rows) {
|
||||
return new ResponseEntity<>(sapToLmsService.getMaterialInfo(rows), HttpStatus.OK);
|
||||
public ResponseEntity<Object> getMaterialInfo(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(sapToLmsService.getMaterialInfo(jo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
|
||||
@@ -7,7 +7,7 @@ public interface SapToLmsService {
|
||||
/*
|
||||
* 获取物料信息
|
||||
* */
|
||||
JSONObject getMaterialInfo(JSONArray rows);
|
||||
JSONObject getMaterialInfo(JSONObject jo);
|
||||
/*
|
||||
* 获取交货单信息
|
||||
* */
|
||||
|
||||
@@ -49,14 +49,12 @@ public class LmsToSapServiceImpl implements LmsToSapService {
|
||||
return result;
|
||||
}
|
||||
|
||||
JSONArray list = new JSONArray();
|
||||
|
||||
// String url = acsUrl + api;
|
||||
String url = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("SAP_URL").getValue();
|
||||
String api = "";
|
||||
url = url + api;
|
||||
url = url + "/sap/center/wms/004";
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
String resultMsg = HttpRequest.post(url).header("TOKEN","FA163EE139D41EED9286BB7E1A2F8D4C")
|
||||
.body(String.valueOf(jo))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms.ext.sap.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@@ -13,9 +14,12 @@ import org.nl.wms.ext.sap.service.SapToLmsService;
|
||||
import org.nl.wms.log.LokiLog;
|
||||
import org.nl.wms.log.LokiLogType;
|
||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.nl.wms.st.outbill.service.impl.CheckOutBillServiceImpl;
|
||||
import org.nl.wms.st.inbill.service.RawAssistIStorService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -23,21 +27,36 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
|
||||
private final CheckOutBillService checkOutBillService;
|
||||
|
||||
private final RawAssistIStorService rawAssistIStorService;
|
||||
|
||||
@LokiLog(type = LokiLogType.SAP_TO_LMS)
|
||||
@Override
|
||||
public JSONObject getMaterialInfo(JSONArray rows) {
|
||||
if (ObjectUtil.isEmpty(rows)) {
|
||||
throw new BadRequestException("物料信息为空!");
|
||||
}
|
||||
public JSONObject getMaterialInfo(JSONObject jo) {
|
||||
JSONArray rows = jo.getJSONArray("DATAS");
|
||||
log.info("getMaterialInfo的输入参数为:------------------------" + rows.toString());
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
String MATNR = row.getString("MATNR");
|
||||
if (StrUtil.isEmpty(MATNR)){
|
||||
throw new BadRequestException("物料编码不能为空!");
|
||||
}
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbaseext").query("MATNR ='"+MATNR+"'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)){
|
||||
WQLObject.getWQLObject("md_me_materialbaseext").insert(row);
|
||||
}else {
|
||||
WQLObject.getWQLObject("md_me_materialbaseext").update(row);
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
result.put("RTYPE", "E");
|
||||
result.put("RTMSG", "操作失败!" + exception.getMessage());
|
||||
return result;
|
||||
}
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("msg", "推送成功!");
|
||||
jo.put("code", "1");
|
||||
return jo;
|
||||
result.put("TYPE", "S");
|
||||
result.put("MESSAGE", "物料同步成功!");
|
||||
return result;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.SAP_TO_LMS)
|
||||
@@ -53,16 +72,17 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
JSONArray item = jo.getJSONArray("ITEM");
|
||||
|
||||
JSONObject jsonMst = new JSONObject();
|
||||
jsonMst.put("stor_id","1582991156504039424");
|
||||
jsonMst.put("stor_code","CP01");
|
||||
jsonMst.put("stor_name","成品仓库");
|
||||
jsonMst.put("detail_count",item.size());
|
||||
jsonMst.put("bill_status","10");
|
||||
jsonMst.put("create_mode","03");
|
||||
jsonMst.put("stor_id", "1582991156504039424");
|
||||
jsonMst.put("stor_code", "CP01");
|
||||
jsonMst.put("stor_name", "成品仓库");
|
||||
jsonMst.put("detail_count", item.size());
|
||||
jsonMst.put("bill_status", "10");
|
||||
jsonMst.put("create_mode", "03");
|
||||
jsonMst.put("biz_date", DateUtil.now());
|
||||
jsonMst.put("user", "sap");
|
||||
|
||||
JSONArray tableData = new JSONArray();
|
||||
ArrayList<HashMap> box_rows = new ArrayList<>();
|
||||
|
||||
String lfart = "";
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
@@ -82,40 +102,123 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
|
||||
// 明细
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater)) throw new BadRequestException("此物料不存在"+json.getString("MATNR"));
|
||||
if (ObjectUtil.isEmpty(jsonMater))
|
||||
throw new BadRequestException("此物料不存在" + json.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",json.getDoubleValue("LFIMG"));
|
||||
jsonDtl.put("source_bill_code",json.getString("VGBEL-VGPOS"));
|
||||
jsonDtl.put("vbeln",json.getString("VBELN")); // 来源交货单
|
||||
jsonDtl.put("posnr",json.getString("POSNR")); // 来源交货单行
|
||||
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", json.getDoubleValue("LFIMG"));
|
||||
jsonDtl.put("source_bill_code", json.getString("VGBEL-VGPOS"));
|
||||
jsonDtl.put("vbeln", json.getString("VBELN")); // 来源交货单
|
||||
jsonDtl.put("posnr", json.getString("POSNR")); // 来源交货单行
|
||||
tableData.add(jsonDtl);
|
||||
}
|
||||
if (StrUtil.equals(lfart, "ZLR")) {
|
||||
HashMap map = new HashMap();
|
||||
//更新包装关系
|
||||
String sap_pcsn = json.getString("CHARG");
|
||||
if (StrUtil.isEmpty(sap_pcsn)) {
|
||||
throw new BadRequestException("批次不能为空!");
|
||||
}
|
||||
String package_box_sn = json.getString("ZZJXH");
|
||||
if (StrUtil.isEmpty(package_box_sn)) {
|
||||
throw new BadRequestException("箱号不能为空!");
|
||||
}
|
||||
String sale_order_name = json.getString("VGBEL-VGPOS");
|
||||
if (StrUtil.isEmpty(sale_order_name)) {
|
||||
throw new BadRequestException("销售订单及行号不能为空!");
|
||||
}
|
||||
String length = json.getString("ZZJCD");
|
||||
if (StrUtil.isEmpty(length)) {
|
||||
throw new BadRequestException("子卷长度不能为空!");
|
||||
}
|
||||
String width = json.getString("HL02");
|
||||
if (StrUtil.isEmpty(width)) {
|
||||
throw new BadRequestException("子卷幅宽不能为空!");
|
||||
}
|
||||
// 明细
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater)) {
|
||||
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
|
||||
}
|
||||
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("sap_pcsn = '" + sap_pcsn + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sub_jo)) {
|
||||
//为空新增一条
|
||||
sub_jo = new JSONObject();
|
||||
sub_jo.put("workorder_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
sub_jo.put("package_box_sn", package_box_sn);
|
||||
sub_jo.put("quanlity_in_box", 1);
|
||||
sub_jo.put("sale_order_name", sale_order_name);
|
||||
sub_jo.put("customer_name", json.getString("KUNNR"));
|
||||
sub_jo.put("customer_description", json.getString("NAMEM"));
|
||||
sub_jo.put("product_name", json.getString("MATNR"));
|
||||
sub_jo.put("product_description", jsonMater.getString("material_name"));
|
||||
sub_jo.put("container_name", sap_pcsn);
|
||||
sub_jo.put("width", width);
|
||||
sub_jo.put("net_weight", json.getString("LFIMG"));
|
||||
sub_jo.put("length", length);
|
||||
sub_jo.put("is_un_plan_production", 0);
|
||||
sub_jo.put("create_id", 0);
|
||||
sub_jo.put("create_name", 0);
|
||||
sub_jo.put("create_time", 0);
|
||||
sub_jo.put("status", "0");
|
||||
sub_jo.put("sap_pcsn", sap_pcsn);
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").insert(sub_jo);
|
||||
} else {
|
||||
//不为空修改子卷包装关系
|
||||
sub_jo.put("vbeln", json.getString("VBELN"));
|
||||
sub_jo.put("posnr", json.getString("POSNR"));
|
||||
sub_jo.put("package_box_sn", package_box_sn);
|
||||
sub_jo.put("width", width);
|
||||
sub_jo.put("length", length);
|
||||
sub_jo.put("status", "0");
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").update(sub_jo);
|
||||
}
|
||||
|
||||
map.put("container_name", sub_jo.getString("container_name"));
|
||||
map.put("net_weight", sub_jo.getString("net_weight"));
|
||||
map.put("package_box_sn", sub_jo.getString("package_box_sn"));
|
||||
map.put("product_name", sub_jo.getString("product_name"));
|
||||
map.put("product_name", sub_jo.getString("product_name"));
|
||||
map.put("vbeln", json.getString("VBELN"));
|
||||
map.put("posnr", json.getString("POSNR"));
|
||||
box_rows.add(map);
|
||||
}
|
||||
}
|
||||
jsonMst.put("tableData", tableData);
|
||||
|
||||
|
||||
if (StrUtil.equals(lfart, "ZLF")) {
|
||||
jsonMst.put("tableData", tableData);
|
||||
// 调用出库新增并分配
|
||||
String iostorinv_id = checkOutBillService.insertDtl(jsonMst);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("iostorinv_id",iostorinv_id);
|
||||
jsonObject.put("iostorinv_id", iostorinv_id);
|
||||
//checkOutBillService.allDiv(jsonObject);
|
||||
|
||||
result.put("RTYPE", "S");
|
||||
result.put("RTMSG", "操作成功!");
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
}
|
||||
if (StrUtil.equals(lfart, "ZLR")) {
|
||||
jsonMst.put("tableData", box_rows);
|
||||
//创建退货入库单
|
||||
jsonMst.put("bill_type", "0002");
|
||||
jsonMst.put("biz_date", DateUtil.now());
|
||||
JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0);
|
||||
jsonMst.put("stor_id", stor.getString("stor_id"));
|
||||
jsonMst.put("bill_status", "10");
|
||||
rawAssistIStorService.insertDtl(jsonMst);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("RTYPE", "E");
|
||||
result.put("RTMSG", "操作失败!"+e.getMessage());
|
||||
result.put("RTMSG", "操作失败!" + e.getMessage());
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.put("RTYPE", "S");
|
||||
result.put("RTMSG", "操作成功!");
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.wms.pda.st.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -55,11 +56,17 @@ public class ProductInstorServiceImpl implements ProductInstorService {
|
||||
map.put("flag", "1");
|
||||
//如果是报废入库要查询对应的报废出库
|
||||
rows = WQL.getWO("PDA_ST_01").addParamMap(map).process().getResultJSONArray(0);
|
||||
} else {
|
||||
}
|
||||
if (option.equals("2")) {
|
||||
map.put("flag", "2");
|
||||
//查询状态为生成的子卷包装关系对应表
|
||||
rows = WQL.getWO("PDA_ST_01").addParamMap(map).process().getResultJSONArray(0);
|
||||
}
|
||||
if (option.equals("3")) {
|
||||
map.put("flag", "4");
|
||||
//查询状态为生成的子卷包装关系对应表
|
||||
rows = WQL.getWO("PDA_ST_01").addParamMap(map).process().getResultJSONArray(0);
|
||||
}
|
||||
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("data", rows);
|
||||
@@ -80,7 +87,7 @@ public class ProductInstorServiceImpl implements ProductInstorService {
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("box_no", box_no);
|
||||
if (option.equals("1")) {
|
||||
if (option.equals("3")) {
|
||||
HashMap<String, String> sub_map = new HashMap<>();
|
||||
sub_map.put("box_type", material_code);
|
||||
//如果是退货入库要更新子卷包装关系的木箱料号
|
||||
@@ -108,13 +115,21 @@ public class ProductInstorServiceImpl implements ProductInstorService {
|
||||
mst_jo.put("stor_id", stor.getString("stor_id"));
|
||||
mst_jo.put("detail_count", box_rows.size());
|
||||
mst_jo.put("total_qty", "0");
|
||||
mst_jo.put("bill_status", "10");
|
||||
String iostorinv_id = rawAssistIStorService.insertDtl(mst_jo);
|
||||
mst_jo.put("bill_status", "30");
|
||||
String iostorinv_id = "";
|
||||
if (!option.equals("3")) {
|
||||
iostorinv_id = rawAssistIStorService.insertDtl(mst_jo);
|
||||
} else {
|
||||
//查询该木箱所在的未完成的入库单
|
||||
JSONObject box_mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("box_no = '" + box_no + "' AND bill_status <'99'").uniqueResult(0);
|
||||
iostorinv_id = box_mst_jo.getString("iostorinv_id");
|
||||
}
|
||||
|
||||
//判断是否虚拟
|
||||
if (!is_virtual.equals("1")) {
|
||||
//创建二楼去一楼的任务
|
||||
} else {
|
||||
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
//直接分配虚拟区货位,并确认
|
||||
JSONObject struct = WQL.getWO("PDA_ST_01").addParam("flag", "3").process().uniqueResult(0);
|
||||
|
||||
@@ -126,9 +141,10 @@ public class ProductInstorServiceImpl implements ProductInstorService {
|
||||
dis_map.put("struct_code", struct.getString("struct_code"));
|
||||
dis_map.put("struct_name", struct.getString("struct_name"));
|
||||
dis_map.put("work_status", "01");
|
||||
dis_map.put("task_id", iostorinv_id);
|
||||
dis_map.put("task_id", task_id);
|
||||
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinv_id = '" + iostorinv_id + "'");
|
||||
//更新该木箱明细对应的分配
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinv_id = '" + iostorinv_id + "' AND box_no = '"+box_no+"'");
|
||||
|
||||
//修改库存
|
||||
//直接取出入库分配表的库存
|
||||
@@ -174,7 +190,7 @@ public class ProductInstorServiceImpl implements ProductInstorService {
|
||||
//调用入库分配确认方法
|
||||
InbillServiceImpl inbillService = SpringContextHolder.getBean(InbillServiceImpl.class);
|
||||
JSONObject dis_form = new JSONObject();
|
||||
dis_form.put("task_id", iostorinv_id);
|
||||
dis_form.put("task_id", task_id);
|
||||
inbillService.confirmDis(dis_form);
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
package_box_SN,
|
||||
@@ -88,7 +88,7 @@
|
||||
FROM
|
||||
pdm_bi_subpackagerelation sub
|
||||
WHERE
|
||||
sub.status = '0'
|
||||
sub.status = '1'
|
||||
AND
|
||||
sub.package_box_SN = 输入.box_no
|
||||
ENDSELECT
|
||||
|
||||
Binary file not shown.
@@ -134,7 +134,7 @@ public class InbillServiceImpl {
|
||||
}
|
||||
|
||||
//更新目的点位,仓位、加库存
|
||||
JSONArray dis_rows = dis_table.query("iostorinv_id = '" + iostorinv_id + "' AND work_status < '99'").getResultJSONArray(0);
|
||||
JSONArray dis_rows = dis_table.query("iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject dis_row = dis_rows.getJSONObject(i);
|
||||
JSONObject point_form = new JSONObject();
|
||||
|
||||
@@ -166,12 +166,22 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
row.put("pcsn", row.get("container_name"));
|
||||
row.put("bill_status", "30");
|
||||
row.put("qty_unit_id", material.getString("base_unit_id"));
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '"+material.getString("base_unit_id")+"'").uniqueResult(0);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + material.getString("base_unit_id") + "'").uniqueResult(0);
|
||||
row.put("qty_unit_name", unit.getString("unit_name"));
|
||||
row.put("assign_qty", row.get("net_weight"));
|
||||
row.put("plan_qty", row.get("net_weight"));
|
||||
row.put("box_no", row.get("package_box_sn"));
|
||||
|
||||
/*//如果是退货入库,查询对应的包装关系维护交货单号和交货单行号
|
||||
if (whereJson.get("bill_type").equals("0002")) {
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("container_name = '" + row.get("container_name") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sub_jo)) {
|
||||
throw new BadRequestException("未查询到对应的子卷包装关系!");
|
||||
}
|
||||
row.put("vbeln", sub_jo.getString("vbeln"));
|
||||
row.put("posnr", sub_jo.getString("posnr"));
|
||||
}*/
|
||||
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(row);
|
||||
|
||||
JSONObject dis = new JSONObject();
|
||||
@@ -184,8 +194,8 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
dis.put("box_no", row.get("box_no"));
|
||||
dis.put("quality_scode", row.get("quality_scode"));
|
||||
dis.put("work_status", "00");
|
||||
dis.put("qty_unit_id", "1");
|
||||
dis.put("qty_unit_name", "KG");
|
||||
dis.put("qty_unit_id", material.getString("base_unit_id"));
|
||||
dis.put("qty_unit_name", unit.getString("unit_name"));
|
||||
dis.put("plan_qty", row.get("plan_qty"));
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").insert(dis);
|
||||
|
||||
@@ -357,8 +367,8 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
//是否分配货位
|
||||
if (ObjectUtil.isNotEmpty(checked) && checked) {
|
||||
JSONObject jo_form = new JSONObject();
|
||||
jo_form.put("box_no",map.get("box_no"));
|
||||
jo_form.put("sect_id","1582991348217286656");
|
||||
jo_form.put("box_no", map.get("box_no"));
|
||||
jo_form.put("sect_id", "1582991348217286656");
|
||||
JSONObject struct_jo = this.autoDis(jo_form);
|
||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||
throw new BadRequestException("未查询到适用仓位!");
|
||||
@@ -403,7 +413,8 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
boolean is_virtual = false;
|
||||
if (sect_jo.getString("sect_type_attr").equals("09")) {
|
||||
is_virtual = true;
|
||||
dis_map.put("task_id", map.get("iostorinv_id"));
|
||||
String task_id = IdUtil.getSnowflake(1, 1).nextId()+"";
|
||||
dis_map.put("task_id", task_id);
|
||||
dis_map.put("work_status", "01");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(ios_dis.getString("point_id")) && !is_virtual) {
|
||||
@@ -506,7 +517,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
//如果是虚拟区,直接更新完成分配任务
|
||||
if (is_virtual) {
|
||||
JSONObject dis_form = new JSONObject();
|
||||
dis_form.put("task_id", map.get("iostorinv_id"));
|
||||
dis_form.put("task_id", dis_map.get("task_id"));
|
||||
inbillService.confirmDis(dis_form);
|
||||
}
|
||||
}
|
||||
@@ -701,9 +712,9 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
String placement_type = row_jo.getString("placement_type");
|
||||
|
||||
if (placement_type.equals("01") || placement_type.equals("03")) {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '"+placement_type+"' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0);
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0);
|
||||
} else {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '"+placement_type+"' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0);
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0);
|
||||
}
|
||||
} else {
|
||||
//如果不存在相同订单物料的巷道
|
||||
@@ -722,20 +733,20 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
int box_num = (int) Math.ceil(plan_rows.size() / 3);
|
||||
|
||||
//查询数量与订单物料箱子数量相近的一排
|
||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id",sect_id).addParam("flag", "13").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0);
|
||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "13").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(empty_row)) {
|
||||
String block_num = empty_row.getString("block_num");
|
||||
String row_num = empty_row.getString("row_num");
|
||||
String placement_type = empty_row.getString("placement_type");
|
||||
|
||||
if (placement_type.equals("01") || placement_type.equals("03")) {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '"+placement_type+"' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq desc").uniqueResult(0);
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '" + placement_type + "' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq desc").uniqueResult(0);
|
||||
} else {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '"+placement_type+"'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq").uniqueResult(0);
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '" + placement_type + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq").uniqueResult(0);
|
||||
}
|
||||
} else {
|
||||
//如果查询不到空的一排,则查询有空位双通的一排
|
||||
JSONObject have_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id",sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0);
|
||||
JSONObject have_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(have_row)) {
|
||||
String block_num = have_row.getString("block_num");
|
||||
@@ -744,16 +755,16 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
//判断该排是左边为空,还是右边为空
|
||||
JSONObject right_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq").uniqueResult(0);
|
||||
JSONObject left_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq desc").uniqueResult(0);
|
||||
if (StrUtil.isNotEmpty(right_str.getString("storagevehicle_code")) || !right_str.getString("lock_type").equals("1")){
|
||||
if (StrUtil.isNotEmpty(right_str.getString("storagevehicle_code")) || !right_str.getString("lock_type").equals("1")) {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(left_str.getString("storagevehicle_code")) || !left_str.getString("lock_type").equals("1")){
|
||||
if (StrUtil.isNotEmpty(left_str.getString("storagevehicle_code")) || !left_str.getString("lock_type").equals("1")) {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isEmpty(struct_jo)){
|
||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||
throw new BadRequestException("未查询到可用的仓位!");
|
||||
}
|
||||
return struct_jo;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class InAndOutReturnlController {
|
||||
@PostMapping("/uploadMES")
|
||||
@Log("回传MES")
|
||||
@ApiOperation("回传MES")
|
||||
public ResponseEntity<Object> uploadMES(@RequestBody Map whereJson) {
|
||||
public ResponseEntity<Object> uploadMES(@RequestBody JSONObject whereJson) {
|
||||
inAndOutReturnService.uploadMES(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class InAndOutReturnlController {
|
||||
@PostMapping("/uploadSAP")
|
||||
@Log("回传SAP")
|
||||
@ApiOperation("回传SAP")
|
||||
public ResponseEntity<Object> uploadSAP(@RequestBody Map whereJson) {
|
||||
public ResponseEntity<Object> uploadSAP(@RequestBody JSONObject whereJson) {
|
||||
inAndOutReturnService.uploadSAP(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface InAndOutReturnService {
|
||||
|
||||
void uploadMES(Map whereJson);
|
||||
|
||||
void uploadSAP(Map whereJson);
|
||||
void uploadSAP(JSONObject whereJson);
|
||||
|
||||
void disupload(Map whereJson);
|
||||
|
||||
|
||||
@@ -57,7 +57,87 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSAP(Map whereJson) {
|
||||
public void uploadSAP(JSONObject whereJson) {
|
||||
//出库分配表
|
||||
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
||||
//出库明细表
|
||||
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
||||
//出库主表
|
||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
||||
// 物料表
|
||||
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||
// 库区表
|
||||
WQLObject sectTab = WQLObject.getWQLObject("st_ivt_sectattr");
|
||||
// 子卷包装关系表
|
||||
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
|
||||
|
||||
JSONArray rows = whereJson.getJSONArray("rows");
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jo_mst = rows.getJSONObject(i);
|
||||
String isUpload = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("is_upload").getValue();
|
||||
if (StrUtil.equals(isUpload, "1")) {
|
||||
String bill_type = jo_mst.getString("bill_type");
|
||||
//退货入库
|
||||
if (StrUtil.equals(bill_type, "0002")) {
|
||||
// 1.回传sap
|
||||
JSONArray paramSapMstArr = new JSONArray();
|
||||
|
||||
JSONObject paramSapMst = new JSONObject();
|
||||
paramSapMst.put("ZACTION", "P");
|
||||
paramSapMst.put("BUDAT", jo_mst.getString("biz_date"));
|
||||
|
||||
JSONArray paramDtlArr = new JSONArray();
|
||||
JSONArray dtlArr = wo_dtl.query("iostorinv_id = '" + jo_mst.getString("iostorinv_id") + "'").getResultJSONArray(0);
|
||||
for (int k = 0; k < dtlArr.size(); k++) {
|
||||
JSONArray paramDisArr = new JSONArray();
|
||||
JSONObject json = dtlArr.getJSONObject(k);
|
||||
JSONObject jsonMater = materTab.query("material_id = '" + json.getString("material_id") + "'").uniqueResult(0);
|
||||
|
||||
// 明细
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
jsonDtl.put("VBELN", json.getString("vbeln")); // 交货
|
||||
paramSapMst.put("VBELN", json.getString("vbeln")); // 主表交货
|
||||
jsonDtl.put("POSNR", json.getString("posnr")); // 项目
|
||||
jsonDtl.put("MATNR", jsonMater.getString("material_code"));
|
||||
|
||||
// 分配明细
|
||||
JSONArray disArr = wo_dis.query("iostorinvdtl_id = '" + json.getString("iostorinvdtl_id") + "'").getResultJSONArray(0);
|
||||
for (int j = 0; j < disArr.size(); j++) {
|
||||
JSONObject json2 = disArr.getJSONObject(j);
|
||||
JSONObject jsonDis = new JSONObject();
|
||||
|
||||
JSONObject jsonSect = sectTab.query("sect_id = '" + json2.getString("sect_id") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonSect)) {
|
||||
jsonDtl.put("LGORT", jsonSect.getString("ext_id")); // 明細储存地点
|
||||
}
|
||||
|
||||
JSONObject jsonSub = subTab.query("container_name = '" + json2.getString("pcsn") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonSect)) {
|
||||
jsonDis.put("CHARG", jsonSub.getString("sap_pcsn")); // sap批次
|
||||
}
|
||||
jsonDis.put("VBELN", json.getString("vbeln")); // 交货
|
||||
jsonDis.put("POSNR", json.getString("posnr")); // 项目
|
||||
jsonDis.put("LFIMG", json2.getString("real_qty"));
|
||||
jsonDis.put("VRKME", json.getString("qty_unit_name"));
|
||||
jsonDis.put("PIKMG", json2.getString("real_qty"));
|
||||
jsonDis.put("VRKMP", json2.getString("qty_unit_name"));
|
||||
paramDisArr.add(jsonDis);
|
||||
}
|
||||
jsonDtl.put("CHARG_T", paramDisArr);
|
||||
paramDtlArr.add(jsonDtl);
|
||||
}
|
||||
paramSapMst.put("ITEM", paramDtlArr);
|
||||
paramSapMstArr.add(paramSapMst);
|
||||
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("HEAD", paramSapMstArr);
|
||||
// System.out.println(param.toString());
|
||||
|
||||
// 调用接口回传
|
||||
new LmsToSapServiceImpl().returnDelivery(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -83,7 +163,7 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
|
||||
//根据出入单类型判断回传业务
|
||||
//1、生产入库:回传MES;手工入库:回传SAP
|
||||
//1、销售出库:回传MES、SAP;改切出库:回传SAP
|
||||
JSONArray rows = whereJson.getJSONArray("rows");
|
||||
JSONArray rows = whereJson.getJSONArray("rows");
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jo_mst = rows.getJSONObject(i);
|
||||
String isUpload = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("is_upload").getValue();
|
||||
@@ -94,6 +174,94 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
|
||||
//1.回传MES
|
||||
|
||||
}
|
||||
|
||||
//退货入库
|
||||
if (StrUtil.equals(bill_type, "0002")) {
|
||||
// 1.回传sap
|
||||
JSONArray paramSapMstArr = new JSONArray();
|
||||
|
||||
JSONObject paramSapMst = new JSONObject();
|
||||
paramSapMst.put("ZACTION", "P");
|
||||
paramSapMst.put("BUDAT", jo_mst.getString("biz_date"));
|
||||
|
||||
JSONArray paramDtlArr = new JSONArray();
|
||||
JSONArray dtlArr = wo_dtl.query("iostorinv_id = '" + jo_mst.getString("iostorinv_id") + "'").getResultJSONArray(0);
|
||||
for (int k = 0; k < dtlArr.size(); k++) {
|
||||
JSONArray paramDisArr = new JSONArray();
|
||||
JSONObject json = dtlArr.getJSONObject(k);
|
||||
JSONObject jsonMater = materTab.query("material_id = '" + json.getString("material_id") + "'").uniqueResult(0);
|
||||
|
||||
// 明细
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
jsonDtl.put("VBELN", json.getString("vbeln")); // 交货
|
||||
paramSapMst.put("VBELN", json.getString("vbeln")); // 主表交货
|
||||
jsonDtl.put("POSNR", json.getString("posnr")); // 项目
|
||||
jsonDtl.put("MATNR", jsonMater.getString("material_code"));
|
||||
|
||||
// 分配明细
|
||||
JSONArray disArr = wo_dis.query("iostorinvdtl_id = '" + json.getString("iostorinvdtl_id") + "'").getResultJSONArray(0);
|
||||
for (int j = 0; j < disArr.size(); j++) {
|
||||
JSONObject json2 = disArr.getJSONObject(j);
|
||||
JSONObject jsonDis = new JSONObject();
|
||||
|
||||
JSONObject jsonSect = sectTab.query("sect_id = '" + json2.getString("sect_id") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonSect)) {
|
||||
jsonDtl.put("LGORT", jsonSect.getString("ext_id")); // 明細储存地点
|
||||
}
|
||||
|
||||
JSONObject jsonSub = subTab.query("container_name = '" + json2.getString("pcsn") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonSect)) {
|
||||
jsonDis.put("CHARG", jsonSub.getString("sap_pcsn")); // sap批次
|
||||
}
|
||||
jsonDis.put("VBELN", json.getString("vbeln")); // 交货
|
||||
jsonDis.put("POSNR", json.getString("posnr")); // 项目
|
||||
jsonDis.put("LFIMG", json2.getString("real_qty"));
|
||||
jsonDis.put("VRKME", json.getString("qty_unit_name"));
|
||||
jsonDis.put("PIKMG", json2.getString("real_qty"));
|
||||
jsonDis.put("VRKMP", json2.getString("qty_unit_name"));
|
||||
paramDisArr.add(jsonDis);
|
||||
}
|
||||
jsonDtl.put("CHARG_T", paramDisArr);
|
||||
paramDtlArr.add(jsonDtl);
|
||||
}
|
||||
paramSapMst.put("ITEM", paramDtlArr);
|
||||
paramSapMstArr.add(paramSapMst);
|
||||
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("HEAD", paramSapMstArr);
|
||||
// System.out.println(param.toString());
|
||||
|
||||
// 调用接口回传
|
||||
new LmsToSapServiceImpl().returnDelivery(param);
|
||||
|
||||
// 2.回传mes
|
||||
JSONObject paramMesMst = new JSONObject();
|
||||
String userName = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("MES_USERNAME").getValue();
|
||||
String passWord = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("MES_PASSWORD").getValue();
|
||||
|
||||
paramMesMst.put("UserName", userName);
|
||||
paramMesMst.put("Password", passWord);
|
||||
paramMesMst.put("OutboundOrderNum", jo_mst.getString("bill_code"));
|
||||
paramMesMst.put("OutboundUser", jo_mst.getString("confirm_optname"));
|
||||
paramMesMst.put("OutboundTime", jo_mst.getString("confirm_time"));
|
||||
|
||||
JSONArray boxArr = WQL.getWO("ST_OUTIVT02").addParam("flag", "2")
|
||||
.addParam("iostorinv_id", jo_mst.getString("iostorinv_id"))
|
||||
.process().getResultJSONArray(0);
|
||||
|
||||
JSONArray paramArr = new JSONArray();
|
||||
for (int j = 0; j < boxArr.size(); j++) {
|
||||
JSONObject json = boxArr.getJSONObject(j);
|
||||
JSONObject jsonBox = new JSONObject();
|
||||
|
||||
jsonBox.put("PackageBoxSN", json.getString("num"));
|
||||
paramArr.add(jsonBox);
|
||||
}
|
||||
paramMesMst.put("item", paramArr);
|
||||
|
||||
// 调用接口回传
|
||||
new LmsToMesServiceImpl().childRollFGOutboundComplete(paramMesMst);
|
||||
}
|
||||
// 销售出库
|
||||
if (StrUtil.equals(bill_type, "1001")) {
|
||||
// 1.回传sap
|
||||
|
||||
Reference in New Issue
Block a user