You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
531 lines
29 KiB
531 lines
29 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using CK.SCP.Models;
|
|
using CK.SCP.Models.Enums;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Models.UniApiEntity;
|
|
using Newtonsoft.Json;
|
|
using CK.SCP.Models.AppBoxEntity;
|
|
|
|
namespace CK.SCP.GrupUniApi.Controller
|
|
{
|
|
public static class OdbcApiScpController
|
|
{
|
|
private static string CreateSeq(string pre)
|
|
{
|
|
return pre + "_" + DateTime.Now.ToString(ScpCache.Config.SCP接口数据流水号格式);
|
|
}
|
|
private static void PutScpCtrl(UniApiEntities idb, string seq, string tableName, int rowCount, string p_domain, string p_site)
|
|
{
|
|
|
|
|
|
|
|
var wmsCtrl = new xxscm_ctrl
|
|
{
|
|
xxscm_seq = seq,
|
|
xxscm_table = tableName,
|
|
xxscm_table_qty = rowCount,
|
|
xxscm_qad = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_mes = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_scm = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_wms = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_rmks = "",
|
|
xxscm_domain = p_domain,
|
|
xxscm_site = (!string.IsNullOrEmpty(p_site)) ? p_site : p_domain,
|
|
//xxscm_create_time = DateTime.Now,
|
|
};
|
|
idb.xxscm_ctrl.Add(wmsCtrl);
|
|
}
|
|
|
|
public static void PutAll(ScpEntities sdb, UniApiEntities idb, List<TS_UNI_API> dataList)
|
|
{
|
|
var billNumList = dataList.Select(p => p.BillNum).Distinct();
|
|
|
|
foreach (string billNum in billNumList)
|
|
{
|
|
var list = dataList.Where(p => p.BillNum == billNum).ToList();
|
|
if (GlobalVar.ApiConfig.Scm采购订单)
|
|
PutScmPo(idb, list.Where(p => p.InterfaceType == UniApiType.Pobillnum.ToString()).ToList());
|
|
if (GlobalVar.ApiConfig.Scm大订单)
|
|
PutScmMaxPo(idb, list.Where(p => p.InterfaceType == UniApiType.MaxPobillnum.ToString()).ToList());
|
|
if (GlobalVar.ApiConfig.Scm发货单)
|
|
PutScmAsn(idb, list.Where(p => p.InterfaceType == UniApiType.Receive.ToString()).ToList());
|
|
//if (GlobalVar.ApiConfig.Scm条码明细)
|
|
// PutScmBarcode(idb, list.Where(p => p.InterfaceType == UniApiType.BarCode.ToString()).ToList());
|
|
//if (GlobalVar.ApiConfig.Scm发票)
|
|
// PutScmInvoice(idb, list.Where(p => p.InterfaceType == UniApiType.Invoice.ToString()).ToList());
|
|
Thread.Sleep(10);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 发货单
|
|
/// </summary>
|
|
/// <param name="idb"></param>
|
|
/// <param name="dataList"></param>
|
|
private static void PutScmAsn(UniApiEntities idb, List<TS_UNI_API> dataList)
|
|
{
|
|
var uni_api = dataList.FirstOrDefault();
|
|
string seq = string.Empty;
|
|
if (dataList.Count > 0)
|
|
{
|
|
seq = CreateSeq(string.IsNullOrEmpty(uni_api.Domain) ? uni_api.Site : uni_api.Domain);
|
|
}
|
|
var tableName = ScmTableName.xxscm_tx_mstr.ToString();
|
|
var qadDataList = new List<xxscm_tx_mstr>();
|
|
var qadDataList1 = new List<PURReplenishQties>();
|
|
foreach (var erpData in dataList)
|
|
{
|
|
|
|
var qadData1 = qadDataList1.FirstOrDefault(p => p.PURDOCNO == erpData.ErpBillNum
|
|
&& p.purDocLineNO == erpData.ErpLineNum.ToString()
|
|
);
|
|
|
|
if (qadData1 == null)
|
|
{
|
|
|
|
qadData1 = new PURReplenishQties
|
|
{
|
|
PURDOCNO = erpData.ErpBillNum,
|
|
purDocLineNO = erpData.Extend3,
|
|
replenishQty = erpData.PackQty,
|
|
client = "800",
|
|
plant = erpData.Site
|
|
|
|
};
|
|
//PutScpCtrl(idb, qadData.xxscm_tx_seq, tableName,1,wmsData.Domain,wmsData.Site );
|
|
qadDataList1.Add(qadData1);
|
|
}
|
|
erpData.State = (int)BillState.Finish;
|
|
erpData.PutTime = DateTime.Now;
|
|
|
|
}
|
|
foreach (var wmsData in dataList)
|
|
{
|
|
if (wmsData.Domain == "BJCIAI")
|
|
{
|
|
wmsData.Domain = "BJINTIER";
|
|
wmsData.Site = "BJCIAI";
|
|
}
|
|
var qadData = qadDataList.SingleOrDefault(p => p.xxscm_tx_nbr == wmsData.BillNum
|
|
&& p.xxscm_tx_domain == wmsData.Site
|
|
&& p.xxscm_tx_part == wmsData.PartCode && p.xxscm_tx_batch == wmsData.Batch && p.xxscm_tx_vend_batch == wmsData.VendBatch
|
|
&&p.xxscm_tx_po_line == wmsData.ErpLineNum.ToString());
|
|
if (qadData == null)
|
|
{
|
|
qadData = new xxscm_tx_mstr
|
|
{
|
|
xxscm_tx_seq = seq,
|
|
xxscm_tx_nbr = wmsData.BillNum,
|
|
|
|
xxscm_tx_part = wmsData.PartCode,
|
|
xxscm_tx_qadread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_wmsread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_scmread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_mesread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_createur = wmsData.CreateOper,
|
|
xxscm_tx_createdt = wmsData.CreateTime,
|
|
xxscm_tx_updateur = "",
|
|
xxscm_tx_updatedt = DateTime.Now,
|
|
xxscm_tx_rmks = "",
|
|
xxscm_tx_domain = wmsData.Domain,
|
|
xxscm_tx_po_nbr = wmsData.ErpBillNum,
|
|
xxscm_tx_po_line = wmsData.ErpLineNum.ToString(),
|
|
xxscm_tx_conv = wmsData.UmConv,
|
|
xxscm_tx_date_Promise = wmsData.ValidDate,
|
|
xxscm_tx_date_due = wmsData.CreateTime,
|
|
xxscm_tx_date_ship = wmsData.CreateTime,
|
|
xxscm_tx_loc_um = wmsData.LocUnit == null ? "" : wmsData.LocUnit,
|
|
xxscm_tx_po_um = wmsData.PoUnit == null ? "" : wmsData.PoUnit,
|
|
xxscm_tx_pprice = wmsData.Price,
|
|
xxscm_tx_qty_std = wmsData.PackQty,
|
|
xxscm_tx_qty_total = wmsData.Qty,
|
|
xxscm_tx_status = ((int)FormState.开放).ToString(),
|
|
xxscm_tx_type = wmsData.Barcode,//版本号
|
|
xxscm_tx_vend = wmsData.VendId,
|
|
xxscm_tx_vend_batch = wmsData.VendBatch,
|
|
xxscm_tx_ware = "",
|
|
xxscm_tx_ware_class =wmsData.ModType,//子件
|
|
xxscm_tx_batch = wmsData.Batch,
|
|
xxscm_tx_produce_date = wmsData.CreateTime,
|
|
xxscm_tx_site = (!string.IsNullOrEmpty(wmsData.Site)) ? wmsData.Site : wmsData.Domain
|
|
};
|
|
qadDataList.Add(qadData);
|
|
}
|
|
wmsData.State = (int)BillState.Finish;
|
|
wmsData.PutTime = DateTime.Now;
|
|
}
|
|
if (qadDataList.Count == 0) return;
|
|
//if (qadDataList1.Count == 0) return;
|
|
idb.xxscm_tx_mstr.AddRange(qadDataList);
|
|
idb.PURReplenishQty.AddRange(qadDataList1);
|
|
Console.WriteLine($"新增 发货单 数据:{qadDataList.Count} 条");
|
|
PutScpCtrl(idb, seq, tableName, qadDataList.Count, uni_api.Domain, uni_api.Site);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 采购订单
|
|
/// </summary>
|
|
/// <param name = "idb" ></ param >
|
|
/// < param name="dataList"></param>
|
|
private static void PutScmPo(UniApiEntities idb, List<TS_UNI_API> dataList)
|
|
{
|
|
var uni_api = dataList.FirstOrDefault();
|
|
string seq = string.Empty;
|
|
if (dataList.Count > 0)
|
|
{
|
|
seq = CreateSeq(string.IsNullOrEmpty(uni_api.Domain) ? uni_api.Site : uni_api.Domain);
|
|
}
|
|
|
|
var tableName = ScmTableName.xxscm_pod_det.ToString();
|
|
var qadDataList = new List<xxscm_pod_det>();
|
|
var qadDataList1 = new List<PURSubcontractors>();
|
|
foreach (var erpData in dataList)
|
|
{
|
|
string company ="";
|
|
if (erpData.Site == "W21")
|
|
{
|
|
company = "F02W21";
|
|
}
|
|
else
|
|
{
|
|
company = "F02U32";
|
|
}
|
|
var qadData1 = qadDataList1.SingleOrDefault(p => p.outPurDocNO == erpData.BillNum
|
|
&& p.outPurDocItemNO == erpData.ErpLineNum.ToString()
|
|
&& p.mtlNO == erpData.PartCode&&p.ctype==erpData.Receiver&&p.groupWareMaterielNO==erpData.Extend1);
|
|
if (qadData1 == null)
|
|
{
|
|
if (erpData.PartCode != null)
|
|
|
|
|
|
qadData1 = new PURSubcontractors
|
|
{
|
|
|
|
docDate = erpData.CreateTime,
|
|
returnsItem = erpData.Extend2,
|
|
purDocItemCtg = erpData.Invoice,
|
|
plant = erpData.Site,
|
|
purOrg = erpData.Site,
|
|
companyCode = company,
|
|
mtlNO = erpData.PartCode,
|
|
quantity = erpData.Qty,
|
|
itemDeliveryDate = erpData.PutTime,
|
|
price = erpData.Price,
|
|
baseUnitMeasure = erpData.PoUnit,
|
|
ordPriceUnit = erpData.Batch,
|
|
vendorNO = erpData.VendId,
|
|
purGrp = erpData.ModType,
|
|
ctype = erpData.Receiver,
|
|
measureBaseUnit = erpData.LocUnit,
|
|
groupWareMaterielNO = erpData.Extend1,
|
|
groupWarePlant = erpData.Site,
|
|
compRequireDate = erpData.PutTime,
|
|
COMPONQUANTITY = string.IsNullOrEmpty(erpData.ErpBillNum) ? 0 : decimal.Parse(erpData.ErpBillNum),
|
|
outPurDocNO = erpData.BillNum,
|
|
outPurDocItemNO = erpData.ErpLineNum.ToString(),
|
|
ordType = erpData.Barcode,
|
|
alternativeBOM = erpData.Currency,
|
|
storeLocation=erpData.Extend3,
|
|
createdBy=erpData.CreateOper,
|
|
remark=erpData.Attn
|
|
};
|
|
qadDataList1.Add(qadData1);
|
|
|
|
}
|
|
erpData.State = (int)BillState.Finish;
|
|
erpData.PutTime = DateTime.Now;
|
|
|
|
}
|
|
foreach (var wmsData in dataList)
|
|
{
|
|
var qadData = qadDataList.SingleOrDefault(p => p.xxscm_pod_nbr == wmsData.BillNum
|
|
&& p.xxscm_pod_nbr == wmsData.BillNum
|
|
&& p.xxscm_pod_part == wmsData.PartCode
|
|
&& p.xxscm_pod_line == wmsData.ErpLineNum&&p.xxscm_pod_groupWareMaterielNO==wmsData.Extend1);
|
|
|
|
if (qadData == null)
|
|
{
|
|
if (wmsData.PartCode != null)
|
|
qadData = new xxscm_pod_det
|
|
{
|
|
xxscm_pod_seq = seq,
|
|
xxscm_pod_nbr = wmsData.BillNum,
|
|
xxscm_pod_part = wmsData.PartCode,
|
|
xxscm_pod_line = wmsData.ErpLineNum,
|
|
xxscm_pod_modtype = "2",
|
|
xxscm_pod_site = wmsData.Site,
|
|
xxscm_pod_domain = wmsData.Domain,
|
|
xxscm_pod_qty_ord = wmsData.Qty,
|
|
xxscm_pod_qty_rct = 0,//0
|
|
xxscm_pod_qty_std = 0,//0
|
|
xxscm_pod_due_date = wmsData.PutTime,
|
|
xxscm_pod_price = wmsData.Price,
|
|
xxscm_pod_loc_um = wmsData.PoUnit,
|
|
xxscm_pod_um = wmsData.Batch,
|
|
xxscm_pod_um_conv = 0,//0
|
|
xxscm_pod_vend = wmsData.VendId,
|
|
xxscm_pod_ship = wmsData.Extend3,
|
|
xxscm_pod_buyer = wmsData.Buyer,
|
|
xxscm_pod_buyer_phone = wmsData.BuyerPhone,
|
|
xxscm_pod_qadread = "0",
|
|
xxscm_pod_wmsread = "0",
|
|
xxscm_pod_scmread = "0",
|
|
xxscm_pod_mesread = "0",
|
|
xxscm_pod_createdt = wmsData.CreateTime,
|
|
xxscm_pod_createur = wmsData.Buyer,
|
|
xxscm_pod_groupWareMaterielNO = wmsData.Extend1,
|
|
xxscm_pod_componquantity = wmsData.ErpBillNum,
|
|
xxscm_pod_measureBaseUnit = wmsData.LocUnit,
|
|
xxscm_pod_returnsItem = "N",
|
|
xxscm_pod_status = "1",
|
|
xxscm_pod_curr = "RMB",
|
|
xxscm_pod_companyCode = wmsData.Receiver,//类型
|
|
xxscm_pod_ctype = wmsData.SubSite,
|
|
xxscm_pod_ordType = wmsData.Currency,//版本号
|
|
xxscm_pod_purOrg = wmsData.Barcode
|
|
};
|
|
qadDataList.Add(qadData);
|
|
|
|
}
|
|
wmsData.State = (int)BillState.Finish;
|
|
wmsData.PutTime = DateTime.Now;
|
|
}
|
|
|
|
if (qadDataList.Count == 0) return;
|
|
//if (qadDataList1.Count == 0) return;
|
|
idb.xxscm_pod_det.AddRange(qadDataList);
|
|
idb.PURSubcontractors.AddRange(qadDataList1);
|
|
Console.WriteLine($"新增 采购订单 数据:{qadDataList.Count} 条");
|
|
|
|
PutScpCtrl(idb, seq, tableName, qadDataList.Count, uni_api.Domain, uni_api.Site);
|
|
}
|
|
/// <summary>
|
|
/// 大订单
|
|
/// </summary>
|
|
/// <param name = "idb" ></ param >
|
|
/// < param name="dataList"></param>
|
|
private static void PutScmMaxPo(UniApiEntities idb, List<TS_UNI_API> dataList)
|
|
{
|
|
var uni_api = dataList.FirstOrDefault();
|
|
string seq = string.Empty;
|
|
if (dataList.Count > 0)
|
|
{
|
|
seq = CreateSeq(string.IsNullOrEmpty(uni_api.Domain) ? uni_api.Site : uni_api.Domain);
|
|
}
|
|
|
|
var tableName = ScmTableName.xxscm_maxpod_det.ToString();
|
|
var qadDataList = new List<xxscm_maxpod_det>();
|
|
|
|
foreach (var wmsData in dataList)
|
|
{
|
|
var qadData = qadDataList.SingleOrDefault(p => p.xxscm_maxpod_nbr == wmsData.BillNum
|
|
&& p.xxscm_maxpod_qty == wmsData.Qty
|
|
&& p.xxscm_maxpod_part == wmsData.PartCode
|
|
&& p.xxscm_maxpod_line == wmsData.ErpLineNum&&p.xxscm_maxpod_idention=="A");
|
|
if (qadData == null)
|
|
{
|
|
if (wmsData.PartCode != null)
|
|
qadData = new xxscm_maxpod_det
|
|
{
|
|
xxscm_maxpod_seq = seq,
|
|
xxscm_maxpod_nbr = wmsData.BillNum,
|
|
xxscm_maxpod_line = wmsData.ErpLineNum,
|
|
xxscm_maxpod_part=wmsData.PartCode,
|
|
xxscm_maxpod_groupart = wmsData.Extend1,//子件物料号
|
|
xxscm_maxpod_qty=wmsData.Qty,//订货件数
|
|
xxscm_maxpod_orderqty=wmsData.PackQty,//起订量
|
|
xxscm_maxpod_orderqtyd=wmsData.Price,//订货量吨
|
|
xxscm_maxpod_orderqtykg=wmsData.Price*1000,//订货量千克
|
|
xxscm_maxpod_createtime=wmsData.CreateTime,//创建时间
|
|
xxscm_maxpod_createuser=wmsData.CreateOper,//创建者
|
|
xxscm_maxpod_month = wmsData.VendBatch,//合同月
|
|
xxscm_maxpod_Model=wmsData.Currency,//车型
|
|
xxscm_maxpod_texture=wmsData.Batch,//材质
|
|
xxscm_maxpod_testandard=wmsData.Buyer,//技术标准
|
|
xxscm_maxpod_forecastone=wmsData.PoUnit,//预测1
|
|
xxscm_maxpod_forecasttwo=wmsData.LocUnit,//预测2
|
|
xxscm_maxpod_forecastthree=wmsData.Attn,//预测3
|
|
xxscm_maxpod_forecastfour=wmsData.Receiver,//预测4
|
|
xxscm_maxpod_forecastfive=wmsData.ModType,//预测5
|
|
xxscm_maxpod_forecastsix=wmsData.SubSite,//预测6
|
|
xxscm_maxpod_site =wmsData.Site,//地点
|
|
xxscm_maxpod_domain = wmsData.Site,//域
|
|
xxscm_maxpod_idention=wmsData.Extend3,//类型
|
|
xxscm_maxpod_vend=wmsData.VendId,//供应商编号
|
|
xxscm_maxpod_manufacturer=wmsData.Extend2,//材料厂家
|
|
xxscm_maxpod_consumption=wmsData.TaxAmt,//单件消耗
|
|
|
|
};
|
|
qadDataList.Add(qadData);
|
|
|
|
}
|
|
wmsData.State = (int)BillState.Finish;
|
|
wmsData.PutTime = DateTime.Now;
|
|
}
|
|
|
|
if (qadDataList.Count == 0) return;
|
|
//if (qadDataList1.Count == 0) return;
|
|
idb.xxscm_maxpod_det.AddRange(qadDataList);
|
|
|
|
Console.WriteLine($"新增 大订单 数据:{qadDataList.Count} 条");
|
|
|
|
PutScpCtrl(idb, seq, tableName, qadDataList.Count, uni_api.Domain, uni_api.Site);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 条码
|
|
/// </summary>
|
|
/// <param name="idb"></param>
|
|
/// <param name="dataList"></param>
|
|
private static void PutScmBarcode(UniApiEntities idb, List<TS_UNI_API> dataList)
|
|
{
|
|
var tableName = ScmTableName.xxscm_tx_det.ToString();
|
|
var qadDataList = new List<xxscm_tx_det>();
|
|
foreach (var wmsData in dataList)
|
|
{
|
|
var qadData = qadDataList.SingleOrDefault(p => p.xxscm_tx_nbr == wmsData.BillNum
|
|
&& p.xxscm_tx_boxcode == wmsData.Barcode);
|
|
if (qadData == null)
|
|
{
|
|
qadData = new xxscm_tx_det
|
|
{
|
|
xxscm_tx_seq = CreateSeq(wmsData.Domain),
|
|
xxscm_tx_nbr = wmsData.BillNum,
|
|
xxscm_tx_part = wmsData.PartCode,
|
|
xxscm_tx_qadread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_wmsread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_scmread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_mesread = ((int)UniApiState.待执行).ToString(),
|
|
xxscm_tx_createur = wmsData.CreateOper,
|
|
xxscm_tx_createdt = wmsData.CreateTime,
|
|
xxscm_tx_updateur = "",
|
|
xxscm_tx_updatedt = DateTime.Now,
|
|
xxscm_tx_rmks = "",
|
|
xxscm_tx_domain = wmsData.Domain,
|
|
xxscm_tx_vend = wmsData.VendId,
|
|
xxscm_tx_batch = wmsData.VendBatch,
|
|
xxscm_tx_boxcode = wmsData.Barcode,
|
|
xxscm_tx_qty_real = wmsData.Qty,
|
|
|
|
};
|
|
qadDataList.Add(qadData);
|
|
}
|
|
wmsData.State = (int)BillState.Finish;
|
|
wmsData.PutTime = DateTime.Now;
|
|
}
|
|
if (qadDataList.Count == 0) return;
|
|
idb.xxscm_tx_det.AddRange(qadDataList);
|
|
Console.WriteLine($"新增 条码 数据:{qadDataList.Count} 条");
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发票
|
|
/// </summary>
|
|
/// <param name="idb"></param>
|
|
/// <param name="dataList"></param>
|
|
//private static void PutScmInvoice(UniApiEntities idb, List<TS_UNI_API> dataList)
|
|
//{
|
|
// try
|
|
// {
|
|
// if (dataList.Count > 0)
|
|
// {
|
|
// var tableName = ScmTableName.xxscm_inv_det.ToString();
|
|
// var _ls = dataList.Select(p => p.BillNum).Distinct().ToList();
|
|
// foreach (var invBillNum in _ls)
|
|
// {
|
|
// var _invList = idb.xxscm_inv_det.Where(p => p.xxscm_inv_nbr == invBillNum).ToList();
|
|
// if (_invList.Count == 0)
|
|
// {
|
|
// var _unapiList = dataList.Where(p => p.BillNum == invBillNum).ToList();
|
|
// var _invbill = _invList.FirstOrDefault();
|
|
// if (_unapiList.Count > 0)
|
|
// {
|
|
// Thread.Sleep(10);
|
|
// string seq = string.Empty;
|
|
// var _api = _unapiList.FirstOrDefault();
|
|
// seq = CreateSeq(string.IsNullOrEmpty(_api.Domain) ? _api.Site : _api.Domain);
|
|
// var qadDataList = new List<xxscm_inv_det>();
|
|
// int i = 0;
|
|
|
|
// _unapiList.ForEach(p =>
|
|
// {
|
|
// if (!string.IsNullOrEmpty(p.Attn))
|
|
// {
|
|
// var _invoice = JsonConvert.DeserializeObject<V_TB_INVOICE>(p.Attn);
|
|
// try
|
|
// {
|
|
// if (p.SourceBillNum != p.ErpBillNum)
|
|
// {
|
|
// var qadData = new xxscm_inv_det();
|
|
// qadData.xxscm_inv_seq = seq;
|
|
// qadData.xxscm_inv_nbr = p.BillNum;
|
|
// qadData.xxscm_inv_site = p.Site;
|
|
// qadData.xxscm_inv_part = p.PartCode;
|
|
// qadData.xxscm_inv_qty = p.Qty;
|
|
// qadData.xxscm_inv_qadread = ((int)UniApiState.待执行).ToString();
|
|
// qadData.xxscm_inv_wmsread = ((int)UniApiState.待执行).ToString();
|
|
// qadData.xxscm_inv_scmread = ((int)UniApiState.待执行).ToString();
|
|
// qadData.xxscm_inv_mesread = ((int)UniApiState.待执行).ToString();
|
|
// qadData.xxscm_inv_createur = p.CreateOper;
|
|
// qadData.xxscm_inv_createdt = p.CreateTime;
|
|
// qadData.xxscm_inv_updateur = "";
|
|
// qadData.xxscm_inv_updatedt = DateTime.Now;
|
|
// qadData.xxscm_inv_rmks = "";
|
|
// qadData.xxscm_inv_domain = p.Domain;
|
|
// qadData.xxscm_inv_amt = Math.Round(p.Price * p.Qty, 2);
|
|
// qadData.xxscm_inv_asn = p.SourceBillNum;
|
|
// qadData.xxscm_inv_curr = p.Currency == null ? "CNY" : p.Currency;
|
|
// qadData.xxscm_inv_vend = p.VendId;
|
|
// qadData.xxscm_inv_project = p.VendBatch;//代替项目传值
|
|
// qadData.xxscm_inv_line = p.ErpLineNum;
|
|
// qadData.xxscm_inv_invoice = p.Invoice;
|
|
// qadData.xxscm_inv_order = p.ErpBillNum;
|
|
// qadData.xxscm_inv_price = p.Price;
|
|
// qadData.xxscm_inv_taxamt = Math.Round(Math.Round(p.Price * p.Qty, 2) * p.Tax, 2) + Math.Round(p.Price * p.Qty, 2);
|
|
// qadData.xxscm_inv_receiver = p.Receiver;
|
|
// qadData.xxscm_inv_taxt = p.Tax;
|
|
// qadData.xxscm_inv_comments = "";
|
|
// qadData.xxscm_inv_holdamt = 0;
|
|
// qadData.xxscm_inv_acctuser = "";
|
|
// qadData.xxscm_inv_date = _invoice.UpdateTime == null ? _invoice.CreateTime.Value.AddDays(1) : _invoice.UpdateTime.Value;
|
|
// qadData.xxscm_inv_totamt = _invoice.Amount.Value;
|
|
// qadData.xxscm_inv_tottax = _invoice.Total.Value;
|
|
// qadData.xxscm_inv_totdiscount = _invoice.DiscountPrice == null ? 0 : _invoice.DiscountPrice.Value;//折扣金额
|
|
// qadData.xxscm_inv_tottaxvar = _invoice.BlancePrice == null ? 0 : _invoice.BlancePrice.Value;//调整税额
|
|
// qadData.xxscm_inv_totclaim = _invoice.ContractPrice == null ? 0 : _invoice.ContractPrice.Value;//索赔金额
|
|
// qadData.xxscm_inv_extend1 = _invoice.Extend1 == null ? 0 : _invoice.Extend1.Value;//纸质发票税前金额
|
|
// qadData.xxscm_inv_extend2 = _invoice.Extend2 == null ? 0 : _invoice.Extend2.Value;//纸质发票税额
|
|
// qadDataList.Add(qadData);
|
|
// p.State = (int)BillState.Finish;
|
|
// p.PutTime = DateTime.Now;
|
|
// i++;
|
|
// }
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// string s = e.Message + "行号" + i.ToString();
|
|
// }
|
|
// }
|
|
// });
|
|
// idb.xxscm_inv_det.AddRange(qadDataList);
|
|
// Console.WriteLine($"新增 发票 数据:{qadDataList.Count} 条");
|
|
// PutScpCtrl(idb, seq, tableName, qadDataList.Count, _api.Domain, _api.Site);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw e;
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
|
|
|