diff --git a/lxapi/com/noblelift/imp/products/mes/api/st/rc/ReceiveService.java b/lxapi/com/noblelift/imp/products/mes/api/st/rc/ReceiveService.java
index 6e06518..b0854f7 100644
--- a/lxapi/com/noblelift/imp/products/mes/api/st/rc/ReceiveService.java
+++ b/lxapi/com/noblelift/imp/products/mes/api/st/rc/ReceiveService.java
@@ -147,6 +147,19 @@ public interface ReceiveService {
* 排序字段
*/
public ServiceResultBean querySourceByForm(ServiceContext context, String accountId, JSONObject form, String orderBy);
+ /**
+ * 分页查询列表
+ *
+ * @param context
+ * 上下文
+ * @param accountId
+ * 操作账号ID
+ * @param form
+ * 信息
+ * @param orderBy
+ * 排序字段
+ */
+ public ServiceResultBean querySourceByForm2(ServiceContext context, String accountId, JSONObject form, String orderBy);
/**
* 生成订单信息查询
*
@@ -201,5 +214,6 @@ public interface ReceiveService {
public ServiceResultBean queryDestroyMater(ServiceContext context, String accountId, JSONObject form, String orderBy);
+ public ServiceResultBean excelSave(ServiceContext context, JSONObject accountInfo,String fileid);
}
diff --git a/lxapp/app/products/mes/md/me/material_query.jsp b/lxapp/app/products/mes/md/me/material_query.jsp
index 66e581b..6375ba0 100644
--- a/lxapp/app/products/mes/md/me/material_query.jsp
+++ b/lxapp/app/products/mes/md/me/material_query.jsp
@@ -10,13 +10,13 @@
//初始化加载左侧的树
$(function(){
- $.exceluploader({
+ /* $.exceluploader({
id:'excel_div'
,uploadSuccess:function(file,res){
fileid = res.fileid;
btn_save(fileid);
}
- });
+ }); */
//物料分类标准下拉初始化
Combo_box_material();
//初始化加载组织树
diff --git a/lxapp/app/products/mes/st/rc/receive_dtl3.jsp b/lxapp/app/products/mes/st/rc/receive_dtl3.jsp
index f63eff6..6b34647 100644
--- a/lxapp/app/products/mes/st/rc/receive_dtl3.jsp
+++ b/lxapp/app/products/mes/st/rc/receive_dtl3.jsp
@@ -13,7 +13,7 @@
$(function() {
//查询grid数据
//组织参数
- var dataParam = getGridQueryParam(stor_uuid);
+ var dataParam = getGridQueryParam(stor_uuid,null);
var gridid = $.grid({
id : _gridid,
containerid : 'layout_grid',
@@ -29,17 +29,20 @@
nowrap:true, //自动换行
pagination:true,
});
+
+ excel();
});
//获取grid查询参数
- function getGridQueryParam(stor_uuid){
+ function getGridQueryParam(stor_uuid,result){
//获取form对象值
var FieldValues = $.getFieldValue({formid:'search_form'});
FieldValues.stor_uuid = stor_uuid;
+ FieldValues.result = result;
FieldValues.flag = "3";
//组织参数
var dataParam = {
_SRVNAME:'server.store.receiveMst'
- ,_SRVMETHOD:'querySourceByForm'
+ ,_SRVMETHOD:'querySourceByForm2'
,_DATA:$.json2str({
accountId:$.getSessionUser().account_id
,form: FieldValues
@@ -51,11 +54,51 @@
};
return dataParam;
}
-
+ function excel(){
+ $.exceluploader({
+ id:'excel_div'
+ ,uploadSuccess:function(file,res){
+ fileid = res.fileid;
+ btn_save(fileid);
+ }
+ });
+ }
+ function btn_save(fileid) {
+ $.wait_open();
+ $.cuajax({
+ url : 'wdk?action=wdk.pub&method=call_service&ajaxparam='+ new Date().getTime(),
+ method : "post",
+ timeout : WDK_Timeout,
+ data : {
+ _SRVNAME : 'server.store.receiveMst',
+ _SRVMETHOD : 'excelSave',//
+ _DATA : $.json2str({
+ accountInfo:$.getSessionUser() //登陆账号的信息
+ ,fileid : fileid
+ })
+ },
+ success : function(result) {
+ $.wait_close();
+ //返回值字符串转json
+ var jres = $.str2json(result);
+ if (jres.code == "1") { //操作成功
+ alert(jres.desc);
+ query(jres.result);
+ } else {
+ alert(jres.desc);
+ }
+ },
+ error : function(result) {
+ $.wait_close();
+ alert('网络错误!result=' + result);
+ }
+ });
+
+ }
//查询
- function query() {
+ function query(result) {
//组织参数
- var dataParam = getGridQueryParam(stor_uuid);
+ var dataParam = getGridQueryParam(stor_uuid,result);
$.grid_reload({
id:_gridid,
queryParams:dataParam
@@ -80,6 +123,9 @@
@@ -91,7 +137,7 @@
-
+
diff --git a/lxapp/src/wql/mes/ifs/sap/IFS_SAP_INTERFACE_01.wql b/lxapp/src/wql/mes/ifs/sap/IFS_SAP_INTERFACE_01.wql
index 193c201..bbed3f2 100644
--- a/lxapp/src/wql/mes/ifs/sap/IFS_SAP_INTERFACE_01.wql
+++ b/lxapp/src/wql/mes/ifs/sap/IFS_SAP_INTERFACE_01.wql
@@ -380,6 +380,48 @@ IF 输入.flag = "7"
ENDSELECT
ENDPAGEQUERY
ENDIF
+
+IF 输入.flag = "8"
+ QUERY
+ SELECT
+ 'uuid-' + ma.MATNR as material_uuid,
+ ma.MATNR as material_code,
+ ma.MAKTX as material_name,
+ unit.measure_unit_uuid as base_unit_uuid,
+ wunit.measure_unit_uuid as weight_unit_uuid,
+ ma.NTGEW as net_weight,
+ ma.LGORT,
+ mb.english_name,
+ sect.sect_type,
+ sect.sect_uuid,
+ sect.sect_code,
+ sect.sect_name
+ FROM
+ if_sap_mater ma
+ LEFT JOIN MD_ME_MaterialBase mb ON (mb.material_code = ma.MATNR and mb.sysisdelete='0')
+ inner join MD_PB_MeasureUnit unit on unit.unit_name = ma.MEINS
+ left join MD_PB_MeasureUnit wunit on wunit.unit_name = ma.GEWEI
+ left join (SELECT
+ sect_type,
+ sect_uuid,
+ sect_name,
+ sect_code,
+ ext_id
+ FROM
+ ST_BS_SectAttr
+ WHERE
+ sysisdelete = '0'
+ AND is_virtual = '0'
+ AND sect_type <> '01'
+ GROUP BY
+ sect_type,
+ sect_uuid,
+ sect_name,
+ sect_code,
+ ext_id) sect on sect.ext_id=ma.LGORT
+ ENDSELECT
+ ENDQUERY
+ENDIF
diff --git a/lxapp/src/wql/mes/st/rc/ST_RC_RECEIVE_04.wql b/lxapp/src/wql/mes/st/rc/ST_RC_RECEIVE_04.wql
index 620ee90..c5fd20e 100644
--- a/lxapp/src/wql/mes/st/rc/ST_RC_RECEIVE_04.wql
+++ b/lxapp/src/wql/mes/st/rc/ST_RC_RECEIVE_04.wql
@@ -55,6 +55,9 @@
//工厂
输入.factory_code TYPEAS s_string
+ //仓位类型
+ 输入.material_codes TYPEAS f_string
+
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -282,7 +285,10 @@
base.sect_type in (输入.sect_types)
ENDOPTION
OPTION 输入.search_bar <> ""
- mater.material_code LIKE 输入.search_bar
+ mater.material_code = 输入.search_bar
+ ENDOPTION
+ OPTION 输入.material_codes <> ""
+ mater.material_code in (输入.material_codes)
ENDOPTION
ENDSELECT
ENDPAGEQUERY
diff --git a/lxservice/com/noblelift/imp/products/mes/service/ifs/sap/SapToWmsServiceImpl.java b/lxservice/com/noblelift/imp/products/mes/service/ifs/sap/SapToWmsServiceImpl.java
index ffc2dd6..f6e662f 100644
--- a/lxservice/com/noblelift/imp/products/mes/service/ifs/sap/SapToWmsServiceImpl.java
+++ b/lxservice/com/noblelift/imp/products/mes/service/ifs/sap/SapToWmsServiceImpl.java
@@ -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
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 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 map = new HashMap();
- 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 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 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 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();
diff --git a/lxservice/com/noblelift/imp/products/mes/service/st/rc/ReceiveServiceImpl.java b/lxservice/com/noblelift/imp/products/mes/service/st/rc/ReceiveServiceImpl.java
index ec88824..01d8885 100644
--- a/lxservice/com/noblelift/imp/products/mes/service/st/rc/ReceiveServiceImpl.java
+++ b/lxservice/com/noblelift/imp/products/mes/service/st/rc/ReceiveServiceImpl.java
@@ -1,6 +1,8 @@
package com.noblelift.imp.products.mes.service.st.rc;
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -10,10 +12,13 @@ import org.wdk.core.bean.WDKException;
import org.wdk.core.env.context.ServiceContext;
import org.wdk.core.spring.SpringContext;
import org.wdk.core.spring.annotation.WDKTransaction;
+import org.wdk.core.util.uExcelUtilByPOI;
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.WQLObject;
+import org.wdk.module.file.FileReturn;
+import org.wdk.module.file.FileServerFactory;
import com.noblelift.imp.products.mes.api.ifs.sap.SapToWmsService;
import com.noblelift.imp.products.mes.api.st.is.UrgentIssueBill;
@@ -1335,6 +1340,102 @@ public class ReceiveServiceImpl implements ReceiveService {
srb.addJSON("result", jres);
return srb;
}
+
+ @Override
+ public ServiceResultBean querySourceByForm2(ServiceContext context, String accountId, JSONObject form, String orderBy) {
+ WQLObject tbObj = WQLObject.getWQLObject("ST_BS_RealStorAttr");
+ String stor_uuid = form.optString("stor_uuid","");
+ JSONArray result = form.optJSONArray("result");
+ JSONObject stor = tbObj.query("stor_uuid='"+stor_uuid+"'").uniqueResult(0);
+ String stor_type = "";
+ if(stor!=null)
+ stor_type = stor.optString("stor_type");
+ String sect_types = "";
+
+ if(stor_type.equals("01")) {
+ sect_types="'01','02'";
+ }
+ if(stor_type.equals("02")) {
+ sect_types="03";
+ }
+ if(form.optString("is_check","").equals("1")) {
+ sect_types="'01','02','03'";
+ }
+ form.put("sect_types", sect_types);
+
+ String material_codes = "";
+ HashMap map = new HashMap ();
+ if(result != null){
+ for (int i = 0; i < result.size(); i++) {
+ map.put(result.getJSONObject(i).optString("material_code"), result.getJSONObject(i).optDouble("fact_qty"));
+ if (material_codes.equals(""))
+ material_codes = result.getJSONObject(i).optString("material_code");
+ else
+ material_codes = material_codes + "," + result.getJSONObject(i).optString("material_code");
+ }
+ if(uString.isNotBlank(material_codes)){
+ material_codes = "'" + material_codes.replaceAll(",", "','") + "'";
+ form.put("material_codes", material_codes);
+ }
+ }
+ JSONObject jres = WQL.getWO("ST_RC_RECEIVE_04").addParamMap(WDK.json2map(form)).pageQuery(context, "");
+
+ if(result != null){
+ JSONArray rows = jres.optJSONArray("rows");
+ JSONArray new_rows = new JSONArray();
+ for(int i=0;i excelList = uExcelUtilByPOI._readExcel(fr.getInputstream());
+
+ JSONArray jres = new JSONArray();
+ for (int i = 0, j = excelList.size(); i < j; i++) {
+ // 对应Excel的每一列
+ ArrayList> list = (ArrayList>) excelList.get(i);
+ JSONObject tblexport = new JSONObject();
+ // 对应Excel的第一列
+ tblexport.put("material_code", list.get(0));
+ tblexport.put("fact_qty", list.get(1));
+
+ // 说明到了最后一行
+ if (uString.isEmpty(tblexport.optString("material_code"))) {
+ break;
+ }
+
+ jres.add(tblexport);
+ }
+
+ ServiceResultBean srb = new ServiceResultBean();
+ srb.setDesc("导入excel成功!");
+ srb.addJSONArray("result", jres);
+ srb.setSuccess();
+ return srb;
+ }
@Override
@WDKTransaction
public ServiceResultBean ProductImport(ServiceContext context, JSONObject account, JSONObject form) {