yl
2023-03-07 f124194894fe28e5b67d0e2d838d5b1524f43e66
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
using Dapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VueWebApi.Models;
 
namespace VueWebApi.Tools
{
    public class SchedulingMethod
    {
        public static List<APSList> SchedulingMethodTF(string wocode, string wkshpcode, string partcode)
        {
            bool TF = true;
            var dynamicParams = new DynamicParameters();
            List<APSList> list = new List<APSList>(); //不属于产线的单机
            List<APSList> list0 = new List<APSList>(); //产线中的单机
            List<APSList> list1 = new List<APSList>(); //产线
            List<APSList> listSum = new List<APSList>(); //汇总
            //查询工艺路线所有的产线设备或者工位
            string sql = @"select distinct D.code,D.name  from  TK_Wrk_Man A
                           left join TFlw_Rout K on A.route_code=K.code
                           left join TFlw_Rtdt B on K.code=B.rout_code 
                           left join TFlw_Rteqp C on B.step_code= C.step_code
                           left join TEqpInfo D on C.eqp_code=D.code
                           where A.wo_code=@wocode and A.materiel_code=@partcode
                           and D.enable='Y' and D.wksp_code=@wkshpcode
                           order by D.code";
            dynamicParams.Add("@wocode", wocode);
            dynamicParams.Add("@wkshpcode", wkshpcode);
            dynamicParams.Add("@partcode", partcode);
            var dt = DapperHelper.selectdata(sql, dynamicParams);
 
            //(0)查询关键工序关联不属于产线的设备或者工位
            string sql0 = @"select distinct  A.wo_code, B.step_code,C.eqp_code,D.name,
                            isnull(D.operation_ration,0) AdvaDevicCropMob,
                            isnull(H.stand_value,0)     AdvaDevicRhythm,
                            D.eqptype_code as style,
                            'D' ClassType
                            from TK_Wrk_Man A 
                            left join TFlw_Rout K on A.route_code=K.code
                            left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
                            left join TFlw_Rteqp C on B.step_code= C.step_code
                            left join TEqpInfo D on C.eqp_code=D.code 
                            left join TPrteEqp_Stad H on  C.eqp_code= H.eqp_code  and  K.code=H.route_code and B.step_code=H.step_code
                            where A.wo_code=@wocode and H.materiel_code=@partcode  and D.wksp_code=@wkshpcode  and D.enable='Y' 
                            order by C.eqp_code";
            dynamicParams.Add("@wocode", wocode);
            dynamicParams.Add("@wkshpcode", wkshpcode);
            dynamicParams.Add("@partcode", partcode);
            var dt0 = DapperHelper.selectdata(sql0, dynamicParams);
 
            if (dt0.Rows.Count > 0)
            {
                for (int j = 0; j < dt0.Rows.Count; j++)
                {
                    APSList asp = new APSList();
                    asp.wo_code = dt0.Rows[j]["wo_code"].ToString();
                    asp.step_id = dt0.Rows[j]["step_code"].ToString();
                    asp.eqp_id = dt0.Rows[j]["eqp_code"].ToString();
                    asp.name = dt0.Rows[j]["name"].ToString();
                    asp.AdvaDevicCropMob = dt0.Rows[j]["AdvaDevicCropMob"].ToString();  //稼动率
                    asp.AdvaDevicRhythm = dt0.Rows[j]["AdvaDevicRhythm"].ToString();    //生产节拍
                    asp.Style = dt0.Rows[j]["Style"].ToString();
                    asp.ClassType = dt0.Rows[j]["ClassType"].ToString();
                    list.Add(asp);
                }
            }
            //关键工序关联的设备全部是单机
            //组合几组数据源
            listSum = list.ToList();
            return listSum;
        }
    }
}