执行代码清理,修复warning
This commit is contained in:
@@ -55,12 +55,12 @@ namespace Tnb.ProductionMgr.APP
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string material_code = queryJson.ContainsKey("material_id") ? queryJson["material_id"].ToString() : "";
|
||||
string equip_code = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : "";
|
||||
var result = await db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<AppPrdMoTaskOneListOutput> result = await db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
|
||||
.LeftJoin<EqpEquipment>((a, b, c, d) => a.eqp_id == d.id)
|
||||
@@ -107,7 +107,11 @@ namespace Tnb.ProductionMgr.APP
|
||||
public async Task<dynamic> GetLogById(Dictionary<string, string> dic)
|
||||
{
|
||||
string mo_task_id = dic.ContainsKey("mo_task_id") ? dic["mo_task_id"] : "";
|
||||
if (string.IsNullOrEmpty(mo_task_id)) return Array.Empty<string>();
|
||||
if (string.IsNullOrEmpty(mo_task_id))
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
Dictionary<string, object> statsDic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
return await _db.Queryable<PrdMoTaskLog>().Where(x => x.mo_task_id == mo_task_id)
|
||||
.OrderBy(x => x.create_time)
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace Tnb.ProductionMgr.APP
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string material_code = queryJson.ContainsKey("material_id") ? queryJson["material_id"].ToString() : "";
|
||||
string equip_code = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : "";
|
||||
var result = await db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<AppPrdMoTaskOneListOutput> result = await db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
|
||||
.LeftJoin<EqpEquipment>((a, b, c, d) => a.eqp_id == d.id)
|
||||
@@ -66,7 +66,7 @@ namespace Tnb.ProductionMgr.APP
|
||||
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e) => b.code.Contains(material_code) || b.name.Contains(material_code))
|
||||
.WhereIF(!string.IsNullOrEmpty(equip_code), (a, b, c, d, e) => d.code.Contains(equip_code) || d.name.Contains(equip_code))
|
||||
.Where(a => a.schedule_type == 1)
|
||||
.Where(a => (a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.InProgressEnCode || a.mo_task_status == DictConst.MoStatusExceptionCode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.ComplatedEnCode))
|
||||
.Where(a => a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.InProgressEnCode || a.mo_task_status == DictConst.MoStatusExceptionCode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.ComplatedEnCode)
|
||||
.OrderByDescending(a => a.create_time)
|
||||
.Select((a, b, c, d, e) => new AppPrdMoTaskOneListOutput
|
||||
{
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace Tnb.ProductionMgr.APP
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string material_code = queryJson.ContainsKey("material_id") ? queryJson["material_id"].ToString() : "";
|
||||
string equip_code = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : "";
|
||||
var result = await db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<AppPrdMoTaskOneListOutput> result = await db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
|
||||
.LeftJoin<EqpEquipment>((a, b, c, d) => a.eqp_id == d.id)
|
||||
@@ -67,7 +67,7 @@ namespace Tnb.ProductionMgr.APP
|
||||
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e) => b.code.Contains(material_code) || b.name.Contains(material_code))
|
||||
.WhereIF(!string.IsNullOrEmpty(equip_code), (a, b, c, d, e) => d.code.Contains(equip_code) || d.name.Contains(equip_code))
|
||||
.Where(a => a.schedule_type == 2)
|
||||
.Where(a => (a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.InProgressEnCode || a.mo_task_status == DictConst.MoStatusExceptionCode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.ComplatedEnCode))
|
||||
.Where(a => a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.InProgressEnCode || a.mo_task_status == DictConst.MoStatusExceptionCode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.ComplatedEnCode)
|
||||
.OrderByDescending(a => a.create_time)
|
||||
.Select((a, b, c, d, e, f) => new AppPrdMoTaskOneListOutput
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
private SendMessageService _sendMessageService;
|
||||
private readonly SendMessageService _sendMessageService;
|
||||
private readonly IBasPushRuleLogService _basPushRuleLogService;
|
||||
private readonly TimeTaskService _timeTaskService;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetAndonPadList(AndonPadListInput input)
|
||||
{
|
||||
var result = await _db.Queryable<AndonRecords>()
|
||||
SqlSugarPagedList<AndonPadListOutput> result = await _db.Queryable<AndonRecords>()
|
||||
.LeftJoin<AndonInfo>((a, b) => a.andon_info_id == b.id)
|
||||
.LeftJoin<UserEntity>((a, b, c) => a.repair_id == c.Id)
|
||||
.LeftJoin<UserEntity>((a, b, c, d) => a.create_id == d.Id)
|
||||
@@ -93,7 +93,7 @@ namespace Tnb.ProductionMgr
|
||||
andonRecords.status = DictConst.AndonStatusHJZ;
|
||||
|
||||
|
||||
List<string> toUsers = new List<string>();
|
||||
List<string> toUsers = new();
|
||||
|
||||
if (!string.IsNullOrEmpty(andonInfo.personnel))
|
||||
{
|
||||
@@ -116,18 +116,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
List<MessageSendModel> list = await _sendMessageService.SendTest(andonInfo.send_config_id);
|
||||
|
||||
foreach (var item in list)
|
||||
foreach (MessageSendModel item in list)
|
||||
{
|
||||
item.toUser = toUsers;
|
||||
}
|
||||
|
||||
foreach (var item in list)
|
||||
foreach (MessageSendModel item in list)
|
||||
{
|
||||
await _sendMessageService.SendMessage(item, new Dictionary<string, object>());
|
||||
_ = await _sendMessageService.SendMessage(item, new Dictionary<string, object>());
|
||||
}
|
||||
}
|
||||
|
||||
await _db.Insertable<AndonRecords>(andonRecords).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable<AndonRecords>(andonRecords).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
@@ -146,25 +146,27 @@ namespace Tnb.ProductionMgr
|
||||
// string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ? {executeTime.Year}";
|
||||
string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ?";
|
||||
|
||||
var comtentModel = new ContentModel();
|
||||
// comtentModel.cron = (2 * 60).ToString();
|
||||
comtentModel.cron = cron;
|
||||
comtentModel.interfaceId = "";
|
||||
comtentModel.interfaceName = "";
|
||||
comtentModel.parameter = new List<InterfaceParameter>();
|
||||
comtentModel.localHostTaskId = "PushMsgTimeWorker/PushMsg";
|
||||
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
// comtentModel.endTime = DateTimeOffset.Now.AddSeconds(3).ToUnixTimeMilliseconds().ToString();
|
||||
comtentModel.TenantId = _userManager?.TenantId;
|
||||
comtentModel.TenantDbName = _userManager?.TenantDbName;
|
||||
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig;
|
||||
comtentModel.Token = _userManager?.ToKen;
|
||||
ContentModel comtentModel = new()
|
||||
{
|
||||
// comtentModel.cron = (2 * 60).ToString();
|
||||
cron = cron,
|
||||
interfaceId = "",
|
||||
interfaceName = "",
|
||||
parameter = new List<InterfaceParameter>(),
|
||||
localHostTaskId = "PushMsgTimeWorker/PushMsg",
|
||||
startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
|
||||
// comtentModel.endTime = DateTimeOffset.Now.AddSeconds(3).ToUnixTimeMilliseconds().ToString();
|
||||
TenantId = _userManager?.TenantId,
|
||||
TenantDbName = _userManager?.TenantDbName,
|
||||
ConnectionConfig = _userManager?.ConnectionConfig,
|
||||
Token = _userManager?.ToKen
|
||||
};
|
||||
|
||||
// foreach (var item in sendModels)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
TimeTaskCrInput timeTaskCrInput = new TimeTaskCrInput()
|
||||
TimeTaskCrInput timeTaskCrInput = new()
|
||||
{
|
||||
enCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
fullName = "andon推送消息" + DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
@@ -179,7 +181,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
TimeTaskEntity timeTaskEntity = await _db.Queryable<TimeTaskEntity>().Where(x => x.EnCode == timeTaskCrInput.enCode).FirstAsync();
|
||||
|
||||
BasPushRuleLog basPushRuleLog = new BasPushRuleLog()
|
||||
BasPushRuleLog basPushRuleLog = new()
|
||||
{
|
||||
push_rule_id = andonInfo.push_rule_id,
|
||||
timetask_id = timeTaskEntity?.Id,
|
||||
@@ -188,14 +190,13 @@ namespace Tnb.ProductionMgr
|
||||
is_push = 1,
|
||||
};
|
||||
|
||||
await _db.Insertable<BasPushRuleLog>(basPushRuleLog).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable<BasPushRuleLog>(basPushRuleLog).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "发起成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "发起成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -218,11 +219,11 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
_ = await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x => x.repair_id == _userManager.UserId)
|
||||
.SetColumns(x => x.response_time == DateTime.Now)
|
||||
.ExecuteCommandAsync();
|
||||
Dictionary<string, string> postData = new Dictionary<string, string>()
|
||||
Dictionary<string, string> postData = new()
|
||||
{
|
||||
["id"] = andonRecords.id
|
||||
};
|
||||
@@ -252,7 +253,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
_ = await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x => x.start_repair_time == DateTime.Now)
|
||||
.Where(x => x.id == id)
|
||||
.ExecuteCommandAsync();
|
||||
@@ -279,7 +280,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
_ = await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x => x.end_repair_time == DateTime.Now)
|
||||
.Where(x => x.id == id)
|
||||
.ExecuteCommandAsync();
|
||||
@@ -306,7 +307,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.Updateable<AndonRecords>()
|
||||
_ = await _db.Updateable<AndonRecords>()
|
||||
.SetColumns(x => x.confirm_time == DateTime.Now)
|
||||
.Where(x => x.id == id)
|
||||
.ExecuteCommandAsync();
|
||||
@@ -322,7 +323,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
private async Task<List<MessageSendModel>> GetSendParamJson(string id)
|
||||
{
|
||||
var list = await _db.Queryable<MessageSendTemplateEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
List<MessageSendModel> list = await _db.Queryable<MessageSendTemplateEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
.Where((a, b) => a.SendConfigId == id && a.DeleteMark == null && b.DeleteMark == null)
|
||||
.Select((a, b) => new MessageSendModel
|
||||
{
|
||||
@@ -333,13 +334,12 @@ namespace Tnb.ProductionMgr
|
||||
sendConfigId = a.SendConfigId,
|
||||
templateId = a.TemplateId,
|
||||
}).ToListAsync();
|
||||
foreach (var item in list)
|
||||
foreach (MessageSendModel? item in list)
|
||||
{
|
||||
// 是否存在参数.
|
||||
var flag = await _db.Queryable<MessageSmsFieldEntity>().AnyAsync(x => x.TemplateId == item.templateId && x.DeleteMark == null);
|
||||
if (flag)
|
||||
{
|
||||
item.paramJson = await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity, MessageSmsFieldEntity>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id, JoinType.Left, a.TemplateId == c.TemplateId))
|
||||
bool flag = await _db.Queryable<MessageSmsFieldEntity>().AnyAsync(x => x.TemplateId == item.templateId && x.DeleteMark == null);
|
||||
item.paramJson = flag
|
||||
? await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity, MessageSmsFieldEntity>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id, JoinType.Left, a.TemplateId == c.TemplateId))
|
||||
.Where((a, b, c) => a.TemplateId == item.templateId && a.DeleteMark == null && b.DeleteMark == null && a.Field == c.Field && a.Field != "@flowLink")
|
||||
.Select((a, b) => new MessageSendParam
|
||||
{
|
||||
@@ -350,11 +350,8 @@ namespace Tnb.ProductionMgr
|
||||
templateId = a.TemplateId,
|
||||
templateName = b.FullName,
|
||||
templateType = b.TemplateType
|
||||
}).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.paramJson = await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
}).ToListAsync()
|
||||
: await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
.Where((a, b) => a.TemplateId == item.templateId && a.DeleteMark == null && b.DeleteMark == null && a.Field != "@flowLink")
|
||||
.Where((a, b) => b.Title.Contains(a.Field) || b.Content.Contains(a.Field))
|
||||
.Select((a, b) => new MessageSendParam
|
||||
@@ -367,7 +364,6 @@ namespace Tnb.ProductionMgr
|
||||
templateName = b.FullName,
|
||||
templateType = b.TemplateType
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -27,21 +27,23 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetPrdTask(string stationId)
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("ToBeStarted", "待开工");
|
||||
dic.Add("InProgress", "进行中");
|
||||
dic.Add("Closed", "关闭");
|
||||
dic.Add("Complated", "完工");
|
||||
dic.Add("ToBeScheduled", "待下发");
|
||||
dic.Add("Pause", "暂停");
|
||||
dic.Add("Exception", "异常");
|
||||
dic.Add("Revoke", "撤销");
|
||||
Dictionary<string, string> dic = new()
|
||||
{
|
||||
{ "ToBeStarted", "待开工" },
|
||||
{ "InProgress", "进行中" },
|
||||
{ "Closed", "关闭" },
|
||||
{ "Complated", "完工" },
|
||||
{ "ToBeScheduled", "待下发" },
|
||||
{ "Pause", "暂停" },
|
||||
{ "Exception", "异常" },
|
||||
{ "Revoke", "撤销" }
|
||||
};
|
||||
List<dynamic> result = new();
|
||||
var List = await _db.Queryable<PrdMoTask>()
|
||||
List<PrdMoTask> List = await _db.Queryable<PrdMoTask>()
|
||||
.WhereIF(!string.IsNullOrEmpty(stationId), p => p.workstation_id == stationId)
|
||||
.ToListAsync();
|
||||
var materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
||||
foreach (var data in List)
|
||||
List<BasMaterial> materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
||||
foreach (PrdMoTask data in List)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
info.id = data.id;
|
||||
@@ -55,31 +57,33 @@ namespace Tnb.ProductionMgr
|
||||
info.plan_end_date = data.estimated_end_date == null ? "" : ((DateTime)data.estimated_end_date!).ToString("yyyy-MM-dd");
|
||||
result.Add(info);
|
||||
}
|
||||
result.OrderByDescending(p => p.plan_start_date);
|
||||
_ = result.OrderByDescending(p => p.plan_start_date);
|
||||
return result;
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task SaveData(AndonRecordInput AndonRecordInput)
|
||||
{
|
||||
var list = _db.Queryable<AndonBreakDown>().ToList();
|
||||
AndonRecords andonRecord = new AndonRecords();
|
||||
andonRecord.mo_id = AndonRecordInput.mo_id;
|
||||
andonRecord.breakdown_type = list.Where(p => p.id == AndonRecordInput.breakdown).Any() ? list.Where(p => p.id == AndonRecordInput.breakdown).First().type_id : "";
|
||||
andonRecord.breakdown = AndonRecordInput.breakdown;
|
||||
andonRecord.create_time = DateTime.Now;
|
||||
andonRecord.create_id = _userManager.UserId;
|
||||
await _db.Insertable(andonRecord).ExecuteCommandAsync();
|
||||
List<AndonBreakDown> list = _db.Queryable<AndonBreakDown>().ToList();
|
||||
AndonRecords andonRecord = new()
|
||||
{
|
||||
mo_id = AndonRecordInput.mo_id,
|
||||
breakdown_type = list.Where(p => p.id == AndonRecordInput.breakdown).Any() ? list.Where(p => p.id == AndonRecordInput.breakdown).First().type_id : "",
|
||||
breakdown = AndonRecordInput.breakdown,
|
||||
create_time = DateTime.Now,
|
||||
create_id = _userManager.UserId
|
||||
};
|
||||
_ = await _db.Insertable(andonRecord).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetAndonCascaderOptions()
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
Dictionary<string, object> result = new();
|
||||
List<AndonType> andonTypes = await _db.Queryable<AndonType>().ToListAsync();
|
||||
List<AndonInfo> andonInfos = await _db.Queryable<AndonInfo>().ToListAsync();
|
||||
List<AndonBreakDown> andonBreakDowns = await _db.Queryable<AndonBreakDown>().ToListAsync();
|
||||
List<AndonCascaderOptionsOuput> options = new List<AndonCascaderOptionsOuput>();
|
||||
foreach (var andonType in andonTypes)
|
||||
List<AndonCascaderOptionsOuput> options = new();
|
||||
foreach (AndonType andonType in andonTypes)
|
||||
{
|
||||
options.Add(new AndonCascaderOptionsOuput()
|
||||
{
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
private readonly TimeTaskService _timeTaskService;
|
||||
private SendMessageService _sendMessageService;
|
||||
private readonly SendMessageService _sendMessageService;
|
||||
|
||||
|
||||
private static Dictionary<string, object> _dicWorkStationAndShopRelacion = new Dictionary<string, object>();
|
||||
private static Dictionary<string, object> _dicWorkShop = new Dictionary<string, object>();
|
||||
private static readonly Dictionary<string, object> _dicWorkStationAndShopRelacion = new();
|
||||
private static Dictionary<string, object> _dicWorkShop = new();
|
||||
private const string PUSHRULEID = "27121606262805";//异常停机的推送规则id
|
||||
|
||||
|
||||
@@ -86,16 +86,16 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
if (_dicWorkShop.Count < 1)
|
||||
{
|
||||
var orgs = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workstation").ToListAsync();
|
||||
List<OrganizeEntity> orgs = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workstation").ToListAsync();
|
||||
if (orgs?.Count > 0)
|
||||
{
|
||||
var shopIds = orgs.Select(x =>
|
||||
List<string> shopIds = orgs.Select(x =>
|
||||
{
|
||||
var shopId = "";
|
||||
var orgTree = x.OrganizeIdTree.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string shopId = "";
|
||||
string[] orgTree = x.OrganizeIdTree.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (orgTree?.Length > 1)
|
||||
{
|
||||
shopId = orgTree[orgTree.Length - 2];
|
||||
shopId = orgTree[^2];
|
||||
_dicWorkStationAndShopRelacion[x.EnCode] = shopId;
|
||||
}
|
||||
return shopId;
|
||||
@@ -106,25 +106,28 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
var result = new List<ClosedownEndListOutput>();
|
||||
var closeDown = await _db.Queryable<PrdCancelClosedown>().FirstAsync(it => it.eqp_id == eqpId);
|
||||
List<ClosedownEndListOutput> result = new();
|
||||
PrdCancelClosedown closeDown = await _db.Queryable<PrdCancelClosedown>().FirstAsync(it => it.eqp_id == eqpId);
|
||||
if (closeDown != null)
|
||||
{
|
||||
if (!closeDown.reason.IsNullOrEmpty())
|
||||
{
|
||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||
EqpEquipType eqpTypeInfo = null;
|
||||
EqpEquipment? eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||
EqpEquipType? eqpTypeInfo = null;
|
||||
if (eqp != null)
|
||||
{
|
||||
eqpTypeInfo = await _db.Queryable<EqpEquipType>().FirstAsync(it => it.id == eqp.equip_type_id);
|
||||
var reasonArr = closeDown.reason.Split(",");
|
||||
foreach (var reason in reasonArr)
|
||||
}
|
||||
|
||||
string[] reasonArr = closeDown.reason.Split(",");
|
||||
foreach (string reason in reasonArr)
|
||||
{
|
||||
ClosedownEndListOutput ot = new();
|
||||
if (eqp != null)
|
||||
{
|
||||
if (_dicWorkStationAndShopRelacion.ContainsKey(eqp.station_code))
|
||||
{
|
||||
var shopId = _dicWorkStationAndShopRelacion[eqp.station_code].ToString();
|
||||
string? shopId = _dicWorkStationAndShopRelacion[eqp.station_code].ToString();
|
||||
ot.workshop_name = _dicWorkShop.ContainsKey(shopId) ? _dicWorkShop[shopId].ToString()! : "";
|
||||
}
|
||||
}
|
||||
@@ -153,7 +156,7 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetClosedownHistory([FromQuery] ClosedownHistoryQuery input)
|
||||
{
|
||||
var pagedList = await _db.Queryable<PrdCancelClosedownRecord>()
|
||||
List<ClosedownHistoryOutput> pagedList = await _db.Queryable<PrdCancelClosedownRecord>()
|
||||
.WhereIF(!string.IsNullOrEmpty(input.eqpName), it => it.eqp_name.Contains(input.eqpName))
|
||||
.WhereIF(input.beginTime.HasValue, it => it.closedown_start_time.Value >= input.beginTime)
|
||||
.WhereIF(input.endTime.HasValue, it => it.closedown_start_time.Value <= input.endTime)
|
||||
@@ -184,10 +187,10 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<dynamic> GetInfoFromEqpId([FromRoute] string eqpId)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
var moTask = await _db.Queryable<PrdMoTask>().Where(it => it.mo_task_status == DictConst.InProgressEnCode).FirstAsync(it => it.eqp_id == eqpId);
|
||||
PrdMoTask moTask = await _db.Queryable<PrdMoTask>().Where(it => it.mo_task_status == DictConst.InProgressEnCode).FirstAsync(it => it.eqp_id == eqpId);
|
||||
if (moTask != null)
|
||||
{
|
||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == moTask.mo_id);
|
||||
ToolMolds? mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == moTask.mo_id);
|
||||
info.mo_task_code = moTask.mo_task_code;
|
||||
info.mold_code = mold?.mold_code;
|
||||
info.mold_name = mold?.mold_name;
|
||||
@@ -204,19 +207,31 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task CloseDownStart(CloseDownStartInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input.eqp_id.IsNullOrWhiteSpace()) throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty");
|
||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.eqp_id);
|
||||
var cancelCloseDown = input.Adapt<PrdCancelClosedown>();
|
||||
EqpRepairApply eqpRepairApply = null;
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException("input");
|
||||
}
|
||||
|
||||
if (input.eqp_id.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty");
|
||||
}
|
||||
|
||||
EqpEquipment? eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.eqp_id);
|
||||
PrdCancelClosedown cancelCloseDown = input.Adapt<PrdCancelClosedown>();
|
||||
EqpRepairApply? eqpRepairApply = null;
|
||||
BasPushRuleD basPushRuleD = await _db.Queryable<BasPushRuleD>().FirstAsync(x => x.push_rule_id == PUSHRULEID && x.ordinal == 1);
|
||||
try
|
||||
{
|
||||
|
||||
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id);
|
||||
if (moTaskList?.Count > 1) throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500);
|
||||
List<PrdMoTask>? moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id);
|
||||
if (moTaskList?.Count > 1)
|
||||
{
|
||||
throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500);
|
||||
}
|
||||
|
||||
if (moTaskList?.Count > 0)
|
||||
{
|
||||
|
||||
@@ -226,23 +241,25 @@ namespace Tnb.ProductionMgr
|
||||
cancelCloseDown.create_time = DateTime.Now;
|
||||
cancelCloseDown.closedown_start_time = DateTime.Now;
|
||||
|
||||
await _db.Insertable(cancelCloseDown).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(cancelCloseDown).ExecuteCommandAsync();
|
||||
|
||||
var record = cancelCloseDown.Adapt<PrdCancelClosedownRecord>();
|
||||
PrdCancelClosedownRecord record = cancelCloseDown.Adapt<PrdCancelClosedownRecord>();
|
||||
record.eqp_code = eqp?.code;
|
||||
record.eqp_name = eqp?.name;
|
||||
await _db.Insertable(record).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(record).ExecuteCommandAsync();
|
||||
|
||||
var moldId = moTaskList.First().mold_id;
|
||||
string? moldId = moTaskList.First().mold_id;
|
||||
if (!moldId.IsNullOrEmpty())
|
||||
{
|
||||
var mold = await _moldService.GetListById(moldId);
|
||||
var maintaindTask = new ToolMoldMaintainTask();
|
||||
maintaindTask.mold_id = moldId;
|
||||
maintaindTask.code = mold?.mold_code ?? "";
|
||||
maintaindTask.create_id = _userManager.UserId;
|
||||
maintaindTask.status = DictConst.UnMaintainStatusCode;
|
||||
maintaindTask.create_time = DateTime.Now;
|
||||
ToolMolds mold = await _moldService.GetListById(moldId);
|
||||
ToolMoldMaintainTask maintaindTask = new()
|
||||
{
|
||||
mold_id = moldId,
|
||||
code = mold?.mold_code ?? "",
|
||||
create_id = _userManager.UserId,
|
||||
status = DictConst.UnMaintainStatusCode,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
|
||||
await _maintainTaskService.Create(maintaindTask);
|
||||
}
|
||||
@@ -252,7 +269,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
List<PrdCancelClosedownReason> prdCancelClosedownReasons = await _db.Queryable<PrdCancelClosedownReason>().ToListAsync();
|
||||
string[] reasonArr = input.reason.Split(",");
|
||||
var reasonList = prdCancelClosedownReasons.Where(x => reasonArr.Contains(x.id)).Select(x => x.reason).ToList();
|
||||
List<string?> reasonList = prdCancelClosedownReasons.Where(x => reasonArr.Contains(x.id)).Select(x => x.reason).ToList();
|
||||
reason = string.Join(',', reasonList);
|
||||
|
||||
}
|
||||
@@ -269,16 +286,16 @@ namespace Tnb.ProductionMgr
|
||||
remark = input.remark,
|
||||
};
|
||||
|
||||
await _db.Insertable(eqpRepairApply).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(eqpRepairApply).ExecuteCommandAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(eqp.responsibler_id))
|
||||
{
|
||||
List<MessageSendModel> list = await _sendMessageService.SendTest(basPushRuleD.send_config_id);
|
||||
List<string> toUsers = JsonConvert.DeserializeObject<List<string>>(eqp.responsibler_id);
|
||||
|
||||
foreach (var item in list)
|
||||
foreach (MessageSendModel item in list)
|
||||
{
|
||||
foreach (var param in item.paramJson)
|
||||
foreach (MessageSendParam param in item.paramJson)
|
||||
{
|
||||
if (param.field == "equip_code")
|
||||
{
|
||||
@@ -288,15 +305,18 @@ namespace Tnb.ProductionMgr
|
||||
item.toUser = toUsers;
|
||||
}
|
||||
|
||||
foreach (var item in list)
|
||||
foreach (MessageSendModel item in list)
|
||||
{
|
||||
await _sendMessageService.SendMessage(item, new Dictionary<string, object>());
|
||||
_ = await _sendMessageService.SendMessage(item, new Dictionary<string, object>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else throw Oops.Oh(ErrorCode.COM1001);
|
||||
else
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
});
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
@@ -312,23 +332,25 @@ namespace Tnb.ProductionMgr
|
||||
// string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ? {executeTime.Year}";
|
||||
string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ?";
|
||||
|
||||
var comtentModel = new ContentModel();
|
||||
// comtentModel.cron = (2 * 60).ToString();
|
||||
comtentModel.cron = cron;
|
||||
comtentModel.interfaceId = "";
|
||||
comtentModel.interfaceName = "";
|
||||
comtentModel.parameter = new List<InterfaceParameter>();
|
||||
comtentModel.localHostTaskId = "PushMsgTimeWorker/PushMsg";
|
||||
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
// comtentModel.endTime = DateTimeOffset.Now.AddSeconds(3).ToUnixTimeMilliseconds().ToString();
|
||||
comtentModel.TenantId = _userManager?.TenantId;
|
||||
comtentModel.TenantDbName = _userManager?.TenantDbName;
|
||||
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig;
|
||||
comtentModel.Token = _userManager?.ToKen;
|
||||
|
||||
foreach (var item in sendModels)
|
||||
ContentModel comtentModel = new()
|
||||
{
|
||||
foreach (var param in item.paramJson)
|
||||
// comtentModel.cron = (2 * 60).ToString();
|
||||
cron = cron,
|
||||
interfaceId = "",
|
||||
interfaceName = "",
|
||||
parameter = new List<InterfaceParameter>(),
|
||||
localHostTaskId = "PushMsgTimeWorker/PushMsg",
|
||||
startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
|
||||
// comtentModel.endTime = DateTimeOffset.Now.AddSeconds(3).ToUnixTimeMilliseconds().ToString();
|
||||
TenantId = _userManager?.TenantId,
|
||||
TenantDbName = _userManager?.TenantDbName,
|
||||
ConnectionConfig = _userManager?.ConnectionConfig,
|
||||
Token = _userManager?.ToKen
|
||||
};
|
||||
|
||||
foreach (MessageSendModel item in sendModels)
|
||||
{
|
||||
foreach (MessageSendParam param in item.paramJson)
|
||||
{
|
||||
if (param.field == "equip_code")
|
||||
{
|
||||
@@ -337,7 +359,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
|
||||
TimeTaskCrInput timeTaskCrInput = new TimeTaskCrInput()
|
||||
TimeTaskCrInput timeTaskCrInput = new()
|
||||
{
|
||||
enCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
fullName = "临时推送消息" + DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
@@ -352,7 +374,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
TimeTaskEntity timeTaskEntity = await _db.Queryable<TimeTaskEntity>().Where(x => x.EnCode == timeTaskCrInput.enCode).FirstAsync();
|
||||
|
||||
BasPushRuleLog basPushRuleLog = new BasPushRuleLog()
|
||||
BasPushRuleLog basPushRuleLog = new()
|
||||
{
|
||||
push_rule_id = PUSHRULEID,
|
||||
timetask_id = timeTaskEntity?.Id,
|
||||
@@ -361,7 +383,7 @@ namespace Tnb.ProductionMgr
|
||||
is_push = 1,
|
||||
};
|
||||
|
||||
await _db.Insertable<BasPushRuleLog>(basPushRuleLog).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable<BasPushRuleLog>(basPushRuleLog).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,25 +406,33 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task CloseDownEnd(CloseDownStartInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input.eqp_id.IsNullOrWhiteSpace()) throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty");
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException("input");
|
||||
}
|
||||
|
||||
if (input.eqp_id.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var closeDown = await _db.Queryable<PrdCancelClosedown>().Where(it => it.eqp_id == input.eqp_id).OrderByDescending(it => it.closedown_start_time).FirstAsync();
|
||||
PrdCancelClosedown closeDown = await _db.Queryable<PrdCancelClosedown>().Where(it => it.eqp_id == input.eqp_id).OrderByDescending(it => it.closedown_start_time).FirstAsync();
|
||||
if (closeDown != null)
|
||||
{
|
||||
closeDown.closedown_end_time = DateTime.Now;
|
||||
await _db.Updateable(closeDown).ExecuteCommandAsync();
|
||||
var record = closeDown.Adapt<PrdCancelClosedownRecord>();
|
||||
_ = await _db.Updateable(closeDown).ExecuteCommandAsync();
|
||||
PrdCancelClosedownRecord record = closeDown.Adapt<PrdCancelClosedownRecord>();
|
||||
//计算停机时间间隔,以小时为单位
|
||||
if (record.closedown_start_time.HasValue && record.closedown_end_time.HasValue)
|
||||
{
|
||||
var interval = record.closedown_end_time.Value.Subtract(record.closedown_start_time.Value).TotalHours;
|
||||
double interval = record.closedown_end_time.Value.Subtract(record.closedown_start_time.Value).TotalHours;
|
||||
record.closedown_time = Convert.ToDecimal(interval);
|
||||
}
|
||||
await _db.Updateable(record).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable(record).ExecuteCommandAsync();
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
@@ -417,7 +447,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
private async Task<List<MessageSendModel>> GetSendParamJson(string id)
|
||||
{
|
||||
var list = await _db.Queryable<MessageSendTemplateEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
List<MessageSendModel> list = await _db.Queryable<MessageSendTemplateEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
.Where((a, b) => a.SendConfigId == id && a.DeleteMark == null && b.DeleteMark == null)
|
||||
.Select((a, b) => new MessageSendModel
|
||||
{
|
||||
@@ -428,13 +458,12 @@ namespace Tnb.ProductionMgr
|
||||
sendConfigId = a.SendConfigId,
|
||||
templateId = a.TemplateId,
|
||||
}).ToListAsync();
|
||||
foreach (var item in list)
|
||||
foreach (MessageSendModel? item in list)
|
||||
{
|
||||
// 是否存在参数.
|
||||
var flag = await _db.Queryable<MessageSmsFieldEntity>().AnyAsync(x => x.TemplateId == item.templateId && x.DeleteMark == null);
|
||||
if (flag)
|
||||
{
|
||||
item.paramJson = await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity, MessageSmsFieldEntity>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id, JoinType.Left, a.TemplateId == c.TemplateId))
|
||||
bool flag = await _db.Queryable<MessageSmsFieldEntity>().AnyAsync(x => x.TemplateId == item.templateId && x.DeleteMark == null);
|
||||
item.paramJson = flag
|
||||
? await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity, MessageSmsFieldEntity>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id, JoinType.Left, a.TemplateId == c.TemplateId))
|
||||
.Where((a, b, c) => a.TemplateId == item.templateId && a.DeleteMark == null && b.DeleteMark == null && a.Field == c.Field && a.Field != "@flowLink")
|
||||
.Select((a, b) => new MessageSendParam
|
||||
{
|
||||
@@ -445,11 +474,8 @@ namespace Tnb.ProductionMgr
|
||||
templateId = a.TemplateId,
|
||||
templateName = b.FullName,
|
||||
templateType = b.TemplateType
|
||||
}).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.paramJson = await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
}).ToListAsync()
|
||||
: await _db.Queryable<MessageTemplateParamEntity, MessageTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
|
||||
.Where((a, b) => a.TemplateId == item.templateId && a.DeleteMark == null && b.DeleteMark == null && a.Field != "@flowLink")
|
||||
.Where((a, b) => b.Title.Contains(a.Field) || b.Content.Contains(a.Field))
|
||||
.Select((a, b) => new MessageSendParam
|
||||
@@ -462,7 +488,6 @@ namespace Tnb.ProductionMgr
|
||||
templateName = b.FullName,
|
||||
templateType = b.TemplateType
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -50,17 +50,17 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(MaterialReceiptInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
PrdMoTask moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == input.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
.ToListAsync();
|
||||
|
||||
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
|
||||
PrdFeedingH prdFeedingH = new PrdFeedingH()
|
||||
PrdFeedingH prdFeedingH = new()
|
||||
{
|
||||
code = code,
|
||||
station_id = input.station_id,
|
||||
@@ -78,15 +78,17 @@ namespace Tnb.ProductionMgr
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
|
||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
List<PrdFeedingD> list = new();
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, object> item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.carry_id == input.carry_id && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
@@ -108,20 +110,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}
|
||||
else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
_ = detail.feeding_num + num == detail.num
|
||||
? await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync()
|
||||
: await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -135,29 +135,31 @@ namespace Tnb.ProductionMgr
|
||||
throw new Exception("没有签收物料");
|
||||
}
|
||||
|
||||
var mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
|
||||
var material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
|
||||
var station = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == input.station_id);
|
||||
var process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == input.process_id);
|
||||
var taskLog = new PrdTaskLog();
|
||||
taskLog.id = SnowflakeIdHelper.NextId();
|
||||
taskLog.mo_code = mo?.mo_code!;
|
||||
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.equip_id))?.code!;
|
||||
taskLog.mold_code = "";
|
||||
taskLog.item_code = material?.code!;
|
||||
taskLog.item_standard = material?.material_standard!;
|
||||
taskLog.status = "生产投料";
|
||||
taskLog.operator_name = _userManager.RealName;
|
||||
taskLog.create_id = _userManager.UserId;
|
||||
taskLog.create_time = DateTime.Now;
|
||||
taskLog.mo_task_id = moTask.id;
|
||||
taskLog.mo_task_code = moTask.mo_task_code;
|
||||
taskLog.station_code = station?.EnCode;
|
||||
taskLog.process_code = process.code;
|
||||
PrdMo mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
|
||||
BasMaterial? material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
|
||||
OrganizeEntity station = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == input.station_id);
|
||||
BasMaterial process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == input.process_id);
|
||||
PrdTaskLog taskLog = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
mo_code = mo?.mo_code!,
|
||||
eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.equip_id))?.code!,
|
||||
mold_code = "",
|
||||
item_code = material?.code!,
|
||||
item_standard = material?.material_standard!,
|
||||
status = "生产投料",
|
||||
operator_name = _userManager.RealName,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
mo_task_id = moTask.id,
|
||||
mo_task_code = moTask.mo_task_code,
|
||||
station_code = station?.EnCode,
|
||||
process_code = process.code
|
||||
};
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
@@ -172,30 +174,29 @@ namespace Tnb.ProductionMgr
|
||||
// });
|
||||
}
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
return result.IsSuccess ? "投料成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Oh(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "投料成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveDataNew(MaterialReceiptNewInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
PrdFeedingH prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdFeedingH? prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new();
|
||||
DbResult<bool> result2 = new();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
var parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
PrdMoTask moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
PrdMoTask parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
string worklineId = moTask.workline_id;
|
||||
if (parentMoTask != null && !string.IsNullOrEmpty(parentMoTask.workline_id))
|
||||
{
|
||||
worklineId = parentMoTask.workline_id;
|
||||
}
|
||||
var carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
var workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
var workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
OrganizeEntity workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
OrganizeEntity workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == moTask.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
.ToListAsync();
|
||||
@@ -222,12 +223,14 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
@@ -249,20 +252,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}
|
||||
else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
_ = detail.feeding_num + num == detail.num
|
||||
? await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync()
|
||||
: await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -277,8 +278,8 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
@@ -322,8 +323,7 @@ namespace Tnb.ProductionMgr
|
||||
// }
|
||||
}
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "签收成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -337,28 +337,32 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> Feeding(MaterialReceiptNewInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
|
||||
{
|
||||
{"station_id",input.station_id}
|
||||
});
|
||||
|
||||
if (moTask == null) throw Oops.Bah("找不到任务单");
|
||||
PrdFeedingH prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new List<PrdFeedingD>();
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
if (moTask == null)
|
||||
{
|
||||
throw Oops.Bah("找不到任务单");
|
||||
}
|
||||
|
||||
PrdFeedingH? prdFeedingH = null;
|
||||
List<PrdFeedingD> list = new();
|
||||
DbResult<bool> result2 = new();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
PrdMoTask parentMoTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == moTask.parent_id);
|
||||
string worklineId = moTask.workline_id;
|
||||
if (parentMoTask != null && !string.IsNullOrEmpty(parentMoTask.workline_id))
|
||||
{
|
||||
worklineId = parentMoTask.workline_id;
|
||||
}
|
||||
var carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
var workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
var workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
WmsCarryH carry = await db.Queryable<WmsCarryH>().SingleAsync(x => x.carry_code == input.carry_code);
|
||||
OrganizeEntity workline = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == worklineId);
|
||||
OrganizeEntity workshop = await db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == workline.ParentId);
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id && x.mbom_process_id == moTask.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
.ToListAsync();
|
||||
@@ -385,12 +389,14 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
|
||||
var detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
|
||||
decimal num = Convert.ToDecimal(item["num"]);
|
||||
list.Add(new PrdFeedingD
|
||||
@@ -412,20 +418,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw new Exception("投料数量不能大于签收数量");
|
||||
}
|
||||
else if (detail.feeding_num + num == detail.num)
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
_ = detail.feeding_num + num == detail.num
|
||||
? await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.SetColumns(x => x.is_all_feeding == 1)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync()
|
||||
: await db.Updateable<PrdMaterialReceiptD>()
|
||||
.SetColumns(x => x.feeding_num == x.feeding_num + num)
|
||||
.Where(x => x.id == detail.id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -440,21 +444,20 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
|
||||
await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingH>(prdFeedingH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdFeedingD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||
return result.IsSuccess ? "签收成功" : result.ErrorMessage;
|
||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "签收成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetFeedingRecordTree()
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Queryable<PrdMoTask>()
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
List<FeedingRecordTreeOutput> result = await db.Queryable<PrdMoTask>()
|
||||
.Where(a => a.schedule_type == 2 && a.parent_id != null)
|
||||
.Select(a => new FeedingRecordTreeOutput()
|
||||
{
|
||||
@@ -479,7 +482,7 @@ namespace Tnb.ProductionMgr
|
||||
})
|
||||
}).Mapper(x =>
|
||||
{
|
||||
foreach (var item in x.children)
|
||||
foreach (FeedingRecordChildren item in x.children)
|
||||
{
|
||||
item.children = db.Queryable<PrdFeedingD>()
|
||||
.LeftJoin<BasMaterial>((c, d) => c.material_id == d.id)
|
||||
|
||||
@@ -57,9 +57,9 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string moCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdMoTask>()
|
||||
List<PrdMoTaskTreeOutput> list = await _repository.AsSugarClient().Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
|
||||
.LeftJoin<EqpEquipment>((a, b, c, d) => a.eqp_id == d.id)
|
||||
@@ -79,7 +79,7 @@ namespace Tnb.ProductionMgr
|
||||
estimated_end_date = a.estimated_end_date.ToString(),
|
||||
create_time = a.create_time.ToString()
|
||||
}).ToListAsync();
|
||||
var treeList = list.ToTree();
|
||||
List<PrdMoTaskTreeOutput> treeList = list.ToTree();
|
||||
treeList = treeList.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList();
|
||||
SqlSugarPagedList<PrdMoTaskTreeOutput> pagedList = new()
|
||||
{
|
||||
@@ -97,11 +97,11 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(PrdInstockInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
|
||||
PrdInstockH prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
BasLocation location = await db.Queryable<BasLocation>().FirstAsync(x => x.location_code == input.location_code);
|
||||
PrdInstockH? prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new() { };
|
||||
DbResult<bool> result2 = new();
|
||||
|
||||
if (string.IsNullOrEmpty(input.station_id))
|
||||
{
|
||||
@@ -130,7 +130,7 @@ namespace Tnb.ProductionMgr
|
||||
status = 0,
|
||||
};
|
||||
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
prdInstockDs.Add(new PrdInstockD()
|
||||
{
|
||||
@@ -158,22 +158,24 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
|
||||
mesCreateInstockInput.instock = new MESWmsInstockHInput()
|
||||
MESCreateInstockInput mesCreateInstockInput = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = input.bill_type,
|
||||
warehouse_id = location?.wh_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code,
|
||||
location_code = input.location_code,
|
||||
is_check = input.is_check,
|
||||
instock = new MESWmsInstockHInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = input.bill_type,
|
||||
warehouse_id = location?.wh_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code,
|
||||
location_code = input.location_code,
|
||||
is_check = input.is_check,
|
||||
},
|
||||
instockds = new List<MESWmsInstockDInput>(),
|
||||
instockcodes = new List<MESWmsInstockCodeInput>()
|
||||
};
|
||||
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
|
||||
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
|
||||
{
|
||||
@@ -197,34 +199,27 @@ namespace Tnb.ProductionMgr
|
||||
});
|
||||
}
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
|
||||
Log.Information(sendResult);
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
|
||||
{
|
||||
throw Oops.Bah(authResponse.msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
result2 = await db.Ado.UseTranAsync(async () =>
|
||||
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
|
||||
? throw Oops.Bah(authResponse.msg)
|
||||
: await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(prdInstockH);
|
||||
_ = await _repository.InsertAsync(prdInstockH);
|
||||
|
||||
if (prdInstockDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result2.IsSuccess ? "保存成功" : result2.ErrorMessage;
|
||||
return !result2.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result2.IsSuccess ? "保存成功" : result2.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -235,20 +230,20 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<dynamic> SyncInstock(Dictionary<string, string> dic)
|
||||
{
|
||||
string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : "";
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(sourceId))
|
||||
{
|
||||
await _repository.UpdateAsync(x => new PrdInstockH()
|
||||
_ = await _repository.UpdateAsync(x => new PrdInstockH()
|
||||
{
|
||||
status = 1
|
||||
}, x => x.id == sourceId);
|
||||
var details = await db.Queryable<PrdInstockD>().Where(x => x.instock_id == sourceId).ToListAsync();
|
||||
List<PrdInstockD> details = await db.Queryable<PrdInstockD>().Where(x => x.instock_id == sourceId).ToListAsync();
|
||||
|
||||
foreach (var item in details)
|
||||
foreach (PrdInstockD item in details)
|
||||
{
|
||||
await db.Updateable<PrdReport>().SetColumns(x => x.status == 1)
|
||||
_ = await db.Updateable<PrdReport>().SetColumns(x => x.status == 1)
|
||||
.Where(x => x.id == item.report_id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
@@ -268,21 +263,40 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
string equip_code = inut.equip_code;
|
||||
string as_location_code = inut.as_location_code;
|
||||
if (!string.IsNullOrEmpty(equip_code)) throw Oops.Bah("请传机台号");
|
||||
var db = _repository.AsSugarClient();
|
||||
if (!string.IsNullOrEmpty(equip_code))
|
||||
{
|
||||
throw Oops.Bah("请传机台号");
|
||||
}
|
||||
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
EqpEquipment equipment = await db.Queryable<EqpEquipment>().Where(x => x.code == equip_code).FirstAsync();
|
||||
if (equipment == null) throw Oops.Bah("未找到机台");
|
||||
if (string.IsNullOrEmpty(equipment.as_location_id)) throw Oops.Bah("未找到入库库位");
|
||||
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("未找到入库库位");
|
||||
if (basLocation == null)
|
||||
{
|
||||
throw Oops.Bah("未找到入库库位");
|
||||
}
|
||||
|
||||
PrdReport prdReport = await db.Queryable<PrdReport>()
|
||||
.Where(x => x.equip_id == equipment.id && x.status == 0).OrderByDescending(x => x.create_time)
|
||||
.FirstAsync();
|
||||
if (prdReport == null) throw Oops.Bah("未找到提报记录");
|
||||
if (prdReport == null)
|
||||
{
|
||||
throw Oops.Bah("未找到提报记录");
|
||||
}
|
||||
|
||||
PrdInstockH prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
PrdInstockH? prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new() { };
|
||||
DbResult<bool> result2 = new();
|
||||
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdReport.material_id);
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
@@ -320,21 +334,23 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
|
||||
mesCreateInstockInput.instock = new MESWmsInstockHInput()
|
||||
MESCreateInstockInput mesCreateInstockInput = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
warehouse_id = basLocation?.wh_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = prdReport.material_box_code,
|
||||
location_code = basLocation.location_code,
|
||||
is_check = 1,
|
||||
instock = new MESWmsInstockHInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
warehouse_id = basLocation?.wh_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = prdReport.material_box_code,
|
||||
location_code = basLocation.location_code,
|
||||
is_check = 1,
|
||||
},
|
||||
instockds = new List<MESWmsInstockDInput>(),
|
||||
instockcodes = new List<MESWmsInstockCodeInput>()
|
||||
};
|
||||
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
|
||||
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
|
||||
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
|
||||
{
|
||||
material_id = prdReport.material_id,
|
||||
@@ -354,46 +370,39 @@ namespace Tnb.ProductionMgr
|
||||
codeqty = (int)prdReport.reported_qty,
|
||||
});
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
|
||||
Log.Information(sendResult);
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
|
||||
{
|
||||
throw Oops.Bah(authResponse.msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
result2 = await db.Ado.UseTranAsync(async () =>
|
||||
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
|
||||
? throw Oops.Bah(authResponse.msg)
|
||||
: await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(prdInstockH);
|
||||
_ = await _repository.InsertAsync(prdInstockH);
|
||||
|
||||
if (prdInstockDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result2.IsSuccess ? "申请成功" : result2.ErrorMessage;
|
||||
return !result2.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result2.IsSuccess ? "申请成功" : result2.ErrorMessage);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> InstockTubeOne(PrdReport prdReport)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
string location_code = "JMXHC-01";
|
||||
string warehouse_id = "26103348825381";
|
||||
|
||||
PrdInstockH prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
PrdInstockH? prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new() { };
|
||||
DbResult<bool> result2 = new();
|
||||
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdReport.material_id);
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
@@ -431,21 +440,23 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
|
||||
mesCreateInstockInput.instock = new MESWmsInstockHInput()
|
||||
MESCreateInstockInput mesCreateInstockInput = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
warehouse_id = warehouse_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = prdReport.material_box_code,
|
||||
location_code = location_code,
|
||||
is_check = 1,
|
||||
instock = new MESWmsInstockHInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
warehouse_id = warehouse_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = prdReport.material_box_code,
|
||||
location_code = location_code,
|
||||
is_check = 1,
|
||||
},
|
||||
instockds = new List<MESWmsInstockDInput>(),
|
||||
instockcodes = new List<MESWmsInstockCodeInput>()
|
||||
};
|
||||
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
|
||||
mesCreateInstockInput.instockcodes = new List<MESWmsInstockCodeInput>();
|
||||
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
|
||||
{
|
||||
material_id = prdReport.material_id,
|
||||
@@ -465,30 +476,24 @@ namespace Tnb.ProductionMgr
|
||||
codeqty = (int)prdReport.reported_qty,
|
||||
});
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
|
||||
Log.Information(sendResult);
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
|
||||
{
|
||||
throw Oops.Bah(authResponse.msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
result2 = await db.Ado.UseTranAsync(async () =>
|
||||
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
|
||||
? throw Oops.Bah(authResponse.msg)
|
||||
: await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(prdInstockH);
|
||||
_ = await _repository.InsertAsync(prdInstockH);
|
||||
|
||||
if (prdInstockDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result2.IsSuccess ? "true" : "false";
|
||||
|
||||
@@ -164,36 +164,38 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> KittingOut(KittingOutInput kittingOutInput)
|
||||
{
|
||||
PrdKittingOutH prdKittingOutH = new PrdKittingOutH();
|
||||
PrdKittingOutH prdKittingOutH = new();
|
||||
try
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(kittingOutInput.workstation_id, DictConst.RegionCategoryWorklineCode);
|
||||
kittingOutInput.workline_id = workline?.Id ?? "";
|
||||
|
||||
List<MESKittingOutStkInput> input = new List<MESKittingOutStkInput>();
|
||||
input.Add(new MESKittingOutStkInput()
|
||||
List<MESKittingOutStkInput> input = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
warehouse_id = kittingOutInput.warehouse_id,
|
||||
location_code = kittingOutInput.location_code,
|
||||
material_id = kittingOutInput.material_id,
|
||||
material_code = kittingOutInput.material_code,
|
||||
collocation_scheme_id = kittingOutInput.collocation_scheme_id,
|
||||
collocation_scheme_code = kittingOutInput.collocation_scheme_code,
|
||||
source_id = prdKittingOutH.id,
|
||||
create_id = _userManager.UserId,
|
||||
wmsKittingoutDs = new List<MESKittingOutStkDInput>(),
|
||||
});
|
||||
new MESKittingOutStkInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
warehouse_id = kittingOutInput.warehouse_id,
|
||||
location_code = kittingOutInput.location_code,
|
||||
material_id = kittingOutInput.material_id,
|
||||
material_code = kittingOutInput.material_code,
|
||||
collocation_scheme_id = kittingOutInput.collocation_scheme_id,
|
||||
collocation_scheme_code = kittingOutInput.collocation_scheme_code,
|
||||
source_id = prdKittingOutH.id,
|
||||
create_id = _userManager.UserId,
|
||||
wmsKittingoutDs = new List<MESKittingOutStkDInput>(),
|
||||
}
|
||||
};
|
||||
|
||||
input[0].wmsKittingoutDs = JsonConvert.DeserializeObject<List<MESKittingOutStkDInput>>(JsonConvert.SerializeObject(kittingOutInput.tableField115));
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_KITTING_OUT_STK, JsonConvert.SerializeObject(input), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_KITTING_OUT_STK, JsonConvert.SerializeObject(input), header);
|
||||
Log.Information(sendResult);
|
||||
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
@@ -217,8 +219,8 @@ namespace Tnb.ProductionMgr
|
||||
prdKittingOutH.create_id = _userManager.UserId;
|
||||
prdKittingOutH.create_time = DateTime.Now;
|
||||
prdKittingOutH.org_id = _userManager.GetUserInfo().Result.organizeId;
|
||||
List<PrdKittingOutD> prdKittingOutDs = new List<PrdKittingOutD>();
|
||||
foreach (var item in kittingOutInput.tableField115)
|
||||
List<PrdKittingOutD> prdKittingOutDs = new();
|
||||
foreach (Dictionary<string, object> item in kittingOutInput.tableField115)
|
||||
{
|
||||
prdKittingOutDs.Add(new PrdKittingOutD()
|
||||
{
|
||||
@@ -238,10 +240,10 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(prdKittingOutH);
|
||||
_ = await _repository.InsertAsync(prdKittingOutH);
|
||||
if (prdKittingOutDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<PrdKittingOutD>(prdKittingOutDs).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdKittingOutD>(prdKittingOutDs).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -271,11 +273,11 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> KittingOutNew(KittingOutNewInput kittingOutInput)
|
||||
{
|
||||
PrdKittingOutH prdKittingOutH = new PrdKittingOutH();
|
||||
PrdKittingOutH prdKittingOutH = new();
|
||||
string warehouse_id = "26103348825381";//二楼缓存仓
|
||||
try
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdMoTask prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == kittingOutInput.mo_task_id);
|
||||
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdMoTask.material_id);
|
||||
WmsCollocationSchemeH wmsCollocationSchemeH = await db.Queryable<WmsCollocationSchemeH>().SingleAsync(x => x.id == kittingOutInput.collocation_scheme_id);
|
||||
@@ -295,23 +297,25 @@ namespace Tnb.ProductionMgr
|
||||
Dictionary<string, string> unitCodeDic = basMaterials.ToDictionary(x => x.id, x => x.unit_id);
|
||||
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(kittingOutInput.workstation_id, DictConst.RegionCategoryWorklineCode);
|
||||
|
||||
List<MESKittingOutStkInput> input = new List<MESKittingOutStkInput>();
|
||||
input.Add(new MESKittingOutStkInput()
|
||||
List<MESKittingOutStkInput> input = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
warehouse_id = warehouse_id,
|
||||
location_code = kittingOutInput.location_code,
|
||||
material_id = prdMoTask.material_id,
|
||||
material_code = basMaterial.code,
|
||||
collocation_scheme_id = kittingOutInput.collocation_scheme_id,
|
||||
collocation_scheme_code = wmsCollocationSchemeH.bill_code,
|
||||
source_id = prdKittingOutH.id,
|
||||
create_id = _userManager.UserId,
|
||||
wmsKittingoutDs = new List<MESKittingOutStkDInput>(),
|
||||
});
|
||||
new MESKittingOutStkInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
warehouse_id = warehouse_id,
|
||||
location_code = kittingOutInput.location_code,
|
||||
material_id = prdMoTask.material_id,
|
||||
material_code = basMaterial.code,
|
||||
collocation_scheme_id = kittingOutInput.collocation_scheme_id,
|
||||
collocation_scheme_code = wmsCollocationSchemeH.bill_code,
|
||||
source_id = prdKittingOutH.id,
|
||||
create_id = _userManager.UserId,
|
||||
wmsKittingoutDs = new List<MESKittingOutStkDInput>(),
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var item in wmsCollocationSchemeDs)
|
||||
foreach (WmsCollocationSchemeD item in wmsCollocationSchemeDs)
|
||||
{
|
||||
input[0].wmsKittingoutDs.Add(new MESKittingOutStkDInput()
|
||||
{
|
||||
@@ -326,11 +330,11 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_KITTING_OUT_STK, JsonConvert.SerializeObject(input), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_KITTING_OUT_STK, JsonConvert.SerializeObject(input), header);
|
||||
Log.Information(sendResult);
|
||||
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
@@ -354,8 +358,8 @@ namespace Tnb.ProductionMgr
|
||||
prdKittingOutH.create_id = _userManager.UserId;
|
||||
prdKittingOutH.create_time = DateTime.Now;
|
||||
prdKittingOutH.org_id = _userManager.GetUserInfo().Result.organizeId;
|
||||
List<PrdKittingOutD> prdKittingOutDs = new List<PrdKittingOutD>();
|
||||
foreach (var item in wmsCollocationSchemeDs)
|
||||
List<PrdKittingOutD> prdKittingOutDs = new();
|
||||
foreach (WmsCollocationSchemeD item in wmsCollocationSchemeDs)
|
||||
{
|
||||
prdKittingOutDs.Add(new PrdKittingOutD()
|
||||
{
|
||||
@@ -375,10 +379,10 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(prdKittingOutH);
|
||||
_ = await _repository.InsertAsync(prdKittingOutH);
|
||||
if (prdKittingOutDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<PrdKittingOutD>(prdKittingOutDs).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdKittingOutD>(prdKittingOutDs).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetInfoByQrCode(string qrCode)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
// var result = await db.Queryable<WmsCarryH>()
|
||||
// .Where((a) => a.carry_code == qrCode)
|
||||
// .Select(a => new
|
||||
@@ -77,7 +77,7 @@ namespace Tnb.ProductionMgr
|
||||
if (await db.Queryable<PrdMaterialReceiptD>()
|
||||
.AnyAsync(x => x.member_carry_code == qrCode && x.is_all_feeding == 0))
|
||||
{
|
||||
var result = await db.Queryable<PrdMaterialReceiptD>()
|
||||
FeedingDetailOutput result = await db.Queryable<PrdMaterialReceiptD>()
|
||||
.LeftJoin<WmsCarryH>((a, b) => a.carry_id == b.id)
|
||||
.Where((a) => a.member_carry_code == qrCode && a.is_all_feeding == 0)
|
||||
.Select((a, b) => new FeedingDetailOutput
|
||||
@@ -103,7 +103,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await db.Queryable<PrdMaterialReceiptH>()
|
||||
FeedingDetailOutput result = await db.Queryable<PrdMaterialReceiptH>()
|
||||
.LeftJoin<WmsCarryH>((a, b) => a.carry_id == b.id)
|
||||
.Where((a) => a.carry_code == qrCode)
|
||||
.Select((a, b) => new FeedingDetailOutput
|
||||
@@ -131,14 +131,14 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(MaterialReceiptInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result2 = new DbResult<bool>();
|
||||
PrdMaterialReceiptH prdMaterialReceiptH = null;
|
||||
List<PrdMaterialReceiptD> list = new List<PrdMaterialReceiptD>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result2 = new();
|
||||
PrdMaterialReceiptH? prdMaterialReceiptH = null;
|
||||
List<PrdMaterialReceiptD> list = new();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
var inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
PrdMoTask moTask = await db.Queryable<PrdMoTask>().FirstAsync(x => x.id == input.mo_task_id);
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mbom_process_id), x => x.mbom_process_id == input.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
@@ -168,10 +168,12 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
foreach (Dictionary<string, object> item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item["material_id"]))
|
||||
{
|
||||
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||
}
|
||||
|
||||
list.Add(new PrdMaterialReceiptD
|
||||
{
|
||||
@@ -214,7 +216,7 @@ namespace Tnb.ProductionMgr
|
||||
// carry_code = input.carry_code ?? "",
|
||||
// });
|
||||
|
||||
var mesCarrySignInput = new MESCarrySignInput()
|
||||
MESCarrySignInput mesCarrySignInput = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
create_id = _userManager.UserId,
|
||||
@@ -222,30 +224,24 @@ namespace Tnb.ProductionMgr
|
||||
};
|
||||
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN, JsonConvert.SerializeObject(mesCarrySignInput), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN, JsonConvert.SerializeObject(mesCarrySignInput), header);
|
||||
Log.Information(sendResult);
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
if (authResponse.code != 200)
|
||||
{
|
||||
throw Oops.Bah(authResponse.msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
result2 = await db.Ado.UseTranAsync(async () =>
|
||||
result2 = authResponse.code != 200
|
||||
? throw Oops.Bah(authResponse.msg)
|
||||
: await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||
await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage);
|
||||
if (!result2.IsSuccess) throw Oops.Bah(result2.ErrorMessage);
|
||||
return "签收成功";
|
||||
return !result.IsSuccess
|
||||
? throw Oops.Bah(result.ErrorMessage)
|
||||
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,12 +108,12 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
string moCode = queryJson.ContainsKey("mo_code") ? queryJson["mo_code"].ToString() : "";
|
||||
string moStatus = queryJson.ContainsKey("mo_status") ? queryJson["mo_status"].ToString() : "";
|
||||
string combineMoCode = queryJson.ContainsKey("combine_mo_code") ? queryJson["combine_mo_code"].ToString() : "";
|
||||
var result = await db.Queryable<PrdMo>()
|
||||
SqlSugarPagedList<PrdMoListOuput> result = await db.Queryable<PrdMo>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<DictionaryTypeEntity>((a, b, c) => c.EnCode == DictConst.MeasurementUnit)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, d) => c.Id == d.DictionaryTypeId && a.unit_id == d.Id)
|
||||
@@ -175,10 +175,10 @@ namespace Tnb.ProductionMgr
|
||||
/// <param name="icmoCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{icmoCode}")]
|
||||
public async Task<dynamic> GetReportRecord(string icmoCode)
|
||||
public dynamic GetReportRecord(string icmoCode)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var output = new PrdMoTaskDefectOutput();
|
||||
_ = _repository.AsSugarClient();
|
||||
PrdMoTaskDefectOutput output = new();
|
||||
//output.mo_task_code = icmoCode;
|
||||
//var scrap = (await db.Queryable<PrdScrapped>().FirstAsync(it => it.icmo_code == icmoCode));
|
||||
//output.items = new List<CategoryItem>();
|
||||
@@ -215,16 +215,16 @@ namespace Tnb.ProductionMgr
|
||||
throw new ArgumentException($"{nameof(input.Behavior)},not be null or empty");
|
||||
}
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
//获取同组工单的Id,一起下发
|
||||
var combineMoCodes = await db.Queryable<PrdMo>().Where(it => input.WorkOrderIds.Contains(it.id)).Select(it => it.combine_mo_code).ToListAsync();
|
||||
List<string?> combineMoCodes = await db.Queryable<PrdMo>().Where(it => input.WorkOrderIds.Contains(it.id)).Select(it => it.combine_mo_code).ToListAsync();
|
||||
if (combineMoCodes?.Count > 0)
|
||||
{
|
||||
var moIds = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code) && !input.WorkOrderIds.Contains(it.id)).Select(it => it.id).ToListAsync();
|
||||
List<string> moIds = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code) && !input.WorkOrderIds.Contains(it.id)).Select(it => it.id).ToListAsync();
|
||||
input.WorkOrderIds = input.WorkOrderIds.Concat(moIds).ToList();
|
||||
}
|
||||
|
||||
string getMoStatus(MoBehavior behavior)
|
||||
static string getMoStatus(MoBehavior behavior)
|
||||
{
|
||||
string status = "";
|
||||
switch (behavior)
|
||||
@@ -238,13 +238,13 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
return status!;
|
||||
}
|
||||
var behavior = input.Behavior.ToEnum<MoBehavior>();
|
||||
var status = getMoStatus(behavior);
|
||||
var row = await db.Updateable<PrdMo>()
|
||||
MoBehavior behavior = input.Behavior.ToEnum<MoBehavior>();
|
||||
string status = getMoStatus(behavior);
|
||||
int row = await db.Updateable<PrdMo>()
|
||||
.SetColumns(it => new PrdMo { mo_status = status })
|
||||
.Where(it => input.WorkOrderIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
return (row > 0);
|
||||
return row > 0;
|
||||
}
|
||||
// /// <summary>
|
||||
// /// 关联同组工单
|
||||
@@ -312,20 +312,20 @@ namespace Tnb.ProductionMgr
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
planDate = a.plan_start_date,
|
||||
mold_code = c.mold_code,
|
||||
c.mold_code,
|
||||
}).ToListAsync();
|
||||
var planDateAll = true;
|
||||
var moldIdAll = true;
|
||||
bool planDateAll = true;
|
||||
bool moldIdAll = true;
|
||||
if (list?.Count > 0)
|
||||
{
|
||||
var planDate = list.FirstOrDefault()?.planDate;
|
||||
var moldCode = list.FirstOrDefault()?.mold_code;
|
||||
DateTime? planDate = list.FirstOrDefault()?.planDate;
|
||||
string? moldCode = list.FirstOrDefault()?.mold_code;
|
||||
|
||||
planDateAll = list.All(x => x.planDate == planDate);
|
||||
moldIdAll = moldCode != null && list.All(x => x.mold_code == moldCode);
|
||||
if (planDateAll && moldIdAll)
|
||||
{
|
||||
var groupId = SnowflakeIdHelper.NextId();
|
||||
string groupId = SnowflakeIdHelper.NextId();
|
||||
multi.executeRes = await _repository.AsSugarClient().Updateable<PrdMo>()
|
||||
.SetColumns(c => new PrdMo { combine_mo_code = groupId })
|
||||
.Where(it => input.WorkOrderIds.Contains(it.id))
|
||||
@@ -369,7 +369,7 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetPrdMoStatistics(PrdMoStatisticsInput input)
|
||||
{
|
||||
var result = await _db.Queryable<PrdMo>()
|
||||
SqlSugarPagedList<PrdMoStatisticsOutput> result = await _db.Queryable<PrdMo>()
|
||||
.LeftJoin<DictionaryDataEntity>((a, b) => a.mo_status == b.Id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mo_status), (a, b) => b.EnCode == input.mo_status)
|
||||
@@ -420,9 +420,9 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromOneList(PrdMoFromQueryInput input)
|
||||
{
|
||||
List<string> ids = new List<string>();
|
||||
List<string> ids1 = new List<string>();
|
||||
List<string> ids2 = new List<string>();
|
||||
List<string> ids = new();
|
||||
List<string> ids1 = new();
|
||||
List<string> ids2 = new();
|
||||
if (!string.IsNullOrEmpty(input.mo_task_code))
|
||||
{
|
||||
ids1 = await _db.Queryable<PrdMoTask>().Where(x => x.mo_task_code.Contains(x.mo_task_code)).Select(x => x.mo_id).ToListAsync();
|
||||
@@ -441,7 +441,7 @@ namespace Tnb.ProductionMgr
|
||||
ids = ids1.Intersect(ids2).ToList();
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMo>()
|
||||
SqlSugarPagedList<PrdMoFromOneListOutput> result = await _db.Queryable<PrdMo>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mo_code), (a, b) => a.mo_code.Contains(input.mo_code))
|
||||
.WhereIF(ids != null && ids.Count > 0, (a, b) => ids.Contains(a.id))
|
||||
@@ -464,7 +464,6 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 工单追溯二级列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromTwoList(PrdMoFromTwoQueryInput prdMoFromTwoQueryInput)
|
||||
@@ -472,16 +471,15 @@ namespace Tnb.ProductionMgr
|
||||
string mo_id = prdMoFromTwoQueryInput.mo_id ?? "";
|
||||
string mo_task_code = prdMoFromTwoQueryInput.mo_task_code ?? "";
|
||||
string barcode = prdMoFromTwoQueryInput.barcode ?? "";
|
||||
List<string> ids = new List<string>();
|
||||
List<string> ids = new();
|
||||
if (!string.IsNullOrEmpty(barcode))
|
||||
{
|
||||
ids = await _db.Queryable<PrdReport>().Where(x => x.barcode.Contains(barcode)).Select(x => x.mo_task_id).ToListAsync();
|
||||
}
|
||||
|
||||
PrdMo prdMo = await _repository.GetSingleAsync(x => x.id == mo_id);
|
||||
if (prdMo.mo_type is DictConst.PrdMoTypeZS or DictConst.PrdMoTypeJC)
|
||||
{
|
||||
return await _db.Queryable<PrdMoTask>()
|
||||
return prdMo.mo_type is DictConst.PrdMoTypeZS or DictConst.PrdMoTypeJC
|
||||
? await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<OrganizeRelationEntity>((a, b, c) => a.eqp_id == c.ObjectId && c.ObjectType == "Eqp")
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => c.OrganizeId == d.Id)
|
||||
@@ -504,11 +502,8 @@ namespace Tnb.ProductionMgr
|
||||
workshop_name = e.FullName,
|
||||
station_name = d.FullName,
|
||||
equip_code = f.code
|
||||
}).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _db.Queryable<PrdMoTask>()
|
||||
}).ToListAsync()
|
||||
: (dynamic)await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c) => a.workline_id == c.Id)
|
||||
.LeftJoin<BasMbom>((a, b, c, d) => a.bom_id == d.id)
|
||||
@@ -529,14 +524,12 @@ namespace Tnb.ProductionMgr
|
||||
workline_name = c.FullName,
|
||||
mbom_version = d.version
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工单追溯三级级列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromThreeList(PrdMoFromThreeQueryInput prdMoFromThreeQueryInput)
|
||||
@@ -544,7 +537,7 @@ namespace Tnb.ProductionMgr
|
||||
string mo_task_id = prdMoFromThreeQueryInput.mo_task_id ?? "";
|
||||
string mo_task_code = prdMoFromThreeQueryInput.mo_task_code ?? "";
|
||||
string barcode = prdMoFromThreeQueryInput.barcode ?? "";
|
||||
List<string> ids = new List<string>();
|
||||
List<string> ids = new();
|
||||
if (!string.IsNullOrEmpty(barcode))
|
||||
{
|
||||
ids = await _db.Queryable<PrdReport>().Where(x => x.barcode.Contains(barcode)).Select(x => x.mo_task_id).ToListAsync();
|
||||
@@ -574,7 +567,7 @@ namespace Tnb.ProductionMgr
|
||||
}).Mapper(x =>
|
||||
{
|
||||
List<string> orgId1 = orgs.Where(y => y.OrganizeIdTree.Contains(x.workline_id)).Select(y => y.Id).ToList();
|
||||
string station_id = orgIds.Intersect(orgId1)?.FirstOrDefault();
|
||||
string? station_id = orgIds.Intersect(orgId1)?.FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(station_id))
|
||||
{
|
||||
x.station_name = orgs.FirstOrDefault(y => y.Id == station_id)?.FullName;
|
||||
@@ -586,14 +579,13 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 工单追溯人列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromManList(PrdMoFromTabQueryInput prdMoFromTabQueryInput)
|
||||
{
|
||||
string mo_task_id = prdMoFromTabQueryInput.mo_task_id ?? "";
|
||||
string barcode = prdMoFromTabQueryInput.barcode ?? "";
|
||||
List<string> ids = new List<string>();
|
||||
List<string> ids = new();
|
||||
if (!string.IsNullOrEmpty(barcode))
|
||||
{
|
||||
ids = await _db.Queryable<PrdReport>().Where(x => x.barcode.Contains(barcode)).Select(x => x.mo_task_id).ToListAsync();
|
||||
@@ -621,14 +613,13 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 工单追溯机列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromEquipList(PrdMoFromTabQueryInput prdMoFromTabQueryInput)
|
||||
{
|
||||
string mo_task_id = prdMoFromTabQueryInput.mo_task_id ?? "";
|
||||
string barcode = prdMoFromTabQueryInput.barcode ?? "";
|
||||
List<string> ids = new List<string>();
|
||||
List<string> ids = new();
|
||||
if (!string.IsNullOrEmpty(barcode))
|
||||
{
|
||||
ids = await _db.Queryable<PrdReport>().Where(x => x.barcode.Contains(barcode)).Select(x => x.mo_task_id).ToListAsync();
|
||||
@@ -649,14 +640,13 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 工单追溯料列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoFromMaterialList(PrdMoFromTabQueryInput prdMoFromTabQueryInput)
|
||||
{
|
||||
string mo_task_id = prdMoFromTabQueryInput.mo_task_id ?? "";
|
||||
string barcode = prdMoFromTabQueryInput.barcode ?? "";
|
||||
List<string> ids = new List<string>();
|
||||
List<string> ids = new();
|
||||
if (!string.IsNullOrEmpty(barcode))
|
||||
{
|
||||
ids = await _db.Queryable<PrdReport>().Where(x => x.barcode.Contains(barcode)).Select(x => x.mo_task_id).ToListAsync();
|
||||
@@ -671,9 +661,8 @@ namespace Tnb.ProductionMgr
|
||||
*/
|
||||
if (string.IsNullOrEmpty(barcode))
|
||||
{
|
||||
if (prdMoTask.schedule_type == 1)
|
||||
{
|
||||
return await _db.Queryable<BasEbomH>()
|
||||
return prdMoTask.schedule_type == 1
|
||||
? await _db.Queryable<BasEbomH>()
|
||||
.LeftJoin<BasEbomD>((a, b) => a.id == b.ebom_id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => b.material_id == c.id)
|
||||
.Where((a, b, c) => a.id == prdMoTask.ebom_id)
|
||||
@@ -681,11 +670,8 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
material_code = c.code,
|
||||
material_name = c.name,
|
||||
}).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _db.Queryable<BasMbomInput>()
|
||||
}).ToListAsync()
|
||||
: (dynamic)await _db.Queryable<BasMbomInput>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => a.mbom_id == prdMoTask.bom_id)
|
||||
.Select((a, b) => new PrdMoFromMaterialListOutput()
|
||||
@@ -693,20 +679,19 @@ namespace Tnb.ProductionMgr
|
||||
material_code = b.code,
|
||||
material_name = b.name,
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PrdReport prdReport = await _db.Queryable<PrdReport>().Where(x => x.barcode == barcode).FirstAsync();
|
||||
List<PrdReport> prdReports = await _db.Queryable<PrdReport>().Where(x => x.create_time <= prdReport.create_time && x.barcode != barcode && x.mo_task_id == mo_task_id).ToListAsync();
|
||||
int? beforeReportNum = prdReports.Sum(x => x.reported_qty);
|
||||
List<string> prdFeedingIds = new List<string>();
|
||||
List<string> prdFeedingIds = new();
|
||||
if (prdMoTask.schedule_type == 1)
|
||||
{
|
||||
BasEbomH basEbomH = await _db.Queryable<BasEbomH>().SingleAsync(x => x.id == prdMoTask.ebom_id);
|
||||
List<BasEbomD> basEbomDs = await _db.Queryable<BasEbomD>().Where(x => x.ebom_id == prdMoTask.ebom_id).ToListAsync();
|
||||
|
||||
foreach (var item in basEbomDs)
|
||||
foreach (BasEbomD item in basEbomDs)
|
||||
{
|
||||
decimal? num1 = beforeReportNum / basEbomH.quantity * item.quantity;
|
||||
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
|
||||
@@ -716,7 +701,7 @@ namespace Tnb.ProductionMgr
|
||||
.Select((a, b) => a).ToListAsync();
|
||||
decimal sum1 = 0;
|
||||
decimal sum2 = 0;
|
||||
foreach (var prdFeedingD in prdFeedingDs)
|
||||
foreach (PrdFeedingD prdFeedingD in prdFeedingDs)
|
||||
{
|
||||
if (sum1 <= num1)
|
||||
{
|
||||
@@ -760,11 +745,15 @@ namespace Tnb.ProductionMgr
|
||||
List<BasMbomInput> basMbomInputs = await _db.Queryable<BasMbomInput>().Where(x => x.mbom_process_id == prdMoTask.mbom_process_id).ToListAsync();
|
||||
BasMbom basMbom = await _db.Queryable<BasMbom>().SingleAsync(x => x.id == prdMoTask.bom_id);
|
||||
BasMbomProcess basMbomProcess = await _db.Queryable<BasMbomProcess>().SingleAsync(x => x.id == prdMoTask.mbom_process_id);
|
||||
List<string> lastPrdReportIds = new List<string>();
|
||||
foreach (var item in basMbomInputs)
|
||||
List<string> lastPrdReportIds = new();
|
||||
foreach (BasMbomInput item in basMbomInputs)
|
||||
{
|
||||
BasMbomOutput basMbomOutput = await _db.Queryable<BasMbomOutput>().Where(x => x.mbom_process_id == basMbomProcess.id && x.material_id == prdMoTask.material_id).FirstAsync();
|
||||
if (basMbomOutput == null) break;
|
||||
if (basMbomOutput == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
decimal? num1 = beforeReportNum / Convert.ToDecimal(basMbomOutput.num) * item.num;
|
||||
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
|
||||
.LeftJoin<PrdFeedingH>((a, b) => a.feeding_id == b.id)
|
||||
@@ -774,22 +763,28 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (prdFeedingDs == null || prdFeedingDs.Count <= 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(basMbomProcess.last_process_no)) continue;
|
||||
if (string.IsNullOrEmpty(basMbomProcess.last_process_no))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<BasMbomProcess> lastBasMbomProcesses = await _db.Queryable<BasMbomProcess>().Where(x => x.no == basMbomProcess.last_process_no && x.mbom_id == prdMoTask.bom_id).ToListAsync();
|
||||
foreach (var lastBasMbomProcess in lastBasMbomProcesses)
|
||||
foreach (BasMbomProcess lastBasMbomProcess in lastBasMbomProcesses)
|
||||
{
|
||||
List<PrdReport> lastPrdReports = await _db.Queryable<PrdReport>()
|
||||
.Where(x => x.mbom_process_id == lastBasMbomProcess.id && x.material_id == item.material_id)
|
||||
.OrderBy(x => x.create_time)
|
||||
.ToListAsync();
|
||||
if (lastPrdReports == null || lastPrdReports.Count <= 0) continue;
|
||||
if (lastPrdReports == null || lastPrdReports.Count <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PrdMoTask lastPrdMoTask = await _db.Queryable<PrdMoTask>().FirstAsync(x => x.mo_id == prdMo.id && x.mbom_process_id == lastBasMbomProcess.id);
|
||||
|
||||
decimal sum1 = 0;
|
||||
decimal sum2 = 0;
|
||||
foreach (var lastPrdReport in lastPrdReports)
|
||||
foreach (PrdReport lastPrdReport in lastPrdReports)
|
||||
{
|
||||
if (sum1 <= num1)
|
||||
{
|
||||
@@ -817,7 +812,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
decimal sum1 = 0;
|
||||
decimal sum2 = 0;
|
||||
foreach (var prdFeedingD in prdFeedingDs)
|
||||
foreach (PrdFeedingD prdFeedingD in prdFeedingDs)
|
||||
{
|
||||
if (sum1 <= num1)
|
||||
{
|
||||
@@ -839,7 +834,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
|
||||
var queryable1 = _db.Queryable<PrdFeedingD>()
|
||||
ISugarQueryable<PrdMoFromMaterialListOutput> queryable1 = _db.Queryable<PrdFeedingD>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<PrdMaterialReceiptD>((a, b, c) => a.material_receipt_detail_id == c.id)
|
||||
.LeftJoin<BasSupplier>((a, b, c, d) => c.supplier_id == d.id)
|
||||
@@ -859,7 +854,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (lastPrdReportIds != null && lastPrdReportIds.Count > 0)
|
||||
{
|
||||
var queryable2 = _db.Queryable<PrdReport>()
|
||||
ISugarQueryable<PrdMoFromMaterialListOutput> queryable2 = _db.Queryable<PrdReport>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => lastPrdReportIds.Contains(a.id))
|
||||
.Select((a, b) => new PrdMoFromMaterialListOutput()
|
||||
@@ -889,25 +884,24 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 物料反向追溯物料信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoReverseFromMaterialInfo(PrdMoReverseFromQueryInput prdMoReverseFromQueryInput)
|
||||
{
|
||||
string barcode = prdMoReverseFromQueryInput.barcode ?? "";
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
Dictionary<string, object> postData = new Dictionary<string, object>()
|
||||
Dictionary<string, object> postData = new()
|
||||
{
|
||||
["org_id"] = _userManager.GetUserInfo().Result.organizeId,
|
||||
["barcode"] = new List<string>() { barcode },
|
||||
["currentPage"] = 1,
|
||||
["pageSize"] = int.MaxValue,
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_FETCH_IN_OUT_STOCK_INFO_BY_BAR_CODE, JsonConvert.SerializeObject(postData), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_FETCH_IN_OUT_STOCK_INFO_BY_BAR_CODE, JsonConvert.SerializeObject(postData), header);
|
||||
Log.Information(sendResult);
|
||||
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
@@ -946,7 +940,6 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 物料反向追溯投料信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoReverseFromFeedingInfo(PrdMoReverseFromQueryInput prdMoReverseFromQueryInput)
|
||||
@@ -958,7 +951,7 @@ namespace Tnb.ProductionMgr
|
||||
.Where(a => a.barcode == barcode)
|
||||
.Select((a, b, c) => c.mo_task_id).ToListAsync();
|
||||
|
||||
var result = await _db.Queryable<PrdMoTask>()
|
||||
List<PrdMoReverseFromFeedingOutput> result = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.Where((a, b, c) => ids.Contains(a.id))
|
||||
@@ -998,14 +991,17 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 物料反向追溯产出信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdMoReverseFromOutInfo(PrdMoReverseFromOutInfoQueryInput prdMoReverseFromOutInfoQueryInput)
|
||||
{
|
||||
string feeding_detail_id = prdMoReverseFromOutInfoQueryInput.feeding_detail_id ?? "";
|
||||
PrdFeedingD prdFeedingD = await _db.Queryable<PrdFeedingD>().FirstAsync(x => x.id == feeding_detail_id);
|
||||
if (prdFeedingD.use_num <= 0) return Array.Empty<string>();
|
||||
if (prdFeedingD.use_num <= 0)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
PrdFeedingH prdFeedingH = await _db.Queryable<PrdFeedingH>().FirstAsync(x => x.id == prdFeedingD.feeding_id);
|
||||
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().FirstAsync(x => x.id == prdFeedingH.mo_task_id);
|
||||
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
|
||||
@@ -1013,7 +1009,7 @@ namespace Tnb.ProductionMgr
|
||||
.Where((a, b) => a.material_id == prdFeedingD.material_id && b.mo_task_id == prdFeedingH.mo_task_id && b.create_time <= prdFeedingH.create_time && a.id != prdFeedingD.id)
|
||||
.Select((a, b) => a).ToListAsync();
|
||||
decimal beforeIn = prdFeedingDs.Sum(x => x.num);
|
||||
List<string> reportIds = new List<string>();
|
||||
List<string> reportIds = new();
|
||||
if (prdMoTask.schedule_type == 1)
|
||||
{
|
||||
BasEbomH basEbomH = await _db.Queryable<BasEbomH>().SingleAsync(x => x.id == prdMoTask.ebom_id);
|
||||
@@ -1026,9 +1022,9 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
bool flag = true;
|
||||
decimal residueNeed = 0;
|
||||
foreach (var prdReport in prdReports)
|
||||
foreach (PrdReport prdReport in prdReports)
|
||||
{
|
||||
var needNum = (prdReport.reported_qty ?? 0) / basEbomH.quantity * basEbomD.quantity;
|
||||
decimal needNum = (prdReport.reported_qty ?? 0) / basEbomH.quantity * basEbomD.quantity;
|
||||
if (beforeIn - needNum >= 0)
|
||||
{
|
||||
beforeIn -= needNum;
|
||||
@@ -1088,7 +1084,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (prdReports != null && prdReports.Count > 0)
|
||||
{
|
||||
List<string> mbomProcesssIds = new List<string>() { prdMoTask.mbom_process_id };
|
||||
List<string> mbomProcesssIds = new() { prdMoTask.mbom_process_id };
|
||||
BasMbomProcess startMbomProcess = await _db.Queryable<BasMbomProcess>().Where(x => x.id == prdMoTask.mbom_process_id).FirstAsync();
|
||||
List<BasMbomProcess> allMbomProcesses = await _db.Queryable<BasMbomProcess>().Where(x => x.mbom_id == prdMoTask.bom_id).ToListAsync();
|
||||
string startNo = startMbomProcess.next_process_no;
|
||||
@@ -1128,7 +1124,7 @@ namespace Tnb.ProductionMgr
|
||||
.Select((a, b) => b).ToListAsync();
|
||||
|
||||
decimal? needNum = 1;//一个最终物料需要本任务单投入物料的数量
|
||||
string tempMaterialId = outputList.FirstOrDefault(x => x.mbom_process_id == mbomProcesssIds[mbomProcesssIds.Count - 1])?.material_id;
|
||||
string? tempMaterialId = outputList.FirstOrDefault(x => x.mbom_process_id == mbomProcesssIds[^1])?.material_id;
|
||||
for (int i = mbomProcesssIds.Count - 1; i > 0; i--)
|
||||
{
|
||||
|
||||
@@ -1150,7 +1146,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
bool flag = true;
|
||||
decimal residueNeed = 0;
|
||||
foreach (var prdReport in prdReports)
|
||||
foreach (PrdReport prdReport in prdReports)
|
||||
{
|
||||
decimal needNumTotal = prdReport.reported_qty * needNum ?? 0;
|
||||
if (beforeIn - needNumTotal >= 0)
|
||||
@@ -1202,18 +1198,18 @@ namespace Tnb.ProductionMgr
|
||||
List<string> barCodes = await _db.Queryable<PrdReport>().Where(x => reportIds.Contains(x.id)).Select(x => x.barcode).ToListAsync();
|
||||
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
Dictionary<string, object> postData = new Dictionary<string, object>()
|
||||
Dictionary<string, object> postData = new()
|
||||
{
|
||||
["org_id"] = _userManager.GetUserInfo().Result.organizeId,
|
||||
["barcode"] = barCodes,
|
||||
["currentPage"] = 1,
|
||||
["pageSize"] = int.MaxValue,
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_FETCH_IN_OUT_STOCK_INFO_BY_BAR_CODE, JsonConvert.SerializeObject(postData), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_FETCH_IN_OUT_STOCK_INFO_BY_BAR_CODE, JsonConvert.SerializeObject(postData), header);
|
||||
Log.Information(sendResult);
|
||||
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
@@ -1227,7 +1223,7 @@ namespace Tnb.ProductionMgr
|
||||
PageResult<PrdMoReverseFromOutput> output = JsonConvert.DeserializeObject<PageResult<PrdMoReverseFromOutput>>(authResponse.data.ToString(), new Tnb.Common.Utils.DateTimeJsonConverter());
|
||||
if (output.list != null && output.list.Count > 0)
|
||||
{
|
||||
foreach (var item in output.list)
|
||||
foreach (PrdMoReverseFromOutput item in output.list)
|
||||
{
|
||||
item.material_name = basMaterial.name;
|
||||
}
|
||||
|
||||
@@ -92,11 +92,11 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, string> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson) : new Dictionary<string, string>();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
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() : "";
|
||||
var result = await db.Queryable<PrdMoTask>()
|
||||
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)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,13 +60,15 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
|
||||
MESCreateOutstockInput input = new MESCreateOutstockInput();
|
||||
input.outstock = new MESWmsOutstockHInput();
|
||||
input.outstockDs = new List<MESWmsOutstockDInput>();
|
||||
MESCreateOutstockInput input = new()
|
||||
{
|
||||
outstock = new MESWmsOutstockHInput(),
|
||||
outstockDs = new List<MESWmsOutstockDInput>()
|
||||
};
|
||||
|
||||
string locationId = visualDevModelDataCrInput.data.ContainsKey("location_id") ? visualDevModelDataCrInput.data["location_id"].ToString() : "";
|
||||
string? locationId = visualDevModelDataCrInput.data.ContainsKey("location_id") ? visualDevModelDataCrInput.data["location_id"].ToString() : "";
|
||||
BasLocation location = await db.Queryable<BasLocation>().SingleAsync(x => x.id == locationId);
|
||||
|
||||
input.outstock.bill_type = visualDevModelDataCrInput.data.ContainsKey("bill_type") ? visualDevModelDataCrInput.data["bill_type"].ToString() : "";
|
||||
@@ -92,11 +94,11 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
input.outstockDs = JsonConvert.DeserializeObject<List<MESWmsOutstockDInput>>(JsonConvert.SerializeObject(visualDevModelDataCrInput.data["tablefield107"]));
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
||||
Log.Information(sendResult);
|
||||
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
@@ -124,16 +126,22 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
string warehouse_id = "26103348825381";//二楼缓存仓
|
||||
|
||||
MESCreateOutstockInput input = new MESCreateOutstockInput();
|
||||
input.outstock = new MESWmsOutstockHInput();
|
||||
input.outstockDs = new List<MESWmsOutstockDInput>();
|
||||
MESCreateOutstockInput input = new()
|
||||
{
|
||||
outstock = new MESWmsOutstockHInput(),
|
||||
outstockDs = new List<MESWmsOutstockDInput>()
|
||||
};
|
||||
|
||||
PrdMoTask prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == generalOutstockInput.mo_task_id);
|
||||
BasLocation location = await db.Queryable<BasLocation>().Where(x => x.location_code == generalOutstockInput.location_code).FirstAsync();
|
||||
if (location == null) throw Oops.Bah("未找到库位");
|
||||
if (location == null)
|
||||
{
|
||||
throw Oops.Bah("未找到库位");
|
||||
}
|
||||
|
||||
string locationId = location.id;
|
||||
|
||||
input.outstock.bill_type = DictConst.SHENGCHANLINGLIAO;
|
||||
@@ -158,7 +166,7 @@ namespace Tnb.ProductionMgr
|
||||
})
|
||||
.ToDictionaryAsync(x => x.key, x => x.value);
|
||||
|
||||
foreach (var item in generalOutstockInput.details)
|
||||
foreach (GeneralOutstockDInput item in generalOutstockInput.details)
|
||||
{
|
||||
input.outstockDs.Add(new MESWmsOutstockDInput()
|
||||
{
|
||||
@@ -170,11 +178,11 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
||||
Log.Information(sendResult);
|
||||
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
@@ -184,18 +192,20 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
PrdOutstockH prdOutstockH = new PrdOutstockH();
|
||||
prdOutstockH.bill_type = DictConst.SHENGCHANLINGLIAO;
|
||||
prdOutstockH.warehouse_id = warehouse_id;
|
||||
prdOutstockH.location_code = generalOutstockInput.location_code;
|
||||
prdOutstockH.create_id = _userManager.UserId;
|
||||
prdOutstockH.org_id = _userManager.GetUserInfo().Result.organizeId;
|
||||
prdOutstockH.bill_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
prdOutstockH.workstation = generalOutstockInput.workstation_id;
|
||||
prdOutstockH.workline = workline?.Id ?? "";
|
||||
PrdOutstockH prdOutstockH = new()
|
||||
{
|
||||
bill_type = DictConst.SHENGCHANLINGLIAO,
|
||||
warehouse_id = warehouse_id,
|
||||
location_code = generalOutstockInput.location_code,
|
||||
create_id = _userManager.UserId,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
workstation = generalOutstockInput.workstation_id,
|
||||
workline = workline?.Id ?? ""
|
||||
};
|
||||
|
||||
List<PrdOutstockD> prdOutstockDs = new List<PrdOutstockD>();
|
||||
foreach (var item in generalOutstockInput.details)
|
||||
List<PrdOutstockD> prdOutstockDs = new();
|
||||
foreach (GeneralOutstockDInput item in generalOutstockInput.details)
|
||||
{
|
||||
prdOutstockDs.Add(new PrdOutstockD()
|
||||
{
|
||||
@@ -211,10 +221,10 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.InsertAsync(prdOutstockH);
|
||||
_ = await _repository.InsertAsync(prdOutstockH);
|
||||
if (prdOutstockDs.Count > 0)
|
||||
{
|
||||
await db.Insertable<PrdOutstockD>(prdOutstockDs).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdOutstockD>(prdOutstockDs).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private static Dictionary<string, Tuple<string, string>> _dicWorkLine = new Dictionary<string, Tuple<string, string>>();
|
||||
private static Dictionary<string, Tuple<string, string>> _dicWorkLine = new();
|
||||
public PrdPackReportService(ISqlSugarRepository<PrdMoTask> repository, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
@@ -44,7 +44,11 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetList(PrdPackReportQueryInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException("input");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(input.stationId))
|
||||
{
|
||||
return new
|
||||
@@ -55,8 +59,8 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
List<PackReportTreeOutput> trees = new();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
|
||||
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
List<OrganizeEntity> list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
|
||||
if (_dicWorkLine.Count < 1)
|
||||
{
|
||||
|
||||
@@ -80,7 +84,7 @@ namespace Tnb.ProductionMgr
|
||||
endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]);
|
||||
|
||||
}
|
||||
var items = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PrdMoTask> items = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
|
||||
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.LeftJoin<PrdMoTask>((a, b, c, d) => a.id == d.parent_id)
|
||||
@@ -107,9 +111,15 @@ namespace Tnb.ProductionMgr
|
||||
})
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
if (start)
|
||||
{
|
||||
items.list = items.list.Where(a => startTimes[0] <= a.plan_start_date && startTimes[1] >= a.plan_start_date).ToList();
|
||||
}
|
||||
|
||||
if (end)
|
||||
{
|
||||
items.list = items.list.Where(a => endTimes[0] <= a.plan_end_date && endTimes[1] >= a.plan_end_date).ToList();
|
||||
}
|
||||
|
||||
_db.ThenMapper(items.list, it =>
|
||||
{
|
||||
it.mo_task_status = it.mo_task_status.IsNotEmptyOrNull() && dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
|
||||
@@ -117,13 +127,13 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (items != null && items.list != null && items.list.Any())
|
||||
{
|
||||
foreach (var item in items.list)
|
||||
foreach (PrdMoTask? item in items.list)
|
||||
{
|
||||
var node = item.Adapt<PackReportTreeOutput>();
|
||||
PackReportTreeOutput node = item.Adapt<PackReportTreeOutput>();
|
||||
node.parentId = "0";
|
||||
if (item.workline_id.IsNotEmptyOrNull())
|
||||
{
|
||||
var workLine = _dicWorkLine.ContainsKey(item.workline_id) ? (Tuple<string, string>)_dicWorkLine[item.workline_id] : null;
|
||||
Tuple<string, string>? workLine = _dicWorkLine.ContainsKey(item.workline_id) ? _dicWorkLine[item.workline_id] : null;
|
||||
if (workLine != null)
|
||||
{
|
||||
node.workline_id = $"{workLine.Item1}/{workLine.Item2}";
|
||||
@@ -135,24 +145,30 @@ namespace Tnb.ProductionMgr
|
||||
trees.Add(node);
|
||||
}
|
||||
}
|
||||
var treeList = trees.ToTree();
|
||||
List<PackReportTreeOutput> treeList = trees.ToTree();
|
||||
if (!string.IsNullOrEmpty(input.process))
|
||||
{
|
||||
List<PackReportTreeOutput> removelist = new List<PackReportTreeOutput>();
|
||||
foreach (var item in treeList)
|
||||
List<PackReportTreeOutput> removelist = new();
|
||||
foreach (PackReportTreeOutput item in treeList)
|
||||
{
|
||||
bool flag = false;
|
||||
if (item.process_id != null && item.process_id.Contains(input.process))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (item.children != null && item.children.Count > 0)
|
||||
{
|
||||
var childs = item.children.Adapt<List<PackReportTreeOutput>>();
|
||||
List<PackReportTreeOutput> childs = item.children.Adapt<List<PackReportTreeOutput>>();
|
||||
if (childs.Where(p => p.process_id.Contains(input.process)).Any())
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
removelist.Add(item);
|
||||
|
||||
}
|
||||
}
|
||||
removelist.ForEach(p => treeList.Remove(p));
|
||||
|
||||
@@ -172,16 +188,16 @@ namespace Tnb.ProductionMgr
|
||||
private static DateTime GetDateTimeMilliseconds(long timestamp)
|
||||
{
|
||||
long begtime = timestamp * 10000;
|
||||
DateTime dt_1970 = new DateTime(1970, 1, 1, 8, 0, 0);
|
||||
DateTime dt_1970 = new(1970, 1, 1, 8, 0, 0);
|
||||
long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度
|
||||
long time_tricks = tricks_1970 + begtime;//日志日期刻度
|
||||
DateTime dt = new DateTime(time_tricks);//转化为DateTime
|
||||
DateTime dt = new(time_tricks);//转化为DateTime
|
||||
return dt;
|
||||
|
||||
}
|
||||
private async Task GetChild(string parentId, List<PackReportTreeOutput> nodes, Dictionary<string, object> dic, string stationId)
|
||||
{
|
||||
var items = await _db.Queryable<PrdMoTask>()
|
||||
List<PrdMoTask> items = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
|
||||
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.LeftJoin<BasMbomProcess>((a, b, c, d) => a.mbom_process_id == d.id)
|
||||
@@ -210,7 +226,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (items?.Count > 0)
|
||||
{
|
||||
var nsChild = items.Adapt<List<PackReportTreeOutput>>();
|
||||
List<PackReportTreeOutput> nsChild = items.Adapt<List<PackReportTreeOutput>>();
|
||||
for (int i = 0; i < nsChild.Count; i++)
|
||||
{
|
||||
nsChild[i].parentId = parentId;
|
||||
@@ -220,7 +236,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (nsChild[i].workline_id.IsNotEmptyOrNull())
|
||||
{
|
||||
var workLine = _dicWorkLine.ContainsKey(nsChild[i].workline_id) ? (Tuple<string, string>)_dicWorkLine[nsChild[i].workline_id] : null;
|
||||
Tuple<string, string>? workLine = _dicWorkLine.ContainsKey(nsChild[i].workline_id) ? _dicWorkLine[nsChild[i].workline_id] : null;
|
||||
if (workLine != null)
|
||||
{
|
||||
nsChild[i].workline_id = $"{workLine.Item1}/{workLine.Item2}";
|
||||
@@ -229,7 +245,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
nodes.AddRange(nsChild);
|
||||
foreach (var item in items)
|
||||
foreach (PrdMoTask? item in items)
|
||||
{
|
||||
await GetChild(item.id, nodes, dic, stationId);
|
||||
}
|
||||
@@ -252,7 +268,7 @@ namespace Tnb.ProductionMgr
|
||||
};
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PADPackageTaskPageOutput> result = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.process_id == c.id)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c, e) => e.DictionaryTypeId == DictConst.PrdTaskStatusTypeId && a.mo_task_status == e.EnCode)
|
||||
@@ -309,7 +325,7 @@ namespace Tnb.ProductionMgr
|
||||
};
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PADPackageTaskPageOutput> result = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.process_id == c.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||
@@ -360,11 +376,11 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
|
||||
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : "";
|
||||
string? mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string? status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : "";
|
||||
DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["start_time"]) : null;
|
||||
DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["end_time"]) : null;
|
||||
List<string> statusList = new List<string>();
|
||||
List<string> statusList = new();
|
||||
if (!string.IsNullOrEmpty(status))
|
||||
{
|
||||
switch (status)
|
||||
@@ -390,7 +406,7 @@ namespace Tnb.ProductionMgr
|
||||
input.sort = "desc";
|
||||
}
|
||||
|
||||
var result = await _db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PADPackageTaskPageOutput> result = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => a.process_id == c.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||
@@ -469,12 +485,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
BasQrcode basQrcode = await _db.Queryable<BasQrcode>().Where(x => x.source_name == "TOOL_MOLDS" && x.code == input.mold_qrcode).FirstAsync();
|
||||
if (prdMoTask != null && basQrcode != null)
|
||||
{
|
||||
return prdMoTask.mold_id == basQrcode.source_id;
|
||||
}
|
||||
|
||||
return false;
|
||||
return prdMoTask != null && basQrcode != null ? prdMoTask.mold_id == basQrcode.source_id : (dynamic)false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +105,10 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, object> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
|
||||
string moTaskCode = queryJson != null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string stationId = queryJson != null && queryJson.ContainsKey("stationId") ? queryJson["stationId"].ToString() : "";
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, object>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
|
||||
string? moTaskCode = queryJson != null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string? stationId = queryJson != null && queryJson.ContainsKey("stationId") ? queryJson["stationId"].ToString() : "";
|
||||
|
||||
if (string.IsNullOrEmpty(stationId))
|
||||
{
|
||||
@@ -121,23 +121,23 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus);
|
||||
|
||||
DateTime[] planStartDateArr = null;
|
||||
DateTime[] planEndDateArr = null;
|
||||
if (queryJson.TryGetValue("plan_start_date", out var value1))
|
||||
DateTime[]? planStartDateArr = null;
|
||||
DateTime[]? planEndDateArr = null;
|
||||
if (queryJson.TryGetValue("plan_start_date", out object? value1))
|
||||
{
|
||||
planStartDateArr = value1.ToObject<long[]>().Select(x => x.TimeStampToDateTime()).ToArray();
|
||||
}
|
||||
if (queryJson.TryGetValue("plan_end_date", out var value2))
|
||||
if (queryJson.TryGetValue("plan_end_date", out object? value2))
|
||||
{
|
||||
planEndDateArr = value2.ToObject<long[]>().Select(x => x.TimeStampToDateTime()).ToArray();
|
||||
}
|
||||
|
||||
|
||||
var result = await db.Queryable<PrdMoTask>()
|
||||
SqlSugarPagedList<PrdTaskManageListOutput> result = await db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<EqpEquipment>((a, b) => a.eqp_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c, d) => a.mold_id == d.id)
|
||||
.Where((a, b, c, d) => (a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.InProgressEnCode || a.mo_task_status == DictConst.MoStatusExceptionCode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.ComplatedEnCode))
|
||||
.Where((a, b, c, d) => a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_status == DictConst.InProgressEnCode || a.mo_task_status == DictConst.MoStatusExceptionCode || a.mo_task_status == DictConst.MoStatusPauseCode || a.mo_task_status == DictConst.ComplatedEnCode)
|
||||
.Where((a, b, c, d) => a.schedule_type == 1)
|
||||
.WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
|
||||
.WhereIF(planStartDateArr != null, (a, b, c, d) => a.estimated_start_date >= planStartDateArr[0] && a.estimated_start_date <= planStartDateArr[1])
|
||||
@@ -243,7 +243,6 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 根据任务单号获取提报记录明细
|
||||
/// </summary>
|
||||
/// <param name="icmoCode">任务单号</param>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
///<br/> {
|
||||
@@ -256,8 +255,8 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetPrdReportByIcmoCode([FromRoute] string mo_task_code)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var prdTask = await db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c) => a.mold_id == c.id)
|
||||
@@ -268,28 +267,28 @@ namespace Tnb.ProductionMgr
|
||||
.Where((a, b) => a.mo_task_code == mo_task_code)
|
||||
.Select((a, b, c, d, e, f, g) => new
|
||||
{
|
||||
id = a.id,
|
||||
mo_task_code = a.mo_task_code,
|
||||
mo_id = a.mo_id,
|
||||
material_id = a.material_id,
|
||||
a.id,
|
||||
a.mo_task_code,
|
||||
a.mo_id,
|
||||
a.material_id,
|
||||
material_code = b.code,
|
||||
material_name = b.name,
|
||||
material_property = b.material_property,
|
||||
b.material_property,
|
||||
mo_task_status = e.FullName,
|
||||
plan_qty = a.plan_qty,
|
||||
scheduled_qty = a.scheduled_qty,
|
||||
a.plan_qty,
|
||||
a.scheduled_qty,
|
||||
complete_qty = a.reported_work_qty + a.scrap_qty,
|
||||
scrap_qty = a.scrap_qty,
|
||||
mold_code = c.mold_code,
|
||||
a.scrap_qty,
|
||||
c.mold_code,
|
||||
// icmo_qty = a.icmo_qty,
|
||||
reported_work_qty = a.reported_work_qty,
|
||||
a.reported_work_qty,
|
||||
// reported_qty = a.reported_qty,
|
||||
// prd_qty = a.prd_qty,
|
||||
eqp_code = d.code,
|
||||
mbom_process_id = a.mbom_process_id,
|
||||
a.mbom_process_id,
|
||||
workline_name = f.FullName,
|
||||
process_name = g.process_name,
|
||||
process_id = a.process_id
|
||||
g.process_name,
|
||||
a.process_id
|
||||
}).FirstAsync();
|
||||
|
||||
return prdTask;
|
||||
|
||||
@@ -83,13 +83,13 @@ namespace Tnb.ProductionMgr
|
||||
if (!string.IsNullOrEmpty(input.queryJson))
|
||||
{
|
||||
Dictionary<string, string> queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
|
||||
if (queryJson.TryGetValue("mo_task_code", out var value))
|
||||
if (queryJson.TryGetValue("mo_task_code", out string? value))
|
||||
{
|
||||
moTaskCode = value;
|
||||
}
|
||||
}
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Queryable<PrdReportRecord>()
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
SqlSugarPagedList<ReportRecordListOutput> result = await db.Queryable<PrdReportRecord>()
|
||||
.LeftJoin<DictionaryDataEntity>((a, b) => a.mo_task_type == b.Id)
|
||||
.LeftJoin<DictionaryDataEntity>((a, b, c) => a.status == c.EnCode)
|
||||
.LeftJoin<PrdMoTask>((a, b, c, d) => a.mo_task_id == d.id)
|
||||
@@ -125,11 +125,11 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
private async Task<dynamic> AddRecord(string id, VisualDevModelDataUpInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Ado.UseTranAsync(async () =>
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
List<PrdReport> prdReports = new List<PrdReport>();
|
||||
foreach (var item in (JArray)input.data["tablefield107"])
|
||||
List<PrdReport> prdReports = new();
|
||||
foreach (JToken item in (JArray)input.data["tablefield107"])
|
||||
{
|
||||
if (item["id"] == null)
|
||||
{
|
||||
@@ -144,10 +144,10 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
|
||||
await db.Insertable<PrdReport>(prdReports).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdReport>(prdReports).ExecuteCommandAsync();
|
||||
|
||||
int? sum = prdReports.Sum(x => x.reported_qty);
|
||||
await db.Updateable<PrdReportRecord>()
|
||||
_ = await db.Updateable<PrdReportRecord>()
|
||||
.SetColumns(x => x.completed_qty == x.completed_qty + sum)
|
||||
.SetColumns(x => x.reported_work_qty == x.reported_work_qty + sum)
|
||||
.Where(x => x.id == input.data["id"].ToString()).ExecuteCommandAsync();
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Tnb.ProductionMgr
|
||||
//redis定时获取数采数据
|
||||
public class RedisBackGround : IHostedService, IDisposable
|
||||
{
|
||||
private Timer? packtimer;
|
||||
private Timer? limittimer;
|
||||
private readonly Timer? packtimer;
|
||||
private readonly Timer? limittimer;
|
||||
private readonly RedisCache _redisCache;
|
||||
private readonly IPrdInstockService _prdInstockService;
|
||||
public RedisBackGround(RedisCache redisCache, IPrdInstockService prdInstockService)
|
||||
@@ -29,19 +29,24 @@ namespace Tnb.ProductionMgr
|
||||
string sign = "agvMode";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
var dic = _redisCache.HGetAll(s).Result;
|
||||
foreach (var kv in dic)
|
||||
Dictionary<string, string> dic = _redisCache.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
{
|
||||
continue;
|
||||
var res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
}
|
||||
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (int.Parse(res["Value"]!.ToString()) != (int)Eagvmode.无请求 || int.Parse(res["Value"]!.ToString()) != (int)Eagvmode.收到请求)
|
||||
if (int.Parse(res["Value"]!.ToString()) is not ((int)Eagvmode.无请求) or not ((int)Eagvmode.收到请求))
|
||||
{
|
||||
InstockInput instockInput = new InstockInput();
|
||||
instockInput.equip_code = res["TagName"]!.ToString();
|
||||
_prdInstockService.InstockTypeOne(instockInput);
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
equip_code = res["TagName"]!.ToString()
|
||||
};
|
||||
_ = _prdInstockService.InstockTypeOne(instockInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,19 +61,24 @@ namespace Tnb.ProductionMgr
|
||||
string sign = "AGVFullCall";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
var dic = _redisCache.HGetAll(s).Result;
|
||||
foreach (var kv in dic)
|
||||
Dictionary<string, string> dic = _redisCache.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
{
|
||||
continue;
|
||||
var res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
}
|
||||
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (res.Value<bool>("Value"))
|
||||
{
|
||||
InstockInput instockInput = new InstockInput();
|
||||
instockInput.equip_code = res["TagName"]!.ToString();
|
||||
_prdInstockService.InstockTypeOne(instockInput);
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
equip_code = res["TagName"]!.ToString()
|
||||
};
|
||||
_ = _prdInstockService.InstockTypeOne(instockInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,12 +93,15 @@ namespace Tnb.ProductionMgr
|
||||
string sign = "AGVCall";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
var dic = _redisCache.HGetAll(s).Result;
|
||||
foreach (var kv in dic)
|
||||
Dictionary<string, string> dic = _redisCache.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
{
|
||||
continue;
|
||||
var res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
}
|
||||
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (res.Value<bool>("Value"))
|
||||
|
||||
@@ -28,6 +28,14 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetWeight(string device, string jihao)
|
||||
{
|
||||
bool flag = await _redisCache.HashExist(device, jihao);
|
||||
if (!flag)
|
||||
{
|
||||
throw Oops.Bah("没有找到" + device + "----" + jihao + "的数据");
|
||||
}
|
||||
|
||||
string data = await _redisCache.GetHash(device, jihao);
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
||||
/*
|
||||
var dic =await _redisCache.HGetAll("TY4C-JICHU");
|
||||
string a = "";
|
||||
@@ -45,20 +53,7 @@ namespace Tnb.ProductionMgr
|
||||
await _redisCache.HSet("TY4C-JICHU", b[0], b[1]);
|
||||
}*/
|
||||
|
||||
decimal result = 0;
|
||||
bool flag = await _redisCache.HashExist(device, jihao);
|
||||
if (!flag)
|
||||
throw Oops.Bah("没有找到" + device + "----" + jihao + "的数据");
|
||||
var data = await _redisCache.GetHash(device, jihao);
|
||||
var res = JsonConvert.DeserializeObject<JObject>(data);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
result = decimal.Parse(res["Value"]!.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("数据格式错误");
|
||||
}
|
||||
decimal result = res != null && res["Value"] != null ? decimal.Parse(res["Value"]!.ToString()) : throw Oops.Bah("数据格式错误");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,31 +39,33 @@ namespace Tnb.ProductionMgr
|
||||
("25546256076325","25530834099477"),
|
||||
};
|
||||
List<MoldsEntity> list = new();
|
||||
var index = 1;
|
||||
foreach (var item in multi)
|
||||
int index = 1;
|
||||
foreach ((string pId, string eqpId) in multi)
|
||||
{
|
||||
MoldsEntity entity = new();
|
||||
entity.id = SnowflakeIdHelper.NextId();
|
||||
entity.MoldCode = $"m00{index}";
|
||||
entity.MoldName = "磨具" + index;
|
||||
entity.ItemId = item.pId;
|
||||
entity.EqpId = item.eqpId;
|
||||
MoldsEntity entity = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
MoldCode = $"m00{index}",
|
||||
MoldName = "磨具" + index,
|
||||
ItemId = pId,
|
||||
EqpId = eqpId
|
||||
};
|
||||
list.Add(entity);
|
||||
index++;
|
||||
}
|
||||
var link = await _repository.GetFirstAsync(x => x.FullName == "tnb_eqp");
|
||||
var db = _dataBaseManager.ChangeDataBase(link);
|
||||
var row = await db.Insertable(list).ExecuteCommandAsync();
|
||||
DbLinkEntity link = await _repository.GetFirstAsync(x => x.FullName == "tnb_eqp");
|
||||
SqlSugarScope db = _dataBaseManager.ChangeDataBase(link);
|
||||
int row = await db.Insertable(list).ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
foreach (var item in list)
|
||||
foreach (MoldsEntity item in list)
|
||||
{
|
||||
var dic = new Dictionary<string, object>
|
||||
Dictionary<string, object> dic = new()
|
||||
{
|
||||
{"id",item.EqpId },
|
||||
{ "mold_id", item.id}
|
||||
};
|
||||
var row2 = await db.Updateable(dic).AS("eqp_equipment")
|
||||
int row2 = await db.Updateable(dic).AS("eqp_equipment")
|
||||
.WhereColumns("id").
|
||||
ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
@@ -48,16 +48,16 @@ public class WorklineCommService : IWorklineCommService, IDynamicApiController,
|
||||
[AllowAnonymous]
|
||||
public async Task<dynamic> GetCartonQrcode(string workline)
|
||||
{
|
||||
var line = await _repository.GetFirstAsync(a => a.id == workline);
|
||||
var productNo = line?.product_code;
|
||||
PrdWorklineState line = await _repository.GetFirstAsync(a => a.id == workline);
|
||||
string? productNo = line?.product_code;
|
||||
//TODO 仅测试接口用
|
||||
if (string.IsNullOrEmpty(productNo))
|
||||
{
|
||||
productNo = "16945" + Random.Shared.Next(0, 999999999).ToString(); //"16945155732431";
|
||||
}
|
||||
var pd = DateTime.Now;
|
||||
var exp = pd.AddYears(3);
|
||||
var lotNo = pd.ToString("yyMMddHH");
|
||||
DateTime pd = DateTime.Now;
|
||||
DateTime exp = pd.AddYears(3);
|
||||
string lotNo = pd.ToString("yyMMddHH");
|
||||
string tpl = "(01){0}\n(11){1}\n(17){2}\n(10){3}";
|
||||
string qrcode = string.Format(tpl, productNo, pd.ToString("yyMM00"), exp.ToString("yyMM00"), lotNo);
|
||||
return new { qrcode };
|
||||
|
||||
Reference in New Issue
Block a user