| | |
| | | |
| | | |
| | | #region[生产进度报表] |
| | | public static ToMessage ProductionScheduleReportSearch(string status, string wkshopcode, string wocode, string partcode, string partname, string partspec, string opendate, string closedate, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage ProductionScheduleReportSearch(string wkshopcode, string status, string wocode, string partcode, string partname, string partspec, string opendate, string closedate, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and AA.wkshp_code=@wkshopcode "; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | } |
| | | if (status != "" && status != null) |
| | | { |
| | | switch (status) |
| | | { |
| | | case "START": |
| | | search += "and AA.status='START' "; |
| | | search += "and AA.status='执行中' "; |
| | | break; |
| | | case "CLOSED": |
| | | search += "and AA.status='CLOSED' "; |
| | | search += "and AA.status='已完成' "; |
| | | break; |
| | | default: |
| | | search += "and AA.status<>'START' and AA.status<>'CLOSED' "; |
| | | search += "and AA.status='未开始' "; |
| | | break; |
| | | } |
| | | } |
| | |
| | | { |
| | | search += "and AA.wo_code like '%'+@wocode+'%' "; |
| | | dynamicParams.Add("@wocode", wocode); |
| | | } |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and AA.wkshp_code=@wkshopcode "; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | | search += "and AA.partcode like '%'+@partcode+'%' "; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | |
| | | search = search.Substring(3);//截取索引2后面的字符 |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select AA.saleOrderCode,AA.m_po,AA.wo_code,AA.wkshp_code,AA.wkshp_name, |
| | | (case when AA.status='START' then '执行中' when AA.status='CLOSED' then '已完成' else '未开始' end) as status, |
| | | AA.lm_date,AA.partcode,AA.partname,AA.partspec,AA.plan_qty,left(AA.concat_name,len(concat_name)-1) as concat_name from |
| | | ( |
| | | select E.saleOrderCode,W.m_po,m.wo_code,W.wkshp_code,F.torg_name as wkshp_name,W.status,W.lm_date,P.partcode,P.partname,P.partspec,m.plan_qty, |
| | | (select s.stepname+'/'+cast(cast(n.good_qty as decimal(18,2)) AS varchar(50))+',' from TK_Wrk_Step n |
| | | inner join TStep S on n.step_code=S.stepcode |
| | | where n.wo_code=m.wo_code for xml path('')) as concat_name |
| | | from TK_Wrk_Step m |
| | | inner join TK_Wrk_Man W on m.wo_code=W.wo_code |
| | | left join TKimp_Ewo E on W.m_po=E.wo |
| | | inner join TMateriel_Info P on W.materiel_code=p.partcode |
| | | left join TOrganization F on W.wkshp_code=F.torg_code |
| | | group by E.saleOrderCode,W.m_po,m.wo_code,W.wkshp_code,F.torg_name,W.status,W.lm_date,P.partcode,P.partname,P.partspec,m.plan_qty |
| | | ) AA |
| | | where " + search; |
| | | var sql = @"select top 100 percent AA.saleOrderCode,AA.m_po,AA.wkshp_code,AA.wkshp_name,AA.wo_code,AA.status,AA.lm_date, |
| | | AA.partcode,AA.partname,AA.partspec,AA.plan_qty,left(AA.concat_name,len(concat_name)-1) as concat_name |
| | | from ( |
| | | select E.saleOrderCode,W.m_po,W.wo_code,W.wkshp_code,F.torg_name as wkshp_name, |
| | | case when W.status='START' then '执行中' when W.status='CLOSED' then '已完成' else '未开始' end as status, |
| | | W.lm_date, |
| | | P.partcode,P.partname,P.partspec,W.plan_qty, |
| | | ( |
| | | select s.stepname+'/'+cast(cast(n.good_qty as decimal(18,2)) AS varchar(50))+',' |
| | | from TK_Wrk_Step n |
| | | inner join TStep S on n.step_code=S.stepcode |
| | | where n.wo_code=W.wo_code for xml path('') |
| | | ) as concat_name |
| | | from TK_Wrk_Man W |
| | | left join ( |
| | | select wo,saleOrderCode from TKimp_Ewo |
| | | ) as E on W.m_po=E.wo |
| | | left join TMateriel_Info P on W.materiel_code=p.partcode |
| | | left join TOrganization F on W.wkshp_code=F.torg_code |
| | | group by E.saleOrderCode,W.m_po,W.wo_code,W.wkshp_code,F.torg_name,W.status,W.lm_date,P.partcode,P.partname,P.partspec,W.plan_qty |
| | | ) as AA where " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |
| | |
| | | #endregion |
| | | |
| | | #region[生产进度报表导出] |
| | | public static ToMessage ProductionScheduleReportExcelSearch(string status, string wkshopcode, string wocode,string partcode, string partname, string partspec, string opendate, string closedate) |
| | | public static ToMessage ProductionScheduleReportExcelSearch(string wkshopcode, string status, string wocode, string partcode, string partname, string partspec, string opendate, string closedate) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and AA.wkshp_code=@wkshopcode "; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | } |
| | | if (status != "" && status != null) |
| | | { |
| | | switch (status) |
| | | { |
| | | case "START": |
| | | search += "and AA.status='START' "; |
| | | search += "and AA.status='执行中' "; |
| | | break; |
| | | case "CLOSED": |
| | | search += "and AA.status='CLOSED' "; |
| | | search += "and AA.status='已完成' "; |
| | | break; |
| | | default: |
| | | search += "and AA.status<>'START' and AA.status<>'CLOSED' "; |
| | | search += "and AA.status='未开始' "; |
| | | break; |
| | | } |
| | | } |
| | |
| | | { |
| | | search += "and AA.wo_code like '%'+@wocode+'%' "; |
| | | dynamicParams.Add("@wocode", wocode); |
| | | } |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and AA.wkshp_code=@wkshopcode "; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | |
| | | search = search.Substring(3);//截取索引2后面的字符 |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select AA.saleOrderCode as ERP源单号,AA.m_po as ERP生产订单,AA.wo_code as 生产工单号,AA.wkshp_code as 车间编码,AA.wkshp_name as 车间名称, |
| | | (case when AA.status='START' then '执行中' when AA.status='CLOSED' then '已完成' else '未开始' end) as 工单状态, |
| | | AA.lm_date as 单据日期,AA.partcode as 产品编码,AA.partname as 产品名称,AA.partspec as 产品规格,AA.plan_qty as 任务数量,left(AA.concat_name,len(concat_name)-1) as 生产进度 from |
| | | ( |
| | | select E.saleOrderCode,W.m_po,m.wo_code,W.status,W.lm_date,W.wkshp_code,F.torg_name as wkshp_name,P.partcode,P.partname,P.partspec,m.plan_qty, |
| | | (select s.stepname+'/'+cast(cast(n.good_qty as decimal(18,2)) AS varchar(50))+',' from TK_Wrk_Step n |
| | | inner join TStep S on n.step_code=S.stepcode |
| | | where n.wo_code=m.wo_code for xml path('')) as concat_name |
| | | from TK_Wrk_Step m |
| | | inner join TK_Wrk_Man W on m.wo_code=W.wo_code |
| | | left join TKimp_Ewo E on W.m_po=E.wo |
| | | inner join TMateriel_Info P on W.materiel_code=p.partcode |
| | | left join TOrganization F on W.wkshp_code=F.torg_code |
| | | group by E.saleOrderCode,W.m_po,m.wo_code,W.wkshp_code,F.torg_name,W.status,W.lm_date,P.partcode,P.partname,P.partspec,m.plan_qty |
| | | ) AA |
| | | |
| | | var sql = @"select top 100 percent AA.saleOrderCode as 销售订单号,AA.m_po as 生产订单号,AA.wkshp_code as 车间编码,AA.wkshp_name as 车间名称,AA.wo_code as 生产工单号, |
| | | AA.status as 工单状态,AA.lm_date as 单据日期,AA.route_code as 工艺路线编号,AA.route_name as 工艺路线名称, |
| | | AA.partcode as 产品编码,AA.partname as 产品名称,AA.partspec as 产品规格,AA.plan_qty as 任务数量,left(AA.concat_name,len(concat_name)-1) as 生产进度 |
| | | from ( |
| | | select E.saleOrderCode,W.m_po,W.wo_code,W.wkshp_code,F.torg_name as wkshp_name, |
| | | case when W.status='START' then '执行中' when W.status='CLOSED' then '已完成' else '未开始' end as status, |
| | | W.lm_date, |
| | | P.partcode,P.partname,P.partspec,W.plan_qty, |
| | | ( |
| | | select s.stepname+'/'+cast(cast(n.good_qty as decimal(18,2)) AS varchar(50))+',' |
| | | from TK_Wrk_Step n |
| | | inner join TStep S on n.step_code=S.stepcode |
| | | where n.wo_code=W.wo_code for xml path('') |
| | | ) as concat_name |
| | | from TK_Wrk_Man W |
| | | left join ( |
| | | select wo,saleOrderCode from TKimp_Ewo |
| | | ) as E on W.m_po=E.wo |
| | | left join TMateriel_Info P on W.materiel_code=p.partcode |
| | | left join TOrganization F on W.wkshp_code=F.torg_code |
| | | group by E.saleOrderCode,W.m_po,W.wo_code,W.wkshp_code,F.torg_name,W.status,W.lm_date,P.partcode,P.partname,P.partspec,W.plan_qty |
| | | ) as AA |
| | | where " + search; |
| | | DataTable data = DapperHelper.selectdata(sql, dynamicParams); |
| | | data.TableName = "Table"; //设置DataTable的名称 |