| | |
| | | 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) |
| | | } |
| | | }); |
| | | } |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[工单派发选择工艺路线或选择生产车间时判断绑定条件] |
| | | public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = ""; |
| | | mes.data = null; |
| | | //判断工艺路线对应工序是否都有关联工作站 |
| | | sql = @"select B.step_code,C.eqp_code from TFlw_Rout A |
| | | inner join TFlw_Rtdt B on A.code=B.rout_code |
| | | left join TFlw_Rteqp C on B.step_code=C.step_code |
| | | where A.code=@routecode"; |
| | | dynamicParams.Add("@routecode", routecode); |
| | | var dtck = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dtck.Rows.Count; i++) |
| | | { |
| | | if (dtck.Rows[i].IsNull("eqp_code")) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工艺路线对应工序【" + dtck.Rows[i]["step_code"].ToString() + "】,未关联设备,请关联所有工序对应设备!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | //判断工艺路线对应工序关联的工作站是否有设置节拍工价 |
| | | sql = @"select AA.step_code,AA.eqp_code,AA.flwtype,S.unprice from ( |
| | | select A.code,B.step_code,C.eqp_code,S.flwtype from TFlw_Rout A |
| | | inner join TFlw_Rtdt B on A.code=B.rout_code |
| | | left join TFlw_Rteqp C on B.step_code=C.step_code |
| | | left join TStep S on B.step_code=S.stepcode |
| | | where A.code=@route_code |
| | | ) as AA |
| | | left join (select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@route_code) as S on |
| | | AA.code=S.route_code and AA.step_code=S.step_code and AA.eqp_code=S.eqp_code"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@route_code", routecode); |
| | | var dtc = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dtc.Rows.Count; i++) |
| | | { |
| | | if (dtc.Rows[i]["flwtype"].ToString() == "Z") //判断工序是否为自制 |
| | | { |
| | | if (dtc.Rows[i].IsNull("unprice") || decimal.Parse(dtc.Rows[i]["unprice"].ToString()) == 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "节拍工价中:当前产品【" + partcode + "】,对应工艺路线【" + routecode + "】未设置(或未设置全)或工价小于等于0!"; |
| | | 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[MES工单新增、编辑提交] |
| | | 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, string is_aps, string bom_id) |
| | | { |
| | |
| | | } |
| | | }); |
| | | |
| | | //写入工单工艺路线工序工价复制表 |
| | | sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code) |
| | | select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice, |
| | | S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code |
| | | from TFlw_Rtdt A |
| | | inner join TFlw_Rteqp C on A.step_code=C.step_code |
| | | inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode, |
| | | materiel_code = partcode, |
| | | routecode = routecode |
| | | } |
| | | }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | |
| | | 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() |
| | | } |
| | | }); |
| | | |
| | | //删除工单工艺路线工序工价复制表 |
| | | sql = @"delete TWoPrteEqp_Stad where wo=@mesordercode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode |
| | | } |
| | | }); |
| | | //写入工单工艺路线工序工价复制表 |
| | | sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code) |
| | | select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice, |
| | | S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code |
| | | from TFlw_Rtdt A |
| | | inner join TFlw_Rteqp C on A.step_code=C.step_code |
| | | inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode, |
| | | materiel_code = partcode, |
| | | routecode = routecode |
| | | } |
| | | }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | 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 |
| | |
| | | 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 |
| | | 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"; |
| | | dt = DapperHelper.selectlist(sql, new { eqpcode = s1.ToArray(), startdate= startdate + " 00:00:00", enddate= enddate + " 23:59:59" }); |
| | | 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"); |