| | |
| | | } |
| | | } |
| | | //获取工序信息 |
| | | sql = @"select S.wo_code,S.seq,S.step_code,T.stepname,S.stepprice,(isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | sql = @"select S.id,S.wo_code,S.seq,S.step_code,T.stepname,T.flwtype,S.stepprice,(isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty,(isnull(S.plan_qty,0)-(isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0))) as delive_qty,S.isbott,S.isend |
| | | from TK_Wrk_Step S |
| | | left join TStep T on S.step_code=T.stepcode |
| | | where S.wo_code=@wocode order by S.seq "; |
| | | dynamicParams.Add("@wocode", wocode); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | var parents = DapperHelper.select<WorkRouteStepEqp>(sql, dynamicParams); |
| | | //获取工序对应设备信息 |
| | | for (int i = 0; i < parents.Count; i++) |
| | | { |
| | | if (parents[i].flwtype == "Z") |
| | | { |
| | | //通过工艺路线工序表ID查找对应设备信息 |
| | | sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as eqp_price, |
| | | (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty |
| | | from TK_Wrk_StepEqp S |
| | | inner join TEqpInfo E on S.eqp_code=E.code |
| | | where S.m_id=@m_id"; |
| | | dynamicParams.Add("@m_id", parents[i].id); |
| | | var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | else |
| | | { |
| | | //通过工艺路线工序表ID查找对应外协供应商信息 |
| | | sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as eqp_price, |
| | | (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty |
| | | from TK_Wrk_StepEqp S |
| | | inner join TCustomer E on S.eqp_code=E.code |
| | | where S.m_id=@m_id"; |
| | | dynamicParams.Add("@m_id", parents[i].id); |
| | | var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | dir.Add("canupdate_qty", canupdate_qty); |
| | | dir.Add("stepdata", data1); |
| | | dir.Add("stepdata", parents); |
| | | mes.code = "200"; |
| | | mes.count = data1.Rows.Count; |
| | | mes.count = parents.Count; |
| | | mes.message = "查询成功"; |
| | | mes.data = dir; |
| | | } |
| | |
| | | if (route) //工艺路线版 |
| | | { |
| | | //MES工单查找历史引用最新工序信息 |
| | | sql = @"select S.wo_code,S.seq,S.step_code,S.stepprice,isbott,isend |
| | | from TK_Wrk_Step S |
| | | inner join ( |
| | | select top 1 A.wo_code,A.route_code from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.route_code=S.route_code |
| | | where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode and A.route_code=@routecode |
| | | order by A.lm_date desc |
| | | ) as W on S.wo_code=W.wo_code and S.route_code=W.route_code |
| | | left join TStep T on S.step_code=T.stepcode |
| | | order by S.seq"; |
| | | sql = @"select S.id,S.wo_code,S.seq,S.step_code,T.stepname,T.flwtype,S.stepprice,'0' as produceq_qty, |
| | | '0' as good_qty,'0' as ng_qty,'0' as laborbad_qty,'0' as materielbad_qty,'0' as delive_qty,isbott,isend |
| | | from TK_Wrk_Step S |
| | | inner join ( |
| | | select top 1 S.id,A.wo_code,A.route_code from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.route_code=S.route_code |
| | | where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode and A.route_code=@routecode |
| | | order by A.lm_date desc |
| | | ) as W on S.wo_code=W.wo_code and S.route_code=W.route_code |
| | | left join TStep T on S.step_code=T.stepcode |
| | | order by S.seq"; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@routecode", routecode); |
| | | var parents = DapperHelper.select<WorkRouteStepEqp>(sql, dynamicParams); |
| | | //获取工序对应设备信息 |
| | | for (int i = 0; i < parents.Count; i++) |
| | | { |
| | | if (parents[i].flwtype == "Z") |
| | | { |
| | | //通过工艺路线工序表ID查找对应设备信息 |
| | | sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as eqp_price, |
| | | (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty |
| | | from TK_Wrk_StepEqp S |
| | | inner join TEqpInfo E on S.eqp_code=E.code |
| | | where S.m_id=@m_id"; |
| | | dynamicParams.Add("@m_id", parents[i].id); |
| | | var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | else |
| | | { |
| | | //通过工艺路线工序表ID查找对应外协供应商信息 |
| | | sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as eqp_price, |
| | | (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty |
| | | from TK_Wrk_StepEqp S |
| | | inner join TCustomer E on S.eqp_code=E.code |
| | | where S.m_id=@m_id"; |
| | | dynamicParams.Add("@m_id", parents[i].id); |
| | | var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //MES工单查找历史引用最新工序信息 |
| | | sql = @"select S.wo_code,S.seq,S.step_code,S.stepprice,isbott,isend |
| | | from TK_Wrk_Step S |
| | | inner join ( |
| | | select top 1 A.wo_code from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code |
| | | where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode |
| | | order by A.lm_date desc |
| | | ) as W on S.wo_code=W.wo_code |
| | | left join TStep T on S.step_code=T.stepcode |
| | | order by S.seq"; |
| | | sql = @"select S.id,S.wo_code,S.seq,S.step_code,T.stepname,T.flwtype,S.stepprice,'0' as produceq_qty, |
| | | '0' as good_qty,'0' as ng_qty,'0' as laborbad_qty,'0' as materielbad_qty,'0' as delive_qty,isbott,isend |
| | | from TK_Wrk_Step S |
| | | inner join ( |
| | | select top 1 A.wo_code from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code |
| | | where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode |
| | | order by A.lm_date desc |
| | | ) as W on S.wo_code=W.wo_code |
| | | left join TStep T on S.step_code=T.stepcode |
| | | order by S.seq"; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | dynamicParams.Add("@partcode", partcode); |
| | | var parents = DapperHelper.select<WorkRouteStepEqp>(sql, dynamicParams); |
| | | //获取工序对应设备信息 |
| | | for (int i = 0; i < parents.Count; i++) |
| | | { |
| | | if (parents[i].flwtype == "Z") |
| | | { |
| | | //通过工艺路线工序表ID查找对应设备信息 |
| | | sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as eqp_price, |
| | | (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty |
| | | from TK_Wrk_StepEqp S |
| | | inner join TEqpInfo E on S.eqp_code=E.code |
| | | where S.m_id=@m_id"; |
| | | dynamicParams.Add("@m_id", parents[i].id); |
| | | var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | else |
| | | { |
| | | //通过工艺路线工序表ID查找对应外协供应商信息 |
| | | sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as eqp_price, |
| | | (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty, |
| | | S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty |
| | | from TK_Wrk_StepEqp S |
| | | inner join TCustomer E on S.eqp_code=E.code |
| | | where S.m_id=@m_id"; |
| | | dynamicParams.Add("@m_id", parents[i].id); |
| | | var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams); |
| | | parents[i].children = children.ToList(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | else //不按序收发料 |
| | | { |
| | | mes = ScanStartReport.NoWXEncodingSeach(SelectType, wocode, stepcode); |
| | | } |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else //不按序 |
| | |
| | | //控制逻辑:当前工序报工调整-> (本道工序当前调整合格数+本道工序非当前报工合格总数)<下道工序报工总数(合格+不良+报废) ==不能小于下道报工总数 |
| | | list.Clear(); |
| | | //判断当前工序是自制工序还是外协工序 |
| | | if (json[0].flw_type.ToString() == "Z") |
| | | if (json[0].flw_type.ToString() == "Z") |
| | | { |
| | | |
| | | //查询当前报工工序非此次报工:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | |
| | | //查询当前报工工序非此次报工:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty |
| | | from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | |
| | | return mes; |
| | | } |
| | | } |
| | | if (json[0].flw_type.ToString() == "W") |
| | | if (json[0].flw_type.ToString() == "W") |
| | | { |
| | | //获取当前工序、供应商对应的总发料数量 |
| | | sql = @"select isnull(sum(fqty),0) as fqty |
| | |
| | | decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //当前末道工序非本次报工总数 |
| | | decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //当前末道工序非本次报工工废总数 |
| | | decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //当前末道工序非本次报工料废总数 |
| | | //获取当前末道工序收料总数量:本次修改收料数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数 |
| | | //获取当前末道工序收料总数量:本次修改收料数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数 |
| | | decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty; |
| | | //判断当前工序供应商收料总数>当前工序供应商对应发料数量 |
| | | if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString())) |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | step_price=decimal.Parse(json[0].unprice), |
| | | step_price = decimal.Parse(json[0].unprice), |
| | | good_qty = decimal.Parse(json[0].report_dvalue), |
| | | ng_qty = this_ng_dvalue, |
| | | laborbad_qty = this_laborbad_dvalue, |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | step_price=decimal.Parse(json[0].unprice), |
| | | step_price = decimal.Parse(json[0].unprice), |
| | | good_qty = decimal.Parse(json[0].report_dvalue), |
| | | ng_qty = this_ng_dvalue, |
| | | laborbad_qty = this_laborbad_dvalue, |