|
|
|
|
@@ -78,102 +78,108 @@ namespace Tnb.WarehouseMgr
|
|
|
|
|
throw new ArgumentNullException(nameof(input));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WmsRawmatOutstockD wmsRawmatOutstockD = await _db.Queryable<WmsRawmatOutstockD>().SingleAsync(x=>x.id==input.requireId);
|
|
|
|
|
// WmsRawmatOutstockH wmsRawmatOutstockH = await _db.Queryable<WmsRawmatOutstockH>().SingleAsync(x=>x.id==wmsRawmatOutstockD.bill_id);
|
|
|
|
|
// List<WmsCarryCode> wmsCarryCodes = await _db.Queryable<WmsCarryCode>()
|
|
|
|
|
// .Where(r => r.carry_id == input.wmsDistaskH.carry_id)
|
|
|
|
|
// .Where(r => r.material_id == wmsRawmatOutstockD.material_id && r.code_batch == wmsRawmatOutstockD.batchno)
|
|
|
|
|
// .ToListAsync();
|
|
|
|
|
//
|
|
|
|
|
// decimal qty = wmsCarryCodes.Sum(r => r.codeqty);
|
|
|
|
|
//
|
|
|
|
|
// List<String> unitCodes = wmsCarryCodes.Select(x => x.unit_id).Distinct().ToList();
|
|
|
|
|
// List<string> materialIds = wmsCarryCodes.Select(x => x.material_id).ToList();
|
|
|
|
|
// List<DictionaryDataEntity> unitDatas = await _db.Queryable<DictionaryTypeEntity>()
|
|
|
|
|
// .LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
|
|
|
|
// .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode))
|
|
|
|
|
// .Select((x, y) => y)
|
|
|
|
|
// .ToListAsync();
|
|
|
|
|
//
|
|
|
|
|
// string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
|
|
|
|
// List<string> tableIds = new List<string>();
|
|
|
|
|
// tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
|
|
|
|
// tableIds.AddRange(materialIds);
|
|
|
|
|
// tableIds.Add(supplierId);
|
|
|
|
|
// tableIds.AddRange(unitDatas.Select(x => x.Id).ToList());
|
|
|
|
|
//
|
|
|
|
|
// List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => tableIds.Contains(x.table_id)).ToListAsync();
|
|
|
|
|
// string userId = wmsRawmatOutstockH.create_id;
|
|
|
|
|
// string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? "";
|
|
|
|
|
// ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId));
|
|
|
|
|
// string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// List<WmsErpWarehouserelaH> wmsErpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>!SqlFunc.IsNullOrEmpty(x.id)).ToListAsync();
|
|
|
|
|
//
|
|
|
|
|
// List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
|
|
|
|
// Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
|
|
|
|
// erpRequestData.Add("billmaker", erpCreateId);
|
|
|
|
|
// erpRequestData.Add("ccostdomainoid", null);
|
|
|
|
|
// erpRequestData.Add("cdrawcalbodyoid", erpOrg.pk_org);
|
|
|
|
|
// erpRequestData.Add("cdrawcalbodyvid", erpOrg.pk_org_v);
|
|
|
|
|
// erpRequestData.Add("cdrawwarehouseid", erpOrg.pk_org_v);
|
|
|
|
|
//
|
|
|
|
|
// erpRequestData.Add("corpoid", erpOrg.corpoid);
|
|
|
|
|
// erpRequestData.Add("corpvid", erpOrg.corpvid);
|
|
|
|
|
// erpRequestData.Add("cdptid","1001A1100000001JFOPQ");//部门先写死
|
|
|
|
|
// erpRequestData.Add("cdptvid","0001A1100000000AOMIQ");//部门先写死
|
|
|
|
|
// erpRequestData.Add("cotherdptid","1001A1100000001JFOPQ");//部门先写死
|
|
|
|
|
// erpRequestData.Add("cotherdptvid","0001A1100000000AOMIQ");//部门先写死
|
|
|
|
|
// erpRequestData.Add("creationtime", nowStr);
|
|
|
|
|
// erpRequestData.Add("creator", erpCreateId);
|
|
|
|
|
// erpRequestData.Add("ctrantypeid", "0001H11000000000D32A");//先写死
|
|
|
|
|
// erpRequestData.Add("cwarehouseid", outWhid);//先写死
|
|
|
|
|
// erpRequestData.Add("dbilldate", wmsRawmatTransferoutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
// erpRequestData.Add("dmakedate", nowStr);
|
|
|
|
|
// erpRequestData.Add("dshldarrivedate", nowStr);
|
|
|
|
|
// erpRequestData.Add("dshlddiliverdate", nowStr);
|
|
|
|
|
// erpRequestData.Add("fbillflag", 1);
|
|
|
|
|
// erpRequestData.Add("isbackdeliver", false);
|
|
|
|
|
// erpRequestData.Add("ntotalnum", qty);
|
|
|
|
|
// erpRequestData.Add("pk_org", erpOrg.pk_org);
|
|
|
|
|
// erpRequestData.Add("pk_org_v", erpOrg.pk_org_v);
|
|
|
|
|
// erpRequestData.Add("pk_group", erpOrg.pk_group);
|
|
|
|
|
// erpRequestData.Add("vbillcode", wmsRawmatTransferoutstockH.bill_code);
|
|
|
|
|
// erpRequestData.Add("vtrantypecode", "4Y-01");//先写死
|
|
|
|
|
//
|
|
|
|
|
// List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
|
|
|
|
// foreach(var item in wmsCarryCodes)
|
|
|
|
|
// {
|
|
|
|
|
// // 出库数量wmsMaterialSignD.sign_qty
|
|
|
|
|
// erpRequestDataDetails.Add(new Dictionary<string, object>()
|
|
|
|
|
// {
|
|
|
|
|
// ["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialoid ?? "",
|
|
|
|
|
// ["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialvid ?? "",
|
|
|
|
|
// ["corpoid"] = erpOrg.corpoid,
|
|
|
|
|
// ["corpvid"] = erpOrg.corpvid,
|
|
|
|
|
// ["crowno"] = (wmsCarryCodes.FindIndex(x => x.id == item.id) + 1) * 10,
|
|
|
|
|
// ["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
|
|
|
|
// ["nnum"] = item.codeqty,
|
|
|
|
|
// ["nshouldnum"] = item.codeqty,
|
|
|
|
|
// ["pk_group"] = erpOrg.pk_group,
|
|
|
|
|
// ["pk_org"] = erpOrg.pk_org,
|
|
|
|
|
// ["pk_org_v"] = erpOrg.pk_org_v,
|
|
|
|
|
// ["vbatchcode"] = item.code_batch,
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// erpRequestData.Add("dtls", erpRequestDataDetails);
|
|
|
|
|
WmsRawmatOutstockD wmsRawmatOutstockD = await _db.Queryable<WmsRawmatOutstockD>().SingleAsync(x=>x.id==input.requireId);
|
|
|
|
|
WmsRawmatOutstockH wmsRawmatOutstockH = await _db.Queryable<WmsRawmatOutstockH>().SingleAsync(x=>x.id==wmsRawmatOutstockD.bill_id);
|
|
|
|
|
List<WmsCarryCode> wmsCarryCodes = await _db.Queryable<WmsCarryCode>()
|
|
|
|
|
.Where(r => r.carry_id == input.wmsDistaskH.carry_id)
|
|
|
|
|
.Where(r => r.material_id == wmsRawmatOutstockD.material_id && r.code_batch == wmsRawmatOutstockD.batchno)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
decimal qty = wmsCarryCodes.Sum(r => r.codeqty);
|
|
|
|
|
|
|
|
|
|
List<String> unitCodes = wmsCarryCodes.Select(x => x.unit_id).Distinct().ToList();
|
|
|
|
|
List<string> materialIds = wmsCarryCodes.Select(x => x.material_id).ToList();
|
|
|
|
|
List<DictionaryDataEntity> unitDatas = await _db.Queryable<DictionaryTypeEntity>()
|
|
|
|
|
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
|
|
|
|
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode))
|
|
|
|
|
.Select((x, y) => y)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
DictionaryDataEntity tranTypeDataEntity = await _db.Queryable<DictionaryTypeEntity>()
|
|
|
|
|
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
|
|
|
|
.Where((x, y) => x.EnCode == DictConst.TransactionType && wmsRawmatOutstockH.outstock_type==y.EnCode)
|
|
|
|
|
.Select((x, y) => y)
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
|
|
|
|
|
List<string> tableIds = new List<string>();
|
|
|
|
|
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
|
|
|
|
|
tableIds.AddRange(materialIds);
|
|
|
|
|
tableIds.Add(supplierId);
|
|
|
|
|
tableIds.Add(tranTypeDataEntity?.Id);
|
|
|
|
|
tableIds.AddRange(unitDatas.Select(x => x.Id).ToList());
|
|
|
|
|
|
|
|
|
|
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => tableIds.Contains(x.table_id)).ToListAsync();
|
|
|
|
|
string userId = wmsRawmatOutstockH.create_id;
|
|
|
|
|
string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? "";
|
|
|
|
|
ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId));
|
|
|
|
|
string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
List<WmsErpWarehouserelaH> wmsErpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>!SqlFunc.IsNullOrEmpty(x.id)).ToListAsync();
|
|
|
|
|
|
|
|
|
|
List<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
|
|
|
|
|
Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
|
|
|
|
|
erpRequestData.Add("billmaker", erpCreateId);
|
|
|
|
|
erpRequestData.Add("ccostdomainoid", null);
|
|
|
|
|
erpRequestData.Add("cdrawcalbodyoid", erpOrg.pk_org);
|
|
|
|
|
erpRequestData.Add("cdrawcalbodyvid", erpOrg.pk_org_v);
|
|
|
|
|
// erpRequestData.Add("cdrawwarehouseid", null);
|
|
|
|
|
erpRequestData.Add("cfanaceorgoid", erpOrg.pk_org);
|
|
|
|
|
erpRequestData.Add("cfanaceorgvid", erpOrg.pk_org_v);
|
|
|
|
|
erpRequestData.Add("corpoid", erpOrg.corpoid);
|
|
|
|
|
erpRequestData.Add("corpvid", erpOrg.corpvid);
|
|
|
|
|
erpRequestData.Add("creationtime", nowStr);
|
|
|
|
|
erpRequestData.Add("creator", erpCreateId);
|
|
|
|
|
erpRequestData.Add("ctrantypeid", erpExtendFields.Find(x=>x.table_id==tranTypeDataEntity?.Id)?.transaction_type_id ?? "");//先写死
|
|
|
|
|
erpRequestData.Add("cwarehouseid", wmsErpWarehouserelaHs.Find(x=>x.wms_warehousecode==wmsRawmatOutstockH.warehouse_id)?.erp_warehouseid ?? "");
|
|
|
|
|
erpRequestData.Add("dbilldate", wmsRawmatOutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
erpRequestData.Add("dmakedate", nowStr);
|
|
|
|
|
erpRequestData.Add("fbillflag", 2);
|
|
|
|
|
erpRequestData.Add("ntotalnum", qty);
|
|
|
|
|
erpRequestData.Add("pk_org", erpOrg.pk_org);
|
|
|
|
|
erpRequestData.Add("pk_org_v", erpOrg.pk_org_v);
|
|
|
|
|
erpRequestData.Add("pk_group", erpOrg.pk_group);
|
|
|
|
|
erpRequestData.Add("vbillcode", wmsRawmatOutstockH.bill_code);
|
|
|
|
|
erpRequestData.Add("vtrantypecode", wmsRawmatOutstockH.outstock_type);
|
|
|
|
|
erpRequestData.Add("vdef20", true);
|
|
|
|
|
|
|
|
|
|
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
|
|
|
|
|
foreach(var item in wmsCarryCodes)
|
|
|
|
|
{
|
|
|
|
|
// 出库数量wmsMaterialSignD.sign_qty
|
|
|
|
|
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
|
|
|
|
{
|
|
|
|
|
["cbodytranstypecode"] = wmsRawmatOutstockH.outstock_type,
|
|
|
|
|
["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialoid ?? "",
|
|
|
|
|
["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialvid ?? "",
|
|
|
|
|
["corpoid"] = erpOrg.corpoid,
|
|
|
|
|
["corpvid"] = erpOrg.corpvid,
|
|
|
|
|
["crowno"] = wmsRawmatOutstockD.lineno,
|
|
|
|
|
["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
|
|
|
|
["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "",
|
|
|
|
|
["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "",
|
|
|
|
|
["dbizdate"] = wmsRawmatOutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
|
["nshouldnum"] = item.codeqty,
|
|
|
|
|
["nnum"] = item.codeqty,
|
|
|
|
|
["pk_group"] = erpOrg.pk_group,
|
|
|
|
|
["pk_org"] = erpOrg.pk_org,
|
|
|
|
|
["pk_org_v"] = erpOrg.pk_org_v,
|
|
|
|
|
["vbatchcode"] = item.code_batch,
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
erpRequestData.Add("dtls", erpRequestDataDetails);
|
|
|
|
|
// requestData.Add(erpRequestData);
|
|
|
|
|
// BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.BIPURL);
|
|
|
|
|
// ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
|
|
|
|
// thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
|
|
|
|
// thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
|
|
|
|
// thirdWebapiRecord.name = "材料出库单(自制)";
|
|
|
|
|
// thirdWebapiRecord.method = "POST";
|
|
|
|
|
// thirdWebapiRecord.url = config.value + "uapws/rest/materialOut/self/save";
|
|
|
|
|
// // thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save";
|
|
|
|
|
// thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData);
|
|
|
|
|
// thirdWebapiRecord.create_time = DateTime.Now;
|
|
|
|
|
// await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
|
|
|
|
BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.BIPURL);
|
|
|
|
|
ThirdWebapiRecord thirdWebapiRecord = new ThirdWebapiRecord();
|
|
|
|
|
thirdWebapiRecord.id = SnowflakeIdHelper.NextId();
|
|
|
|
|
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
|
|
|
|
thirdWebapiRecord.name = "材料出库单(自制)";
|
|
|
|
|
thirdWebapiRecord.method = "POST";
|
|
|
|
|
thirdWebapiRecord.url = config.value + "uapws/rest/materialOut/self/save";
|
|
|
|
|
// thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save";
|
|
|
|
|
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData);
|
|
|
|
|
thirdWebapiRecord.create_time = DateTime.Now;
|
|
|
|
|
await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|