wyb
2021-05-11 49ce087bd2a34a150597e1cc1da157af242c0b6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Pcb.Common.Config;
using Pcb.Domain;
 
 
namespace Pcb.Common
{
    /// <summary>
    /// PCB生产帮助类
    /// </summary>
    public class PcbProductHeper
    {
        #region 工序是否允许过序列表
        /// <summary>
        /// 生产协同工厂流程中哪些工序允许过序列表:0,1,0,0,0,1,0 (0允许1不允许)
        /// </summary>
        /// <param name="StepKeys"></param>
        /// <param name="JoinFactoryId"></param>
        /// <returns></returns>
        public static string GetIsFlowList(string StepKeys, int JoinFactoryId)
        {
            LogHelper.Info(StepKeys + ":" + JoinFactoryId);
            if (!string.IsNullOrEmpty(StepKeys))
            {
                var keys = GetIsFlowList(StepKeys.Split(','), JoinFactoryId);
                return keys;
            }
            return string.Empty;
        }
        /// <summary>
        /// 生产协同工厂流程中哪些工序允许过序列表:0,1,0,0,0,1,0 (0允许1不允许)
        /// </summary>
        /// <param name="StepKeys"></param>
        /// <param name="JoinFactoryId"></param>
        /// <returns></returns>
        public static string GetIsFlowList(IEnumerable<string> StepKeys, int JoinFactoryId)
        {
            if (JoinFactoryId == 0) { return string.Empty; }
 
            var cfgs = PcbQutoConfigHeler.GetFactoryTypes();
            var cfg = cfgs._GetValue("JoinFactory");
            if (cfg == null) { return string.Empty; }
            var value = cfg._GetValue(JoinFactoryId.ToString());
            if (string.IsNullOrEmpty(value)) { return string.Empty; }
            var allowkeys = value.Split(',')._ToHashSet(t => t);
 
            var lstisflows = new List<int>();
            foreach (var key in StepKeys)
            {
                if (string.IsNullOrEmpty(key)) { continue; }
                lstisflows.Add(allowkeys.Contains(key) ? 0 : 1);
            }
            var isflows = string.Join(",", lstisflows);
            return isflows;
        }
        #endregion
 
        /// <summary>
        /// 更新拼版信息(包括片数、面积等)
        /// </summary>
        /// <returns></returns>
        public static List<ProOrder> CalcPinBanInfo(List<ProOrder> Models)
        {
            Models.ForEach(x =>
            {
                //x.Num = ControlCardManage.GetActualNum(x);
                if (x.BoardType != "set")
                {
                    int[] array = Array.ConvertAll(x.PinBanType.Split('x'), s => int.Parse(s));
                    int pinbannum = array[0] * array[1];
                    x.Num = Math.Ceiling(Convert.ToDecimal(x.Num) / Convert.ToDecimal(pinbannum)).ToInt2();
                }
                x.DeliveryDate = x.DeliveryDate.AddDays(-1);
 
                if (x.OrderNo.Contains("ALL"))
                {
                    x.OrderNoType = 2;
                }
                else
                {
                    x.OrderNoType = 1;
                }
                if (x.DeliveryDays == 1 && x.OrderType == 2)
                {
                    x.OrderType = 1;
                }
                if (x.BoardArea == null)
                {
                    x.BoardArea = (x.BoardWidth * x.BoardHeight * x.Num / 1000000).ToDecimal2();
                }
            });
            return Models;
        }
 
    }
}