Commit fca1c9db authored by 刘学辉's avatar 刘学辉

存货转移单接口、选择框动态配置宽度

parent 6a0c2432
...@@ -74,7 +74,7 @@ function loadGrid() { ...@@ -74,7 +74,7 @@ function loadGrid() {
UICtrl.addGridRow(gridManager, UICtrl.addGridRow(gridManager,
{ {
// 行号加一 // 行号加一
ebelp: gridManager.getData().length + 1,reprf:"X" ebelp: (gridManager.getData().length + 1)*10,reprf:"X"
} }
); );
}, },
...@@ -97,8 +97,8 @@ function loadGrid() { ...@@ -97,8 +97,8 @@ function loadGrid() {
gridManager = UICtrl.grid("#maingrid", { gridManager = UICtrl.grid("#maingrid", {
columns: [ columns: [
{ {
display: "行号", name: "ebelp", width: 100, minWidth: 60, type: "String", align: "left", display: "行号", name: "ebelp", width: 100, minWidth: 60, type: "String", align: "left"
editor: {type: 'spinner', min: 1, max: 100, mask: 'nn'} // editor: {type: 'spinner', min: 1, max: 100, mask: 'nn'}
}, },
// { display: "项目类别", name: "epstp", width: 380, minWidth: 200, type: "string", align: "left", // { display: "项目类别", name: "epstp", width: 380, minWidth: 200, type: "string", align: "left",
// editor: { type: "text",required: true } // editor: { type: "text",required: true }
...@@ -139,16 +139,20 @@ function loadGrid() { ...@@ -139,16 +139,20 @@ function loadGrid() {
{display: "数量", name: "menge", width: 120, minWidth: 60, type: "string", align: "left", {display: "数量", name: "menge", width: 120, minWidth: 60, type: "string", align: "left",
editor: { type: "text",mask: 'nnnn',required: true } editor: { type: "text",mask: 'nnnn',required: true }
}, },
{ display: "单位", name: "meinsTextView", width: 120, minWidth: 60, type: "string", align: "left", { display: "单位", name: "meinsName", width: 120, minWidth: 60, type: "string", align: "left",
editor: { editor: {
type: 'dictionary', required: false, type: "select",
data: {name: 'sapPermitUnit'}, data: {
textField: 'meinsTextView', type: 'system',
valueField: 'meins', name: "dictionary",
required: true, getParam: function (item) {
render: function (item) { return {fieldName: "MEINS"}
return item.meinsTextView; },
},required: true back: {
MSEHI: "meins",
MSEHL: "meinsName"
}
},
} }
}, },
......
...@@ -143,9 +143,9 @@ public class ResourceSearchController { ...@@ -143,9 +143,9 @@ public class ResourceSearchController {
EasySearchParse easySearchParse = new EasySearchParse(); EasySearchParse easySearchParse = new EasySearchParse();
List<QuerySchemeField> fields = List<QuerySchemeField> fields =
Arrays.asList( Arrays.asList(
new QuerySchemeField("工厂", "WERKS", "string", 100L), new QuerySchemeField("工厂", "WERKS", "string", 60L),
new QuerySchemeField("工厂名称", "NAME1", "string", 200L), new QuerySchemeField("工厂名称", "NAME1", "string", 160L),
new QuerySchemeField("物料编码", "MATNR", "string", 200L), new QuerySchemeField("物料编码", "MATNR", "string", 140L),
new QuerySchemeField("物料名称", "MAKTX", "string", 200L), new QuerySchemeField("物料名称", "MAKTX", "string", 200L),
new QuerySchemeField("库存地点", "LGFSB", "string", 100L), new QuerySchemeField("库存地点", "LGFSB", "string", 100L),
new QuerySchemeField("库存地点名称", "LGOBE", "string", 200L), new QuerySchemeField("库存地点名称", "LGOBE", "string", 200L),
...@@ -158,7 +158,7 @@ public class ResourceSearchController { ...@@ -158,7 +158,7 @@ public class ResourceSearchController {
new QuerySchemeField("价格基数", "PEINH", "string", 100L) new QuerySchemeField("价格基数", "PEINH", "string", 100L)
); );
easySearchParse.setFields(fields); easySearchParse.setFields(fields);
easySearchParse.setWidth(450L); easySearchParse.setWidth(500L);
MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>(); MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null); Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
return model; return model;
...@@ -224,6 +224,7 @@ public class ResourceSearchController { ...@@ -224,6 +224,7 @@ public class ResourceSearchController {
List<Map<String, String>> mapList = new ArrayList<>(); List<Map<String, String>> mapList = new ArrayList<>();
mapList = sapDictionaryApplication.getSapDictionary(fieldName); mapList = sapDictionaryApplication.getSapDictionary(fieldName);
List<QuerySchemeField> fields = new ArrayList<>(); List<QuerySchemeField> fields = new ArrayList<>();
Long totalWidths=100L;
if (CollectionUtil.isNotEmpty(mapList)){ if (CollectionUtil.isNotEmpty(mapList)){
if (StringUtil.isNotBlank(filterValue)){//固定条件过滤,比如选了工厂后,只能读取改工厂下的物料组 if (StringUtil.isNotBlank(filterValue)){//固定条件过滤,比如选了工厂后,只能读取改工厂下的物料组
String[] split = filterValue.split(","); String[] split = filterValue.split(",");
...@@ -241,14 +242,50 @@ public class ResourceSearchController { ...@@ -241,14 +242,50 @@ public class ResourceSearchController {
.filter(map -> map.values().stream().anyMatch(value->value.contains(param))) .filter(map -> map.values().stream().anyMatch(value->value.contains(param)))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if (!CollectionUtils.isEmpty(mapList)){ if (!CollectionUtils.isEmpty(mapList)){
Map<String, String> map = mapList.get(0); Map<String, String> map = mapList.get(0);
map.keySet().forEach(key->{ String []widths=new String[map.size()];
QuerySchemeField querySchemeField = new QuerySchemeField(key,key,"string",300L); for (int i=0;i<mapList.size();i++){
Map<String, String> mapp = mapList.get(i);
int u=0;
for (String key : mapp.keySet()) {
if (widths[u]==null){
widths[u] = "40";
}
String tmpWidth=widths[u];
String value=(String) mapp.get(key);
if (value.trim().length()>10){
if (Integer.parseInt(tmpWidth)<150){
widths[u]="120";
}
}
u++;
}
}
for (int y=0;y<widths.length;y++){
totalWidths+=Long.valueOf(widths[y]);
}
// map.keySet().forEach((index,key)->{
/* String widths="30";
String value=(String) map.get(key);
if (value.trim().length()>10){
widths="100";
}*/
// QuerySchemeField querySchemeField = new QuerySchemeField(key,key,"string",Long.valueOf(widths[0]));
// fields.add(querySchemeField);
//});
int x=0;
for (String key : map.keySet()) {
QuerySchemeField querySchemeField = new QuerySchemeField(key,key,"string",Long.valueOf(widths[x]));
fields.add(querySchemeField); fields.add(querySchemeField);
}); x++;
} }
} }
}
System.out.println("数据条数:"+ mapList.size()); System.out.println("数据条数:"+ mapList.size());
String string = JSONUtil.toString(mapList); String string = JSONUtil.toString(mapList);
Integer intPage = sdo.getInteger("intPage", 1); Integer intPage = sdo.getInteger("intPage", 1);
...@@ -256,7 +293,7 @@ public class ResourceSearchController { ...@@ -256,7 +293,7 @@ public class ResourceSearchController {
PageRequest pageRequest = new PageRequest(intPage - 1, pageSize); PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
EasySearchParse easySearchParse = new EasySearchParse(); EasySearchParse easySearchParse = new EasySearchParse();
easySearchParse.setFields(fields); easySearchParse.setFields(fields);
easySearchParse.setWidth(450L); easySearchParse.setWidth(totalWidths);
MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>(); MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null); Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
return model; return model;
......
...@@ -38,7 +38,8 @@ public class SapMutualEpLogApplicationImpl extends FlowBroker implements SapMutu ...@@ -38,7 +38,8 @@ public class SapMutualEpLogApplicationImpl extends FlowBroker implements SapMutu
sapMutualEpLog.setBusinessId(map.get("businessId")!=null?map.get("businessId").toString():""); sapMutualEpLog.setBusinessId(map.get("businessId")!=null?map.get("businessId").toString():"");
sapMutualEpLog.setBusinessType(map.get("businessType")!=null?map.get("businessType").toString():""); sapMutualEpLog.setBusinessType(map.get("businessType")!=null?map.get("businessType").toString():"");
sapMutualEpLog = ClassHelper.fromMap(SapMutualEpLog.class, map); sapMutualEpLog = ClassHelper.fromMap(SapMutualEpLog.class, map);
sapMutualEpLog.setMessage(map.get("MESSAGE").toString()); String message = map.get("MESSAGE")!=null?map.get("MESSAGE").toString():"";
sapMutualEpLog.setMessage(message);
//BeanUtil.mapToBean(map, ClassHelpersapMutualEpLog); //BeanUtil.mapToBean(map, ClassHelpersapMutualEpLog);
Date date = new Date(); Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......
...@@ -303,7 +303,7 @@ public class NonProdApplyController extends CommonController { ...@@ -303,7 +303,7 @@ public class NonProdApplyController extends CommonController {
LOG.info("参数:=={}",prodApplyFromSapVO); LOG.info("参数:=={}",prodApplyFromSapVO);
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("type", "S"); resultMap.put("type", "S");
resultMap.put("message","成功"); resultMap.put("MESSAGE","成功");
resultMap.put("businessType", "接收SAP产品数据"); resultMap.put("businessType", "接收SAP产品数据");
resultMap.put("businessId",prodApplyFromSapVO.getMatnr().length()>31?prodApplyFromSapVO.getMatnr().substring(0,31):prodApplyFromSapVO.getMatnr()); resultMap.put("businessId",prodApplyFromSapVO.getMatnr().length()>31?prodApplyFromSapVO.getMatnr().substring(0,31):prodApplyFromSapVO.getMatnr());
...@@ -323,12 +323,12 @@ public class NonProdApplyController extends CommonController { ...@@ -323,12 +323,12 @@ public class NonProdApplyController extends CommonController {
resultMap.put("type", "E"); resultMap.put("type", "E");
} }
} }
resultMap.put("message",message); resultMap.put("MESSAGE",message);
}catch (Exception e){ }catch (Exception e){
messageMap.put("Message_Status","E"); messageMap.put("Message_Status","E");
messageMap.put("Message_Text",e); messageMap.put("Message_Text",e);
resultMap.put("type", "E"); resultMap.put("type", "E");
resultMap.put("message",e.getMessage()); resultMap.put("MESSAGE",e.getMessage());
} }
sapMutualEpLogApplication.saveSapMutualEpLog(resultMap); sapMutualEpLogApplication.saveSapMutualEpLog(resultMap);
return messageMap; return messageMap;
......
...@@ -378,7 +378,7 @@ public class SuppliersDataApplicationImpl extends FlowBroker implements Supplier ...@@ -378,7 +378,7 @@ public class SuppliersDataApplicationImpl extends FlowBroker implements Supplier
if ("S".equals(sapResult.getTYPE())&&"0".equals(suppliersInfo.getApplyType())) { if ("S".equals(sapResult.getTYPE())&&"0".equals(suppliersInfo.getApplyType())) {
suppliersInfo.setPartner(sapResult.getMESSAGE_V1()); suppliersInfo.setPartner(sapResult.getMESSAGE_V1());
resultMap.put("type", sapResult.getTYPE()); resultMap.put("type", sapResult.getTYPE());
resultMap.put("message", sapResult.getMESSAGE()); resultMap.put("MESSAGE", sapResult.getMESSAGE());
suppliersInfoRepository.save(suppliersInfo); suppliersInfoRepository.save(suppliersInfo);
} else { } else {
...@@ -386,7 +386,7 @@ public class SuppliersDataApplicationImpl extends FlowBroker implements Supplier ...@@ -386,7 +386,7 @@ public class SuppliersDataApplicationImpl extends FlowBroker implements Supplier
} }
} catch (Exception e) { } catch (Exception e) {
resultMap.put("type", "E"); resultMap.put("type", "E");
resultMap.put("message", e.getMessage()); resultMap.put("MESSAGE", e.getMessage());
throw new RuntimeException("数据传输失败请检查数据后重试!" + e.getMessage()); throw new RuntimeException("数据传输失败请检查数据后重试!" + e.getMessage());
} finally { } finally {
sapMutualEpLogApplication.saveSapMutualEpLog(resultMap); sapMutualEpLogApplication.saveSapMutualEpLog(resultMap);
......
package com.huigou.topsun.sap.transfers.application.impl; package com.huigou.topsun.sap.transfers.application.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.cache.DictUtil; import com.huigou.cache.DictUtil;
import com.huigou.data.query.model.QueryDescriptor; import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.data.query.model.QueryModel; import com.huigou.data.query.model.QueryModel;
import com.huigou.topsun.base.coderule.application.CodeRuleApplication; import com.huigou.topsun.base.coderule.application.CodeRuleApplication;
import com.huigou.topsun.sap.common.DefaultHttpClient;
import com.huigou.topsun.sap.common.application.SapMutualEpLogApplication;
import com.huigou.topsun.sap.common.domain.SapResult;
import com.huigou.topsun.sap.suppliers.domain.SuppliersBank;
import com.huigou.topsun.sap.suppliers.domain.SuppliersBuyer;
import com.huigou.topsun.sap.suppliers.domain.SuppliersInfo;
import com.huigou.topsun.sap.suppliers.domain.SuppliersPay;
import com.huigou.topsun.sap.suppliers.domain.vo.SuppliersBankVo;
import com.huigou.topsun.sap.suppliers.domain.vo.SuppliersBuyerVo;
import com.huigou.topsun.sap.suppliers.domain.vo.SuppliersInfoVo;
import com.huigou.topsun.sap.suppliers.domain.vo.SuppliersPayVo;
import com.huigou.topsun.sap.transfers.application.SapStockTransfersApplication; import com.huigou.topsun.sap.transfers.application.SapStockTransfersApplication;
import com.huigou.topsun.sap.transfers.application.SapStockTransfersItemApplication; import com.huigou.topsun.sap.transfers.application.SapStockTransfersItemApplication;
import com.huigou.topsun.sap.transfers.domain.SapStockTransfers; import com.huigou.topsun.sap.transfers.domain.SapStockTransfers;
import com.huigou.topsun.sap.transfers.domain.SapStockTransfersItem; import com.huigou.topsun.sap.transfers.domain.SapStockTransfersItem;
import com.huigou.topsun.sap.transfers.domain.query.SapStockTransfersQueryRequest; import com.huigou.topsun.sap.transfers.domain.query.SapStockTransfersQueryRequest;
import com.huigou.topsun.sap.transfers.domain.vo.SapStockTransfersItemVO;
import com.huigou.topsun.sap.transfers.domain.vo.SapStockTransfersVO;
import com.huigou.topsun.sap.transfers.repository.SapStockTransfersItemRepository; import com.huigou.topsun.sap.transfers.repository.SapStockTransfersItemRepository;
import com.huigou.topsun.sap.transfers.repository.SapStockTransfersRepository; import com.huigou.topsun.sap.transfers.repository.SapStockTransfersRepository;
import com.huigou.uasp.bmp.common.BizBillStatus; import com.huigou.uasp.bmp.common.BizBillStatus;
...@@ -21,6 +38,9 @@ import org.activiti.engine.delegate.DelegateTask; ...@@ -21,6 +38,9 @@ import org.activiti.engine.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -41,6 +61,11 @@ public class SapStockTransfersApplicationImpl extends FlowBroker implements SapS ...@@ -41,6 +61,11 @@ public class SapStockTransfersApplicationImpl extends FlowBroker implements SapS
private AttachmentApplication attachmentApplication; private AttachmentApplication attachmentApplication;
@Autowired @Autowired
private CodeRuleApplication codeRuleApplication; private CodeRuleApplication codeRuleApplication;
@Autowired
DefaultHttpClient defaultHttpClient;
@Autowired
SapMutualEpLogApplication sapMutualEpLogApplication;
@Override @Override
public Map<String, Object> getStockTransfersList(SapStockTransfersQueryRequest queryRequest) { public Map<String, Object> getStockTransfersList(SapStockTransfersQueryRequest queryRequest) {
QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "sapStockTransfers"); QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "sapStockTransfers");
...@@ -96,9 +121,25 @@ public class SapStockTransfersApplicationImpl extends FlowBroker implements SapS ...@@ -96,9 +121,25 @@ public class SapStockTransfersApplicationImpl extends FlowBroker implements SapS
super.onEnd(delegateExecution); super.onEnd(delegateExecution);
String bizId = delegateExecution.getProcessBusinessKey(); String bizId = delegateExecution.getProcessBusinessKey();
BizBillStatus status = approvePassed() ? BizBillStatus.COMPLETED : BizBillStatus.ABORTED; BizBillStatus status = approvePassed() ? BizBillStatus.COMPLETED : BizBillStatus.ABORTED;
SapStockTransfers StockTransfers = sapStockTransfersRepository.findOne(bizId); SapStockTransfers stockTransfers = sapStockTransfersRepository.findOne(bizId);
StockTransfers.setStatusId(status.getId()); stockTransfers.setStatusId(status.getId());
sapStockTransfersRepository.save(StockTransfers); sapStockTransfersRepository.save(stockTransfers);
List <SapStockTransfersItem> itemList= sapStockTransfersItemApplication.findByTransfersId(stockTransfers.getId());
//推送SAP
SapStockTransfersVO sapStockTransfersVO=new SapStockTransfersVO();
BeanUtil.copyProperties(stockTransfers, sapStockTransfersVO);
List <SapStockTransfersItemVO> newItemList=new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (SapStockTransfersItem item:itemList){
SapStockTransfersItemVO sapStockTransfersItemVO=new SapStockTransfersItemVO();
BeanUtil.copyProperties(item, sapStockTransfersItemVO);
sapStockTransfersItemVO.setEeind(sdf.format(item.getEeind()));
sapStockTransfersItemVO.setWerks(stockTransfers.getWerks());
newItemList.add(sapStockTransfersItemVO);
}
sapStockTransfersVO.setItem(newItemList);
sendSapData(sapStockTransfersVO,stockTransfers.getId());
} }
@Override @Override
...@@ -154,5 +195,41 @@ public class SapStockTransfersApplicationImpl extends FlowBroker implements SapS ...@@ -154,5 +195,41 @@ public class SapStockTransfersApplicationImpl extends FlowBroker implements SapS
} }
/**
* 远程调用sap接口,传递数据
*/
public void sendSapData(SapStockTransfersVO sapStockTransfersVO,String id) {
ObjectMapper objectMapper = new ObjectMapper();
String url = "cud_po_zub/po_zub";
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("businessType", "存货转移数据");
resultMap.put("businessId", id);
resultMap.put("parameter", JSON.toJSONString(sapStockTransfersVO));
// List<SapStockTransfersVO> sapStockTransfersVOs = new ArrayList<>();
// sapStockTransfersVOs.add(sapStockTransfersVO);
try {
String result = defaultHttpClient.execute(sapStockTransfersVO, url);
List<SapResult> sapResultList = JSONObject.parseArray(result, SapResult.class);
if (sapResultList.size()<1){
throw new RuntimeException("数据传输失败,没有收到返回结果:" + sapResultList);
}
SapResult sapResult = sapResultList.get(0);
resultMap.put("sequence", resultMap.get("row"));
if ("S".equals(sapResult.getTYPE())) {
// suppliersInfo.setPartner(sapResult.getMESSAGE_V1());
resultMap.put("type", sapResult.getTYPE());
resultMap.put("MESSAGE", sapResult.getMESSAGE());
// suppliersInfoRepository.save(suppliersInfo);
} else {
throw new RuntimeException("数据传输失败,请稍后手动重试!" + sapResult.getMESSAGE());
}
} catch (Exception e) {
resultMap.put("type", "E");
resultMap.put("MESSAGE", e.getMessage());
throw new RuntimeException("数据传输失败请检查数据后重试!" + e.getMessage());
} finally {
sapMutualEpLogApplication.saveSapMutualEpLog(resultMap);
}
}
} }
...@@ -68,4 +68,8 @@ public class SapStockTransfersItem extends AbstractEntity { ...@@ -68,4 +68,8 @@ public class SapStockTransfersItem extends AbstractEntity {
@Column(name = "matnr_name") @Column(name = "matnr_name")
private String matnrName; private String matnrName;
@Column(name = "meins_name")
private String meinsName;
} }
\ No newline at end of file
package com.huigou.topsun.sap.transfers.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import javax.persistence.Column;
import java.util.Date;
@Data
public class SapStockTransfersItemVO {
//项目编号 EBELP
@JsonProperty("EBELP")
private String ebelp;
//项目类别
@JsonProperty("EPSTP")
private String epstp;
//物料编码
@Column(name = "MATNR")
private String matnr;
//数量
@Column(name = "MENGE")
private Integer menge;
//基本计量单位
@Column(name = "MEINS")
private String meins;
/**
* 交货日期
*/
@Column(name = "EEIND")
private String eeind;
//存储地点
@Column(name = "LOGORT")
private String lgort;
//工厂
@Column(name = "WERKS")
private String werks;
}
package com.huigou.topsun.sap.transfers.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.huigou.topsun.sap.suppliers.domain.vo.SuppliersPayVo;
import com.topsunit.query.annotations.Dictionary;
import lombok.Data;
import javax.persistence.Column;
import java.util.List;
@Data
public class SapStockTransfersVO {
//订单类型(采购)
@JsonProperty("BSART")
private String bsart;
/**
* 供货工厂
*/
@JsonProperty("LIFNR")
private String lifnr;
/*
*采购组织
*/
@JsonProperty("EKORG")
private String ekorg;
/**
* 采购组
*/
@JsonProperty("EKGRP")
private String ekgrp;
/*
* 公司代码
*/
@JsonProperty("BUKRS")
private String burks;
@JsonProperty("ITEM")
private List<SapStockTransfersItemVO> item;
}
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