| | |
| | | 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,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)"; |
| | | 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,injectnumber,customercode,customername,colour) 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,@injectnumber,@customercode,@customername,@colour)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | saleOrderDeliveryDate = Convert.ToDateTime(model.saleOrderDeliveryDate), |
| | | data_sources = "ERP", |
| | | isstep = "N", //是否关联工序 |
| | | clerkuser= model.clerkuser //销售订单业务员 |
| | | clerkuser= model.clerkuser, //销售订单业务员 |
| | | injectnumber = model.injectnumber,//注塑机号 |
| | | customercode = model.customercode,//客户编码 |
| | | customername = model.customername,//客户名称 |
| | | colour = model.colour //颜色 |
| | | } |
| | | }); |
| | | |
| | |
| | | if (operType == "Add") |
| | | { |
| | | //写入工单表 |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,lm_user,lm_date,materiel_code,sourceid,m_po,saleOrderDeliveryDate,piroque,isaps,data_sources,isstep) |
| | | values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@lm_user,@lm_date,@materiel_code,@sourceid,@m_po,@saleOrderDeliveryDate,@orderlev,@isaps,@data_sources,@isstep)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,lm_user,lm_date,materiel_code,sourceid,m_po,saleOrderDeliveryDate,piroque,isaps,data_sources,isstep,injectnumber,customercode,customername,colour) |
| | | values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@lm_user,@lm_date,@materiel_code,@sourceid,@m_po,@saleOrderDeliveryDate,@orderlev,@isaps,@data_sources,@isstep,@injectnumber,@customercode,@customername,@colour)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | orderlev = "3",//优先级:特级(1) 紧急(2) 正常(3) |
| | | isaps = "N", //是否排产,默认N Y=是 N=否 |
| | | data_sources = json.data_sources, |
| | | isstep = json.isstep //是否关联工序 |
| | | isstep = json.isstep, //是否关联工序 |
| | | injectnumber = json.injectnumber,//注塑机号 |
| | | customercode = json.customercode,//客户编码 |
| | | customername = json.customername,//客户名称 |
| | | colour = json.colour //颜色 |
| | | } |
| | | }); |
| | | //写入工序任务表 |
| | |
| | | { |
| | | //修改工单表 |
| | | sql = @"update TK_Wrk_Man set wotype=@wotype,wkshp_code=@wkshp_code,plan_qty=@plan_qty,lm_user=@lm_user,lm_date=@lm_date, |
| | | materiel_code=@materiel_code,sourceid=@sourceid,m_po=@m_po,saleOrderDeliveryDate=@saleOrderDeliveryDate,isstep=@isstep |
| | | materiel_code=@materiel_code,sourceid=@sourceid,m_po=@m_po,saleOrderDeliveryDate=@saleOrderDeliveryDate,isstep=@isstep,injectnumber=@injectnumber,customercode=@customercode,customername=@customername,colour=@colour |
| | | where wo_code=@wo_code"; |
| | | list.Add(new |
| | | { |
| | |
| | | saleOrderDeliveryDate = json.deliverydate, |
| | | lm_user = us.usercode, |
| | | lm_date = DateTime.Now.ToString(), |
| | | isstep = json.isstep //是否关联工序 |
| | | isstep = json.isstep, //是否关联工序 |
| | | injectnumber = json.injectnumber,//注塑机号 |
| | | customercode = json.customercode,//客户编码 |
| | | customername = json.customername,//客户名称 |
| | | colour = json.colour //颜色 |
| | | } |
| | | }); |
| | | //删除工单工序表 |
| | |
| | | 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 MesOrderExcelSearch(string mesorderstus, string wkshopcode, string mesordercode, string sourceorder, string saleordercode, string ordertype, string partcode, string partname, string partspec, string creatuser, string createdate) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (mesorderstus != "" && mesorderstus != null) |
| | | { |
| | | search += "and A.status=@mesorderstus "; |
| | | dynamicParams.Add("@mesorderstus", mesorderstus); |
| | | } |
| | | if (wkshopcode != "" && wkshopcode != null) |
| | | { |
| | | search += "and A.wkshp_code=@wkshopcode "; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | } |
| | | 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 (saleordercode != "" && saleordercode != null) |
| | | { |
| | | search += "and W.saleOrderCode like '%'+@saleordercode+'%' "; |
| | | dynamicParams.Add("@saleordercode", saleordercode); |
| | | } |
| | | 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.injectnumber as '注塑机号',A.customername as '客户名称',A.materiel_code as '产品编码',B.partname as '产品名称',B.partspec as '产品规格',A.colour as '颜色',A.plan_qty as '工单数',W.saleOrderCode as '销售订单',A.clerkuser as '销售业务员', |
| | | (case when A.status='NEW' then '新工单' |
| | | when A.status='ALLO' then '已排发' |
| | | when A.status='START' then '已开工' |
| | | when A.status='CLOSED' then '已完工' |
| | | end) as '工单状态', |
| | | (case when A.wotype='PO' then '标准工单' else '报废补单' end) as '单据类型',A.wo_code as '工单编号',A.m_po as '源单单号',C.torg_name as '生产车间',A.saleOrderDeliveryDate as '预计交付日期',U.username as '创建人员',A.lm_date as '创建时间' |
| | | from TK_Wrk_Man A |
| | | 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 |
| | | left join TUser U on A.lm_user=U.usercode |
| | | left join TOrganization L on C.parent_id=L.id |
| | | where A.is_delete<>'1' " + search; |
| | | DataTable data = DapperHelper.selectdata(sql, dynamicParams); |
| | | data.TableName = "Table"; //设置DataTable的名称 |
| | | string msg = DownLoad.DataTableToExcel(data, "生产工单"); |
| | | mes.code = "200"; |
| | | mes.message = "查询成功!"; |
| | | mes.count = total; |
| | | mes.data = msg; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.id,A.status,B.wkshp_code,T.torg_name as wkshp_name,A.wo_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.laborbad_qty,A.materielbad_qty,B.lm_date |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.laborbad_qty,A.materielbad_qty,B.lm_date,B.injectnumber,B.customercode,B.customername,B.colour |
| | | 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.id,A.status,B.wkshp_code,T.torg_name as wkshp_name,A.wo_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, |
| | | (select isnull(sum(fqty),0) as fqty from TK_Wrk_OutRecord where wo_code=A.wo_code and step_code=A.step_code and style='F') as fqty, |
| | | A.laborbad_qty,A.materielbad_qty,A.plan_startdate,A.plan_enddate,B.lm_date |
| | | A.laborbad_qty,A.materielbad_qty,A.plan_startdate,A.plan_enddate,B.lm_date,B.injectnumber,B.customercode,B.customername,B.colour |
| | | 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.id,B.wkshp_code,T.torg_name as wkshp_name,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.laborbad_qty,A.materielbad_qty,B.lm_date |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.laborbad_qty,A.materielbad_qty,B.lm_date,B.injectnumber,B.customercode,B.customername,B.colour |
| | | 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 |