|
|
@ -11,6 +11,7 @@ import org.wdk.core.bean.WDKLogger; |
|
|
|
import org.wdk.core.env.context.ServiceContext; |
|
|
|
import org.wdk.core.spring.annotation.WDKTransaction; |
|
|
|
import org.wdk.core.util.uString; |
|
|
|
import org.wdk.core.wql.WQL; |
|
|
|
import org.wdk.core.wql.core.bean.ResultBean; |
|
|
|
import org.wdk.core.wql.core.bean.WQLData; |
|
|
|
import org.wdk.core.wql.core.bean.WQLObject; |
|
|
@ -741,16 +742,25 @@ public class SapToWmsServiceImpl implements SapToWmsService { |
|
|
|
|
|
|
|
// 物料基本信息接口表
|
|
|
|
WQLObject wo_SAP_Mater = WQLObject.getWQLObject("IF_SAP_Mater"); |
|
|
|
WQLData wd_SAP_Mater = new WQLData(wo_SAP_Mater); |
|
|
|
// 物料表
|
|
|
|
WQLObject MD_ME_MaterialBase = WQLObject.getWQLObject("MD_ME_MaterialBase"); |
|
|
|
WQLData wd_MaterialBase = new WQLData(MD_ME_MaterialBase); |
|
|
|
// 物料分类中间表
|
|
|
|
WQLObject MD_PB_BaseData_ClassInfo = WQLObject.getWQLObject("MD_PB_BaseData_ClassInfo"); |
|
|
|
WQLData wd_BaseData_ClassInfo = new WQLData(MD_PB_BaseData_ClassInfo); |
|
|
|
// 物料唯一表
|
|
|
|
WQLObject ST_BS_WMSMaterial = WQLObject.getWQLObject("ST_BS_WMSMaterial"); |
|
|
|
WQLData wd_WMSMaterial = new WQLData(ST_BS_WMSMaterial); |
|
|
|
// 物料呆滞表
|
|
|
|
WQLObject ST_BS_WMSMaterialIsDull = WQLObject.getWQLObject("ST_BS_WMSMaterialIsDull"); |
|
|
|
WQLData wd_WMSMaterialIsDull = new WQLData(ST_BS_WMSMaterialIsDull); |
|
|
|
|
|
|
|
|
|
|
|
logger.debug("数据数量:" + tblexport.getNumRows()); |
|
|
|
nums = tblexport.getNumRows() + ""; |
|
|
|
// 删除
|
|
|
|
wo_SAP_Mater.delete("1=1"); |
|
|
|
for (int i = 0; i < tblexport.getNumRows(); i++) { |
|
|
|
tblexport.setRow(i); |
|
|
|
JSONObject joi = new JSONObject(); |
|
|
@ -760,6 +770,9 @@ public class SapToWmsServiceImpl implements SapToWmsService { |
|
|
|
String MEINS = tblexport.getString("MEINS"); |
|
|
|
String LGORT = tblexport.getString("LGORT"); |
|
|
|
|
|
|
|
MAKTX = MAKTX.replace("\"","’"); |
|
|
|
|
|
|
|
MAKTX = MAKTX.replace("'","’"); |
|
|
|
joi.put("MATNR", MATNR); |
|
|
|
joi.put("MAKTX", MAKTX); |
|
|
|
joi.put("LGORT", LGORT); |
|
|
@ -772,158 +785,131 @@ public class SapToWmsServiceImpl implements SapToWmsService { |
|
|
|
Double startdirection2 = bd1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
joi.put("NTGEW", startdirection2 + ""); |
|
|
|
joi.put("MEINS", MEINS); |
|
|
|
|
|
|
|
FieldWhereUtil whereExpr = new FieldWhereUtil(); |
|
|
|
whereExpr.add("MAKTX", "=", MAKTX); |
|
|
|
whereExpr.add("MATNR", "=", MATNR); |
|
|
|
whereExpr.add("MEINS", "=", MEINS); |
|
|
|
whereExpr.add("LGORT", "=", LGORT); |
|
|
|
// 删除
|
|
|
|
WdkUtil.deleteByAttr(whereExpr.toJSONArray(), "IF_SAP_Mater"); |
|
|
|
|
|
|
|
joi.put("id", WDK.getUUID()); |
|
|
|
// 新增
|
|
|
|
wo_SAP_Mater.insert(joi); |
|
|
|
Iterator<String> it = joi.keys(); |
|
|
|
wd_SAP_Mater.insert(); |
|
|
|
while(it.hasNext()){ |
|
|
|
String key = it.next(); |
|
|
|
String value = joi.optString(key); |
|
|
|
if(wo_SAP_Mater.existField(key)) |
|
|
|
wd_SAP_Mater.setValue(key, value); |
|
|
|
} |
|
|
|
} |
|
|
|
//批量新增物料到接口表
|
|
|
|
if(wd_SAP_Mater.getRowCount()!=0){ |
|
|
|
wo_SAP_Mater.updateAll(wd_SAP_Mater); |
|
|
|
} |
|
|
|
|
|
|
|
JSONArray ja = WQL.getWO("IFS_SAP_INTERFACE_01").addParam("flag", "8").process().getResultJSONArray(0); |
|
|
|
String datanow = WDK.getDateTime(); |
|
|
|
|
|
|
|
for(int i=0;i<ja.size();i++){ |
|
|
|
JSONObject jo = ja.getJSONObject(i); |
|
|
|
|
|
|
|
JSONObject jo = MD_ME_MaterialBase.query("sysisdelete='0' and material_code='" + MATNR + "'").uniqueResult(0); |
|
|
|
|
|
|
|
String datanow = WDK.getDateTime(); |
|
|
|
if (jo == null) {// 新增
|
|
|
|
jo = new JSONObject(); |
|
|
|
jo.put("material_code", joi.optString("MATNR")); |
|
|
|
String material_name = joi.optString("MAKTX"); |
|
|
|
material_name = material_name.replace("\"","’"); |
|
|
|
|
|
|
|
material_name = material_name.replace("'","’"); |
|
|
|
jo.put("material_name", material_name); |
|
|
|
JSONObject unit = WQLObject.getWQLObject("MD_PB_MeasureUnit") |
|
|
|
.query("unit_name = '" + joi.optString("MEINS") + "'").uniqueResult(0); |
|
|
|
jo.put("base_unit_uuid", unit.optString("measure_unit_uuid")); |
|
|
|
|
|
|
|
String GEWEI = joi.optString("GEWEI"); |
|
|
|
if (uString.isBlank(GEWEI)) { |
|
|
|
GEWEI = "KG"; |
|
|
|
} |
|
|
|
JSONObject weight_unit = WQLObject.getWQLObject("MD_PB_MeasureUnit") |
|
|
|
.query("unit_name = '" + GEWEI + "'").uniqueResult(0); |
|
|
|
if(weight_unit==null||weight_unit.isNullObject()){ |
|
|
|
jo.put("weight_unit_uuid", "EFA1CBA910AF4EBFA7246DBA89C73058"); |
|
|
|
}else{ |
|
|
|
jo.put("weight_unit_uuid", weight_unit.optString("measure_unit_uuid")); |
|
|
|
} |
|
|
|
jo.put("sysupdateuseruuid", "0000"); |
|
|
|
jo.put("sysupdatetime", datanow); |
|
|
|
jo.put("syscreatedate", datanow); |
|
|
|
jo.put("syscreatoruuid", "0000"); |
|
|
|
jo.put("material_uuid", "uuid-" + MATNR); |
|
|
|
jo.put("is_seal_up", "0"); |
|
|
|
jo.put("sysisdelete", "0"); |
|
|
|
jo.put("salver_limit_height", "0"); |
|
|
|
jo.put("salver_qty", "0"); |
|
|
|
jo.put("net_weight", joi.optString("NTGEW")); |
|
|
|
|
|
|
|
String LGORT2 = joi.optString("LGORT"); |
|
|
|
if (uString.isBlank(LGORT2)) { |
|
|
|
LGORT2 = "-1"; |
|
|
|
} |
|
|
|
JSONObject sect = WQLObject.getWQLObject("ST_BS_SectAttr") |
|
|
|
.query("sysisdelete='0' and ext_id = '" + LGORT2 + "'").uniqueResult(0); |
|
|
|
if (sect == null) { |
|
|
|
sect = new JSONObject(); |
|
|
|
sect.put("sect_type", ""); |
|
|
|
} |
|
|
|
if (sect.optString("sect_type").equals("01")) { |
|
|
|
jo.put("sect_type", "01"); |
|
|
|
} else { |
|
|
|
jo.put("sect_type", sect.optString("sect_type", "")); |
|
|
|
jo.put("sect_uuid", sect.optString("sect_uuid", "")); |
|
|
|
jo.put("sect_code", sect.optString("sect_code", "")); |
|
|
|
jo.put("sect_name", sect.optString("sect_name", "")); |
|
|
|
} |
|
|
|
MD_ME_MaterialBase.insert(jo); |
|
|
|
|
|
|
|
jo.put("class_uuid", "B5CFEA82959F4A8EB53847C693F58E6B"); |
|
|
|
jo.put("base_data_uuid", "uuid-" + MATNR); |
|
|
|
jo.put("base_data_type", "03"); |
|
|
|
jo.put("sysisdelete", "0"); |
|
|
|
MD_PB_BaseData_ClassInfo.insert(jo); |
|
|
|
|
|
|
|
JSONObject wmsmaterial = new JSONObject(); |
|
|
|
wmsmaterial.put("wmsmaterial_uuid", "uuid-" + MATNR + "-1060"); |
|
|
|
wmsmaterial.put("material_uuid", "uuid-" + MATNR); |
|
|
|
wmsmaterial.put("material_code", MATNR); |
|
|
|
wmsmaterial.put("material_name", MAKTX); |
|
|
|
wmsmaterial.put("factory_uuid", "1060"); |
|
|
|
ST_BS_WMSMaterial.insert(wmsmaterial); |
|
|
|
wmsmaterial.put("is_dull", "0"); |
|
|
|
ST_BS_WMSMaterialIsDull.insert(wmsmaterial); |
|
|
|
|
|
|
|
//暂时屏蔽1061的物料
|
|
|
|
/*wmsmaterial.put("wmsmaterial_uuid", "uuid-" + MATNR + "-1061"); |
|
|
|
wmsmaterial.put("factory_uuid", "1061"); |
|
|
|
ST_BS_WMSMaterial.insert(wmsmaterial); |
|
|
|
wmsmaterial.put("is_dull", "0"); |
|
|
|
ST_BS_WMSMaterialIsDull.insert(wmsmaterial);*/ |
|
|
|
|
|
|
|
} else {// 更新
|
|
|
|
|
|
|
|
jo.put("sysupdatetime", datanow); |
|
|
|
jo.put("sysupdateuseruuid", "0000"); |
|
|
|
String material_code = jo.optString("material_code"); |
|
|
|
String material_name = jo.optString("material_name"); |
|
|
|
|
|
|
|
if (uString.isNotBlank(jo.getString("english_name"))) { |
|
|
|
material_name = "(旧"+jo.getString("english_name")+")"+material_name; |
|
|
|
} |
|
|
|
jo.put("material_name", material_name); |
|
|
|
if (uString.isBlank(jo.optString("weight_unit_uuid"))) { |
|
|
|
jo.put("weight_unit_uuid", "EFA1CBA910AF4EBFA7246DBA89C73058"); |
|
|
|
} |
|
|
|
jo.put("sysupdateuseruuid", "0000"); |
|
|
|
jo.put("sysupdatetime", datanow); |
|
|
|
jo.put("syscreatedate", datanow); |
|
|
|
jo.put("syscreatoruuid", "0000"); |
|
|
|
jo.put("is_seal_up", "0"); |
|
|
|
jo.put("sysisdelete", "0"); |
|
|
|
jo.put("salver_limit_height", "0"); |
|
|
|
jo.put("salver_qty", "0"); |
|
|
|
|
|
|
|
if ("1002".equals(jo.optString("LGORT"))) { |
|
|
|
jo.put("sect_type", "01"); |
|
|
|
} |
|
|
|
if (uString.isBlank(jo.optString("LGORT"))) { |
|
|
|
jo.put("sect_type", "01"); |
|
|
|
jo.put("sect_uuid", ""); |
|
|
|
jo.put("sect_code", ""); |
|
|
|
jo.put("sect_name", ""); |
|
|
|
} |
|
|
|
|
|
|
|
Iterator<String> it = jo.keys(); |
|
|
|
wd_MaterialBase.insert(); |
|
|
|
while(it.hasNext()){ |
|
|
|
String key = it.next(); |
|
|
|
String value = jo.optString(key); |
|
|
|
if(MD_ME_MaterialBase.existField(key)) |
|
|
|
wd_MaterialBase.setValue(key, value); |
|
|
|
} |
|
|
|
MD_ME_MaterialBase.delete("material_uuid='"+jo.getString("material_uuid")+"'"); |
|
|
|
|
|
|
|
String material_name = joi.optString("MAKTX"); |
|
|
|
material_name = material_name.replace("\"","’"); |
|
|
|
|
|
|
|
material_name = material_name.replace("'","’"); |
|
|
|
|
|
|
|
if (uString.isNotBlank(jo.getString("english_name"))) { |
|
|
|
material_name = "(旧"+jo.getString("english_name")+")"+material_name; |
|
|
|
} |
|
|
|
jo.put("material_name", material_name); |
|
|
|
|
|
|
|
JSONObject unit = WQLObject.getWQLObject("MD_PB_MeasureUnit") |
|
|
|
.query("unit_name = '" + joi.optString("MEINS") + "'").uniqueResult(0); |
|
|
|
jo.put("base_unit_uuid", unit.optString("measure_unit_uuid")); |
|
|
|
|
|
|
|
String GEWEI = joi.optString("GEWEI"); |
|
|
|
if (uString.isBlank(GEWEI)) { |
|
|
|
GEWEI = "KG"; |
|
|
|
} |
|
|
|
JSONObject weight_unit = WQLObject.getWQLObject("MD_PB_MeasureUnit") |
|
|
|
.query("unit_name = '" + GEWEI + "'").uniqueResult(0); |
|
|
|
if(weight_unit==null||weight_unit.isNullObject()){ |
|
|
|
jo.put("weight_unit_uuid", "EFA1CBA910AF4EBFA7246DBA89C73058"); |
|
|
|
}else{ |
|
|
|
jo.put("weight_unit_uuid", weight_unit.optString("measure_unit_uuid")); |
|
|
|
} |
|
|
|
jo.put("net_weight", joi.optString("NTGEW")); |
|
|
|
String LGORT2 = joi.optString("LGORT"); |
|
|
|
if (uString.isBlank(LGORT2)) { |
|
|
|
LGORT2 = "-1"; |
|
|
|
} |
|
|
|
JSONObject sect = WQLObject.getWQLObject("ST_BS_SectAttr") |
|
|
|
.query("sysisdelete='0' and ext_id = '" + LGORT2 + "'").uniqueResult(0); |
|
|
|
if (sect == null) { |
|
|
|
sect = new JSONObject(); |
|
|
|
sect.put("sect_type", ""); |
|
|
|
} |
|
|
|
if (sect.optString("sect_type").equals("01")) { |
|
|
|
jo.put("sect_type", "01"); |
|
|
|
jo.put("sect_uuid", ""); |
|
|
|
jo.put("sect_code", ""); |
|
|
|
jo.put("sect_name", ""); |
|
|
|
} else { |
|
|
|
jo.put("sect_type", sect.optString("sect_type", "")); |
|
|
|
jo.put("sect_uuid", sect.optString("sect_uuid", "")); |
|
|
|
jo.put("sect_code", sect.optString("sect_code", "")); |
|
|
|
jo.put("sect_name", sect.optString("sect_name", "")); |
|
|
|
} |
|
|
|
MD_ME_MaterialBase.update(jo); |
|
|
|
//更新物料唯一表
|
|
|
|
HashMap<String, String> map = new HashMap<String, String>(); |
|
|
|
map.put("material_name", material_name); |
|
|
|
ResultBean rb2 = ST_BS_WMSMaterial.update(map, "material_code = ?", |
|
|
|
new String[] { MATNR }); |
|
|
|
JSONObject jo2 = new JSONObject(); |
|
|
|
jo2.put("class_uuid", "B5CFEA82959F4A8EB53847C693F58E6B"); |
|
|
|
jo2.put("base_data_uuid", "uuid-" + material_code); |
|
|
|
jo2.put("base_data_type", "03"); |
|
|
|
jo2.put("sysisdelete", "0"); |
|
|
|
|
|
|
|
Iterator<String> it2 = jo2.keys(); |
|
|
|
wd_BaseData_ClassInfo.insert(); |
|
|
|
while(it2.hasNext()){ |
|
|
|
String key = it2.next(); |
|
|
|
String value = jo2.optString(key); |
|
|
|
if(MD_PB_BaseData_ClassInfo.existField(key)) |
|
|
|
wd_BaseData_ClassInfo.setValue(key, value); |
|
|
|
} |
|
|
|
MD_PB_BaseData_ClassInfo.delete("class_uuid='B5CFEA82959F4A8EB53847C693F58E6B' and base_data_uuid='"+jo2.optString("base_data_uuid")+"'"); |
|
|
|
|
|
|
|
JSONObject wmsmaterial = new JSONObject(); |
|
|
|
wmsmaterial.put("wmsmaterial_uuid", "uuid-" + material_code + "-1060"); |
|
|
|
wmsmaterial.put("material_uuid", "uuid-" + material_code); |
|
|
|
wmsmaterial.put("material_code", material_code); |
|
|
|
wmsmaterial.put("material_name", material_name); |
|
|
|
wmsmaterial.put("factory_uuid", "1060"); |
|
|
|
Iterator<String> it3 = wmsmaterial.keys(); |
|
|
|
wd_WMSMaterial.insert(); |
|
|
|
while(it3.hasNext()){ |
|
|
|
String key = it3.next(); |
|
|
|
String value = wmsmaterial.optString(key); |
|
|
|
if(ST_BS_WMSMaterial.existField(key)) |
|
|
|
wd_WMSMaterial.setValue(key, value); |
|
|
|
} |
|
|
|
ST_BS_WMSMaterial.delete("wmsmaterial_uuid='"+wmsmaterial.getString("wmsmaterial_uuid")+"'"); |
|
|
|
|
|
|
|
|
|
|
|
JSONObject wmsmaterial2 = new JSONObject(); |
|
|
|
wmsmaterial2.put("is_dull", "0"); |
|
|
|
wmsmaterial2.put("wmsmaterial_uuid", "uuid-" + material_code + "-1060"); |
|
|
|
Iterator<String> it4 = wmsmaterial2.keys(); |
|
|
|
wd_WMSMaterialIsDull.insert(); |
|
|
|
while(it4.hasNext()){ |
|
|
|
String key = it4.next(); |
|
|
|
String value = wmsmaterial2.optString(key); |
|
|
|
if(ST_BS_WMSMaterialIsDull.existField(key)) |
|
|
|
wd_WMSMaterialIsDull.setValue(key, value); |
|
|
|
} |
|
|
|
ST_BS_WMSMaterialIsDull.delete("wmsmaterial_uuid='"+wmsmaterial2.getString("wmsmaterial_uuid")+"'"); |
|
|
|
|
|
|
|
}//end if
|
|
|
|
|
|
|
|
if(wd_MaterialBase.getRowCount()!=0){ |
|
|
|
MD_ME_MaterialBase.updateAll(wd_MaterialBase); |
|
|
|
} |
|
|
|
if(wd_WMSMaterial.getRowCount()!=0){ |
|
|
|
ST_BS_WMSMaterial.updateAll(wd_WMSMaterial); |
|
|
|
} |
|
|
|
if(wd_WMSMaterialIsDull.getRowCount()!=0){ |
|
|
|
ST_BS_WMSMaterialIsDull.updateAll(wd_WMSMaterialIsDull); |
|
|
|
} |
|
|
|
|
|
|
|
if(wd_BaseData_ClassInfo.getRowCount()!=0){ |
|
|
|
MD_PB_BaseData_ClassInfo.updateAll(wd_BaseData_ClassInfo); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
srb.addParam("result", nums); |
|
|
|
srb.setSuccess(); |
|
|
|