|
|
@@ -19,6 +19,7 @@ using MongoDB.Driver;
|
|
|
using MongoDB.Driver.Linq;
|
|
|
using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
+using Org.BouncyCastle.Crypto;
|
|
|
using SixLabors.ImageSharp;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
@@ -2626,21 +2627,48 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 计划工单资源检查
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<string> PlanOrderResourceCheck(string domain)
|
|
|
+ {
|
|
|
+ return await PlanOrderResourceCheckByWorkOrd(domain);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 根据工单范围资源检查
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="domain"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<string> PlanOrderResourceCheckByWorkOrd(string domain, string workords = null)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(domain))
|
|
|
{
|
|
|
return "当前任务工厂编号为空,请检查。";
|
|
|
}
|
|
|
List<string> tsWork = new List<string> { "test", "tcn", "rw" };
|
|
|
- var ordlist = _workOrdMaster.Select(x => x.Domain == domain && (string.IsNullOrEmpty(x.Typed) == true || tsWork.Contains(x.Typed)) && x.Status.ToLower() == "p").ToList();
|
|
|
- List<mes_morder> Mes_Morders = _mysql_mes_morder.GetListAsync(x => ordlist.Select(c=>c.WorkOrd).Contains(x.morder_no) && x.factory_id.ToString() == domain).Result;
|
|
|
+ List<WorkOrdMaster> ordlist = new List<WorkOrdMaster>();
|
|
|
+ List<string> workordList = new List<string>();
|
|
|
+ if (string.IsNullOrEmpty(workords))
|
|
|
+ {
|
|
|
+ ordlist = _workOrdMaster.Select(x => x.Domain == domain && (string.IsNullOrEmpty(x.Typed) == true || tsWork.Contains(x.Typed)) && x.Status.ToLower() == "p").ToList();
|
|
|
+ workordList = ordlist.Select(c => c.WorkOrd).ToList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Array alist = workords.Split(',');
|
|
|
+ foreach (var w in alist)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(w.ToString()))
|
|
|
+ {
|
|
|
+ workordList.Add(w.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<mes_morder> Mes_Morders = _mysql_mes_morder.GetListAsync(x => workordList.Contains(x.morder_no) && x.factory_id.ToString() == domain).Result;
|
|
|
|
|
|
/*//先排除锁定期内的工单 //优先级排序
|
|
|
var sysSet = _generalizedCodeMaster.Select(s => s.FldName == "SystemConfig" && s.Val == "WorkOrderLockPeriod" && s.Domain == domain).ToList();
|
|
|
@@ -6059,6 +6087,69 @@ namespace Business.ResourceExamineManagement
|
|
|
return "保存失败,请联系管理员。";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public async Task<string> WorkOrdKittingCheckByNo(string workord, string qty, string instockdate, string priority, string domain, string userAccount)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(qty))
|
|
|
+ return "数量不正确,请检查";
|
|
|
+ if (string.IsNullOrEmpty(instockdate))
|
|
|
+ return "工单开工日期不正确,请检查";
|
|
|
+ if (string.IsNullOrEmpty(priority))
|
|
|
+ return "优先级不正确,请检查";
|
|
|
+ if (string.IsNullOrEmpty(workord))
|
|
|
+ return "工单号为空,请检查";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //先执行工单数量、优先级、开工日期、完工日期的修改
|
|
|
+ decimal newpriority = Convert.ToDecimal(priority);
|
|
|
+ DateTime newinstockdate = Convert.ToDateTime(instockdate);
|
|
|
+ decimal newqty = Convert.ToDecimal(qty);
|
|
|
+ WorkOrdMaster work = null;
|
|
|
+ var workords = _workOrdMaster.Select(x => x.WorkOrd == workord && x.Domain == domain).ToList(); ;
|
|
|
+ if (workords.Any())
|
|
|
+ {
|
|
|
+ work = workords[0];
|
|
|
+ }
|
|
|
+ if (work == null)
|
|
|
+ return "未查找到对应工单,请刷新界面重试。";
|
|
|
+ if (!string.IsNullOrEmpty(work.Status) && work.Status.ToUpper() != "P")
|
|
|
+ {
|
|
|
+ return "当前工单不是未下达,不允许调整。";
|
|
|
+ }
|
|
|
+ var isExistSamePriority = _workOrdMaster.Select(a => a.WorkOrd != workord && (string.IsNullOrEmpty(a.Status) || a.Status.ToUpper() == "P") && (string.IsNullOrEmpty(a.Typed) || (!string.IsNullOrEmpty(a.Typed) && a.Typed.ToUpper() != "PW" && a.BusinessID > 0)) && a.Priority == newpriority);
|
|
|
+ if (isExistSamePriority.Any())
|
|
|
+ return "优先级重复,请重新调整。";
|
|
|
+ if (newinstockdate <= DateTime.Now.Date)
|
|
|
+ return "请调整开工日期为今天之后。";
|
|
|
+
|
|
|
+ TimeSpan difference = newinstockdate.Subtract(work.OrdDate.GetValueOrDefault());
|
|
|
+ int daysDifference = difference.Days;
|
|
|
+ work.OrdDate = newinstockdate;
|
|
|
+ work.QtyOrded = newqty;
|
|
|
+ work.Priority = newpriority;
|
|
|
+ work.DueDate = work.DueDate.GetValueOrDefault().AddDays(daysDifference);
|
|
|
+ var molist = _mysql_mes_morder.GetListAsync(x => x.morder_no == work.WorkOrd && x.factory_id.ToString() == domain).Result;
|
|
|
+ if (molist.Any())
|
|
|
+ {
|
|
|
+ molist.ForEach(x =>
|
|
|
+ {
|
|
|
+ x.morder_production_number = newqty;
|
|
|
+ x.need_number = newqty;
|
|
|
+ x.moentry_sys_stime = work.OrdDate;
|
|
|
+ x.moentry_sys_etime = work.DueDate;
|
|
|
+ });
|
|
|
+ _businessDbContext.BulkUpdate(molist);
|
|
|
+ }
|
|
|
+ //再执行工单的MRP,更新工单物料明细
|
|
|
+ _workOrdMaster.Update(work);
|
|
|
+ return await PlanOrderResourceCheckByWorkOrd(domain);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ new NLogHelper("ResourceExamineAppService").WriteLog("WorkOrdKittingCheckByNo", "修改计划工单失败:" + e.Message, _currentTenant.Id.ToString());
|
|
|
+ return "修改失败,请联系管理员。";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public class WorkOrdDto
|