| | |
| | | using System.Linq; |
| | | using System.Threading.Tasks; |
| | | using VueWebCoreApi.Models; |
| | | using VueWebCoreApi.Models.ReportVerify; |
| | | using VueWebCoreApi.Models.UpdateReport; |
| | | using VueWebCoreApi.Models.WorkData; |
| | | using VueWebCoreApi.Tools; |
| | |
| | | { |
| | | public static DataTable dt; //定义全局变量dt |
| | | public static bool res; //定义全局变量dt |
| | | |
| | | public static ToMessage mes = new ToMessage(); //定义全局返回信息对象 |
| | | public static string strProcName = ""; //定义全局sql变量 |
| | | public static List<SqlParameter> listStr = new List<SqlParameter>(); //定义全局参数集合 |
| | |
| | | search = search.Substring(3);//截取索引2后面的字符 |
| | | // --------------查询指定自制报工外协收料数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @" select * from( |
| | | select A.id,B.id as sbid,A.wo_code,A.materiel_code as partnumber,P.partname,P.partspec,A.task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,B.reckway,B.usergroup_code,G.usergroupname as usergroup_name, |
| | | B.report_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | | FROM TUser U |
| | | WHERE CHARINDEX(',' + U.usercode + ',', ',' + B.report_person + ',') > 0 |
| | | FOR XML PATH('')), 1, 1, '') AS username, |
| | | B.report_date,B.report_qty,B.ng_qty,B.laborbad_qty,B.materielbad_qty |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_RecordSub B on A.id=B.m_id |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TK_Wrk_Step K on M.wo_code=K.wo_code and A.step_code=K.step_code |
| | | left join TStep S on A.step_code=S.stepcode |
| | | left join TMateriel_Info P on A.materiel_code=P.partcode |
| | | left join TOrganization T on M.wkshp_code=T.torg_code |
| | | left join TEqpInfo E on A.eqp_code=E.code |
| | | left join TGroup G on G.usergroupcode=B.usergroup_code |
| | | where A.style='B' and B.style='B' and M.status<>'CLOSED' and B.verify='N' |
| | | union all |
| | | select A.id,B.id as sbid,A.wo_code,A.materiel_code as partnumber,P.partname,P.partspec,M.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.wx_code as eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,'person' as reckway,'' as usergroup_code,'' as usergroup_name, |
| | | B.in_person as usercode, |
| | | var sql = @"select * from( |
| | | select A.id,B.id as sbid,A.wo_code,A.materiel_code as partnumber,P.partname,P.partspec,A.task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,B.reckway,B.usergroup_code,G.usergroupname as usergroup_name, |
| | | B.report_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | | FROM TUser U |
| | | WHERE CHARINDEX(',' + U.usercode + ',', ',' + B.in_person + ',') > 0 |
| | | FOR XML PATH('')), 1, 1, '') AS username, |
| | | B.in_time as report_date,B.sqty as report_qty,B.ng_qty,B.laborbad_qty,B.materielbad_qty |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_OutRecordSub B on A.id = B.m_id |
| | | left join TK_Wrk_Man M on A.wo_code = M.wo_code |
| | | left join TK_Wrk_Step K on M.wo_code=K.wo_code and A.step_code=K.step_code |
| | | left join TStep S on A.step_code = S.stepcode |
| | | left join TMateriel_Info P on A.materiel_code = P.partcode |
| | | left join TOrganization T on M.wkshp_code = T.torg_code |
| | | left join TCustomer E on A.wx_code = E.code |
| | | where A.style = 'S' and B.style = 'S' and M.status<>'CLOSED' and B.verify='N' |
| | | ) as AA where" + search; |
| | | FROM TUser U |
| | | WHERE CHARINDEX(',' + U.usercode + ',', ',' + B.report_person + ',') > 0 |
| | | FOR XML PATH('')), 1, 1, '') AS username, |
| | | B.report_date,B.report_qty,B.ng_qty,B.laborbad_qty,B.materielbad_qty,'' as wx_code,'' as wx_name |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_RecordSub B on A.id=B.m_id |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TK_Wrk_Step K on M.wo_code=K.wo_code and A.step_code=K.step_code |
| | | left join TStep S on A.step_code=S.stepcode |
| | | left join TMateriel_Info P on A.materiel_code=P.partcode |
| | | left join TOrganization T on M.wkshp_code=T.torg_code |
| | | left join TEqpInfo E on A.eqp_code=E.code |
| | | left join TGroup G on G.usergroupcode=B.usergroup_code |
| | | where A.style='B' and B.style='B' and M.status<>'CLOSED' and A.verify='N' |
| | | union all |
| | | select A.id,B.id as sbid,A.wo_code,A.materiel_code as partnumber,P.partname,P.partspec,M.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.wx_code as eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,'person' as reckway,'' as usergroup_code,'' as usergroup_name, |
| | | B.in_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | | FROM TUser U |
| | | WHERE CHARINDEX(',' + U.usercode + ',', ',' + B.in_person + ',') > 0 |
| | | FOR XML PATH('')), 1, 1, '') AS username, |
| | | B.in_time as report_date,B.sqty as report_qty,B.ng_qty,B.laborbad_qty,B.materielbad_qty,A.wx_code,C.name as wx_name |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_OutRecordSub B on A.id = B.m_id |
| | | left join TK_Wrk_Man M on A.wo_code = M.wo_code |
| | | left join TK_Wrk_Step K on M.wo_code=K.wo_code and A.step_code=K.step_code |
| | | left join TStep S on A.step_code = S.stepcode |
| | | left join TMateriel_Info P on A.materiel_code = P.partcode |
| | | left join TOrganization T on M.wkshp_code = T.torg_code |
| | | left join TCustomer E on A.wx_code = E.code |
| | | left join TCustomer C on A.wx_code=C.code |
| | | where A.style = 'S' and B.style = 'S' and M.status<>'CLOSED' and A.verify='N' |
| | | ) as AA where" + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | //控制逻辑:中间工序调整-> (本道工序当前调整合格数+本道工序非当前报工合格总数)<下道工序报工总数(合格+不良+报废) ==不能小于下道报工总数 |
| | | string date = DateTime.Now.ToString(); //获取系统时间 |
| | | list.Clear(); |
| | | //获取当前工序上道工序及属性 |
| | | sql = @"select T.stepcode,T.stepname,T.flwtype from TK_Wrk_Step A |
| | | left join TStep T on A.step_code=T.stepcode |
| | | where A.wo_code=@ordercode and A.seq=@seq-1 "; |
| | | dynamicParams.Add("@ordercode", json[0].wo_code); |
| | | dynamicParams.Add("@seq", json[0].step_seq); |
| | | var pre = DapperHelper.selectdata(sql, dynamicParams); |
| | | //获取当前工序下道工序及属性 |
| | | sql = @"select T.stepcode,T.stepname,T.flwtype from TK_Wrk_Step A |
| | | left join TStep T on A.step_code=T.stepcode |
| | | where A.wo_code=@ordercode and A.seq=@seq+1 "; |
| | | dynamicParams.Add("@ordercode", json[0].wo_code); |
| | | dynamicParams.Add("@seq", json[0].step_seq); |
| | | var next = DapperHelper.selectdata(sql, dynamicParams); |
| | | //判断当前工序是自制工序还是外协工序 |
| | | if (json[0].flw_type.ToString() == "Z")//自制工序 |
| | | { |
| | |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | //判断是否存在下道工序及属性 |
| | | if (next.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序报工总数 |
| | | if ((notthis_reportqty + decimal.Parse(json[0].report_qty) < last_updatereportsumqty)) |
| | | if (next.Rows[0]["flwtype"].ToString() == "Z") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序修改报工总合格数量:【" + (notthis_reportqty + decimal.Parse(json[0].report_qty)) + "】不能小于下道工序报工总数量:【" + last_updatereportsumqty + "】,请输入合法数值或先修改下道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序报工总数 |
| | | if ((notthis_reportqty + this_reportqty) < last_updatereportsumqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序修改报工总合格数量:【" + (notthis_reportqty + this_reportqty) + "】不能小于下道自制工序报工总数量:【" + last_updatereportsumqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //查询当前工序下道工序:总发料数量 |
| | | sql = @"select isnull(sum(fqty),0) as good_qty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:发料总数数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序发料总数量 |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序发料总数 |
| | | if ((notthis_reportqty + this_reportqty) < last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序修改报工总合格数量:【" + (notthis_reportqty + this_reportqty) + "】不能小于下道外协工序发料总数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | //末道工序的报工 |
| | | else if (json[0].last_choke == "Y") |
| | |
| | | //获取当前末道工序报工总数量:本次修改报工数量+本次修改不良数量+本次修改工废数量+本次修改报工料废数量+当前末道工序非本次报工总数+当前末道工序非本次不良总数+当前末道工序非本次工废总数+当前末道工序非本次料废总数 |
| | | decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty; |
| | | |
| | | //查询当前末道工序上道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | //判断是否存在上道工序及属性 |
| | | if (pre.Rows.Count > 0) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //上道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //上道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //上道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //上道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断:当前末道工序报工记录:当前末道工序报工总数量>上道工序报工合格总数 |
| | | if (updatereportsumqty > last_reportqty) |
| | | if (pre.Rows[0]["flwtype"].ToString() == "Z") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前末道工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序报工总合格数量:【" + last_reportqty + "】,请输入合法数值或先修改上道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | //查询当前末道工序上道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //上道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //上道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //上道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //上道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断:当前末道工序报工记录:当前末道工序报工总数量>上道工序报工合格总数 |
| | | if (updatereportsumqty > last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前末道工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序报工总合格数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //查询当前工序上道工序:总收料数量 |
| | | sql = @"select isnull(sum(sqty),0) as good_qty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:收料总数数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序发料总数量 |
| | | //判断:当前末道工序报工记录:当前末道工序报工总数量>上道工序收料合格总数 |
| | | if (updatereportsumqty > last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前末道工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序收料总合格数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else //中间工序的报工 |
| | | { |
| | | //查询当前中间报工工序非此次报工:总报工数量、总不良数量、总报废数量 |
| | | //查询当前中间报工工序非此次报工:总报工数量、总不良数量、总报废数量 |
| | | 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); |
| | |
| | | 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; |
| | | //查询当前工序上道工序:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | 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 step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | |
| | | //判断是否存在上道工序及属性 |
| | | if (pre.Rows.Count > 0) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //上道工序报工总合格数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //上道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //上道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());//上道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断:当前工序报工记录:当前工序报工总数>上道工序报工总合格数 |
| | | if (updatereportsumqty > last_reportqty) |
| | | if (pre.Rows[0]["flwtype"].ToString() == "Z") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序报工总合格数量:【" + last_reportqty + "】,请输入合法数值或先修改上道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | //查询当前工序上道工序:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | 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 step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //上道工序报工总合格数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //上道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //上道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());//上道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断:当前工序报工记录:当前工序报工总数>上道工序报工总合格数 |
| | | if (updatereportsumqty > last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序报工总合格数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //查询当前工序上道工序:总收料数量 |
| | | sql = @"select isnull(sum(sqty),0) as good_qty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:收料总数数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //上道工序收料总合格数量 |
| | | //判断:当前末道工序报工记录:当前工序报工总数量>上道工序收料总合格数量 |
| | | if (updatereportsumqty > last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序收料总合格数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt1.Rows.Count > 0) |
| | | //判断是否存在下道工序属性 |
| | | if (next.Rows.Count > 0) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt1.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt1.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt1.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt1.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序报工总数 |
| | | if ((notthis_reportqty + decimal.Parse(json[0].report_qty)< last_updatereportsumqty)) |
| | | if (next.Rows[0]["flwtype"].ToString() == "Z") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总合格数量:【" + (notthis_reportqty + decimal.Parse(json[0].report_qty)) + "】不能小于下道工序报工总数量:【" + last_updatereportsumqty + "】,请输入合法数值或先修改下道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt1.Rows.Count > 0) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt1.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt1.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt1.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt1.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序报工总数 |
| | | if ((notthis_reportqty + this_reportqty) < last_updatereportsumqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总合格数量:【" + (notthis_reportqty + this_reportqty) + "】不能小于下道工序报工总数量:【" + last_updatereportsumqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //查询当前工序下道工序:总发料数量 |
| | | sql = @"select isnull(sum(fqty),0) as good_qty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:发料总数数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序发料总合格数量 |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序发料总数 |
| | | if ((notthis_reportqty + this_reportqty) < last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总数量:【" + (notthis_reportqty + this_reportqty) + "】不能大于下道工序发料总数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | }); |
| | | //回写对应的报工记录主表合格数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_Record set start_qty=start_qty+@good_qty, good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty |
| | | sql = @"update TK_Wrk_Record set start_qty=start_qty+@good_qty, good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty, |
| | | updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | where wo_code=@wo_code and step_code=@step_code and id=@id and style='B'"; |
| | | list.Add(new |
| | | { |
| | |
| | | materielbad_qty = this_materielbad_dvalue, |
| | | wo_code = json[0].wo_code, |
| | | step_code = json[0].step_code, |
| | | id = int.Parse(json[0].id) |
| | | id = int.Parse(json[0].id), |
| | | updatereportuser = us.usercode, |
| | | updatereportdate = date |
| | | } |
| | | }); |
| | | //回写工单工序表 |
| | |
| | | step_code = json[0].step_code |
| | | } |
| | | }); |
| | | |
| | | |
| | | for (int i = 0; i < json[0].children.Count; i++) |
| | | { |
| | | //回写不良 |
| | |
| | | } |
| | | if (json[0].flw_type.ToString() == "W")//外协工序 |
| | | { |
| | | //获取此次报工调整提交的数据(合格数量、不良数量、工废数量、料废数量) |
| | | decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //报工数量(合格) |
| | | //查询当前首道工序非此次供应商收料:总收料数量 |
| | | sql = @"select isnull(sum(sqty),0) as sqty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code<>@wx_code"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@id", json[0].id); |
| | | dynamicParams.Add("@step_code", json[0].step_code); |
| | | dynamicParams.Add("@wx_code", json[0].wxcode); |
| | | var dt_c = DapperHelper.selectdata(sql, dynamicParams); |
| | | //获取此次报工调整提交的数据(收料数量、不良数量、工废数量、料废数量) |
| | | decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //收料数量 |
| | | decimal this_ngqty = json[0].children.Sum(item => decimal.Parse(item.ng_qty));//不良数量汇总 |
| | | decimal this_laborbadqty = json[0].children.Sum(item => decimal.Parse(item.laborbad_qty));//工废数量汇总 |
| | | decimal this_materielbadqty = json[0].children.Sum(item => decimal.Parse(item.materielbad_qty));//料废数量汇总 |
| | | decimal this_ng_dvalue = json[0].children.Sum(item => decimal.Parse(item.ng_dvalue));//不良数量差值汇总 |
| | | decimal this_laborbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.laborbad_dvalue));//工废数量差值汇总 |
| | | decimal this_materielbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.materielbad_dvalue));//料废数量差值汇总 |
| | | //首道工序的报工 |
| | | //获取当前工序、供应商对应的发料数量 |
| | | sql = @"select isnull(sum(fqty),0) as fqty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and id<>@id and step_code=@step_code and wx_code=@wx_code"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@id", json[0].id); |
| | | dynamicParams.Add("@step_code", json[0].step_code); |
| | | dynamicParams.Add("@wx_code", json[0].wxcode); |
| | | var dt_0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | //首道工序的收料 |
| | | if (json[0].first_choke == "Y") |
| | | { |
| | | //查询当前首道报工工序非此次报工:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | //查询当前首道工序非此次收料:总收料数量、总不良数量、总工废数量、总料废数量 |
| | | sql = @"select isnull(sum(sqty),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_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code"; |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@id", json[0].id); |
| | | dynamicParams.Add("@step_code", json[0].step_code); |
| | | dynamicParams.Add("@wx_code", json[0].wxcode); |
| | | var dt = DapperHelper.selectdata(sql, dynamicParams); |
| | | decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //当前工序非本次报工总数 |
| | | decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //当前工序非本次收料总数 |
| | | decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //当前工序非本次报工总不良数 |
| | | decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //当前工序非本次报工总工废数 |
| | | decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //当前工序非本次报工总料废数 |
| | | //判断:当前工序报工记录:本次报工数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次报工总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>工单任务数量 |
| | | //判断:当前工序报工记录:本次收料数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>发料数量 |
| | | decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty; |
| | | if (updatereportsumqty > decimal.Parse(json[0].task_qty.ToString())) |
| | | if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString())) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序修改报工总数量:【" + updatereportsumqty + "】不能大于工单任务数量:【" + json[0].task_qty.ToString() + "】!"; |
| | | mes.Message = "当前首道工序对应供应商收料总数量:【" + updatereportsumqty + "】不能大于发料数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | sql = @"select isnull(sum(sqty),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_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | //判断是否存在下道工序及属性 |
| | | if (next.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序报工总数 |
| | | if ((notthis_reportqty + decimal.Parse(json[0].report_qty) < last_updatereportsumqty)) |
| | | if (next.Rows[0]["flwtype"].ToString() == "Z") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序修改报工总合格数量:【" + (notthis_reportqty + decimal.Parse(json[0].report_qty)) + "】不能小于下道工序报工总数量:【" + last_updatereportsumqty + "】,请输入合法数值或先修改下道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次收料数+本次收料调整数+非当前供应商同工序收料总数)<下道工序报工总数 |
| | | if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序收料数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道自制工序报工总数量:【" + last_updatereportsumqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //查询当前工序下道工序:总发料数量 |
| | | sql = @"select isnull(sum(fqty),0) as good_qty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:发料总数数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序发料总数量 |
| | | //判断(当前非本次收料数+本次报工调整收料数)<下道工序发料总数 |
| | | if ((notthis_reportqty + this_reportqty) < last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序收料总数量:【" + (notthis_reportqty + this_reportqty) + "】不能小于下道外协工序发料总数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | //末道工序的报工 |
| | | else if (json[0].last_choke == "Y") |
| | | { |
| | | //查询当前末道报工工序非此次报工:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | //查询当前末道报工工序非此次收料:总收料数量、总不良数量、总工废数量、总料废数量 |
| | | sql = @"select isnull(sum(sqty),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_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code"; |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@id", json[0].id); |
| | | dynamicParams.Add("@step_code", json[0].step_code); |
| | | var dt = DapperHelper.selectdata(sql, dynamicParams); |
| | | decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //当前末道工序非本次报工总数 |
| | | decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //当前末道工序非本次收料总数 |
| | | 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; |
| | | |
| | | //查询当前末道工序上道工序:总报工数量、总不良数量、总报废数量 |
| | | sql = @"select isnull(sum(sqty),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_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | //判断当前工序供应商收料总数>当前工序供应商对应发料数量 |
| | | if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString())) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //上道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //上道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //上道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //上道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断:当前末道工序报工记录:当前末道工序报工总数量>上道工序报工合格总数 |
| | | if (updatereportsumqty > last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前末道工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序报工总合格数量:【" + last_reportqty + "】,请输入合法数值或先修改上道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序供应商收料总数量:【" + updatereportsumqty + "】不能大于工序供应商发料总数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | |
| | | } |
| | | else //中间工序的报工 |
| | | { |
| | | //查询当前中间报工工序非此次报工:总报工数量、总不良数量、总报废数量 |
| | | |
| | | //查询当前首道工序供应商非此次收料:总收料数量、总不良数量、总工废数量、总料废数量 |
| | | sql = @"select isnull(sum(sqty),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_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code"; |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@id", json[0].id); |
| | | dynamicParams.Add("@step_code", json[0].step_code); |
| | | dynamicParams.Add("@wx_code", json[0].wxcode); |
| | | var dt = DapperHelper.selectdata(sql, dynamicParams); |
| | | decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //当前工序非本次报工总数 |
| | | 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; |
| | | //查询当前工序上道工序:总报工数量、总不良数量、总工废数量、总料废数量 |
| | | sql = @"select isnull(sum(sqty),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_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //当前工序非本次收料总数 |
| | | decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //当前工序非本次报工总不良数 |
| | | decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //当前工序非本次报工总工废数 |
| | | decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //当前工序非本次报工总料废数 |
| | | //判断:当前工序报工记录:本次收料数量+本次不良数量+本次工废数量+本次料废数量+当前工序非本次收料总数+当前工序非本次不良总数+当前工序非本次工废总数+当前工序非本次料废总数>发料数量 |
| | | decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty; |
| | | if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString())) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //上道工序报工总合格数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //上道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //上道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());//上道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断:当前工序报工记录:当前工序报工总数>上道工序报工总合格数 |
| | | if (updatereportsumqty > last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总数量:【" + updatereportsumqty + "】不能大于上道工序报工总合格数量:【" + last_reportqty + "】,请输入合法数值或先修改上道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序对应供应商收料总数量:【" + updatereportsumqty + "】不能大于发料数量:【" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | sql = @"select isnull(sum(sqty),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_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt1.Rows.Count > 0) |
| | | //判断是否存在下道工序及属性 |
| | | if (next.Rows.Count > 0) |
| | | { |
| | | decimal last_reportqty = decimal.Parse(dt1.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt1.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt1.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt1.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次报工总合格数+本次报工调整合格数)<下道工序报工总数 |
| | | if ((notthis_reportqty + decimal.Parse(json[0].report_qty)< last_updatereportsumqty)) |
| | | if (next.Rows[0]["flwtype"].ToString() == "Z") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序修改报工总合格数量:【" + (notthis_reportqty + decimal.Parse(json[0].report_qty)) + "】不能小于下道工序报工总数量:【" + last_updatereportsumqty + "】,请输入合法数值或先修改下道工序报工数量!"; |
| | | mes.data = null; |
| | | return mes; |
| | | //查询当前工序下道工序:总报工数量、总不良数量、总报废数量 |
| | | 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 step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:报工总数数量+不良总数数量+工废总数量+料废总数量<下道工序报工总数量+下道工序不良总数量+下道工序工废总数量+下道工序料废总数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序报工总数量 |
| | | decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //下道工序不良总数量 |
| | | decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //下道工序工废总数量 |
| | | decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //下道工序料废总数量 |
| | | decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty; |
| | | //判断(当前非本次收料数+本次收料调整数+非当前供应商同工序收料总数)<下道工序报工总数 |
| | | if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序收料数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道自制工序报工总数量:【" + last_updatereportsumqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //查询当前工序下道工序:总发料数量 |
| | | sql = @"select isnull(sum(fqty),0) as good_qty |
| | | from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1"; |
| | | dynamicParams.Add("@wo_code", json[0].wo_code); |
| | | dynamicParams.Add("@step_seq", json[0].step_seq); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | //判断当前工序:发料总数数量 |
| | | decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //下道工序发料总数量 |
| | | //判断(当前非本次收料数+本次报工调整收料数+非当前供应商同工序收料总数)<下道工序发料总数 |
| | | if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_reportqty) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前首道工序收料总数量:【" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "】不能小于下道外协工序发料总数量:【" + last_reportqty + "】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | ///////////////////////////////修改报工////////////////////////////// |
| | | |
| | | //回写对应的外协记录子表合格数量、不良数量、报废数量 |
| | | //回写对应的外协记录子表收料数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty, |
| | | updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | where m_id=@m_id and id=@id and style='S'"; |
| | | where m_id=@m_id and id=@id and style='S' and wx_code=@wx_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | ng_qty = this_ng_dvalue, |
| | | laborbad_qty = this_laborbad_dvalue, |
| | | materielbad_qty = this_materielbad_dvalue, |
| | | wx_code = json[0].wxcode, |
| | | //bad_money = decimal.Parse(json[i].badmoney_dvalue), |
| | | updatereportuser = us.usercode, |
| | | updatereportdate = date |
| | | } |
| | | }); |
| | | //回写对应的外协记录主表合格数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_OutRecord set sqty=sqty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty |
| | | where wo_code=@wo_code and step_code=@step_code and id=@id and style='S'"; |
| | | //回写对应的收料记录主表收料数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_OutRecord set sqty=sqty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty, |
| | | updatereportuser=@updatereportuser,updatereportdate=@updatereportdate |
| | | where wo_code=@wo_code and step_code=@step_code and id=@id and style='S' and wx_code=@wx_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | ng_qty = this_ng_dvalue, |
| | | laborbad_qty = this_laborbad_dvalue, |
| | | materielbad_qty = this_materielbad_dvalue, |
| | | wx_code = json[0].wxcode, |
| | | wo_code = json[0].wo_code, |
| | | step_code = json[0].step_code, |
| | | id = int.Parse(json[0].id) |
| | | id = int.Parse(json[0].id), |
| | | updatereportuser = us.usercode, |
| | | updatereportdate = date |
| | | } |
| | | }); |
| | | //回写工单工序表 |
| | |
| | | step_code = json[0].step_code |
| | | } |
| | | }); |
| | | |
| | | |
| | | for (int i = 0; i < json[0].children.Count; i++) |
| | | { |
| | | //回写不良 |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[生产执行,报工审核列表数据查询接口] |
| | | public static ToMessage MesOrderStepReportVerifySearch(string wo_code, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (wo_code != "" && wo_code != null) |
| | | { |
| | | search += "and AA.wo_code like '%'+@wo_code+'%' "; |
| | | dynamicParams.Add("@wo_code", wo_code); |
| | | } |
| | | if (partnumber != "" && partnumber != null) |
| | | { |
| | | search += "and AA.partnumber like '%'+@partnumber+'%' "; |
| | | dynamicParams.Add("@partnumber", partnumber); |
| | | } |
| | | if (partname != "" && partname != null) |
| | | { |
| | | search += "and AA.partname like '%'+@partname+'%' "; |
| | | dynamicParams.Add("@partname", partname); |
| | | } |
| | | if (partspec != "" && partspec != null) |
| | | { |
| | | search += "and AA.partspec like '%'+@partspec+'%' "; |
| | | dynamicParams.Add("@partspec", partspec); |
| | | } |
| | | if (stepname != "" && stepname != null) |
| | | { |
| | | search += "and AA.stepname like '%'+@stepname+'%' "; |
| | | dynamicParams.Add("@stepname", stepname); |
| | | } |
| | | if (reportuser != "" && reportuser != null) |
| | | { |
| | | search += "and AA.usercode like '%'+@reportuser+'%' "; |
| | | dynamicParams.Add("@reportuser", reportuser); |
| | | } |
| | | if (reportdateopendate != "" && reportdateopendate != null) |
| | | { |
| | | search += "and AA.report_date between @reportdateopendate and @reportdateclosedate "; |
| | | dynamicParams.Add("@reportdateopendate", reportdateopendate + " 00:00:00"); |
| | | dynamicParams.Add("@reportdateclosedate", reportdateclosedate + " 23:59:59"); |
| | | } |
| | | |
| | | |
| | | if (search == "") |
| | | { |
| | | search = "and 1=1 "; |
| | | } |
| | | search = search.Substring(3);//截取索引2后面的字符 |
| | | // --------------查询指定自制报工外协收料数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select * from( |
| | | select A.id,B.id as sbid,A.wo_code,A.materiel_code as partnumber,P.partname,P.partspec,A.task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,B.reckway,B.usergroup_code,G.usergroupname as usergroup_name, |
| | | B.report_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | | FROM TUser U |
| | | WHERE CHARINDEX(',' + U.usercode + ',', ',' + B.report_person + ',') > 0 |
| | | FOR XML PATH('')), 1, 1, '') AS username, |
| | | B.report_date,B.report_qty,B.ng_qty,B.laborbad_qty,B.materielbad_qty,'' as wx_code,'' as wx_name,A.verify |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_RecordSub B on A.id=B.m_id |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TK_Wrk_Step K on M.wo_code=K.wo_code and A.step_code=K.step_code |
| | | left join TStep S on A.step_code=S.stepcode |
| | | left join TMateriel_Info P on A.materiel_code=P.partcode |
| | | left join TOrganization T on M.wkshp_code=T.torg_code |
| | | left join TEqpInfo E on A.eqp_code=E.code |
| | | left join TGroup G on G.usergroupcode=B.usergroup_code |
| | | where A.style='B' and B.style='B' and M.status<>'CLOSED' |
| | | union all |
| | | select A.id,B.id as sbid,A.wo_code,A.materiel_code as partnumber,P.partname,P.partspec,M.plan_qty as task_qty,M.wkshp_code,T.torg_name as wkshp_name,A.wx_code as eqp_code,E.name as eqp_name, |
| | | A.step_seq,A.step_code,S.stepname,S.flwtype as steptype,k.isbott as first_choke,k.isend as last_choke,A.step_price,'person' as reckway,'' as usergroup_code,'' as usergroup_name, |
| | | B.in_person as usercode, |
| | | STUFF((SELECT ',' + U.username |
| | | FROM TUser U |
| | | WHERE CHARINDEX(',' + U.usercode + ',', ',' + B.in_person + ',') > 0 |
| | | FOR XML PATH('')), 1, 1, '') AS username, |
| | | B.in_time as report_date,B.sqty as report_qty,B.ng_qty,B.laborbad_qty,B.materielbad_qty,A.wx_code,C.name as wx_name,A.verify |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_OutRecordSub B on A.id = B.m_id |
| | | left join TK_Wrk_Man M on A.wo_code = M.wo_code |
| | | left join TK_Wrk_Step K on M.wo_code=K.wo_code and A.step_code=K.step_code |
| | | left join TStep S on A.step_code = S.stepcode |
| | | left join TMateriel_Info P on A.materiel_code = P.partcode |
| | | left join TOrganization T on M.wkshp_code = T.torg_code |
| | | left join TCustomer E on A.wx_code = E.code |
| | | left join TCustomer C on A.wx_code=C.code |
| | | where A.style = 'S' and B.style = 'S' and M.status<>'CLOSED' |
| | | ) as AA where" + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.count = total; |
| | | mes.data = data.ToList(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产执行,报工审核数据提交] |
| | | public static ToMessage MesOrderStepReportVerifySeave(User us, DataModel json) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (json.zdata.Count > 0) |
| | | { |
| | | //回写报工记录主表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_Record set verify='Y',verifyuser=@verifyuser,verifydate=@verifydate where id in @id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = us.usercode, verifydate = DateTime.Now.ToString(), id = json.zdata } }); |
| | | //回写报工记录子表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_RecordSub set verify='Y',verifyuser=@verifyuser,verifydate=@verifydate where m_id in @id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = us.usercode, verifydate = DateTime.Now.ToString(), id = json.zdata } }); |
| | | } |
| | | if (json.wdata.Count > 0) |
| | | { |
| | | //回写外协记录主表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_OutRecord set verify='Y',verifyuser=@verifyuser,verifydate=@verifydate where id in @id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = us.usercode, verifydate = DateTime.Now.ToString(), id = json.wdata } }); |
| | | //回写外协记录子表审核状态、审核人、审核时间 |
| | | sql = @"update TK_Wrk_OutRecordSub set verify='Y',verifyuser=@verifyuser,verifydate=@verifydate where m_id in @id"; |
| | | list.Add(new { str = sql, parm = new { verifyuser = us.usercode, verifydate = DateTime.Now.ToString(), id = json.wdata } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | //写入操作记录表 |
| | | LogHelper.DbOperateLog(us.usercode, "报工审核", "自制报工记录id:" + string.Join(",", json.zdata), us.usertype); |
| | | LogHelper.DbOperateLog(us.usercode, "报工审核", "外协收料记录id:" + string.Join(",", json.wdata), us.usertype); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "审核成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "审核失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | } |
| | | } |