| | |
| | | |
| | | |
| | | #region[ERP订单查询] |
| | | public static ToMessage ErpOrderSearch(string erporderstus,string wkshopcode, string erpordercode, string saleordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string paydatestartdate1, string paydateenddate2, string creatuser, int endNum, string prop, string order) |
| | | public static ToMessage ErpOrderSearch(string erporderstus, string wkshopcode, string erpordercode, string saleordercode, 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 = ""; |
| | |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | 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.torg_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.saleOrderCode,A.saleOrderDeliveryDate,A.planstartdate,A.planenddate,U.username as createuser,A.createdate,A.sbid |
| | | A.stck_code,D.name as stck_name,A.saleOrderCode,A.saleOrderDeliveryDate,A.planstartdate,A.planenddate,U.username as createuser,A.createdate,A.sbid,A.clerkuser |
| | | from TKimp_Ewo A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.torg_code |
| | |
| | | #endregion |
| | | |
| | | #region[ERP订单下达] |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string saleOrderDeliveryDate, User us) |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string saleOrderDeliveryDate,string clerkuser, User us) |
| | | { |
| | | 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,sbid,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderCode,saleOrderDeliveryDate,data_sources,isstep) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@sbid,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderCode,@saleOrderDeliveryDate,@data_sources,@isstep)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,sbid,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderCode,saleOrderDeliveryDate,data_sources,isstep,clerkuser) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@sbid,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderCode,@saleOrderDeliveryDate,@data_sources,@isstep,@clerkuser)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | saleOrderCode = saleordercode, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate), |
| | | data_sources = "ERP", |
| | | isstep = "N" //是否关联工序 |
| | | isstep = "N", //是否关联工序 |
| | | clerkuser= clerkuser //销售订单业务员 |
| | | } |
| | | }); |
| | | sumqty = sumqty + (decimal.Parse(markqty) - sumqty); |
| | |
| | | else |
| | | { |
| | | |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,sbid,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderCode,saleOrderDeliveryDate,data_sources,isstep) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@sbid,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderCode,@saleOrderDeliveryDate,@data_sources,@isstep)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,sbid,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderCode,saleOrderDeliveryDate,data_sources,isstep,clerkuser) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@sbid,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderCode,@saleOrderDeliveryDate,@data_sources,@isstep,@clerkuser)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | saleOrderCode = saleordercode, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate), |
| | | data_sources = "ERP", |
| | | isstep = "N"//是否关联工序 |
| | | isstep = "N",//是否关联工序 |
| | | clerkuser= clerkuser |
| | | } |
| | | }); |
| | | } |
| | |
| | | { |
| | | list.Clear(); |
| | | string result = ""; |
| | | var groupedModels = obj.GroupBy(m => m.erpordercode); |
| | | //var groupedModels = obj.GroupBy(m => m.erpordercode); |
| | | var groupedModels = obj.GroupBy(s => s.erpordercode).Select(g => new { erpordercode = g.Key }).ToList(); |
| | | foreach (var group in groupedModels) |
| | | { |
| | | string erpordercode = group.Key; |
| | | string erpordercode = group.erpordercode; |
| | | int count = 1; |
| | | foreach (var model in group) |
| | | foreach (var model in obj.Where(s => s.erpordercode==erpordercode).ToList()) |
| | | { |
| | | //获取当前最大工单号 |
| | | sql = @"select isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0) as worknumb |
| | |
| | | string wo = model.erpordercode + "_" + (num + count); |
| | | result += wo.ToString() + ","; |
| | | //写入工单表 |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,sbid,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderCode,saleOrderDeliveryDate,data_sources,isstep) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@sbid,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderCode,@saleOrderDeliveryDate,@data_sources,@isstep)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,sbid,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderCode,saleOrderDeliveryDate,data_sources,isstep,clerkuser) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@sbid,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderCode,@saleOrderDeliveryDate,@data_sources,@isstep,@clerkuser)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | saleOrderCode = model.saleordercode, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(model.saleOrderDeliveryDate), |
| | | data_sources = "ERP", |
| | | isstep = "N" //是否关联工序 |
| | | isstep = "N", //是否关联工序 |
| | | clerkuser= model.clerkuser //销售订单业务员 |
| | | } |
| | | }); |
| | | |
| | |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | sql = @"select * from TK_Wrk_Man where m_po=@erpordercode and status<> 'CLOSED'"; |
| | | sql = @"select * from TK_Wrk_Man where m_po=@erpordercode and sourceid=@sourceid and status<> 'CLOSED'"; |
| | | dynamicParams.Add("@erpordercode", erpordercode); |
| | | dynamicParams.Add("@sourceid", erporderid); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = "当前订单有下达未关闭的MES工单,订单不允许关闭,请先删除或关闭相关工单!"; |
| | | mes.message = "当前订单产品有下达未关闭的MES工单,订单不允许关闭,请先删除或关闭相关工单!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | |
| | | #region[MES工单查询] |
| | | public static ToMessage MesOrderSearch(string mesorderstus,string wkshopcode, string mesordercode, string sourceorder, string saleordercode, string ordertype, 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 wkshopcode, string mesordercode, string sourceorder, string saleordercode, 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 = ""; |
| | |
| | | // --------------查询指定数据-------------- |
| | | 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.torg_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources,A.isstep |
| | | A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources,A.isstep,A.clerkuser |
| | | from TK_Wrk_Man A |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.torg_code |
| | | left join TSecStck D on A.stck_code=D.code |
| | |
| | | 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.torg_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,S.laborbad_qty,S.materielbad_qty |
| | | from TK_Wrk_Man A |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid |
| | | left join (select wo_code,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty from TK_Wrk_Step where (laborbad_qty+materielbad_qty)>0 group by wo_code) S on A.wo_code=S.wo_code |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.torg_code |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单查找历史引用最新工序信息] |
| | | public static ToMessage MesOrderNewStepContent(string wkshopcode, string partcode, User us) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //MES工单查找历史引用最新工序信息 |
| | | sql = @"select S.wo_code,S.seq,S.step_code,S.stepprice,isbott,isend |
| | | from TK_Wrk_Step S |
| | | inner join ( |
| | | select top 1 A.wo_code from TK_Wrk_Man A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code |
| | | where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode |
| | | order by A.lm_date desc |
| | | ) as W on S.wo_code=W.wo_code |
| | | left join TStep T on S.step_code=T.stepcode |
| | | order by S.seq"; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | dynamicParams.Add("@partcode", partcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.count = data.Rows.Count; |
| | | mes.data = data; |
| | | mes.message = "查询成功!"; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[MES工单派发提交] |
| | | public static ToMessage MesOrderDistribution(string[] wocodelist, User us) |
| | |
| | | |
| | | |
| | | #region[工单关闭列表查询] |
| | | public static ToMessage MesOrderClosedSearch(string mesorderstus,string wkshopcode, string mesordercode, string sourceorder, string saleordercode, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderClosedSearch(string mesorderstus, string wkshopcode, string mesordercode, string sourceorder, string saleordercode, 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 = ""; |
| | |
| | | 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.torg_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources |
| | | from TK_Wrk_Man A |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code |
| | | left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sourceid=W.id |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.torg_code |
| | | left join TSecStck D on A.stck_code=D.code |
| | |
| | | |
| | | |
| | | #region[生产执行,报工审核列表数据查询接口] |
| | | public static ToMessage MesOrderStepReportVerifySearch(string wkshopcode, string wo_code, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderStepReportVerifySearch(string reviewstatus, string wkshopcode, string wo_code, string partnumber, string partname, string partspec, string stepname, string reportuser, string reportdateopendate, string reportdateclosedate, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (reviewstatus != "" && reviewstatus != null) |
| | | { |
| | | search += "and AA.verify=@reviewstatus "; |
| | | dynamicParams.Add("@reviewstatus", reviewstatus); |
| | | } |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and AA.wkshp_code=@wkshopcode "; |
| | |
| | | left join TCustomer E on A.wx_code = E.code |
| | | left join TCustomer C on A.wx_code=C.code |
| | | where A.style = 'S' and B.style = 'S' and M.status<>'CLOSED' |
| | | ) as AA where" + search; |
| | | ) as AA where " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |