| | |
| | | { |
| | | |
| | | //1.根据工单+工序查找当前工序是否首道工序 |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.isbott,A.isend |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.isbott,A.isend,L.org_code,L.org_name |
| | | from TK_Wrk_Step A |
| | | left join TStep T on A.step_code=T.stepcode |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TMateriel_Info P on M.materiel_code=P.partcode |
| | | left join TOrganization L on M.wkshp_code=L.org_code |
| | | where A.wo_code=@ordercode and A.step_code=@stepcode"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | rt.wkshopcode= data.Rows[0]["org_code"].ToString(); //车间编码 |
| | | rt.wkshopname = data.Rows[0]["org_name"].ToString(); //车间名称 |
| | | rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //工单号 |
| | | rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //产品编码 |
| | | rt.partname = data.Rows[0]["PARTNAME"].ToString(); //产品名称 |
| | |
| | | if (isbott == "Y") //首道工序 |
| | | { |
| | | //1.首道工序时,判断是否有开工记录 |
| | | sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='S'"; |
| | | sql = @"select * from TK_Wrk_Record R |
| | | left join TEqpInfo E on R.eqp_code=E.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S'"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | } |
| | | else |
| | | { |
| | | rt.eqpcode = data0.Rows[0]["code"].ToString(); //开工设备编码 |
| | | rt.eqpname = data0.Rows[0]["name"].ToString(); //开工设备名称 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.startqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //开工数量=任务数量 |
| | | rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()) - good_qty- ng_qty-bad_qty; //未报数量=任务数量-已报数量-不良数量-报废数量 |
| | |
| | | } |
| | | else |
| | | { |
| | | rt.eqpcode = data0.Rows[0]["code"].ToString(); //开工设备编码 |
| | | rt.eqpname = data0.Rows[0]["name"].ToString(); //开工设备名称 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.startqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //开工数量 |
| | | rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //未报数量 |
| | |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | //1.非首道工序时,判断本道是否有开工记录 |
| | | sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='S'"; |
| | | sql = @"select * from TK_Wrk_Record R |
| | | left join TEqpInfo E on R.eqp_code=E.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S'"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | var data2 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data2.Rows.Count > 0) //有报工记录 |
| | | { |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //自制工序 |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //判断上道工序属性:自制工序 |
| | | { |
| | | //查找上到工序报工记录 |
| | | sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'"; |
| | |
| | | } |
| | | else |
| | | { |
| | | rt.eqpcode = data1.Rows[0]["code"].ToString(); //开工设备编码 |
| | | rt.eqpname = data1.Rows[0]["name"].ToString(); //开工设备名称 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.startqty = sybqty; //开工数量=本道剩余可报数量 |
| | | rt.noreportqty = sybqty; //未报数量=本道剩余可报数量 |
| | |
| | | return mes; |
| | | } |
| | | } |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //委外工序 |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //判断上道工序属性:委外工序 |
| | | { |
| | | //查找上到工序收料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'"; |
| | |
| | | } |
| | | else |
| | | { |
| | | rt.eqpcode = data1.Rows[0]["code"].ToString(); //开工设备编码 |
| | | rt.eqpname = data1.Rows[0]["name"].ToString(); //开工设备名称 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.startqty = sybqty; //开工数量=本道剩余可报数量 |
| | | rt.noreportqty = sybqty; //未报数量=本道剩余可报数量 |
| | |
| | | decimal sgood_qty = data3.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //本道报工总数量 |
| | | decimal sybqty = sgood_qty; //本道剩余可报数量=上道报工数量 |
| | | |
| | | rt.eqpcode = data1.Rows[0]["code"].ToString(); //开工设备编码 |
| | | rt.eqpname = data1.Rows[0]["name"].ToString(); //开工设备名称 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.startqty = sybqty; //开工数量=本道剩余可报数量 |
| | | rt.noreportqty = sybqty; //未报数量=本道剩余可报数量 |
| | |
| | | decimal sqty = data3.AsEnumerable().Select(d =>d.Field<decimal>("SQTY")).Sum();//上道收料数量 |
| | | decimal sybqty = sqty; //本道剩余可收数量=上道收料数量 |
| | | |
| | | rt.eqpcode = data1.Rows[0]["code"].ToString(); //开工设备编码 |
| | | rt.eqpname = data1.Rows[0]["name"].ToString(); //开工设备名称 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.startqty = sybqty; //开工数量=本道剩余可收数量 |
| | | rt.noreportqty = sybqty; //未报数量=本道剩余可收数量 |
| | |
| | | string isend = ""; //末道工序 |
| | | string seq = ""; //工序序号 |
| | | List<object> list = new List<object>(); |
| | | ScanStartReportData rt = new ScanStartReportData(); |
| | | ScanStartReportDataOut rt = new ScanStartReportDataOut(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //1.根据工单+工序查找当前工序是否首道工序 |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.isbott,A.isend |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.isbott,A.isend,L.org_code,L.org_name |
| | | from TK_Wrk_Step A |
| | | left join TStep T on A.step_code=T.stepcode |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TMateriel_Info P on M.materiel_code=P.partcode |
| | | left join TOrganization L on M.wkshp_code=L.org_code |
| | | where A.wo_code=@ordercode and A.step_code=@stepcode"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | |
| | | rt.wkshopcode = data.Rows[0]["org_code"].ToString(); //车间编码 |
| | | rt.wkshopname = data.Rows[0]["org_name"].ToString(); //车间名称 |
| | | rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //工单号 |
| | | rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //产品编码 |
| | | rt.partname = data.Rows[0]["PARTNAME"].ToString(); //产品名称 |
| | |
| | | if (isbott == "Y") //首道工序 |
| | | { |
| | | //1.首道工序时,判断是否有发料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='F'"; |
| | | sql = @"select * from TK_Wrk_OutRecord R |
| | | left join TCustomer C on R.wx_code=C.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | //1.非首道工序时,判断本道是否有发料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='F'"; |
| | | sql = @"select * from TK_Wrk_OutRecord R |
| | | left join TCustomer C on R.wx_code=C.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0)//本道有发料记录 |
| | | { |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //自制工序 |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //判断上道工序属性:自制工序 |
| | | { |
| | | //查找上到工序报工记录 |
| | | sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'"; |
| | |
| | | return mes; |
| | | } |
| | | } |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //外协工序 |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //判断上道工序属性:外协工序 |
| | | { |
| | | //查找上到工序收料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'"; |
| | |
| | | if (isbott == "Y") //首道工序 |
| | | { |
| | | //1.首道工序时,判断是否有发料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='F'"; |
| | | sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code, |
| | | isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty |
| | | from TK_Wrk_OutRecord R |
| | | left join TCustomer C on R.wx_code=C.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F' |
| | | group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) //有发料记录 |
| | | { |
| | | //1.首道工序时,判断是否有收料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'"; |
| | | sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code, |
| | | isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty |
| | | from TK_Wrk_OutRecord R |
| | | left join TCustomer C on R.wx_code=C.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S' |
| | | group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code"; |
| | | //sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | rt.noreportqty = ksqty; //未收数量=本道发料数量 |
| | | rt.reportqty = sqty + ng_qty+bad_qty; //已收数量 |
| | | rt.startqty = ksqty; //收料数量=本道发料数量 |
| | | |
| | | data0.Merge(data1);//将指定的dt合并 |
| | | rt.list = data0.AsEnumerable().GroupBy(r => new { |
| | | wo_code = r["wo_code"], |
| | | step_code = r["step_code"], |
| | | code = r["code"], |
| | | name = r["name"] |
| | | }).Select(g => new { |
| | | Name = g.Key.code, |
| | | tp = g.Key.name, |
| | | fqty = g.Sum(i => (decimal)i["fqty"]), |
| | | sqty = g.Sum(i => (decimal)i["sqty"]), |
| | | ng_qty = g.Sum(i => (decimal)i["ng_qty"]), |
| | | bad_qty = g.Sum(i => (decimal)i["bad_qty"]) |
| | | }).ToList(); |
| | | |
| | | mes.code = "200"; |
| | | mes.count = 3; |
| | |
| | | else |
| | | { |
| | | decimal fqty = data0.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//本道发料数量 |
| | | |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.noreportqty = fqty; //未收数量=本道发料数量 |
| | | rt.reportqty = 0; //已收数量 |
| | | rt.startqty = fqty; //收料数量=本道发料数量 |
| | | rt.startqty = fqty; //收料数量=本道发料数量 |
| | | // |
| | | data0.Merge(data1);//将指定的dt合并 |
| | | rt.list = data0.AsEnumerable().GroupBy(r => new { |
| | | wo_code = r["wo_code"], |
| | | step_code = r["step_code"], |
| | | code = r["code"], |
| | | name = r["name"] |
| | | }).Select(g => new { |
| | | Name = g.Key.code, |
| | | tp = g.Key.name, |
| | | fqty = g.Sum(i => (decimal)i["fqty"]), |
| | | sqty = g.Sum(i => (decimal)i["sqty"]), |
| | | ng_qty = g.Sum(i => (decimal)i["ng_qty"]), |
| | | bad_qty = g.Sum(i => (decimal)i["bad_qty"]) |
| | | }).ToList(); |
| | | |
| | | mes.code = "200"; |
| | | mes.count = 3; |
| | |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | //1.非首道工序时,判断本道是否有发料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='F'"; |
| | | sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code, |
| | | isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty |
| | | from TK_Wrk_OutRecord R |
| | | left join TCustomer C on R.wx_code=C.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F' |
| | | group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0)//本道有发料记录 |
| | | { |
| | | //2.非首道工序时,判断本道是否有收料记录 |
| | | sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'"; |
| | | sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code, |
| | | isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty |
| | | from TK_Wrk_OutRecord R |
| | | left join TCustomer C on R.wx_code=C.code |
| | | where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S' |
| | | group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data2 = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | rt.noreportqty = ksqty; //未收数量=本道发料数量 |
| | | rt.reportqty = sqty + ng_qty+bad_qty; //已收数量 |
| | | rt.startqty = ksqty; //收料数量=本道发料数量 |
| | | |
| | | |
| | | data1.Merge(data2);//将指定的dt合并 |
| | | rt.list = data1.AsEnumerable().GroupBy(r => new { |
| | | wo_code = r["wo_code"], |
| | | step_code = r["step_code"], |
| | | code= r["code"], |
| | | name = r["name"] |
| | | }).Select(g => new { |
| | | Name = g.Key.code, |
| | | tp = g.Key.name, |
| | | fqty = g.Sum(i => (decimal)i["fqty"]), |
| | | sqty = g.Sum(i => (decimal)i["sqty"]), |
| | | ng_qty = g.Sum(i => (decimal)i["ng_qty"]), |
| | | bad_qty = g.Sum(i => (decimal)i["bad_qty"]) |
| | | }).ToList(); |
| | | |
| | | mes.code = "200"; |
| | | mes.count = 3; |
| | | mes.Message = "弹窗收料界面!"; |
| | |
| | | else |
| | | { |
| | | decimal fqty = data1.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum(); //本道发料数量 |
| | | |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.noreportqty = fqty; //未收数量=本道发料数量 |
| | | rt.reportqty = 0; //已收数量 |
| | | rt.startqty = fqty; //收料数量=本道发料数量 |
| | | |
| | | data1.Merge(data2);//将指定的dt合并 |
| | | rt.list = data1.AsEnumerable().GroupBy(r => new { |
| | | wo_code = r["wo_code"], |
| | | step_code = r["step_code"], |
| | | code = r["code"], |
| | | name = r["name"] |
| | | }).Select(g => new { |
| | | Name = g.Key.code, |
| | | tp = g.Key.name, |
| | | fqty = g.Sum(i => (decimal)i["fqty"]), |
| | | sqty = g.Sum(i => (decimal)i["sqty"]), |
| | | ng_qty = g.Sum(i => (decimal)i["ng_qty"]), |
| | | bad_qty = g.Sum(i => (decimal)i["bad_qty"]) |
| | | }).ToList(); |
| | | mes.code = "200"; |
| | | mes.count = 3; |
| | | mes.Message = "弹窗收料界面!"; |