Commit b715a812 authored by 1650842865's avatar 1650842865

供应商异常处理:货币结算(扣除应付款)通过sap接口创建数据

parent b6862956
......@@ -27,9 +27,11 @@ function initialize() {
});
if ((dealWay=="cash"&&"financial" === getSubProcUnitId())
||(dealWay=="pay"&&"buyer" === getSubProcUnitId())
//||(dealWay=="pay"&&"buyer" === getSubProcUnitId())
){
UICtrl.setElRequiredFlag("#sapBillNo",true);
}else {
UICtrl.setElRequiredFlag("#sapBillNo",false);
}
}
......@@ -270,44 +272,63 @@ columns1 = [
required: false, type: "select",
data: {
type: 'system',
name: "dictionary",
name: "sapPurchaseOrderSelect",
getParam: function (item) {
return {fieldName: "EKKO"}
return {
werks: $('#werks').val(),
lifnr: $("#customerNo").val()
}
},
//[
// {
// "EBELN": "8000000272",
// "EBELP": "00010",
// "GJAHR": "2025",
// "BELNR": "5000000409",
// "BUZEI": "0001",
// "BUKRS": "1000",
// "WERKS": "1000",
// "NAME1": "广州市宝绅科技有限公司",
// "MATNR": "000000000010100012",
// "TXZ01": "白格背印AW4200A",
// "BPMNG": 400000.000,
// "MEINS": "M2",
// "MSEHL": "平方米",
// "MWSKZ": "J0",
// "ZBRTWR": 720000.00,
// "WAERS": "USD",
// "KTEXT": "美元",
// "MENGE": 400000.000,
// "KWERT": 720000.00
// }
// ]
back: {
EBELN: "purchaseNo"
// MSEHL: "unitName"
EBELN: "purchaseNo",
EBELP: "ebelp",
GJAHR: "gjahr",
BELNR: "belnr",
BUZEI: "buzei",
BUKRS: "bukrs",
WERKS: "werks",
MATNR: "productCode",
TXZ01: "productName",
BPMNG: "bpmng",
MEINS: "unit",
MSEHL: "unitName",
MWSKZ: "mwskz",
WAERS: "waers",
KTEXT: "ktext",
MENGE: "menge",
ZBRTWR: "zbrtwr"
}
}
}
},
{
display: "产品名称", name: "productName", width: "200", align: "left", type: "string"
// , editor: {type: 'text', required: true}
,editor: {
required: true, type: "select",
data: {
type: 'system',
name: "sapMaterialSelect",
getParam: function (item) {
return {
// filterValue:item.company
}
},
back: {
MATNR: "productCode",
MAKTX: "productName",
// EKGRP: "ekgrp",
MEINS: "unit",
MSEHL: "unitName"
}
}
}
},
{
display: "产品编码", name: "productCode", width: "160", align: "left", type: "string"
//, editor: {type: 'text', required: true}
},
{
display: "数量", name: "number", width: "100", align: "left", type: "string"
......@@ -315,23 +336,15 @@ columns1 = [
},
{
display: "单位", name: "unitName", width: "80", align: "left", type: "string"
// ,editor: {type: "text"}
, editor: {
required: true, type: "select",
data: {
type: 'system',
name: "dictionary",
getParam: function (item) {
return {fieldName: "MEINS"}
},
back: {
MSEH3: "unit",
MSEHL: "unitName"
}
}
}
},
{display: "金额", name: "money", width: "100", align: "left", type: "string"
{
display: "货币", name: "ktext", width: "80", align: "left", type: "string"
},
{
display: "过账金额(含税)", name: "zbrtwr", width: "80", align: "left", type: "money"
},
//填写现有金额必须≤ZBRTWR(过账金额(含税))
{display: "金额", name: "money", width: "100", align: "left", type: "money"
,editor: {required: true,type: "text",mask: '9999999.999'}
},
{display: "日期", name: "sendDate", width: "140", align: "left", type: "date"
......@@ -549,7 +562,7 @@ if (processAction == ProcessAction.BACK
return false;
}
if (($("input[name='dealWay']")[x].value=="cash"&&"financial" === getSubProcUnitId())
||($("input[name='dealWay']")[x].value=="pay"&&"buyer" === getSubProcUnitId())
//||($("input[name='dealWay']")[x].value=="pay"&&"buyer" === getSubProcUnitId())
){
if ($('#sapBillNo').val()==""){
Public.errorTip("SAP单据编号必输!");
......
......@@ -318,6 +318,7 @@
<x:inputC name="ausmeName" label="投料计量单位" labelCol="1" fieldCol="2" wrapper="select"/>
<x:hidden name="ausme"/>
<x:inputC name="umrenProd" label="转换分母(生产)" labelCol="1" fieldCol="2"/>
<x:inputC name="umrezProd" label="转换分子(生产)" labelCol="1" fieldCol="2"/>
<x:selectC name="ueetk" label="允许未限制的过量交货" labelCol="1" fieldCol="2" dictionary="ueetk"/>
</div>
<div class="hg-form-row">
......
......@@ -161,6 +161,20 @@ function loadOrderItemGrid() {
})
amountChange();
}
if (item.column.name == "eeind"){
var _grid = UICtrl.getGridManager('#orderItemGrid');
if (_grid != null ){
var datas = _grid.rows;
if (datas.length > 0 ){
$.each(datas, function (i, row) {
orderItemGridManager.updateRow(row,{
eeind:item.value,
})
});
}
}
}
},
onAfterShowData:function (item) {
amountChange();
......
......@@ -67,6 +67,8 @@ public class ResourceSearchController {
private ExceptionReasonTypeDetailApplication exceptionReasonTypeDetailApplication;
@Autowired
private CashSettlementUnPayItemDetailApplication cashSettlementUnPayItemDetailApplication;
@Autowired
private SapOrderApplication sapOrderApplication;
@EasySearch(queryName = "knttp")
public Map<String, Object> knttpSelect(SDO sdo){
......@@ -993,4 +995,14 @@ public class ResourceSearchController {
return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
}
@EasySearch(queryName = "sapPurchaseOrderSelect")
public Map<String, Object> sapPurchaseOrderSelect(SDO sdo) throws IOException {
String param = sdo.getString("paramValue");
String werks = sdo.getString("werks");
String lifnr = sdo.getString("lifnr");
List<Map<String, String>> mapList = new ArrayList<>();
mapList = sapOrderApplication.sapPurchaseOrder(werks,lifnr);
return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
}
}
......@@ -22,6 +22,7 @@ import com.huigou.topsun.sap.common.domain.SapResult;
import com.huigou.topsun.sap.exceptionReport.application.*;
import com.huigou.topsun.sap.exceptionReport.domain.*;
import com.huigou.topsun.sap.exceptionReport.domain.query.ExceptionReportQueryRequest;
import com.huigou.topsun.sap.exceptionReport.domain.vo.ExceptionReportPayableVo;
import com.huigou.topsun.sap.exceptionReport.domain.vo.PurchaseOrderItemVo;
import com.huigou.topsun.sap.exceptionReport.domain.vo.PurchaseOrderVo;
......@@ -432,10 +433,9 @@ public class ExceptionReportApplicationImpl extends FlowBroker implements Except
ExceptionReport exceptionReport = this.findById(bizId);
exceptionReport.setStatusId(status.getId());
List <ExceptionReportGoods> goodslist=exceptionReportGoodsApplication.findByExceptionReportId(exceptionReport.getId());
//供应商异常 商品赔付 创建采购订单
if ("supplier".equals(exceptionReport.getBillType())) {
if ("supplier".equals(exceptionReport.getBillType())&&"goods".equals(exceptionReport.getDealWay())) {
List <ExceptionReportGoods> goodslist=exceptionReportGoodsApplication.findByExceptionReportId(exceptionReport.getId());
int u=0;
for (ExceptionReportGoods goods:goodslist ) {
u++;
......@@ -467,7 +467,7 @@ public class ExceptionReportApplicationImpl extends FlowBroker implements Except
purchaseOrderVo.setItem(itemVos);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("businessType", "供应商异常的采购订单");
resultMap.put("businessType", "供应商异常的商品结算");
resultMap.put("businessId", exceptionReport.getId());
resultMap.put("parameter", JSON.toJSONString(purchaseOrderVo));
try {
......@@ -498,6 +498,53 @@ public class ExceptionReportApplicationImpl extends FlowBroker implements Except
sapMutualEpLogApplication.saveSapMutualEpLog(resultMap);
}
}
}
//供应商异常 货币结算(扣除应付款)
if (("supplier".equals(exceptionReport.getBillType()))&&"pay".equals(exceptionReport.getDealWay())){
List<ExceptionReportPayable> payableList = exceptionReportPayableApplication.findByExceptionReportId(exceptionReport.getId());
List<ExceptionReportPayableVo> payableVoList = new ArrayList<>();
payableList.forEach(
payable -> {
ExceptionReportPayableVo payableVo = new ExceptionReportPayableVo();
BeanUtil.copyProperties(payable, payableVo);
payableVoList.add(payableVo);
}
);
Map<String,Object> map = new HashMap<>();
map.put("ZTYPE","SUPPDR");
map.put("ZCODE","I");
map.put("SUPPDR",payableVoList);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("businessType", "供应商异常的货币结算(扣除应付款)");
resultMap.put("businessId", exceptionReport.getId());
resultMap.put("parameter", JSON.toJSONString(map));
try {
String url = "cud_table";
//String url = SystemCache.getParameter("", String.class);
String execute = httpClient.execute(map, url);
List<SapResult> resultList = JSONObject.parseArray(execute, SapResult.class);
//SAP返回数据结构
SapResult sapResult = resultList.get(0);
if (!"S".equals(sapResult.getTYPE())) {
List<String> messages = resultList
.stream()
.map(SapResult::getMESSAGE).collect(Collectors.toList());
throw new RuntimeException("数据传输失败," + String.join(";", messages));
} else {
resultMap.put("TYPE", sapResult.getTYPE());
resultMap.put("MESSAGE", sapResult.getMESSAGE());
}
//SAP单据编号
exceptionReport.setSapBillNo(sapResult.getMESSAGE_V1());
//exceptionReport.setDealResult(sapResult.getMESSAGE_V1());
} catch (IOException e) {
resultMap.put("TYPE", "E");
resultMap.put("MESSAGE", e.getMessage());
throw new RuntimeException(e);
} finally {
sapMutualEpLogApplication.saveSapMutualEpLog(resultMap);
}
}
this.saveExceptionReport(exceptionReport);
//根据责任部门是采购部门 则生成供应商异常单
......
......@@ -66,4 +66,34 @@ public class ExceptionReportPayable extends AbstractEntity {
@Column(name = "remark")
private String remark;
@Column(name = "BUKRS", length = 4)
private String bukrs; // 公司代码 CHAR(4)
@Column(name = "EBELP", length = 5)
private String ebelp; // 采购凭证的项目编号 NUMC(5)
@Column(name = "GJAHR", length = 4)
private String gjahr; // 物料凭证的年份 NUMC(4)
@Column(name = "BELNR", length = 10)
private String belnr; // 物料凭证编号 CHAR(10)
@Column(name = "BUZEI", length = 4)
private String buzei; // 物料凭证中的项目 NUMC(4)
@Column(name = "BPMNG", precision = 13, scale = 3)
private BigDecimal bpmng; // 过账数量(订单单位) QUAN
@Column(name = "MWSKZ", length = 2)
private String mwskz; // 销售/购买税代码 CHAR(2)
@Column(name = "WAERS", length = 5)
private String waers; // 货币 CUKY(5)
@Column(name = "KTEXT", length = 4)
private String ktext; // 货币名称 CHAR(4)
@Column(name = "ZBRTWR", precision = 13, scale = 2)
private BigDecimal zbrtwr; // 过账金额(含税) CURR
}
package com.huigou.topsun.sap.exceptionReport.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author xin.lu
* @Description: TODO
* @date 2025/7/3016:07
*/
@Data
public class ExceptionReportPayableVo implements Serializable {
@JsonProperty("BUKRS")
private String bukrs; // 公司代码 CHAR(4)
@JsonProperty("EBELN")
private String purchaseNo; // 采购凭证编号 CHAR(10)
@JsonProperty("EBELP")
private String ebelp; // 采购凭证的项目编号 NUMC(5)
@JsonProperty("GJAHR")
private String gjahr; // 物料凭证的年份 NUMC(4)
@JsonProperty("BELNR")
private String belnr; // 物料凭证编号 CHAR(10)
@JsonProperty("BUZEI")
private String buzei; // 物料凭证中的项目 NUMC(4)
@JsonProperty("MATNR")
private String productCode; // 物料编码 CHAR(18)
@JsonProperty("TXZ01")
private String productName; // 物料描述 CHAR(40)
@JsonProperty("BPMNG")
private BigDecimal bpmng; // 过账数量(订单单位) QUAN
@JsonProperty("MEINS")
private String unit; // 订单单位 UNIT(3)
@JsonProperty("MWSKZ")
private String mwskz; // 销售/购买税代码 CHAR(2)
@JsonProperty("WAERS")
private String waers; // 货币 CUKY(5)
@JsonProperty("ZWRBTR")
private BigDecimal money; // 扣款金额(含税) CURR
}
package com.huigou.topsun.sap.sapApplication.application;
import com.huigou.topsun.sap.sapApplication.domain.query.SapPurchaseOrderQuery;
import java.util.List;
import java.util.Map;
/**
* @author xin.lu
* @Description: TODO
* @date 2025/7/3016:49
*/
public interface SapOrderApplication {
List<Map<String, String>> sapPurchaseOrder(String werks,String lifnr);
}
package com.huigou.topsun.sap.sapApplication.application.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
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.common.domain.SapResult;
import com.huigou.topsun.sap.sapApplication.application.SapOrderApplication;
import com.huigou.topsun.sap.sapApplication.domain.query.SapPurchaseOrderQuery;
import com.huigou.topsun.util.SAPUtils;
import com.huigou.util.JSONUtil;
import com.huigou.util.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author xin.lu
* @Description: 查询sap采购订单
* @date 2025/7/3016:49
*/
@Service("sapOrderApplication")
public class SapOrderApplicationImpl implements SapOrderApplication {
@Resource
private HttpClient httpClient;
@Override
public List<Map<String, String>> sapPurchaseOrder(String werks,String lifnr) {
List<Map<String,String>> sapMaterialVoList = new ArrayList<>();
//{
// "ZTYPE": "BRTWR",
// "data": {
// "WERKS": [
// {
// "SIGN": "I",
// "OPTION":"EQ",
// "LOW": "1000",
// "HIGH": ""
// }
// ],
// "LIFNR": [
// {
// "SIGN": "I",
// "OPTION":"EQ",
// "LOW": "0000100029",
// "HIGH": ""
// }
// ]
// }
//}
Map<String,Object> queryMap = new HashMap<>();
Map<String,Object> param = new HashMap<>();
queryMap.put("ZTYPE","BRTWR");
if (StringUtil.isNotBlank(werks)){
List<Map<String,Object>> werksList = new ArrayList<>();
Map<String, Object> param1 = buildParam(werks);
werksList.add(param1);
param.put("WERKS",werksList);
}
if (StringUtil.isNotBlank(lifnr)){
List<Map<String,Object>> lifnrList = new ArrayList<>();
Map<String, Object> param2 = buildParam(lifnr);
lifnrList.add(param2);
param.put("LIFNR",lifnrList);
}
queryMap.put("data",param);
try {
String json = httpClient.execute(queryMap, "sch_table");
ObjectMapper objectMapper = SAPUtils.objectMapper();
sapMaterialVoList = objectMapper.readValue(json, new TypeReference<List<Map<String, String>>>() {});
} catch (IOException e) {
throw new RuntimeException("查询sap采购订单失败:"+e.getMessage());
}
return sapMaterialVoList;
}
public Map<String,Object> buildParam(String value){
Map<String,Object> param = new HashMap<>();
param.put("SIGN","I");
param.put("OPTION","EQ");
param.put("LOW",value);
param.put("HIGH","");
return param;
}
}
package com.huigou.topsun.sap.sapApplication.domain.query;
import lombok.Data;
/**
* @author xin.lu
* @Description: TODO
* @date 2025/7/3016:52
*/
@Data
public class SapPurchaseOrderQuery {
private String werks;// 工厂代码
private String lifnr;//供应商编码
}
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