外包装入库申请
This commit is contained in:
@@ -2,6 +2,11 @@ namespace Tnb.BasicData;
|
||||
|
||||
public static class DictConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统默认用户id 非人工的用此id
|
||||
/// </summary>
|
||||
public const string DEFAULTUSERID = "30018908123413";
|
||||
|
||||
#region BasicData
|
||||
/// <summary>
|
||||
/// 计量单位
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto
|
||||
{
|
||||
public class MarkingLabelInput
|
||||
{
|
||||
public string station_id { get; set; }
|
||||
public string mark_code { get; set; }
|
||||
public string label_code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto
|
||||
{
|
||||
public class TrayQrcodeInput
|
||||
{
|
||||
public string qrcode { get; set; }
|
||||
|
||||
public string station_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 外包装喷码贴标验证表
|
||||
/// </summary>
|
||||
[SugarTable("prd_out_pack_mark_label")]
|
||||
public partial class PrdOutPackMarkLabel : BaseEntity<string>
|
||||
{
|
||||
public PrdOutPackMarkLabel()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否喷码 0 否 1 是
|
||||
/// </summary>
|
||||
public int is_mark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否贴标 0 否 1 是
|
||||
/// </summary>
|
||||
public int is_label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单号
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 物料号
|
||||
/// </summary>
|
||||
public string material_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string station_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime create_time { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 状态 0 未提报 1 已提报 2 已发起入库申请
|
||||
/// </summary>
|
||||
public string status { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 提报记录id
|
||||
/// </summary>
|
||||
public string report_id { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 外包装空托盘码表
|
||||
/// </summary>
|
||||
[SugarTable("prd_out_packing")]
|
||||
public partial class PrdOutPacking : BaseEntity<string>
|
||||
{
|
||||
public PrdOutPacking()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 托盘码
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string station_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 状态 0 未使用 1 已使用
|
||||
/// </summary>
|
||||
public string status { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime create_time { get; set; } = DateTime.Now;
|
||||
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> InstockTypeOne(InstockInput inut);
|
||||
public Task<dynamic> InstockTypeOne(InstockInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 短管挤出入库申请
|
||||
@@ -49,6 +49,6 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> InstockOutPack(InstockInput inut);
|
||||
public Task<string> InstockOutPack(InstockInput input);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
@@ -26,6 +27,21 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<PrdMoTask> GetPrdMoTaskInfoByStationId(Dictionary<string, string> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 外包装根据工位id获取喷码数据
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<dynamic> GetMarkingInfoByStationId(MarkingLabelInput input);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 外包装根据工位id获取贴标数据
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
Task<dynamic> GetLabelInfoByStationId(MarkingLabelInput input);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
public interface IPrdOutPackingService
|
||||
{
|
||||
/// <summary>
|
||||
/// 托盘二维码
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> TrayQrcode(TrayQrcodeInput input);
|
||||
}
|
||||
}
|
||||
@@ -259,10 +259,10 @@ namespace Tnb.ProductionMgr
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[AllowAnonymous]
|
||||
public async Task<dynamic> InstockTypeOne(InstockInput inut)
|
||||
public async Task<dynamic> InstockTypeOne(InstockInput input)
|
||||
{
|
||||
string equip_code = inut.equip_code;
|
||||
string label_code = inut.label_code;
|
||||
string equip_code = input.equip_code;
|
||||
string label_code = input.label_code;
|
||||
string warehouse_id = "2";
|
||||
if (!string.IsNullOrEmpty(equip_code))
|
||||
{
|
||||
@@ -399,6 +399,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
}
|
||||
//todo 入库申请后是否修改提报记录状态
|
||||
});
|
||||
}
|
||||
|
||||
@@ -626,9 +627,189 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> InstockOutPack(InstockInput inut)
|
||||
public async Task<string> InstockOutPack(InstockInput input)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
string equip_code = input.equip_code;
|
||||
string label_code = input.label_code;
|
||||
string warehouse_id = "26103367464997";//四楼解析库
|
||||
if (!string.IsNullOrEmpty(equip_code))
|
||||
{
|
||||
throw Oops.Bah("请传机台号");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(label_code))
|
||||
{
|
||||
throw Oops.Bah("请传标签号");
|
||||
}
|
||||
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
EqpEquipment equipment = await db.Queryable<EqpEquipment>()
|
||||
.LeftJoin<EqpDaq>((x,y)=>x.id==y.equip_id)
|
||||
.Where((x,y) => y.equip_code==equip_code && y.label_name==label_code && y.label_point=="外包装成品码垛点位")
|
||||
.Select((x,y)=>x)
|
||||
.FirstAsync();
|
||||
|
||||
|
||||
if (equipment == null)
|
||||
{
|
||||
throw Oops.Bah("未找到机台");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(equipment.as_location_id))
|
||||
{
|
||||
throw Oops.Bah("未找到入库库位");
|
||||
}
|
||||
|
||||
BasLocation basLocation = await db.Queryable<BasLocation>().SingleAsync(x => x.id == equipment.as_location_id);
|
||||
if (basLocation == null)
|
||||
{
|
||||
throw Oops.Bah("未找到入库库位");
|
||||
}
|
||||
|
||||
OrganizeEntity station = await db.Queryable<OrganizeEntity>()
|
||||
.LeftJoin<OrganizeRelationEntity>((x, y) => x.Id == y.OrganizeId)
|
||||
.Where((x, y) => y.ObjectType == "Eqp" && y.ObjectId == equipment.id).FirstAsync();
|
||||
|
||||
if (station == null)
|
||||
{
|
||||
throw Oops.Bah("未找到工位");
|
||||
}
|
||||
|
||||
PrdOutPacking prdOutPacking = await db.Queryable<PrdOutPacking>().Where(x=>x.station_id==station.Id && x.status=="0").OrderByDescending(x=>x.create_time).FirstAsync();
|
||||
if (prdOutPacking == null)
|
||||
{
|
||||
throw Oops.Bah("未找到托盘");
|
||||
}
|
||||
|
||||
var prdOutPackMarkLabelList = await db.Queryable<PrdOutPackMarkLabel>().Where(x=>x.station_id==station.Id && x.status=="1").ToListAsync();
|
||||
if (prdOutPackMarkLabelList == null || prdOutPackMarkLabelList.Count <= 0)
|
||||
{
|
||||
throw Oops.Bah("未找到提报记录");
|
||||
}
|
||||
|
||||
List<string> reportIds = prdOutPackMarkLabelList.Select(x => x.report_id).ToList();
|
||||
|
||||
List<PrdReport> prdReports = await db.Queryable<PrdReport>().Where(x => reportIds.Contains(x.id)).ToListAsync();
|
||||
|
||||
if (prdReports == null || prdReports.Count<=0)
|
||||
{
|
||||
throw Oops.Bah("未找到提报记录");
|
||||
}
|
||||
|
||||
PrdInstockH? prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new() { };
|
||||
DbResult<bool> result2 = new();
|
||||
string material_id = prdReports[0].material_id;
|
||||
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == material_id);
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(station.Id, DictConst.RegionCategoryWorklineCode);
|
||||
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(station.Id, DictConst.RegionCategoryWorkshopCode);
|
||||
|
||||
prdInstockH = new PrdInstockH()
|
||||
{
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
bill_date = DateTime.Now,
|
||||
create_id = _userManager.UserId,
|
||||
location_code = basLocation.location_code,
|
||||
carry_code = prdOutPacking.code,
|
||||
is_check = 1,
|
||||
station_id = station.Id,
|
||||
workline_id = workline?.Id ?? "",
|
||||
workshop_id = workshop?.Id ?? "",
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
// warehouse_id = basLocation?.wh_id,
|
||||
warehouse_id = warehouse_id,
|
||||
status = 0,
|
||||
};
|
||||
|
||||
foreach (var prdReport in prdReports)
|
||||
{
|
||||
prdInstockDs.Add(new PrdInstockD()
|
||||
{
|
||||
instock_id = prdInstockH.id,
|
||||
report_id = prdReport.create_id,
|
||||
material_id = prdReport.material_id,
|
||||
material_code = basMaterial.code,
|
||||
unit_id = prdReport.unit_id,
|
||||
barcode = prdReport.barcode,
|
||||
code_batch = prdReport.barcode + "0001",
|
||||
quantity = (int)prdReport.reported_qty,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
MESCreateInstockInput mesCreateInstockInput = new()
|
||||
{
|
||||
instock = new MESWmsInstockHInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
// warehouse_id = basLocation?.wh_id,
|
||||
warehouse_id = warehouse_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = prdOutPacking.code,
|
||||
location_code = basLocation.location_code,
|
||||
is_check = 1,
|
||||
},
|
||||
instockds = new List<MESWmsInstockDInput>(),
|
||||
instockcodes = new List<MESWmsInstockCodeInput>()
|
||||
};
|
||||
|
||||
foreach (var prdReport in prdReports)
|
||||
{
|
||||
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
|
||||
{
|
||||
material_id = prdReport.material_id,
|
||||
material_code = basMaterial.code,
|
||||
unit_id = prdReport.unit_id,
|
||||
code_batch = prdReport.barcode,
|
||||
pr_qty = (int)prdReport.reported_qty,
|
||||
});
|
||||
|
||||
mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput()
|
||||
{
|
||||
material_id = prdReport.material_id,
|
||||
material_code = basMaterial.code,
|
||||
unit_id = prdReport.unit_id,
|
||||
barcode = prdReport.barcode,
|
||||
code_batch = prdReport.barcode + "0001",
|
||||
codeqty = (int)prdReport.reported_qty,
|
||||
});
|
||||
}
|
||||
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
|
||||
Log.Information(sendResult);
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
|
||||
? throw Oops.Bah(authResponse.msg)
|
||||
: await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
_ = await _repository.InsertAsync(prdInstockH);
|
||||
|
||||
if (prdInstockDs.Count > 0)
|
||||
{
|
||||
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await db.Updateable<PrdOutPackMarkLabel>()
|
||||
.SetColumns(x => x.status == "2")
|
||||
.Where(x => x.station_id == station.Id && x.status == "1").ExecuteCommandAsync();
|
||||
|
||||
//todo 入库申请后是否修改提报记录状态
|
||||
});
|
||||
}
|
||||
|
||||
return !result2.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result2.IsSuccess ? "申请成功" : result2.ErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1114,9 +1114,12 @@ namespace Tnb.ProductionMgr
|
||||
throw Oops.Bah("已开始的不能再开始");
|
||||
}
|
||||
|
||||
if (await db.Queryable<PrdMoTask>().AnyAsync(x => x.workstation_id == item.workstation_id && x.mo_task_status == DictConst.InProgressEnCode && x.id != item.id))
|
||||
if (item.schedule_type == 2)
|
||||
{
|
||||
throw Oops.Bah("该工位已有生产中的任务单");
|
||||
if (await db.Queryable<PrdMoTask>().AnyAsync(x => x.workstation_id == item.workstation_id && x.mo_task_status == DictConst.InProgressEnCode && x.id != item.id))
|
||||
{
|
||||
throw Oops.Bah("该工位已有生产中的任务单");
|
||||
}
|
||||
}
|
||||
|
||||
if (item.mo_task_status is not DictConst.ToBeStartedEnCode and not DictConst.MoStatusPauseCode)
|
||||
@@ -2735,6 +2738,63 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
return prdMoTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 外包装根据工位id获取喷码数据
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetMarkingInfoByStationId(MarkingLabelInput input)
|
||||
{
|
||||
PrdMoTask prdMoTask = await GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
|
||||
{
|
||||
{ "station_id", input.station_id }
|
||||
});
|
||||
if (prdMoTask == null) throw Oops.Bah("没找到对应任务单");
|
||||
|
||||
PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel()
|
||||
{
|
||||
is_mark = 0,
|
||||
is_label = 0,
|
||||
mo_task_code = prdMoTask.mo_task_code,
|
||||
material_code = prdMoTask.material_code,
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
|
||||
await _db.Insertable<PrdOutPackMarkLabel>(prdOutPackMarkLabel).ExecuteCommandAsync();
|
||||
|
||||
return prdMoTask.mo_task_code + "/" + prdMoTask.material_code;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 外包装根据工位id获取贴标数据
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetLabelInfoByStationId(MarkingLabelInput input)
|
||||
{
|
||||
PrdMoTask prdMoTask = await GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
|
||||
{
|
||||
{ "station_id", input.station_id }
|
||||
});
|
||||
if (prdMoTask == null) throw Oops.Bah("没找到对应任务单");
|
||||
|
||||
PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel()
|
||||
{
|
||||
is_mark = 0,
|
||||
is_label = 0,
|
||||
mo_task_code = prdMoTask.mo_task_code,
|
||||
material_code = prdMoTask.material_code,
|
||||
create_time = DateTime.Now,
|
||||
station_id = input.station_id,
|
||||
};
|
||||
|
||||
await _db.Insertable<PrdOutPackMarkLabel>(prdOutPackMarkLabel).ExecuteCommandAsync();
|
||||
|
||||
return prdMoTask.mo_task_code + "/" + prdMoTask.material_code;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
46
ProductionMgr/Tnb.ProductionMgr/PrdOutPackingService.cs
Normal file
46
ProductionMgr/Tnb.ProductionMgr/PrdOutPackingService.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class PrdOutPackingService : IPrdOutPackingService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<PrdOutPacking> _repository;
|
||||
|
||||
public PrdOutPackingService(ISqlSugarRepository<PrdOutPacking> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 托盘二维码
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> TrayQrcode(TrayQrcodeInput input)
|
||||
{
|
||||
PrdOutPacking prdOutPacking = await _repository.GetFirstAsync(x=>x.code==input.qrcode && x.station_id==input.station_id && x.status=="0");
|
||||
if (prdOutPacking != null) throw Oops.Bah("已存在该托盘");
|
||||
|
||||
prdOutPacking = new PrdOutPacking()
|
||||
{
|
||||
code = input.qrcode,
|
||||
station_id = input.station_id,
|
||||
create_time = DateTime.Now,
|
||||
status = "0",
|
||||
};
|
||||
|
||||
return await _repository.InsertAsync(prdOutPacking);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
@@ -17,6 +19,7 @@ using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
@@ -487,5 +490,144 @@ namespace Tnb.ProductionMgr
|
||||
BasQrcode basQrcode = await _db.Queryable<BasQrcode>().Where(x => x.source_name == "TOOL_MOLDS" && x.code == input.mold_qrcode).FirstAsync();
|
||||
return prdMoTask != null && basQrcode != null ? prdMoTask.mold_id == basQrcode.source_id : (dynamic)false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 外包装喷码校验
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> OutPackMarkCheck(MarkingLabelInput input)
|
||||
{
|
||||
string[] arr = input.mark_code.Split("/");
|
||||
if (arr.Length > 1)
|
||||
{
|
||||
string mo_task_code = arr[0];
|
||||
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().Where(x => x.mo_task_code == mo_task_code).FirstAsync();
|
||||
if (prdMoTask == null) throw Oops.Bah("未找到对应任务单");
|
||||
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(x => x.id == prdMoTask.material_id).FirstAsync();
|
||||
DictionaryDataEntity unit = await _db.Queryable<DictionaryTypeEntity>()
|
||||
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
||||
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == basMaterial.unit_id)
|
||||
.Select((x, y) => y).FirstAsync();
|
||||
PrdOutPackMarkLabel prdOutPackMarkLabel = await _db.Queryable<PrdOutPackMarkLabel>().Where(x=>x.mo_task_code==mo_task_code && x.status=="0" && x.is_mark==0).OrderByDescending(x=>x.create_time).FirstAsync();
|
||||
if (prdOutPackMarkLabel != null)
|
||||
{
|
||||
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
|
||||
if (prdOutPackMarkLabel.is_label == 1)
|
||||
{
|
||||
PrdReport prdReport = new PrdReport()
|
||||
{
|
||||
mo_task_id = prdMoTask.id,
|
||||
mo_task_code = prdMoTask.mo_task_code,
|
||||
create_id = DictConst.DEFAULTUSERID,
|
||||
create_time = DateTime.Now,
|
||||
reported_qty = 1,
|
||||
unit_id = unit?.Id ?? "",
|
||||
barcode = mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(),
|
||||
equip_id = prdMoTask.eqp_id,
|
||||
mbom_process_id = prdMoTask.mbom_process_id,
|
||||
station = prdMoTask.workstation_id,
|
||||
status=0,
|
||||
material_id = prdMoTask.material_id,
|
||||
process_id = prdMoTask.process_id,
|
||||
};
|
||||
|
||||
await _db.Updateable<PrdOutPackMarkLabel>()
|
||||
.SetColumns(x=>x.is_mark==1)
|
||||
.SetColumns(x=>x.status=="1")
|
||||
.SetColumns(x=>x.report_id==prdReport.id)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
await _db.Insertable<PrdReport>(prdReport).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<PrdOutPackMarkLabel>().SetColumns(x=>x.is_mark==1).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "校验成功" : result.ErrorMessage;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("校验失败");
|
||||
}
|
||||
}
|
||||
|
||||
throw Oops.Bah("校验失败");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 外包装贴标校验
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> OutPackLabelCheck(MarkingLabelInput input)
|
||||
{
|
||||
string[] arr = input.mark_code.Split("/");
|
||||
if (arr.Length > 1)
|
||||
{
|
||||
string mo_task_code = arr[0];
|
||||
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().Where(x => x.mo_task_code == mo_task_code).FirstAsync();
|
||||
if (prdMoTask == null) throw Oops.Bah("未找到对应任务单");
|
||||
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(x => x.id == prdMoTask.material_id).FirstAsync();
|
||||
DictionaryDataEntity unit = await _db.Queryable<DictionaryTypeEntity>()
|
||||
.LeftJoin<DictionaryDataEntity>((x, y) => x.Id == y.DictionaryTypeId)
|
||||
.Where((x, y) => x.EnCode == DictConst.MeasurementUnit && y.EnCode == basMaterial.unit_id)
|
||||
.Select((x, y) => y).FirstAsync();
|
||||
PrdOutPackMarkLabel prdOutPackMarkLabel = await _db.Queryable<PrdOutPackMarkLabel>().Where(x=>x.mo_task_code==mo_task_code && x.status=="0" && x.is_label==0).OrderByDescending(x=>x.create_time).FirstAsync();
|
||||
if (prdOutPackMarkLabel != null)
|
||||
{
|
||||
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
|
||||
if (prdOutPackMarkLabel.is_mark == 1)
|
||||
{
|
||||
PrdReport prdReport = new PrdReport()
|
||||
{
|
||||
mo_task_id = prdMoTask.id,
|
||||
mo_task_code = prdMoTask.mo_task_code,
|
||||
create_id = DictConst.DEFAULTUSERID,
|
||||
create_time = DateTime.Now,
|
||||
reported_qty = 1,
|
||||
unit_id = unit?.Id ?? "",
|
||||
barcode = mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(),
|
||||
equip_id = prdMoTask.eqp_id,
|
||||
mbom_process_id = prdMoTask.mbom_process_id,
|
||||
station = prdMoTask.workstation_id,
|
||||
status=0,
|
||||
material_id = prdMoTask.material_id,
|
||||
process_id = prdMoTask.process_id,
|
||||
};
|
||||
|
||||
await _db.Updateable<PrdOutPackMarkLabel>()
|
||||
.SetColumns(x=>x.is_label==1)
|
||||
.SetColumns(x=>x.status=="1")
|
||||
.SetColumns(x=>x.report_id==prdReport.id)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
await _db.Insertable<PrdReport>(prdReport).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<PrdOutPackMarkLabel>().SetColumns(x=>x.is_label==1).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "校验成功" : result.ErrorMessage;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("校验失败");
|
||||
}
|
||||
}
|
||||
|
||||
throw Oops.Bah("校验失败");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user