调拨出库

This commit is contained in:
2024-08-26 14:26:08 +08:00
parent 94c22b8888
commit f56c0ed321
7 changed files with 114 additions and 123 deletions

View File

@@ -501,6 +501,7 @@ namespace Tnb.ProductionMgr
await db.Updateable<WmsCarryH>()
.SetColumns(x => x.carry_status == ((int)EnumCarryStatus.).ToString())
.SetColumns(x => x.is_check == ((int)EnumCheckConclusion.).ToString())
.Where(x => x.carry_code==input.carry_code)
.ExecuteCommandAsync();
@@ -586,6 +587,7 @@ namespace Tnb.ProductionMgr
await db.Updateable<WmsCarryH>()
.SetColumns(x => x.carry_status == ((int)EnumCarryStatus.).ToString())
.SetColumns(x => x.is_check == ((int)EnumCheckConclusion.).ToString())
.Where(x => carryIds.Contains(x.id))
.ExecuteCommandAsync();

View File

@@ -97,6 +97,7 @@ namespace Tnb.ProductionMgr
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
string moTaskStatus = queryJson.ContainsKey("mo_task_status") ? queryJson["mo_task_status"].ToString() : "";
string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : "";
SqlSugarPagedList<PrdMoTaskIssueListOutput> result = await db.Queryable<PrdMoTask>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<DictionaryTypeEntity>((a, b, c) => c.EnCode == DictConst.TaskStatus)
@@ -108,6 +109,7 @@ namespace Tnb.ProductionMgr
//.LeftJoin<UserEntity>((a, b, c, d, e, f, g,h,i)=>a.worker_id==i.Id)
.WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
.WhereIF(!string.IsNullOrEmpty(moTaskStatus), (a, b, c, d) => a.mo_task_status == moTaskStatus)
.WhereIF(!string.IsNullOrEmpty(eqpId), (a, b, c, d,e,f,g) => g.code.Contains(eqpId) || g.name.Contains(eqpId))
.Where((a, b, c, d, e, f) => a.schedule_type == 1)
.Select((a, b, c, d, e, f, g,h) => new PrdMoTaskIssueListOutput
{

View File

@@ -132,6 +132,10 @@
public string check_type { get; set; }
public string remark { get; set; }
/// <summary>
/// 附件对象.
/// </summary>
public string attachment { get; set; } = string.Empty;
public List<List<Exextype>>? checktypes { get; set; }
}

View File

@@ -129,5 +129,9 @@ namespace Tnb.QcMgr.Entities
/// </summary>
public string remark { get; set; }
public string batch { get; set; }
/// <summary>
/// 附件对象.
/// </summary>
public string attachment { get; set; } = string.Empty;
}
}

View File

@@ -136,10 +136,10 @@ namespace Tnb.QcMgr
throw Oops.Bah($"未找到任务单{QcCheckExecH.mo_task_code}");
}
if (string.IsNullOrEmpty(QcCheckExecH.report_id))
{
throw Oops.Bah($"未找到提报记录{QcCheckExecH.report_id}");
}
// if (string.IsNullOrEmpty(QcCheckExecH.report_id))
// {
// throw Oops.Bah($"未找到提报记录{QcCheckExecH.report_id}");
// }
BasMaterial basMaterial = await db.Queryable<BasMaterial>().Where(x=>x.id==moTask.material_id).FirstAsync();
PrdReport prdReport = await db.Queryable<PrdReport>().SingleAsync(x => x.id == QcCheckExecH.report_id);
UserEntity userEntity = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == prdReport.create_id);
@@ -156,7 +156,7 @@ namespace Tnb.QcMgr
checknum = !string.IsNullOrEmpty(QcCheckExecH.checknum) ? int.Parse(QcCheckExecH.checknum) : 0,
worker_name = userEntity?.RealName ?? "",
bill_code = QcCheckExecH.bill_code,
carry_code = prdReport.material_box_code,
carry_code = prdReport?.material_box_code,
};
if (!string.IsNullOrEmpty(CheckTaskOut.workid))
{
@@ -262,6 +262,7 @@ namespace Tnb.QcMgr
QcCheckExecH.exectime = DateTime.Now.ToString();
QcCheckExecH.check_type = CheckTaskInput.check_type;
QcCheckExecH.remark = CheckTaskInput.remark;
QcCheckExecH.attachment = CheckTaskInput.attachment;
List<QcCheckExecD> QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == CheckTaskInput.mainid).ToListAsync();
int rqty = 0;

View File

@@ -28,6 +28,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Interfaces;
using Tnb.ProductionMgr.Entities.Entity;
using Tnb.BasicData;
namespace Tnb.WarehouseMgr
{
@@ -243,120 +244,97 @@ namespace Tnb.WarehouseMgr
{
// 出库数量wmsMaterialSignD.sign_qty
}
//todo 对接调拨出库
// WmsInstockH instock = await _db.Queryable<WmsInstockH>().SingleAsync(x => x.id == input.requireId);
// List<WmsInstockD> allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
//
// WmsTempCode wmsTempCode = await _db.Queryable<WmsCarryCode>()
// .LeftJoin<WmsTempCode>((a, b) => a.barcode == b.barcode)
// .Where((a, b) => a.carry_id == input.wmsDistaskH.carry_id)
// .Select((a, b) => b)
// .FirstAsync();
//
// string rawmatTransferinstockDId = wmsTempCode?.require_id ?? "";
// WmsRawmatTransferinstockD wmsRawmatTransferinstockD = await _db.Queryable<WmsRawmatTransferinstockD>().SingleAsync(x => x.id == rawmatTransferinstockDId);
// string rawmatTransferinstockHId = wmsRawmatTransferinstockD?.bill_id ?? "";
// WmsRawmatTransferinstockH wmsRawmatTransferinstockH = await _db.Queryable<WmsRawmatTransferinstockH>().SingleAsync(x => x.id == rawmatTransferinstockHId);
//
// List<String> materialIds = allInstockDetails.Select(x => x.material_id).Distinct().ToList();
// List<String> unitCodes = allInstockDetails.Select(x => x.unit_id).Distinct().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();
// List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>x.id!=null).ToListAsync();
// BasWarehouse basWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x=>x.id==instock.warehouse_id);
//
// string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
// List<string> tableIds = new List<string>();
// tableIds.Add(_userManager.UserId);
// tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
// tableIds.Add(instock.warehouse_id);
// 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 userAccount = wmsRawmatTransferinstockH?.biller ?? "";
// string deptCode = wmsRawmatTransferinstockH?.dept_code ?? "";
// UserEntity userEntity = await _db.Queryable<UserEntity>().Where(x=>x.Account==userAccount).FirstAsync();
// string userId = userEntity?.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<Dictionary<string, object>> requestData = new List<Dictionary<string, object>>();
// Dictionary<string, object> erpRequestData = new Dictionary<string, object>();
// erpRequestData.Add("billmaker", erpCreateId);
List<String> materialIds = wmsMaterialSignDs.Select(x => x.material_id).Distinct().ToList();
List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>x.id!=null).ToListAsync();
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
List<string> tableIds = new List<string>();
tableIds.Add( wmsMaterialSignH.create_id);
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
tableIds.AddRange(materialIds);
tableIds.Add(supplierId);
tableIds.Add(wmsRawmatTransferoutstockD.unit_id);
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => tableIds.Contains(x.table_id)).ToListAsync();
string userId = input.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("cbiztype", "");
// erpRequestData.Add("cdptid","1001A1100000000JRLI1");//部门先写死
// erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死
// erpRequestData.Add("corpoid", erpOrg.corpoid);
// erpRequestData.Add("corpvid", erpOrg.corpvid);
// erpRequestData.Add("creationtime", nowStr);
// erpRequestData.Add("creator", erpCreateId);
// // erpRequestData.Add("cwarehouseid", erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "");//类型视图里取
// erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "");//类型视图里取
// erpRequestData.Add("dbilldate", nowStr);
// erpRequestData.Add("dmakedate", nowStr);
// erpRequestData.Add("fbillflag", 1);
// erpRequestData.Add("ntotalnum", allInstockDetails.Sum(x => x.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("vdef1", null);
// erpRequestData.Add("vbillcode", instock.bill_code);
// erpRequestData.Add("ctrantypeid", "0001H11000000000D31E");//先写死
// erpRequestData.Add("vtrantypecode", "4E-01");//先写死
// erpRequestData.Add("csourcebillhid", wmsRawmatTransferinstockH?.erp_pk ?? "");
//
//
// List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
// foreach (WmsInstockD item in allInstockDetails)
// {
// erpRequestDataDetails.Add(new Dictionary<string, object>()
// {
// ["cbodytranstypecode"] = "4E-01",
// // ["cbodywarehouseid"] = erpExtendFields.Find(x => x.table_id == instock.warehouse_id)?.cotherwhid ?? "",
// ["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == basWarehouse.whcode)?.erp_warehouseid ?? "",
// ["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"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10,
// ["csourcebillhid"] = wmsRawmatTransferinstockH?.erp_pk ?? "",
// ["csourcebillbid"] = wmsRawmatTransferinstockD?.erp_line_pk ?? "",
// ["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"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
// ["dplanarrivedate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
// ["dplanoutdate"] = instock.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
// ["nnum"] = item.qty,
// ["nshouldnum"] = item.pr_qty,
// ["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/transIn/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();
erpRequestData.Add("cdptid","1001A1100000000JRLI1");//部门先写死
erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死
erpRequestData.Add("corpoid", erpOrg.corpoid);
erpRequestData.Add("corpvid", erpOrg.corpvid);
erpRequestData.Add("corpvid", erpOrg.corpvid);
erpRequestData.Add("cotherwhid", wmsErpWarehouserelaHs.Find(x=>x.wms_warehousecode==wmsRawmatTransferoutstockD.warehouse_instock_code)?.erp_warehouseid ?? "");
erpRequestData.Add("cwarehouseid", wmsErpWarehouserelaHs.Find(x=>x.erp_warehousecode==wmsRawmatTransferoutstockD.erp_wh_type)?.erp_warehouseid ?? "");
erpRequestData.Add("creationtime", nowStr);
erpRequestData.Add("creator", erpCreateId);
erpRequestData.Add("ctrantypeid", "0001H11000000000D32A");//先写死
erpRequestData.Add("vtrantypecode", "4Y-01");//先写死
erpRequestData.Add("dbilldate", nowStr);
erpRequestData.Add("dmakedate", nowStr);
erpRequestData.Add("fbillflag", 1);
erpRequestData.Add("fmodetype", 0);
erpRequestData.Add("ntotalnum", input.details.Sum(x=>x.sign_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("csourcebillhid", wmsTransferOrderH.erp_pk);
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
foreach(var item in wmsMaterialSignDs)
{
// 出库数量wmsMaterialSignD.sign_qty
erpRequestDataDetails.Add(new Dictionary<string, object>()
{
["cbodytranstypecode"] = "4Y-01",
["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.wms_warehousecode==wmsRawmatTransferoutstockD.warehouse_instock_code)?.erp_warehouseid ?? "",
["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"] = wmsRawmatTransferoutstockD.lineno,
["csourcebillhid"] = wmsTransferOrderH?.erp_pk ?? "",
["csourcebillbid"] = wmsRawmatTransferoutstockD?.erp_line_pk ?? "",
["vsourcebillcode"] = wmsTransferOrderH?.erp_bill_code ?? "",
["vsourcerowno"] = wmsRawmatTransferoutstockD?.lineno ?? "",
["cunitid"] = erpExtendFields.Find(x => x.table_id == wmsRawmatTransferoutstockD.unit_id)?.cunitid ?? "",
["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "",
["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "",
["dbizdate"] = wmsTransferOrderH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
["dplanarrivedate"] = nowStr,
["dplanoutdate"] = nowStr,
["nnum"] = item.sign_qty,
["nshouldnum"] = item.sign_qty,
["pk_group"] = erpOrg.pk_group,
["pk_org"] = erpOrg.pk_org,
["pk_org_v"] = erpOrg.pk_org_v,
["vbatchcode"] = item.code_batch,
["vfree1"] = 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/transIn/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();
break;
}

View File

@@ -98,10 +98,14 @@ namespace Tnb.WarehouseMgr
.ToListAsync();
List<WmsErpWarehouserelaH> erpWarehouserelaHs = await _db.Queryable<WmsErpWarehouserelaH>().Where(x=>x.id!=null).ToListAsync();
BasWarehouse basWarehouse = await _db.Queryable<BasWarehouse>().SingleAsync(x=>x.id==instock.warehouse_id);
string userAccount = wmsRawmatTransferinstockH?.biller ?? "";
string deptCode = wmsRawmatTransferinstockH?.dept_code ?? "";
UserEntity userEntity = await _db.Queryable<UserEntity>().Where(x=>x.Account==userAccount).FirstAsync();
string userId = userEntity?.Id ?? "";
string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID;
List<string> tableIds = new List<string>();
tableIds.Add(_userManager.UserId);
tableIds.Add(userId);
tableIds.Add(WmsWareHouseConst.AdministratorOrgId);
tableIds.Add(instock.warehouse_id);
tableIds.AddRange(materialIds);
@@ -109,10 +113,6 @@ namespace Tnb.WarehouseMgr
tableIds.AddRange(unitDatas.Select(x => x.Id).ToList());
List<ErpExtendField> erpExtendFields = await _db.Queryable<ErpExtendField>().Where(x => tableIds.Contains(x.table_id)).ToListAsync();
string userAccount = wmsRawmatTransferinstockH?.biller ?? "";
string deptCode = wmsRawmatTransferinstockH?.dept_code ?? "";
UserEntity userEntity = await _db.Queryable<UserEntity>().Where(x=>x.Account==userAccount).FirstAsync();
string userId = userEntity?.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");