| | |
| | | using Tiger.Model; |
| | | using static Tiger.Business.Biz; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using System.Globalization; |
| | | |
| | | namespace Tiger.Business.MES.Transaction |
| | | { |
| | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据包装工单和条码获取华为要求的生产周期 |
| | | /// </summary> |
| | | /// <param name="snList"></param> |
| | | /// <returns></returns> |
| | | private string GetHuaWeiWeek(string pkgOrder, List<string> snList) |
| | | { |
| | | Dictionary<string, string> dic = new(); |
| | | var snOrder = Biz.Db.Queryable<MES_CUST_SN, BIZ_MES_WO>((q, w) => new JoinQueryInfos(JoinType.Left, q.WORK_ORDER == w.ORDER_NO)) |
| | | .Where((q, w) => q.PKG_ORDER == pkgOrder && (snList.Contains(q.FLOW_SN) || snList.Contains(q.CUST_SN))) |
| | | .Select((q, w) => new { q.PKG_ORDER, q.WORK_ORDER, w.ACT_START_TIME, w.PLAN_START_TIME, q.FLOW_SN, q.CUST_SN }).ToList(); |
| | | foreach (var sn in snList) |
| | | { |
| | | var item = snOrder.FirstOrDefault(q => q.FLOW_SN == sn || q.CUST_SN == sn); |
| | | if (!item.IsNullOrEmpty()) |
| | | { |
| | | var date = item.ACT_START_TIME < new DateTime(2000, 1, 1) ? item.PLAN_START_TIME : item.ACT_START_TIME; ; |
| | | var firstDay = new DateTime(date.Year, 1, 1); |
| | | int daysOffset = firstDay.DayOfWeek.GetValue() > 3 ? (firstDay.DayOfWeek.GetValue() - 7) : 0; |
| | | int year = date.Year + ((date - firstDay).TotalDays + daysOffset < 0 ? -1 : 0); |
| | | int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday); |
| | | dic.Add(sn, $"{year.ToString().Substring(2, 2)}{week:00}"); |
| | | } |
| | | else |
| | | { |
| | | dic.Add(sn, ""); |
| | | } |
| | | } |
| | | var weeks = dic.Select(q => q.Value).Where(q => !q.IsNullOrEmpty()).Distinct().OrderBy(q => q).ToList(); |
| | | |
| | | switch (weeks.Count) |
| | | { |
| | | case 0: |
| | | return ""; |
| | | case 1: |
| | | return weeks.First(); |
| | | case 2: |
| | | return string.Join("/", weeks.Select(q => q + $"({dic.Count(d => d.Value == q)})")); |
| | | default: |
| | | return string.Join("/", weeks.Take(2)) + " (+)"; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion Functions |
| | | |
| | |
| | | |
| | | //更新厂内流程码 |
| | | FlowCSN.CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE; |
| | | FlowCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | FlowCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | FlowCSN.PKG_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | FlowCSN.PROD_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | |
| | | //记录行为操作记录 |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | |
| | | return list; |
| | | } |
| | | |
| | | public List<MES_WIP_PKG> GetMinPackageList(WipPkgItem parent) |
| | | { |
| | | List<MES_WIP_PKG> list = new(); |
| | | if (parent.Items.Any()) |
| | | { |
| | | foreach (var item in parent.Items) |
| | | { |
| | | item.Package.PARENT_SN = parent.Package?.SN; |
| | | list.AddRange(GetMinPackageList(item)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!parent.Package.IsNullOrEmpty()) |
| | | { |
| | | list.Add(parent.Package); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public ApiAction<SubmitOutput> CompletePkg() |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | |
| | | |
| | | //更新厂内流程码 |
| | | FlowCSN.CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE; |
| | | FlowCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | FlowCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | FlowCSN.PKG_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | FlowCSN.PROD_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | |
| | | //记录行为操作记录 |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | |
| | | ITEM_CODE = basItem != null ? basItem.ITEM_CODE : "", |
| | | CREATE_TIME = di["CreatedOn"].ToDateTime(), |
| | | UPDATE_TIME = di["ModifiedOn"].ToDateTime(), |
| | | PLAN_START_TIME = di["CheckDate"].ToDateTime(), |
| | | PLAN_START_TIME = di["CreatedOn"].ToDateTime(), |
| | | STATUS = 0, |
| | | AUTH_ORG = orgs.Where(x => x.ID == orgId).Select(q => q.ORG_CODE).FirstOrDefault(), |
| | | SALES_ORDER = di["SrcDoc_SrcDocNo"] == null ? "" : di["SrcDoc_SrcDocNo"].ToString(), |
| | |
| | | using System; |
| | | using Rhea.Common; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Globalization; |
| | | using System.Linq; |
| | |
| | | [TestMethod()] |
| | | public void CommonTest() |
| | | { |
| | | var date = new DateTime(2022,1,1); |
| | | var date = new DateTime(2021,1,2); |
| | | |
| | | var firstDay = new DateTime(date.Year, 1, 1); |
| | | int daysOffset = firstDay.DayOfWeek.GetValue() > 3 ? (firstDay.DayOfWeek.GetValue() - 7) : 0; |
| | | int year = date.Year + ((date - firstDay).TotalDays + daysOffset < 0 ? -1 : 0); |
| | | int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday); |
| | | var str = $"{year.ToString().Substring(2, 2)}{week:00}"; |
| | | ; |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// 厂内流转条码(若是导入的未绑定客户条码,此字段为空) |
| | | /// </summary> |
| | | [DisplayName("厂内流转条码")] |
| | | [DisplayName("厂内流转条码(若是导入的未绑定客户条码,此字段为空)")] |
| | | public string FLOW_SN { get; set; } |
| | | /// <summary> |
| | | /// 工单号 |
| | | /// 生产工单号 |
| | | /// </summary> |
| | | [DisplayName("工单号")] |
| | | [DisplayName("生产工单号")] |
| | | public string WORK_ORDER { get; set; } |
| | | /// <summary> |
| | | /// 物料编码 |
| | | /// 半成品物料编码 |
| | | /// </summary> |
| | | [DisplayName("物料编码")] |
| | | [DisplayName("半成品物料编码")] |
| | | public string ITEM_CODE { get; set; } |
| | | /// <summary> |
| | | /// 包装工单号 |
| | | /// </summary> |
| | | [DisplayName("包装工单号")] |
| | | public string PKG_ORDER { get; set; } |
| | | /// <summary> |
| | | /// 成品物料编码 |
| | | /// </summary> |
| | | [DisplayName("成品物料编码")] |
| | | public string PROD_CODE { get; set; } |
| | | /// <summary> |
| | | /// 备注 |
| | | /// </summary> |
| | | [DisplayName("备注")] |