| | |
| | | using System.Data.SqlClient; |
| | | using System.Linq; |
| | | using System.Web; |
| | | using VueWebApi.Models; |
| | | using VueWebApi.Tools; |
| | | |
| | | namespace VueWebApi.DLL.DAL |
| | |
| | | |
| | | |
| | | #region[ERP订单查询] |
| | | public static ToMessage ErpOrderSearch(string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string creatuser, string createstartdate, string createenddate, int endNum, string prop, string order) |
| | | public static ToMessage ErpOrderSearch(string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string paydatestartdate1, string paydateenddate2, string creatuser, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | } |
| | | if (paydatestartdate != "" && paydatestartdate != null) |
| | | { |
| | | search += "and A.paydate between @paydatestartdate and @paydateenddate "; |
| | | dynamicParams.Add("@paydatestartdate", paydatestartdate+" 00:00:00"); |
| | | search += "and A.planstartdate between @paydatestartdate and @paydateenddate "; |
| | | dynamicParams.Add("@paydatestartdate", paydatestartdate + " 00:00:00"); |
| | | dynamicParams.Add("@paydateenddate", paydateenddate + " 23:59:59"); |
| | | } |
| | | if (createstartdate != "" && createstartdate != null) |
| | | if (paydatestartdate1 != "" && paydatestartdate1 != null) |
| | | { |
| | | search += "and A.createdate between @createstartdate and @createenddate "; |
| | | dynamicParams.Add("@createstartdate", createstartdate); |
| | | dynamicParams.Add("@createenddate", createenddate + " 23:59:59"); |
| | | search += "and A.planenddate between @paydatestartdate1 and @paydateenddate2 "; |
| | | dynamicParams.Add("@paydatestartdate1", paydatestartdate1); |
| | | dynamicParams.Add("@paydateenddate2", paydateenddate2 + " 23:59:59"); |
| | | } |
| | | if (creatuser != "" && creatuser != null) |
| | | { |
| | | search += "and A.createuser like '%'+@creatuser+'%' "; |
| | | search += "and U.username like '%'+@creatuser+'%' "; |
| | | dynamicParams.Add("@creatuser", creatuser); |
| | | } |
| | | |
| | |
| | | } |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.paydate,A.createuser,A.createdate |
| | | var sql = @"select A.id, A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.planstartdate,A.planenddate,U.username as createuser,A.createdate |
| | | from TKimp_Ewo A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code where A.is_delete<>'1' " + search; |
| | | left join T_Sec_Stck D on A.stck_code=D.code |
| | | left join TUser U on A.createuser=U.usercode |
| | | where A.is_delete<>'1' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | #endregion |
| | | |
| | | #region[ERP订单下达] |
| | | public static ToMessage MarkSaveErpOrder(string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string username) |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string username) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | } |
| | | if (i == Convert.ToInt32(ordernum)) //最后一单时 |
| | | { |
| | | sql = @"insert into TK_Wrk_Man(wo_code,status,wkshp_code,plan_qty,stck_code,materiel_code,m_po,lm_user,lm_date) values(@wo_code,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@m_po,@username,@CreateDate)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,materiel_code,sourceid,m_po,lm_user,lm_date) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo_code = wo, |
| | | wotype="PO", |
| | | status = "NEW", |
| | | wkshp_code = wkshopcode, |
| | | plan_qty = cdqty + (decimal.Parse(markqty) - sumqty), //末单下单数量=切分数量+(下单数量-累计切分下单数量) |
| | | stck_code = warehousecode, |
| | | materiel_code = partcode, |
| | | sourceid=erporderid, |
| | | m_po = erpordercode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString() |
| | |
| | | else |
| | | { |
| | | |
| | | sql = @"insert into TK_Wrk_Man(wo_code,status,wkshp_code,plan_qty,stck_code,materiel_code,m_po,lm_user,lm_date) values(@wo_code,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@m_po,@username,@CreateDate)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,materiel_code,sourceid,m_po,lm_user,lm_date) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo_code = wo, |
| | | wotype = "PO", |
| | | status = "NEW", |
| | | wkshp_code = wkshopcode, |
| | | plan_qty = cdqty, |
| | | stck_code = warehousecode, |
| | | materiel_code = partcode, |
| | | sourceid = erporderid, |
| | | m_po = erpordercode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString() |
| | |
| | | } |
| | | if (decimal.Parse(erpqty) == decimal.Parse(markqty) + decimal.Parse(relse_qty)) //如果ERP订单=下单数量+已下单数量,则更新ERP订单表状态为CREATED:已创建 |
| | | { |
| | | sql = @"update TKimp_Ewo set status='CREATED',relse_qty=relse_qty+@sumqty where wo=@wo"; |
| | | sql = @"update TKimp_Ewo set status='CREATED',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo = erpordercode, |
| | | erporderid = erporderid, |
| | | sumqty = sumqty |
| | | } |
| | | }); |
| | | } |
| | | else //更新ERP订单表状态为CREATING:创建中 |
| | | { |
| | | sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty+@sumqty where wo=@wo"; |
| | | sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo = erpordercode, |
| | | erporderid = erporderid, |
| | | sumqty = sumqty |
| | | } |
| | | }); |
| | |
| | | #endregion |
| | | |
| | | #region[ERP订单关闭] |
| | | public static ToMessage ClosedErpOrder(string erpordercode, string username) |
| | | public static ToMessage ClosedErpOrder(string erporderid, string erpordercode, string username) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | else |
| | | { |
| | | //关闭订单 |
| | | sql = @"update TKimp_Ewo set status='CLOSED' where wo=@wo"; |
| | | sql = @"update TKimp_Ewo set status='CLOSED' where wo=@wo and id=@erporderid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo = erpordercode |
| | | wo = erpordercode, |
| | | erporderid = erporderid |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | |
| | | #region[MES工单查询] |
| | | public static ToMessage ErpOrderSearch(string mesorderstus, string mesordercode, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderSearch(string mesorderstus, string mesordercode,string sourceorder,string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | { |
| | | search += "and A.wo_code like '%'+@mesordercode+'%' "; |
| | | dynamicParams.Add("@mesordercode", mesordercode); |
| | | } |
| | | if (sourceorder != "" && sourceorder != null) |
| | | { |
| | | search += "and A.m_po like '%'+@sourceorder+'%' "; |
| | | dynamicParams.Add("@sourceorder", sourceorder); |
| | | } |
| | | if (ordertype != "" && ordertype != null) |
| | | { |
| | | search += "and A.wotype like '%'+@ordertype+'%' "; |
| | | dynamicParams.Add("@ordertype", ordertype); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | |
| | | } |
| | | if (creatuser != "" && creatuser != null) |
| | | { |
| | | search += "and A.lm_user like '%'+@creatuser+'%' "; |
| | | search += "and U.username like '%'+@creatuser+'%' "; |
| | | dynamicParams.Add("@creatuser", creatuser); |
| | | } |
| | | |
| | |
| | | } |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.status,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.m_po,A.lm_user,A.lm_date |
| | | var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date |
| | | from TK_Wrk_Man A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code |
| | | left join TFlw_Rout E on A.route_code=E.code |
| | | left join T_Sec_Stck F on A.stck_code=F.code where A.is_delete<>'1' " + search; |
| | | left join T_Sec_Stck F on A.stck_code=F.code |
| | | left join TUser U on A.lm_user=U.usercode |
| | | where A.is_delete<>'1' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | #endregion |
| | | |
| | | #region[MES工单新增、编辑提交] |
| | | public static ToMessage AddUpdateMesOrder(string mesorderstus, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype) |
| | | public static ToMessage AddUpdateMesOrder(string mesorderstus,string sourceorder,string ordertype, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype) |
| | | { |
| | | var sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | |
| | | if (opertype == "Add") |
| | | { |
| | | //写入工单表 |
| | | sql = @"insert into TK_Wrk_Man(wo_code,status,wkshp_code,plan_qty,plan_startdate,plan_enddate,route_code,stck_code,lm_user,lm_date,materiel_code,m_po,piroque) |
| | | values(@mesordercode,@mesorderstus,@wkshopcode,@mesqty,@planstartdate,@planenddate,@routecode,@stck_code,@username,@CreateDate,@materiel_code,@m_po,@orderlev)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,plan_startdate,plan_enddate,route_code,stck_code,lm_user,lm_date,materiel_code,m_po,piroque) |
| | | values(@mesordercode,@wotype,@mesorderstus,@wkshopcode,@mesqty,@planstartdate,@planenddate,@routecode,@stck_code,@username,@CreateDate,@materiel_code,@m_po,@orderlev)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode, |
| | | wotype = ordertype, |
| | | m_po = sourceorder, |
| | | mesorderstus = "ALLO", //派发 |
| | | wkshopcode = wkshopcode, |
| | | mesqty = mesqty, |
| | |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | materiel_code = partcode, |
| | | m_po = "", |
| | | orderlev = orderlev |
| | | } |
| | | }); |
| | |
| | | planenddate = planenddate, |
| | | status = "ALLO", //派发 |
| | | username = username, |
| | | routecode= routecode, |
| | | routecode = routecode, |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | |
| | | #endregion |
| | | |
| | | #region[MES工单删除] |
| | | public static ToMessage DeleteMesOrder(string wocode, string m_po, string orderqty) |
| | | public static ToMessage DeleteMesOrder(string souceid, string wocode, string m_po, string orderqty) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | if (m_po != "" && m_po != null) |
| | | { |
| | | //查询生产订单表数据 |
| | | sql = @"select * from TKimp_Ewo where wo=@m_po"; |
| | | sql = @"select * from TKimp_Ewo where wo=@m_po and id=@souceid"; |
| | | dynamicParams.Add("@m_po", m_po); |
| | | dynamicParams.Add("@souceid", souceid); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//以下单数量 |
| | | if ((relse_qty - decimal.Parse(orderqty)) == 0) //全部撤销 订单状态回写未开始,已下单数量为0 |
| | | { |
| | | //回写订单表状态及已下单数量 |
| | | sql = @"update TKimp_Ewo set status='NEW',relse_qty=0 where wo=@m_po"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po } }); |
| | | sql = @"update TKimp_Ewo set status='NEW',relse_qty=0 where wo=@m_po and id=@souceid"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po, souceid= souceid } }); |
| | | } |
| | | else |
| | | { |
| | | //回写订单表状态及已下单数量 |
| | | sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty where wo=@m_po"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } }); |
| | | sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty where wo=@m_po and id=@souceid"; |
| | | list.Add(new { str = sql, parm = new { m_po = m_po, souceid= souceid, orderqty = decimal.Parse(orderqty) } }); |
| | | } |
| | | } |
| | | //删除工单工序表 |
| | |
| | | #endregion |
| | | |
| | | #region[MES工单关闭] |
| | | public static ToMessage ClosedMesOrder(string wocode, string m_po) |
| | | public static ToMessage ClosedMesOrder(string username,string wocode, string m_po) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | sql = @"update TK_Wrk_Step set status='CLOSED' where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocode } }); |
| | | //回写工单表状态为(关闭) |
| | | sql = @"update TK_Wrk_Man set status='CLOSED' where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocode } }); |
| | | sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocode, username = username, closedate=DateTime.Now.ToString() } }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | try |
| | | { |
| | | //获取工序任务信息 |
| | | sql = @"select A.wo_code,A.seq,B.stepcode,B.stepname,A.plan_qty,A.good_qty,A.ng_qty from TK_Wrk_Step A |
| | | left join TStep B on A.step_code=B.stepcode |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec,A.seq,B.stepcode,B.stepname,A.plan_qty,A.good_qty,A.ng_qty from TK_Wrk_Step A |
| | | left join TStep B on A.step_code=B.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 |
| | | where A.wo_code=@wo_code"; |
| | | dynamicParams.Add("@wo_code", wo_code); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | sql = @"select * from TStep where stepcode=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.plan_startdate |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.plan_startdate |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | |
| | | mes.Message = "无可执行的生产任务,任务已完成或已关闭!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(不良)] |
| | | public static ToMessage MesOrderNgStepSearch(string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | var total = 0; //总条数 |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | | { |
| | | string[] arra = orderstepqrcode.Split(';'); |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序二维码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | if (ordercode != "" && ordercode != null) //工单号不为空,工序号为空 |
| | | { |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | } |
| | | if (ordercode != "" && stepcode != "") //工单号不为空,工序号不为空 |
| | | { |
| | | search += "and A.wo_code=@ordercode "; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | search += "and S.stepcode=@stepcode "; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | } |
| | | } |
| | | if (stepcode != "") |
| | | { |
| | | //查找当前工序任务 |
| | | sql = @"select * from TK_Wrk_Step where step_code=@stepcode and wo_code=@ordercode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序任务不存在,无效条码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | //根据条件查询工单工序任务,且不良数量大于0 |
| | | sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,A.seq,A.isend, |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | | left join TStep S on A.step_code=S.stepcode |
| | | where A.status<>'CLOSED' and A.ng_qty>0 " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | if (data.ToList().Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = total; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data.ToList(); |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "301"; |
| | | mes.count = 0; |
| | | mes.Message = "无可执行的生产任务,任务已完成或已关闭!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(不良明细)] |
| | | public static ToMessage MesOrderNgSubStepSearch(string orderstepqrcode) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | var dynamicParams1 = new DynamicParameters(); |
| | | Dictionary<string, object> list = new Dictionary<string, object>(); |
| | | ScanStartReportData rt = new ScanStartReportData(); |
| | | var total = 0; //总条数 |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | | { |
| | | string[] arra = orderstepqrcode.Split(';'); |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序二维码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | } |
| | | //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.good_qty,A.ng_qty,A.bad_qty,A.isbott,A.isend |
| | | 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 |
| | | 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.wo_code = data.Rows[0]["WO_CODE"].ToString(); //工单号 |
| | | rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //产品编码 |
| | | rt.partname = data.Rows[0]["PARTNAME"].ToString(); //产品名称 |
| | | rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //产品规格 |
| | | rt.stepcode = data.Rows[0]["STEPCODE"].ToString(); //工序编码 |
| | | rt.stepname = data.Rows[0]["STEPNAME"].ToString(); //工序名称 |
| | | rt.stepdesc = data.Rows[0]["DESCR"].ToString(); //工序描述 |
| | | rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //任务数量 |
| | | rt.noreportqty = decimal.Parse(data.Rows[0]["GOOD_QTY"].ToString()); //报工数量 |
| | | rt.noputqty = decimal.Parse(data.Rows[0]["NG_QTY"].ToString()); //不良数量 |
| | | string isend = data.Rows[0]["ISEND"].ToString();//末道工序 |
| | | rt.seq = data.Rows[0]["SEQ"].ToString();//工序序号 |
| | | |
| | | //获取当前工序下道工序 |
| | | sql = @"select A.isbott,A.isend,T.stepcode,T.stepname 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", ordercode); |
| | | dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString())); |
| | | var dt0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt0.Rows.Count > 0) //有下道工序 |
| | | { |
| | | rt.nextstepcode = dt0.Rows[0]["STEPCODE"].ToString();//下道工序编码 |
| | | rt.nextstepname = dt0.Rows[0]["STEPNAME"].ToString();//下道工序名称 |
| | | } |
| | | if (isend == "Y") //当前工序是末道工序 |
| | | { |
| | | rt.nextstepcode ="";//赋空 |
| | | rt.nextstepname = "";//赋空 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前扫码工序任务不存在!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //根据条件查询工单工序报工(收料)记录,且不良数量大于0 |
| | | //存储过程名 |
| | | sql = @"h_p_IFCLD_MesReportDefectHandleSelect"; |
| | | dynamicParams1.Add("@ordercode", ordercode); |
| | | dynamicParams1.Add("@stepcode", stepcode); |
| | | DataTable dt = DapperHelper.selectProcedure(sql, dynamicParams1); |
| | | if (dt.Rows.Count > 0) |
| | | { |
| | | list.Add("data1", rt); |
| | | list.Add("data2", dt); |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = list; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "无可执行的生产任务,任务已完成或已关闭!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | dynamicParams.Add("@usercode", usercode); |
| | | } |
| | | //班组获取人员列表 |
| | | sql = @"select usercode,username from TUser where is_delete<>'1' "+search; |
| | | sql = @"select usercode,username from TUser where is_delete<>'1' and usercode<>'9999'" + search; |
| | | dynamicParams.Add("@usercode", usercode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | |
| | | left join TCustomer C on A.eqp_code=C.code |
| | | where A.step_code=@stepcode and A.style='W'"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql,dynamicParams); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | |
| | | sql = @"update TK_Wrk_Step set status='START' where wo_code=@mesordercode and step_code=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } }); |
| | | |
| | | |
| | | //回写工单工序表状态为已开工 |
| | | sql = @"update TK_Wrk_Step set status='START' where wo_code=@mesordercode and step_code=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } }); |
| | | //回写工单表状态为: 开工:START |
| | | sql = @"update TK_Wrk_Man set status='START' where wo_code=@mesordercode"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode } }); |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工,报工提交] |
| | | public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string username) |
| | | public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode,string remarks, string username) |
| | | { |
| | | var sql = ""; |
| | | string[] arra = new string[] { }; |
| | |
| | | dynamicParams.Add("@wo_code", mesordercode); |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | //获取开工记录的默认选中的设备(产线)与报工时的设备产线做对比判断 |
| | | sql = @"select A.eqp_code,B.name from TK_Wrk_Record A |
| | | inner join TEqpInfo B on A.eqp_code=B.code |
| | | where A.wo_code=@wo_code and A.step_code=@step_code and A.style='S'"; |
| | | dynamicParams.Add("@wo_code", mesordercode); |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | var da = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (da.Rows[0]["EQP_CODE"].ToString() != eqpcode) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败,当前报工产线应为:" + da.Rows[0]["NAME"].ToString() + "!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | //修改报工记录 |
| | | sql = @"update TK_Wrk_Record set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty, |
| | | lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode and step_code=@stepcode and style='B'"; |
| | | list.Add(new { str = sql, parm = new { reportqty = decimal.Parse(reportqty), ngqty = decimal.Parse(ngqty), mesordercode = mesordercode, stepcode = stepcode, username = username, CreateDate = date } }); |
| | | //写入子表 |
| | | for (int i = 0; i < arra.Length; i++) |
| | | { |
| | | sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,usergroup_code,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@usergroup_code,@ng_qty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //获取主表最大ID |
| | | sql = @"select IDENT_CURRENT('TK_Wrk_Record')+1 as id"; |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入开报工记录表 |
| | | sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date) |
| | |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "B", lm_user = username, lm_date = date } }); |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i],remarks=remarks,style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | | ////修改报工记录 |
| | | //sql = @"update TK_Wrk_Record set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty, |
| | | // lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode and step_code=@stepcode and style='B'"; |
| | | //list.Add(new { str = sql, parm = new { reportqty = decimal.Parse(reportqty), ngqty = decimal.Parse(ngqty), mesordercode = mesordercode, stepcode = stepcode, username = username, CreateDate = date } }); |
| | | ////写入子表 |
| | | //for (int i = 0; i < arra.Length; i++) |
| | | //{ |
| | | // sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,usergroup_code,ng_qty,style,lm_user,lm_date) |
| | | // values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@usergroup_code,@ng_qty,@style,@lm_user,@lm_date)"; |
| | | // list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | //} |
| | | //if (badcode != "" && ngqty != "0") |
| | | //{ |
| | | // //写入缺陷记录表 |
| | | // for (int i = 0; i < arra1.Length; i++) |
| | | // { |
| | | // sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | // values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | // list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | // } |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | //获取主表最大ID |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入开报工记录表 |
| | | sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date) |
| | | values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | //写入子表 |
| | | for (int i = 0; i < arra.Length; i++) |
| | | { |
| | | sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,usergroup_code,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@usergroup_code,@ng_qty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks= remarks, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | //回写工单工序表合格数量、不良数量 |
| | | sql = @"update TK_Wrk_Step set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode and step_code=@stepcode"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode,reportqty=reportqty,ngqty=ngqty } }); |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, reportqty = reportqty, ngqty = ngqty } }); |
| | | |
| | | //回写工单表合格数量、不良数量 |
| | | sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } }); |
| | | //sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | |
| | | else |
| | | { |
| | | //获取主表最大ID |
| | | sql = @"select IDENT_CURRENT('TK_Wrk_OutRecord')+1 as id"; |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入外协记录主表 |
| | | sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,fqty,lm_user,lm_date) |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工, 收料提交] |
| | | public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string username) |
| | | public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inuser, string taskqty, string sqty, string ngqty, string badcode,string remarks, string username) |
| | | { |
| | | var sql = ""; |
| | | string[] arra1 = new string[] { }; |
| | |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | dynamicParams.Add("@wx_code", wxcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | //获取发料记录的默认选中的外协供应商与收料时的外协供应商做对比判断 |
| | | sql = @"select A.wx_code,B.name,A.fqty from TK_Wrk_OutRecord A |
| | | inner join TCustomer B on A.wx_code=B.code |
| | | where A.wo_code=@wo_code and A.step_code=@step_code and wx_code=@wx_code and A.style='F' "; |
| | | dynamicParams.Add("@wo_code", mesordercode); |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | dynamicParams.Add("@wx_code", wxcode); |
| | | var da = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (da.Rows.Count<=0) |
| | | { |
| | | sql = @"select A.wx_code,B.name,A.fqty from TK_Wrk_OutRecord A |
| | | inner join TCustomer B on A.wx_code=B.code |
| | | where A.wo_code=@wo_code and A.step_code=@step_code and A.style='F' "; |
| | | dynamicParams.Add("@wo_code", mesordercode); |
| | | dynamicParams.Add("@step_code", stepcode); |
| | | var da1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | var dr = da1.AsEnumerable().ToList().Select(x => x.Field<string>("NAME")).ToList(); |
| | | string wxstring = (string.Join(",", dr.Select(x => x.ToString()).ToArray())); |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败,当前收料外协供方与发料外协供应商不匹配,应为:【"+wxstring+"】!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if ((decimal.Parse(sqty) + decimal.Parse(ngqty)) > decimal.Parse(da.Rows[0]["FQTY"].ToString())) //收料数量+不良数量>发料数量 |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败,当前收料数量+不良数量,不能大于发料数量:"+da.Rows[0]["FQTY"].ToString()+"!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //if (da.Rows[0]["WX_CODE"].ToString() != wxcode) |
| | | //{ |
| | | // mes.code = "300"; |
| | | // mes.count = 0; |
| | | // mes.Message = "操作失败,当前收料外协供方应为:" + da.Rows[0]["NAME"].ToString() + "!"; |
| | | // mes.data = null; |
| | | // return mes; |
| | | //} |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | //修改外协记录主表 |
| | | sql = @"update TK_Wrk_OutRecord set sqty=sqty+@sqty,ng_qty=ng_qty+@ngqty,lm_user=@username,lm_date=@CreateDate |
| | | where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='S'"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } }); |
| | | //写入外协记录子表 |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } }); |
| | | |
| | | if (badcode != "" && ngqty != "0") |
| | | decimal sum_sqty = data.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum(); //获取同单号,同工序,同外协供应商收料总数量 |
| | | decimal sum_fqty = da.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum(); //获取同单号,同工序,同外协供应商发料总数量 |
| | | if ((sum_sqty + decimal.Parse(sqty) + decimal.Parse(ngqty)) > sum_fqty) //已收料总数+当前收料数量+不良数量>总发料数量 |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败,当前收料数量+不良数量,不能大于待收数量:" + (sum_fqty- sum_sqty) + "!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | |
| | | //获取主表最大ID |
| | | sql = @"select IDENT_CURRENT('TK_Wrk_OutRecord')+1 as id"; |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入外协记录主表 |
| | | sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date) |
| | |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } }); |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks= remarks, style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | ////修改外协记录主表 |
| | | //sql = @"update TK_Wrk_OutRecord set sqty=sqty+@sqty,ng_qty=ng_qty+@ngqty,lm_user=@username,lm_date=@CreateDate |
| | | // where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='S'"; |
| | | //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } }); |
| | | ////写入外协记录子表 |
| | | //sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | | // values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@style,@lm_user,@lm_date)"; |
| | | //list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } }); |
| | | |
| | | //if (badcode != "" && ngqty != "0") |
| | | //{ |
| | | // //写入缺陷记录表 |
| | | // for (int i = 0; i < arra1.Length; i++) |
| | | // { |
| | | // sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date) |
| | | // values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | // list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | // } |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | //获取主表最大ID |
| | | sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | //写入外协记录主表 |
| | | sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date) |
| | | values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } }); |
| | | |
| | | //写入外协记录子表 |
| | | sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | if (badcode != "" && ngqty != "0") |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < arra1.Length; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks= remarks, style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, sqty = sqty, ngqty = ngqty } }); |
| | | |
| | | //回写工单表合格数量、不良数量 |
| | | sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } }); |
| | | //sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | } |
| | | #endregion' |
| | | |
| | | #region[不良处理,提交] |
| | | public static ToMessage EditOrderNgStepSeave(ReportDefectHandle json, string username) |
| | | { |
| | | var sql = ""; |
| | | string[] arra1 = new string[] { }; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | decimal sumrepair_qty = 0, sumbad_qty = 0; //累计维修数量、累计报废数量 |
| | | try |
| | | { |
| | | string date = DateTime.Now.ToString(); //获取系统时间 |
| | | list.Clear(); |
| | | |
| | | |
| | | //循环json数据 |
| | | for (int i = 0; i < json.Data.Rows.Count; i++) |
| | | { |
| | | //自制工序 |
| | | if (json.Data.Rows[i]["STYLE"].ToString() == "Z") |
| | | { |
| | | //回写对应的报工记录子表合格数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_RecordSub set report_qty=report_qty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty |
| | | where m_id=@m_id and style='B'"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | m_id = int.Parse(json.Data.Rows[i]["ID"].ToString()), |
| | | repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()), |
| | | bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()) |
| | | } |
| | | }); |
| | | //回写对应的报工记录主表合格数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_Record set good_qty=good_qty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty |
| | | where wo_code=@wo_code and step_code=@step_code and id=@id and style='B'"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()), |
| | | bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()), |
| | | wo_code = json.Data.Rows[i]["WO_CODE"].ToString(), |
| | | step_code = json.Data.Rows[i]["STEP_CODE"].ToString(), |
| | | id = int.Parse(json.Data.Rows[i]["ID"].ToString()) |
| | | } |
| | | }); |
| | | //写入报工缺陷处理记录表 |
| | | sql = @"insert into CSR_WorkRecord_DefectHandle(record_subid,wo_code,partnumber,step_seq,step_code,repair_qty,bad_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_subid,@wo_code,@partcode,@stepseq,@stepcode,@repair_qty,@bad_qty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | record_subid = int.Parse(json.Data.Rows[i]["M_ID"].ToString()), |
| | | wo_code = json.Data.Rows[i]["WO_CODE"].ToString(), |
| | | partcode = json.Data.Rows[i]["MATERIEL_CODE"].ToString(), |
| | | stepseq = json.Data.Rows[i]["SEQ"].ToString(), |
| | | stepcode = json.Data.Rows[i]["STEP_CODE"].ToString(), |
| | | repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()), |
| | | bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()), |
| | | defect_code = json.Data.Rows[i]["DEFECT_CODE"].ToString(), |
| | | style = "B", |
| | | lm_user = username, |
| | | lm_date = date |
| | | } |
| | | }); |
| | | |
| | | sumrepair_qty = sumrepair_qty + decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()); |
| | | sumbad_qty = sumbad_qty + decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()); |
| | | } |
| | | //外协工序 |
| | | if (json.Data.Rows[i]["STYLE"].ToString() == "S") |
| | | { |
| | | //回写对应的收料记录子表收料数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty |
| | | where m_id=@m_id and style='S'"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | m_id = int.Parse(json.Data.Rows[i]["ID"].ToString()), |
| | | repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()), |
| | | bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()) |
| | | } |
| | | }); |
| | | //回写对应的收料记录主表合格数量、不良数量、报废数量 |
| | | sql = @"update TK_Wrk_OutRecord set sqty=sqty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty |
| | | where wo_code=@wo_code and step_code=@step_code and id=@id and style='S'"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()), |
| | | bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()), |
| | | wo_code = json.Data.Rows[i]["WO_CODE"].ToString(), |
| | | step_code = json.Data.Rows[i]["STEP_CODE"].ToString(), |
| | | id = int.Parse(json.Data.Rows[i]["ID"].ToString()) |
| | | } |
| | | }); |
| | | //写入报工缺陷处理记录表 |
| | | sql = @"insert into CSR_WorkRecord_DefectHandle(record_subid,wo_code,partnumber,step_seq,step_code,repair_qty,bad_qty,defect_code,style,lm_user,lm_date) |
| | | values(@record_subid,@wo_code,@partcode,@stepseq,@stepcode,@repair_qty,@bad_qty,@defect_code,@style,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | record_subid = int.Parse(json.Data.Rows[i]["M_ID"].ToString()), |
| | | wo_code = json.Data.Rows[i]["WO_CODE"].ToString(), |
| | | partcode = json.Data.Rows[i]["MATERIEL_CODE"].ToString(), |
| | | stepseq = json.Data.Rows[i]["SEQ"].ToString(), |
| | | stepcode = json.Data.Rows[i]["STEP_CODE"].ToString(), |
| | | repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()), |
| | | bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()), |
| | | defect_code = json.Data.Rows[i]["DEFECT_CODE"].ToString(), |
| | | style = "S", |
| | | lm_user = username, |
| | | lm_date = date |
| | | } |
| | | }); |
| | | sumrepair_qty = sumrepair_qty + decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()); |
| | | sumbad_qty = sumbad_qty + decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()); |
| | | } |
| | | } |
| | | |
| | | //回写工单工序表合格数量、不良数量 |
| | | sql = @"update TK_Wrk_Step set good_qty=good_qty+@sumrepair_qty,ng_qty=ng_qty-@sumrepair_qty-@sumbad_qty,bad_qty=bad_qty+@sumbad_qty where wo_code=@wo_code and step_code=@stepcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo_code = json.Data.Rows[0]["WO_CODE"].ToString(), |
| | | stepcode = json.Data.Rows[0]["STEP_CODE"].ToString(), |
| | | sumrepair_qty = sumrepair_qty, |
| | | sumbad_qty = sumbad_qty |
| | | } |
| | | }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | 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 |
| | | |
| | | #region[生产开报工,工序检验扫码获取任务信息] |
| | | public static ToMessage MesOrderStepCheckSearch(string orderstepqrcode) |
| | | { |
| | | var sql = ""; |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | | { |
| | | string[] arra = orderstepqrcode.Split(';'); |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序条码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | //通过扫描二维码信息查找任务信息 |
| | | sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,S.stepcode,S.stepname |
| | | from TK_Wrk_Step A |
| | | inner join TK_Wrk_Man P on A.wo_code=P.wo_code |
| | | left join TMateriel_Info M on P.materiel_code=M.partcode |
| | | left join TStep S on A.step_code=S.stepcode |
| | | where A.wo_code=@wo_code and A.step_code=@stepcode"; |
| | | dynamicParams.Add("@wo_code", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "生产任务不存在!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "二维码信息为空!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工,工序检验获取检验标准下拉框数据] |
| | | public static ToMessage MesOrderStepCheckSelect() |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取工序检验标准 |
| | | sql = @"select code,name from TStepCheckStandard where is_delete<>'1'"; |
| | | var data = DapperHelper.selecttable(sql); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工,工序检验根据检验标准获取检验项目列表] |
| | | public static ToMessage MesOrderStepCheckItemList(string checkstandcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //根据检验标准编码获取工序检验项目 |
| | | sql = @"select B.code,B.name,A.stepcheckitem_desc,A.stepcheckitem_seq from TStepCheckStandardSub A |
| | | left join TStepCheckItem B on A.stepcheckitem_code=B.code |
| | | where B.is_delete<>'1' and A.stepstaned_code=@checkstandcode"; |
| | | dynamicParams.Add("@checkstandcode", checkstandcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[生产开报工,工序检验提交保存] |
| | | public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkusercode, string checktypecode, string checkresult, string checkdescr,string checkqty, string username, List<StepCheck> json) |
| | | { |
| | | var sql = ""; |
| | | string[] arra = new string[] { }; |
| | | string[] arra1 = new string[] { }; |
| | | List<object> list = new List<object>(); |
| | | string checktypename = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | string date = DateTime.Now.ToString(); //获取系统时间 |
| | | |
| | | list.Clear(); |
| | | switch (checktypecode) |
| | | { |
| | | case "FirstCheck": |
| | | checktypename = "首检"; |
| | | break; |
| | | case "PatroCheck": |
| | | checktypename = "巡检"; |
| | | break; |
| | | case "EndCheck": |
| | | checktypename = "完工检验"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | //写入工序检验记录主表 |
| | | sql = @"insert into TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_typename,check_result,check_descr,check_qty,lm_user,lm_date) |
| | | values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkusercode,@checktypecode,@checktypename,@checkresult,@checkdescr,@check_qty,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkusercode = checkusercode, checktypecode = checktypecode, checktypename = checktypename, checkresult = checkresult, checkdescr = checkdescr, check_qty=checkqty, lm_user = username, lm_date = date } }); |
| | | //写入工序检验记录子表 |
| | | //获取主表最大ID |
| | | sql = @"select ISNULL(IDENT_CURRENT('TStepCheckRecord')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql); |
| | | for (int i = 0; i < json.Count; i++) |
| | | { |
| | | sql = @"insert into TStepCheckRecordSub(m_id,checkitem_seq,checkitem_code,checkitem_name,checkitem_descr,check_result,lm_user,lm_date) |
| | | values(@m_id,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_result,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), checkiem_seq = int.Parse(json[i].seq), checkitem_code = json[i].code, checkitem_name = json[i].name, checkitem_descr = json[i].descr, check_result = json[i].checkresult, lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | 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 |
| | | |
| | | |
| | | #region[MES工单批量关闭查询] |
| | | public static ToMessage MesOrderBitchClosedSearch(string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (mesorderstus != "" && mesorderstus != null) |
| | | { |
| | | search += "and A.status=@mesorderstus "; |
| | | dynamicParams.Add("@mesorderstus", mesorderstus); |
| | | } |
| | | if (mesordercode != "" && mesordercode != null) |
| | | { |
| | | search += "and A.wo_code like '%'+@mesordercode+'%' "; |
| | | dynamicParams.Add("@mesordercode", mesordercode); |
| | | } |
| | | if (sourceorder != "" && sourceorder != null) |
| | | { |
| | | search += "and A.m_po like '%'+@sourceorder+'%' "; |
| | | dynamicParams.Add("@sourceorder", sourceorder); |
| | | } |
| | | if (ordertype != "" && ordertype != null) |
| | | { |
| | | search += "and A.wotype like '%'+@ordertype+'%' "; |
| | | dynamicParams.Add("@ordertype", ordertype); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | | search += "and A.materiel_code like '%'+@partcode+'%' "; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | } |
| | | if (partname != "" && partname != null) |
| | | { |
| | | search += "and B.partname like '%'+@partname+'%' "; |
| | | dynamicParams.Add("@partname", partname); |
| | | } |
| | | if (partspec != "" && partspec != null) |
| | | { |
| | | search += "and B.partspec like '%'+@partspec+'%' "; |
| | | dynamicParams.Add("@partspec", partspec); |
| | | } |
| | | if (createdate != "" && createdate != null) |
| | | { |
| | | search += "and CONVERT(varchar(100),A.lm_date,23)=@createdate "; |
| | | dynamicParams.Add("@createdate", createdate); |
| | | } |
| | | if (creatuser != "" && creatuser != null) |
| | | { |
| | | search += "and U.username like '%'+@creatuser+'%' "; |
| | | dynamicParams.Add("@creatuser", creatuser); |
| | | } |
| | | |
| | | if (search == "") |
| | | { |
| | | search = "and 1=1 "; |
| | | } |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date |
| | | ,(select sum(S.good_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as good_qty |
| | | ,(select sum(S.ng_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as ng_qty |
| | | ,(select sum(S.bad_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as bad_qty |
| | | from TK_Wrk_Man A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code |
| | | left join TFlw_Rout E on A.route_code=E.code |
| | | left join T_Sec_Stck F on A.stck_code=F.code |
| | | left join TUser U on A.lm_user=U.usercode |
| | | where A.is_delete<>'1' " + 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[MES工单批量关闭提交] |
| | | public static ToMessage MesOrderBitchClosedSeave(string username, DataTable dt) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | { |
| | | //关闭工单对应工序任务 |
| | | sql = @"update TK_Wrk_Step set status='CLOSED' where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } }); |
| | | //回写工单表状态为(关闭) |
| | | sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.ToString() } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | 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 |
| | | |
| | | #region[MES工单批量反关闭] |
| | | public static ToMessage MesOrderBitchAntiClosedSeave(string username, DataTable dt) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | { |
| | | //关闭工单对应工序任务 |
| | | sql = @"update TK_Wrk_Step set status='START' where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } }); |
| | | //回写工单表状态为(关闭) |
| | | sql = @"update TK_Wrk_Man set status='START',closeuser=@username,closedate=@closedate where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.ToString() } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | 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 |
| | | } |
| | | } |