提报质量bug

This commit is contained in:
2024-08-23 16:16:20 +08:00
parent fd150f1804
commit 649867d2d0
8 changed files with 189 additions and 39 deletions

View File

@@ -59,6 +59,6 @@ namespace Tnb.ProductionMgr.Interfaces
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<string> ReportInstock(CheckCompleteInput input,ISqlSugarClient db = null);
Task<string> ReportInstock(CheckCompleteInput input,PrdReport report = null,ISqlSugarClient db = null);
}
}

View File

@@ -2146,12 +2146,12 @@ namespace Tnb.ProductionMgr
return "提报成功";
}
public async Task<string> ReportInstock(CheckCompleteInput input,ISqlSugarClient db = null)
public async Task<string> ReportInstock(CheckCompleteInput input,PrdReport report = null, ISqlSugarClient db = null)
{
try
{
if(db==null) db = _repository.AsSugarClient();
PrdReport report = await db.Queryable<PrdReport>().FirstAsync(it => it.id==input.report_id && !SqlFunc.IsNullOrEmpty(it.id));
if(report==null) report = await db.Queryable<PrdReport>().FirstAsync(it => it.id==input.report_id && !SqlFunc.IsNullOrEmpty(it.id));
PrdMoTask? prdMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == report.mo_task_id && !SqlFunc.IsNullOrEmpty(x.id));
EqpEquipment equip = await db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdMoTask.material_id);
@@ -2387,7 +2387,7 @@ namespace Tnb.ProductionMgr
catch (Exception e)
{
Log.Error("提报入库任务下发失败", e);
throw Oops.Bah("提报入库任务下发失败:"+e.Message);
throw new Exception("提报入库任务下发失败");
}
return "入库任务下发成功";

View File

@@ -19,6 +19,7 @@
public string batch { get; set; }
public int? qty { get; set; }
public string bill_code { get; set; }
public string equip_name { get; set; }
}
public class CheckTaskOut

View File

@@ -1,5 +1,6 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
@@ -421,43 +422,67 @@ namespace Tnb.QcMgr
JoinType.Left,a.id == e.planid,
});
GetQuery(Query, entity);
// if (!string.IsNullOrEmpty(entity.materialid))
// {
// Query = Query.Where((a, b, c, d, e) => c.materialid==entity.materialid);
// }
// if (!string.IsNullOrEmpty(entity.processid))
// {
// Query = Query.Where((a, b, c, d, e) => d.processid==entity.processid);
// }
// if (!string.IsNullOrEmpty(entity.workid))
// {
// Query = Query.Where((a, b, c, d, e) => e.workid==entity.workid);
// }
Query = Query.Where((a, b, c, d, e)=>c.materialid==entity.materialid || d.processid==entity.processid || e.workid==entity.workid);
List<QcCheckPlanH> list = await Query.ToListAsync();
List<string> removes = new();
foreach (QcCheckPlanH data in list)
if (list.IsEmpty())
{
if (!string.IsNullOrEmpty(entity.materialid))
{
if (_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id).Any())
{
if (!_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id && p.materialid == entity.materialid).Any())
{
removes.Add(data.id);
}
}
}
if (!string.IsNullOrEmpty(entity.processid))
{
if (_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id).Any())
{
if (!_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id && p.processid == entity.processid).Any())
{
removes.Add(data.id);
}
}
}
if (!string.IsNullOrEmpty(entity.workid))
{
if (_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id).Any())
{
if (!_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id && p.workid == entity.workid).Any())
{
removes.Add(data.id);
}
}
}
throw Oops.Bah("未找到质检方案");
}
if (list.Count > 1)
{
throw Oops.Bah("找到多个质检方案");
}
// List<string> removes = new();
// foreach (QcCheckPlanH data in list)
// {
// if (!string.IsNullOrEmpty(entity.materialid))
// {
// // if (_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id).Any())
// // {
// // if (!_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id && p.materialid == entity.materialid).Any())
// // {
// // removes.Add(data.id);
// // }
// // }
// }
// if (!string.IsNullOrEmpty(entity.processid))
// {
// if (_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id).Any())
// {
// if (!_repository.AsSugarClient().Queryable<QcCheckPlanProcess>().Where(p => p.planid == data.id && p.processid == entity.processid).Any())
// {
// removes.Add(data.id);
// }
//
// }
// }
// if (!string.IsNullOrEmpty(entity.workid))
// {
// if (_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id).Any())
// {
// if (!_repository.AsSugarClient().Queryable<QcCheckPlanWork>().Where(p => p.planid == data.id && p.workid == entity.workid).Any())
// {
// removes.Add(data.id);
// }
// }
// }
// }
//
// list = list.Where(p => !removes.Contains(p.id)).ToList();
// .WhereIF(!string.IsNullOrEmpty(entity.materialid), (a, b, c, d, e) => c.materialid == entity.materialid)
// .WhereIF(!string.IsNullOrEmpty(entity.processid), (a, b, c, d, e) => d.processid == entity.processid)

View File

@@ -11,6 +11,8 @@ using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
using Tnb.QcMgr.Entities;
namespace Tnb.QcMgr
@@ -113,11 +115,13 @@ namespace Tnb.QcMgr
.LeftJoin<BasProcess>((a, b, c) => a.processid == c.id)
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workid == d.Id)
.LeftJoin<UserEntity>((a, b, c, d, e) => a.execuser == e.Id)
.LeftJoin<PrdMoTask>((a,b,c,d,e,f)=>a.mo_task_code==f.mo_task_code)
.LeftJoin<EqpEquipment>((a,b,c,d,e,f,g)=>f.eqp_id==g.id)
.WhereIF(!string.IsNullOrEmpty(materialid), (a, b, c, d, e) => a.materialid == materialid)
.WhereIF(!string.IsNullOrEmpty(checktype), (a, b, c, d, e) => a.checktype == checktype)
.WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d, e) => a.status == status)
// .Where((a, b, c, d, e) => a.status == list.Where(p => p.FullName == "已完成").First().Id)
.Select((a, b, c, d, e) => new QcCheckExecHOut
.Select((a, b, c, d, e,f,g) => new QcCheckExecHOut
{
id = a.id,
bill_code = a.bill_code,
@@ -132,6 +136,7 @@ namespace Tnb.QcMgr
tasktime = a.tasktime ?? "",
exectime = a.exectime ?? "",
execuser = e.RealName ?? "",
equip_name = g.name,
}).OrderByDescending(expression).ToPagedListAsync(input.currentPage, input.pageSize);
foreach (QcCheckExecHOut? item in result.list)

View File

@@ -368,7 +368,7 @@ namespace Tnb.QcMgr
pqty = pqty,
rqty = rqty,
check_result = ((EnumCheckConclusion)dic[CheckTaskInput.result]).ToString(),
},db);
},prdReport,db);
}
}
await db.Ado.CommitTranAsync();

View File

@@ -8,13 +8,17 @@ using Aop.Api.Domain;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
@@ -23,6 +27,7 @@ using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Interfaces;
using Tnb.ProductionMgr.Entities.Entity;
namespace Tnb.WarehouseMgr
{
@@ -227,6 +232,118 @@ namespace Tnb.WarehouseMgr
// 原材料调拨出库
case WmsWareHouseConst.BIZTYPE_WmsRawmatTransferoutstock_ID:
{
//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);
// 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();
break;
}
}

View File

@@ -166,6 +166,8 @@ namespace Tnb.WarehouseMgr
["pk_org"] = erpOrg.pk_org,
["pk_org_v"] = erpOrg.pk_org_v,
["vbatchcode"] = item.code_batch,
["coutcalbodyoid"] = wmsRawmatTransferinstockH.outstockorg_code,
["coutcalbodyvid"] = wmsRawmatTransferinstockH.outstockorg_id,
});
}
erpRequestData.Add("dtls", erpRequestDataDetails);