| | |
| | | using Dapper; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | |
| | | #endregion |
| | | |
| | | #region[ERP订单下达] |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty,string saleOrderDeliveryDate, 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 saleOrderDeliveryDate, string username) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | } |
| | | if (i == Convert.ToInt32(ordernum)) //最后一单时 |
| | | { |
| | | 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)"; |
| | | 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,saleOrderDeliveryDate) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderDeliveryDate)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | sourceid = erporderid, |
| | | m_po = erpordercode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString() |
| | | CreateDate = DateTime.Now.ToString(), |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | | sumqty = sumqty + (decimal.Parse(markqty) - sumqty); |
| | |
| | | else |
| | | { |
| | | |
| | | 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)"; |
| | | 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,saleOrderDeliveryDate) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderDeliveryDate)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | sourceid = erporderid, |
| | | m_po = erpordercode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString() |
| | | CreateDate = DateTime.Now.ToString(), |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | | } |
| | |
| | | wkshopcode = wkshopcode, |
| | | planstartdate = planstartdate, |
| | | planenddate = planenddate, |
| | | status = wo_status, |
| | | status = wo_status, |
| | | routecode = routecode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | orderlev = orderlev, |
| | | isaps= is_aps |
| | | isaps = is_aps |
| | | } |
| | | }); |
| | | //写入工序任务表 |
| | |
| | | mesqty = mesqty, |
| | | planstartdate = planstartdate, |
| | | planenddate = planenddate, |
| | | status = wo_status, |
| | | status = wo_status, |
| | | username = username, |
| | | routecode = routecode, |
| | | CreateDate = DateTime.Now.ToString() |
| | |
| | | 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 S.flwtype='Z' " + search; |
| | | where A.status in('ALLO','START') and S.flwtype='Z' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | if (data.ToList().Count > 0) |
| | | { |
| | |
| | | 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 S.flwtype='W' " + search; |
| | | where A.status in('ALLO','START') and S.flwtype='W' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | if (data.ToList().Count > 0) |
| | | { |
| | |
| | | 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; |
| | | where A.status in('ALLO','START') and A.ng_qty>0 " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | if (data.ToList().Count > 0) |
| | | { |
| | |
| | | #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 remarks, string username) |
| | | public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string reckway, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string remarks, string username) |
| | | { |
| | | var sql = ""; |
| | | string[] arra = new string[] { }; |
| | | //string[] arra = new string[] { }; |
| | | string[] arra1 = new string[] { }; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | string date = DateTime.Now.ToString(); //获取系统时间 |
| | | //截取报工人员 |
| | | arra = reportuser.Split(';'); |
| | | //获取报工人员、分配比例 |
| | | JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(reportuser); |
| | | if (ngqty != "" || ngqty != "0") |
| | | { |
| | | //截取不良原因 |
| | |
| | | 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++) |
| | | for (int i = 0; i < arra.Count; 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 } }); |
| | | sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,reckway,usergroup_code,ratio,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@reckway,@usergroup_code,@ratio,@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]["usercode"].ToString(), |
| | | report_date = date, |
| | | report_qty = reportqty, |
| | | reckway = reckway, |
| | | usergroup_code = usergroupcode, |
| | | ratio = decimal.Parse(arra[i]["ratio"].ToString()), |
| | | ng_qty = ngqty, |
| | | style = "B", |
| | | lm_user = username, |
| | | lm_date = date |
| | | } |
| | | }); |
| | | |
| | | } |
| | | if (badcode != "" && ngqty != "0") |
| | |
| | | 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++) |
| | | for (int i = 0; i < arra.Count; 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 } }); |
| | | sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,reckway,usergroup_code,ratio,ng_qty,style,lm_user,lm_date) |
| | | values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@reckway,@usergroup_code,@ratio,@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]["usercode"].ToString(), |
| | | report_date = date, |
| | | report_qty = reportqty, |
| | | reckway = reckway, |
| | | usergroup_code = usergroupcode, |
| | | ratio = decimal.Parse(arra[i]["ratio"].ToString()), |
| | | ng_qty = ngqty, |
| | | style = "B", |
| | | lm_user = username, |
| | | lm_date = date |
| | | } |
| | | }); |
| | | |
| | | } |
| | | if (badcode != "" && ngqty != "0") |
| | |
| | | A.plan_qty AdvaScheQty, |
| | | U.name AdvaScheUom, |
| | | isnull(E.sched_qty,0) AdvaScheYPQty, |
| | | CONVERT(varchar(100), B.planenddate, 23) AdvaScheEndDate, |
| | | CONVERT(varchar(100), A.saleOrderDeliveryDate, 23) AdvaScheEndDate, |
| | | convert(varchar(20),isnull(E.sched_qty,0))+'/'+convert(varchar(20),isnull(A.plan_qty,0)) AdvaScheSpeed, |
| | | A.route_code AdvaScheRoutid, |
| | | F.name AdvaScheRoutName, |
| | |
| | | (case when CONVERT(varchar(100), H.maxtime, 23)<=CONVERT(varchar(100), E.plan_enddate, 23) then 'Y' when H.MAXTime is null then 'Y' else 'N' end) Flag, |
| | | (case when A.PiroQue='1' then '特急' when A.PiroQue='2' then '紧急' when A.PiroQue='3' then '正常' end) AdvaSchePiroQue |
| | | from TK_Wrk_Man A |
| | | left join TKimp_Ewo B on A.m_po=B.wo |
| | | left join TMateriel_Info C on C.partcode= A.materiel_code |
| | | left join T_Dict D on C.stocktype_code= d.code |
| | | left join TK_Wrk_Step E on E.wo_code=A.wo_code |
| | |
| | | public static DataTable AlreadyScheduling(string wocode, string wkshpcode, string partcode, string botproccode, string startdate, string enddate) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | DataTable dt; |
| | | try |
| | | { |
| | | List<APSList> listData = SchedulingMethod.SchedulingMethodTF(wocode, wkshpcode, partcode); |
| | | string[] empIds = listData.Select(a => a.eqp_id).ToArray(); |
| | | string str = string.Join(",", empIds); |
| | | string s1 = string.Format("'{0}'", str.Replace(",", "','")); |
| | | string[] s1 = Array.ConvertAll<string, string>(str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string分割转string[] |
| | | //string s1 = string.Format("'{0}'", str.Replace(",", "','")); |
| | | |
| | | string sql = @"select B.wo_code, B.eqp_code,B.time_start,B.time_end, 'S' status , B.alloc_qty,D.partname as part_name |
| | | string sql = @"select B.wo_code, B.eqp_code,B.time_start,B.time_end, 'S' status , B.alloc_qty,D.partcode as part_code,D.partname as part_name,T.name as uom_name |
| | | from TK_Wrk_EqpAps B |
| | | left join TK_Wrk_Man C on B.wo_code=C.wo_code |
| | | left join TMateriel_Info D on C.materiel_code=D.partcode |
| | | where B.eqp_code in(@s1) |
| | | left join TUom T on D.uom_code=T.code |
| | | where B.eqp_code in @eqpcode |
| | | and convert(varchar(100),B.Time_Start,21)>=@startdate and convert(varchar(100),B.Time_End,21)<=@enddate order by time_end"; |
| | | dynamicParams.Add("@s1", s1); |
| | | dynamicParams.Add("@startdate", startdate + " 00:00:00"); |
| | | dynamicParams.Add("@enddate", enddate + " 23:59:59"); |
| | | var dt_0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | dt = DapperHelper.selectlist(sql, new { eqpcode = s1.ToArray(), startdate = startdate + " 00:00:00", enddate = enddate + " 23:59:59" }); |
| | | //dynamicParams.Add("@s1", new { shopcode = s1.ToArray() }); |
| | | //dynamicParams.Add("@startdate", startdate + " 00:00:00"); |
| | | //dynamicParams.Add("@enddate", enddate + " 23:59:59"); |
| | | //var dt_0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt == null || dt.Rows.Count == 0) |
| | | { |
| | | return null; |