Commit 1ca89f7f authored by 鲁鑫's avatar 鲁鑫

SAP查询物料接口

parent 0f40f43f
...@@ -99,19 +99,38 @@ function getGridColumns() { ...@@ -99,19 +99,38 @@ function getGridColumns() {
{display: "工厂名称", name: "name1", width: "200", align: "left", type: "string", {display: "工厂名称", name: "name1", width: "200", align: "left", type: "string",
editor: {required: false, type: "text"} editor: {required: false, type: "text"}
}, },
{display: "物料编号", name: "matnr", width: "100", align: "left", type: "string", {display: "物料编号", name: "matnr", width: "300", align: "left", type: "string",
/*editor: { editor: {
required: true, type: "select", required: true, type: "select",
data: { getEditor:function (editParam) {
type: 'system', UICtrl.showAjaxDialog({
name: "chooseUnit", title: '',
getParam: function (item) { width: 800,
return {paramValue: item.materNo} height: 400,
}, url: web_app.name + '/sapDialogSelect/forwardSapMaterial.load',
back: {meins: "unit"} okVal:'common.button.ok',
}, ok:function(item){
}*/ var row = DataUtil.getSelectedRow(mainGridManager);
editor: {required: false, type: "text"} if (!row){
return ;
}
itemGridManager.updateRow(editParam,
{
matnr: row.matnr,
txz01:row.maktx,
lgort:row.lgfsb,
lgobe:row.lgobe,
matkl:row.matkl,
ekgrp:row.ekgrp,
peinh:row.peinh,
meins:row.meins,
});
return true;
},
close:true
});
}
}
}, },
{display: "库存地点", name: "lgort", width: "100", align: "left", type: "string", {display: "库存地点", name: "lgort", width: "100", align: "left", type: "string",
editor: { editor: {
...@@ -188,13 +207,13 @@ function getGridColumns() { ...@@ -188,13 +207,13 @@ function getGridColumns() {
editor: {required: false, type: "date"} editor: {required: false, type: "date"}
}, },
{display: "创建日期", name: "erdat", width: "100", align: "left", type: "string", {display: "创建日期", name: "erdat", width: "100", align: "left", type: "string",
editor: {required: false, type: "date"} //editor: {required: false, type: "date"}
}, },
{display: "批准日期", name: "frgdt", width: "80", align: "left", type: "string", {display: "批准日期", name: "frgdt", width: "80", align: "left", type: "string",
editor: {required: false, type: "date"} editor: {required: false, type: "date"}
}, },
{display: "要求交货日期", name: "lfdat", width: "100", align: "left", type: "string", {display: "要求交货日期", name: "lfdat", width: "100", align: "left", type: "string",
editor: {required: false, type: "date"} editor: {required: true, type: "date"}
}, },
{display: "服务主数据编号", name: "srvpos", width: "80", align: "left", type: "string", {display: "服务主数据编号", name: "srvpos", width: "80", align: "left", type: "string",
editor: {type: 'text', required: false}, editor: {type: 'text', required: false},
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</head> </head>
<body> <body>
<div class="container-fluid"> <div class="container-fluid">
<x:billTitle title="采购申请" needStatus="true" needPerson="true"/> <x:billTitle title="采购申请审批" needStatus="true" needPerson="true"/>
<form class="hg-form" method="post" action="" id="submitForm"> <form class="hg-form" method="post" action="" id="submitForm">
<x:hidden name="id"/> <x:hidden name="id"/>
<x:hidden name="version"/> <x:hidden name="version"/>
......
var mainGridManager = null,refreshFlag = false;
$(document).ready(function () {
initializeGrid();
}
);
//初始化提前备料表格
function initializeGrid() {
let toolbarOptions = UICtrl.getDefaultToolbarOptions({
});
mainGridManager = UICtrl.grid('#mainGrid', {
columns: getGridColumns(),
dataAction: 'server',
url: web_app.name + '/sapDialogSelect/sapMaterialSelect.ajax',
parms: {
//query:"0"
},
width: '100%',
height: '300',
checkbox: true,
heightDiff: -5,
//sortName: 'createdDate',
//sortOrder: 'desc',
toolbar: toolbarOptions
});
UICtrl.setSearchAreaToggle(mainGridManager);
}
function getGridColumns(){
var columns=[];
columns.push({display:"工厂", name: "werks", title:"工厂", width: 100, minWidth: 60, type: "string", align: "left",});
columns.push({display:"工厂名称", name: "name1", title: "工厂名称", width: 200, minWidth: 60, type: "string", align: "left"});
columns.push({display:"物料编码", name: "matnr", title: "物料编码", width: 300, minWidth: 60, type: "string", align: "left"});
columns.push({display:"物料名称", name: "maktx", title: "物料名称", width: 300, minWidth: 60, type: "string", align: "left"});
columns.push({display:"库存地点", name: "lgfsb", title: "库存地点", width: 100, minWidth: 60, type: "string", align: "left"});
columns.push({display:"库存地点名称", name: "lgobe", title: "库存地点名称", width: 200, minWidth: 60, type: "string", align: "left"});
columns.push({display:"物料组", name: "matkl", title: "物料组", width: 100, minWidth: 60, type: "string", align: "left"});
columns.push({display:"物料组名称", name: "wgbez", title: "物料组名称", width: 200, minWidth: 60, type: "string", align: "left"});
columns.push({display:"基本计量单位", name: "meins", title: "基本计量单位", width: 100, minWidth: 60, type: "string", align: "left"});
columns.push({display:"基本计量单位名称", name: "msehl", title: "基本计量单位名称", width: 100, minWidth: 60, type: "string", align: "left"});
columns.push({display:"采购组", name: "ekgrp", title: "采购组", width: 100, minWidth: 60, type: "string", align: "left"});
columns.push({display:"采购组名称", name: "eknam", title: "采购组名称", width: 200, minWidth: 60, type: "string", align: "left"});
columns.push({display:"价格基数", name: "peinh", title: "价格基数", width: 100, minWidth: 60, type: "string", align: "left"});
return columns;
}
// 查询
function query(obj) {
let param = $(obj).formToJSON();
UICtrl.gridSearch(mainGridManager, param);
}
//关闭对话框
function dialogClose(){
if(refreshFlag){
reloadGrid();
refreshFlag=false;
}
}
//重置表单
function resetForm(obj) {
$(obj).formClean();
}
\ No newline at end of file
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/taglib.tld" prefix="x" %>
<html>
<head>
<x:script src='/biz/topsun/sap/sapDialogSelect/sapMaterial.js'/>
</head>
<body>
<div class="container-fluid">
<form method="post" class="hg-form" action="" id="queryMaterialForm" style="width:90%;">
<div class="hg-form-row">
<x:inputC name="werks" title="工厂" required="false" label="工厂" labelCol="2"/>
<x:inputC name="matkl" title="物料组" required="false" label="物料组" labelCol="2"/>
<x:inputC name="maktx" title="物料名称" label="物料名称" labelCol="2"/>
</div>
<x:searchButtons/>
</form>
<div class="blank_div"></div>
<div id="mainGrid"></div>
</div>
</body>
\ No newline at end of file
...@@ -2,7 +2,7 @@ package com.huigou.topsun.controller; ...@@ -2,7 +2,7 @@ package com.huigou.topsun.controller;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.huigou.cache.DictUtil; import com.huigou.cache.DictUtil;
import com.huigou.topsun.sap.dictionary.application.SapDictionaryApplication; import com.huigou.topsun.sap.sapApplication.dictionary.application.SapDictionaryApplication;
import com.huigou.uasp.annotation.ControllerMapping; import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.bmp.common.easysearch.EasySearch; import com.huigou.uasp.bmp.common.easysearch.EasySearch;
import com.huigou.uasp.bmp.common.easysearch.domain.model.EasySearchParse; import com.huigou.uasp.bmp.common.easysearch.domain.model.EasySearchParse;
...@@ -28,41 +28,6 @@ public class ResourceSearchController { ...@@ -28,41 +28,6 @@ public class ResourceSearchController {
@Resource @Resource
private SapDictionaryApplication sapDictionaryApplication; private SapDictionaryApplication sapDictionaryApplication;
@EasySearch(queryName = "sapMaterialSelect")
public Map<String, Object> sapMaterialSelect(SDO sdo){
Integer intPage = sdo.getInteger("intPage", 1);
Integer pageSize = sdo.getInteger("pageSize",10);
PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
List<QuerySchemeField> fields =
Arrays.asList(new QuerySchemeField("materialId", "materialId", "hidden"),
new QuerySchemeField("物料名称", "materialName", "string", 200L),
new QuerySchemeField("物料编码", "materialCode", "string", 200L),
new QuerySchemeField("SAP物料相关内容", "materialJson", "hidden", 200L),
new QuerySchemeField("物料计量单位", "materialUnit", "string", 100L)
);
EasySearchParse easySearchParse = new EasySearchParse();
easySearchParse.setFields(fields);
easySearchParse.setWidth(450L);
Map<String ,Object> map = new HashMap<>();
map.put("materialId","1");
map.put("materialCode","code1");
map.put("materialName","测试物料1");
map.put("materialJson","相关内容11");
map.put("materialUnit","张");
Map<String ,Object> map2 = new HashMap<>();
map2.put("materialId","2");
map2.put("materialCode","code2");
map2.put("materialName","测试物料2");
map2.put("materialJson","相关内容22");
map2.put("materialUnit","张");
List<Map<String,Object>> mapList = new ArrayList<>();
mapList.add(map);
mapList.add(map2);
MemEasySearcher<Map<String, Object>> memEasySearcher = new MemEasySearcherImpl<>();
Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
return model;
}
@EasySearch(queryName = "knttp") @EasySearch(queryName = "knttp")
public Map<String, Object> knttpSelect(SDO sdo){ public Map<String, Object> knttpSelect(SDO sdo){
Integer intPage = sdo.getInteger("intPage", 1); Integer intPage = sdo.getInteger("intPage", 1);
...@@ -96,6 +61,29 @@ public class ResourceSearchController { ...@@ -96,6 +61,29 @@ public class ResourceSearchController {
return model; return model;
} }
@EasySearch(queryName = "sapMaterialSelect")
public Map<String, Object> sapMaterialSelect(SDO sdo) throws IOException {
String fieldName = sdo.getString("paramValue");
List<Map<String, Object>> mapList = sapDictionaryApplication.getSapDictionary(fieldName);
List<QuerySchemeField> fields = new ArrayList<>();
if (CollectionUtil.isNotEmpty(mapList)){
Map<String, Object> map = mapList.get(0);
map.keySet().forEach(key->{
QuerySchemeField querySchemeField = new QuerySchemeField("",key,"string",200L);
fields.add(querySchemeField);
});
}
Integer intPage = sdo.getInteger("intPage", 1);
Integer pageSize = sdo.getInteger("pageSize",10);
PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
EasySearchParse easySearchParse = new EasySearchParse();
easySearchParse.setFields(fields);
easySearchParse.setWidth(450L);
MemEasySearcher<Map<String, Object>> memEasySearcher = new MemEasySearcherImpl<>();
Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
return model;
}
@EasySearch(queryName = "dictionary") @EasySearch(queryName = "dictionary")
public Map<String, Object> queryDictionary(SDO sdo) throws IOException { public Map<String, Object> queryDictionary(SDO sdo) throws IOException {
String fieldName = sdo.getString("paramValue"); String fieldName = sdo.getString("paramValue");
......
...@@ -54,14 +54,14 @@ public class SapPurchaseApplicationImpl extends FlowBroker implements SapPurchas ...@@ -54,14 +54,14 @@ public class SapPurchaseApplicationImpl extends FlowBroker implements SapPurchas
List<SapPurchaseItem> sapPurchaseItems = getBizEntities(SapPurchaseItem.class, "sapPurchaseItems"); List<SapPurchaseItem> sapPurchaseItems = getBizEntities(SapPurchaseItem.class, "sapPurchaseItems");
sapPurchaseItemApplication.saveSapPurchaseItems(sapPurchase.getId(),sapPurchaseItems); sapPurchaseItemApplication.saveSapPurchaseItems(sapPurchase.getId(),sapPurchaseItems);
List<SapPurchaseVo> purchaseVoList = this.getSapPurchaseVoJson(sapPurchase); /*List<SapPurchaseVo> purchaseVoList = this.getSapPurchaseVoJson(sapPurchase);
try { try {
String url = SystemCache.getParameter("sap.purchase.url", String.class); String url = SystemCache.getParameter("sap.purchase.url", String.class);
String execute = httpClient.execute(purchaseVoList, url); String execute = httpClient.execute(purchaseVoList, url);
System.out.println("返回结果:"+execute); System.out.println("返回结果:"+execute);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }*/
return sapPurchase.getId(); return sapPurchase.getId();
} }
......
package com.huigou.topsun.sap.sapApplication.controller;
import com.huigou.topsun.sap.sapApplication.domain.query.SapDialogQuery;
import com.huigou.topsun.sap.sapApplication.materail.SapMaterialApplication;
import com.huigou.topsun.sap.sapApplication.domain.query.SapDialogQueryRequest;
import com.huigou.topsun.sap.sapApplication.materail.vo.SapMaterialVo;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.client.CommonController;
import com.huigou.util.SDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @Auther: xin.lu
* @Date: 2024/03/03/11:20
* @Description: 选择SAP数据的dialog页面控制器
*/
@Controller
@ControllerMapping("sapDialogSelect")
public class SapDialogSelectController extends CommonController {
@Autowired
private SapMaterialApplication sapMaterialApplication;
@Override
protected String getPagePath() {
return "/biz/topsun/sap/sapDialogSelect/";
}
public String forwardSapMaterial(){
return forward("sapMaterial");
}
public String sapMaterialSelect() throws IOException {
SDO sdo = this.getSDO();
SapDialogQuery queryRequest = sdo.toObject(SapDialogQuery.class);
List<SapMaterialVo> sapMaterial = sapMaterialApplication.getSapMaterial(queryRequest);
return packGridDataAndResult(sapMaterial);
}
}
package com.huigou.topsun.sap.dictionary.application; package com.huigou.topsun.sap.sapApplication.dictionary.application;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
......
package com.huigou.topsun.sap.dictionary.application.impl; package com.huigou.topsun.sap.sapApplication.dictionary.application.impl;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.huigou.cache.SystemCache; import com.huigou.cache.SystemCache;
import com.huigou.topsun.sap.common.HttpClient; import com.huigou.topsun.sap.common.HttpClient;
import com.huigou.topsun.sap.dictionary.application.SapDictionaryApplication; import com.huigou.topsun.sap.sapApplication.dictionary.application.SapDictionaryApplication;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
......
package com.huigou.topsun.sap.dictionary.controller; package com.huigou.topsun.sap.sapApplication.dictionary.controller;
import com.huigou.topsun.sap.dictionary.application.SapDictionaryApplication; import com.huigou.topsun.sap.sapApplication.dictionary.application.SapDictionaryApplication;
import com.huigou.uasp.annotation.ControllerMapping; import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.annotation.SkipAuth; import com.huigou.uasp.annotation.SkipAuth;
import com.huigou.uasp.client.CommonController; import com.huigou.uasp.client.CommonController;
......
package com.huigou.topsun.sap.sapApplication.domain.query;
import lombok.Data;
/**
* @Auther: xin.lu
* @Date: 2024/03/03/11:49
* @Description:
*/
@Data
public class SapDialogQuery {
private String werks;
private String maktx;
private String matkl;
}
package com.huigou.topsun.sap.sapApplication.domain.query;
import com.huigou.data.domain.query.QueryAbstractRequest;
import lombok.Data;
/**
* @Auther: xin.lu
* @Date: 2024/03/03/11:49
* @Description:
*/
@Data
public class SapDialogQueryRequest extends QueryAbstractRequest {
private String name1;
private String maktx;
private String wgbez;
}
package com.huigou.topsun.sap.sapApplication.materail;
import com.huigou.topsun.sap.sapApplication.domain.query.SapDialogQuery;
import com.huigou.topsun.sap.sapApplication.materail.vo.SapMaterialVo;
import java.io.IOException;
import java.util.List;
/**
* @Auther: xin.lu
* @Date: 2024/03/03/11:12
* @Description:
*/
public interface SapMaterialApplication {
List<SapMaterialVo> getSapMaterial(SapDialogQuery queryRequest) throws IOException;
}
package com.huigou.topsun.sap.sapApplication.materail.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.topsun.sap.common.HttpClient;
import com.huigou.topsun.sap.purchaseInfoRecord.domain.SapResult;
import com.huigou.topsun.sap.sapApplication.domain.query.SapDialogQuery;
import com.huigou.topsun.sap.sapApplication.materail.SapMaterialApplication;
import com.huigou.topsun.sap.sapApplication.domain.query.SapDialogQueryRequest;
import com.huigou.topsun.sap.sapApplication.materail.vo.SapMaterialVo;
import com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicatorsResult;
import com.huigou.util.JSONUtil;
import com.huigou.util.StringUtil;
import oracle.sql.NUMBER;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Auther: xin.lu
* @Date: 2024/03/03/11:13
* @Description:
*/
@Service("sapMaterialApplication")
public class SapMaterialApplicationImpl implements SapMaterialApplication {
@Resource
private HttpClient httpClient;
@Override
public List<SapMaterialVo> getSapMaterial(SapDialogQuery queryRequest) throws IOException {
List<SapMaterialVo> sapMaterialVoList = new ArrayList<>();
/*if (StringUtil.isBlank(queryRequest.getWerks()) || StringUtil.isBlank(queryRequest.getMatkl())){
return sapMaterialVoList;
}*/
String paramJson = new ObjectMapper().writeValueAsString(queryRequest);
String json = httpClient.executeByJson(paramJson, "search/sch_matnr");
Map<String, Object> map = JSONUtil.toMap(json);
SapResult sapResult = JSONObject.parseObject(JSONUtil.toString(map.get("MSG")), SapResult.class);
if ("S".equals(sapResult.getTYPE())){
sapMaterialVoList = JSONObject.parseArray(JSONUtil.toString(map.get("RDATA")), SapMaterialVo.class);
}else {
throw new RuntimeException("查询物料失败:"+sapResult.getMESSAGE());
}
return sapMaterialVoList;
}
}
package com.huigou.topsun.sap.sapApplication.materail.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @Auther: xin.lu
* @Date: 2024/03/03/15:21
* @Description:
*/
@Data
public class SapMaterialVo implements Serializable {
private String WERKS;
private String NAME1;
private String MATNR;
private String MAKTX;
private String LGFSB;
private String LGOBE;
private String MATKL;
private String WGBEZ;
private String MEINS;
private String MSEHL;
private String EKGRP;
private String EKNAM;
private String PEINH;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment