| | |
| | | |
| | | |
| | | #region[ERP订单查询] |
| | | public static ToMessage ErpOrderSearch(string stu_torgcode,string stu_torgtypecode,string erporderstus, 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 stu_torgcode, string stu_torgtypecode, string erporderstus, 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 = ""; |
| | |
| | | #endregion |
| | | |
| | | #region[ERP订单下达] |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode,string saleordercode, 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 saleordercode, 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>(); |
| | |
| | | m_po = erpordercode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | saleOrderCode=saleordercode, |
| | | saleOrderCode = saleordercode, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | |
| | | m_po = erpordercode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | saleOrderCode=saleordercode, |
| | | saleOrderCode = saleordercode, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | |
| | | mes.Message = "下达MES工单成功失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[ERP订单批量下达] |
| | | public static ToMessage MarkBatchSaveErpOrder(List<ErpOrderBatch> obj, string username) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | |
| | | try |
| | | { |
| | | list.Clear(); |
| | | |
| | | var groupedModels = obj.GroupBy(m => m.erpordercode); |
| | | foreach (var group in groupedModels) |
| | | { |
| | | string erpordercode = group.Key; |
| | | int count = 1; |
| | | foreach (var model in group) |
| | | { |
| | | //获取当前最大工单号 |
| | | sql = @"select isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0) as worknumb |
| | | from TK_Wrk_Man where m_po=@erpordercode"; |
| | | dynamicParams.Add("@erpordercode", model.erpordercode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | int num = Convert.ToInt32(data.Rows[0]["WORKNUMB"].ToString()); |
| | | string wo = model.erpordercode + "_" + (num + count); |
| | | //写入工单表 |
| | | 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,saleOrderCode,saleOrderDeliveryDate) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderCode,@saleOrderDeliveryDate)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo_code = wo, |
| | | wotype = "PO", |
| | | status = "NEW", |
| | | wkshp_code = model.wkshopcode, |
| | | plan_qty = decimal.Parse(model.erpqty), //订单数量 |
| | | stck_code = model.warehousecode, |
| | | materiel_code = model.partcode, |
| | | sourceid = model.erporderid, |
| | | m_po = model.erpordercode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | saleOrderCode = model.saleordercode, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(model.saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | | |
| | | //更新订单状态 |
| | | sql = @"update TKimp_Ewo set status='CREATED',saleOrderDeliveryDate=@saleOrderDeliveryDate,relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | wo = model.erpordercode, |
| | | erporderid = model.erporderid, |
| | | sumqty = decimal.Parse(model.markqty), |
| | | saleOrderDeliveryDate = Convert.ToDateTime(model.saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | | count++; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "批量下达MES工单成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "批量下达MES工单成功失败!"; |
| | | mes.data = null; |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | |
| | | #region[MES工单查询] |
| | | public static ToMessage MesOrderSearch(string stu_torgcode,string stu_torgtypecode,string mesorderstus, 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 stu_torgcode, string stu_torgtypecode, string mesorderstus, 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 = ""; |
| | |
| | | #endregion |
| | | |
| | | #region[MES报废补单工单查询] |
| | | public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder,string saleordercode, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder, string saleordercode, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | #endregion |
| | | |
| | | #region[产品编码查找工艺路线下拉接口] |
| | | public static ToMessage PartSelectRoute(string partcode,string wkshopcode) |
| | | public static ToMessage PartSelectRoute(string partcode, string wkshopcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | |
| | | #endregion |
| | | |
| | | #region[工艺路线查找车间下拉接口] |
| | | public static ToMessage RouteSelectWkshop(string stu_torgcode,string stu_torgtypecode,string partcode) |
| | | public static ToMessage RouteSelectWkshop(string stu_torgcode, string stu_torgtypecode, string partcode) |
| | | { |
| | | string sql = ""; |
| | | string search = ""; |
| | |
| | | inner join TEqpInfo E on D.eqp_code=E.code |
| | | left join TOrganization F on E.wksp_code=F.org_code |
| | | left join TOrganization L on F.parent_id=L.id |
| | | where M.materiel_code=@partcode and E.enable='Y' "+search; |
| | | where M.materiel_code=@partcode and E.enable='Y' " + search; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | |
| | | try |
| | | { |
| | | //获取工艺路线对应工序信息 |
| | | sql = @"select A.seq,T.stepcode,T.stepname,T.flwtype,T.descr from TFlw_Rtdt A |
| | | sql = @"select A.seq,T.stepcode,T.stepname,T.flwtype,T.descr,'0' as stepprice from TFlw_Rtdt A |
| | | left join TStep T on A.step_code=T.stepcode |
| | | where A.rout_code=@partcode "; |
| | | dynamicParams.Add("@partcode", routecode); |
| | |
| | | #endregion |
| | | |
| | | #region[工单派发选择工艺路线或选择生产车间时判断绑定条件] |
| | | public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode) |
| | | public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode, string is_steprice) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | |
| | | return mes; |
| | | } |
| | | } |
| | | //判断工艺路线对应工序关联的工作站是否有设置节拍工价 |
| | | sql = @"select AA.step_code,AA.eqp_code,AA.flwtype,S.unprice from ( |
| | | if (is_steprice == "Y") |
| | | { |
| | | //判断工艺路线对应工序关联的工作站是否有设置节拍工价 |
| | | 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 |
| | |
| | | ) as AA |
| | | left join (select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@route_code and wkspcode=@wkshopcode) 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); |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | var dtc = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dtc.Rows.Count; i++) |
| | | { |
| | | if (dtc.Rows[i]["flwtype"].ToString() == "Z") //判断工序是否为自制 |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@route_code", routecode); |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | var dtc = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dtc.Rows.Count; i++) |
| | | { |
| | | if (dtc.Rows[i].IsNull("unprice") || decimal.Parse(dtc.Rows[i]["unprice"].ToString()) == 0) |
| | | if (dtc.Rows[i]["flwtype"].ToString() == "Z") //判断工序是否为自制 |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "节拍工价中:当前产品【" + partcode + "】,对应工艺路线【" + routecode + "】未设置(或未设置全)或工价小于等于0!"; |
| | | mes.data = null; |
| | | return mes; |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | |
| | | //写入工单工艺路线工序工价复制表 |
| | | 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 |
| | | select distinct @mesordercode as wo,@partcode as materiel_code,AA.eqp_code,isnull(S.stand_value,0) as stand_value,isnull(S.opc_conver,0) as opc_conver,AA.rout_code, |
| | | isnull(S.unprice,0) as unprice,isnull(S.eqp_value,0) as eqp_value,isnull(S.cavity_qty,0) as cavity_qty,@wkshopcode as wkspcode,@usercode as lm_user, |
| | | getdate() as lm_date,S.torg_code,isnull(S.is_delete,0) as is_delete,AA.step_code from ( |
| | | select A.rout_code,A.step_code,C.eqp_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"; |
| | | where A.rout_code=@routecode |
| | | ) as AA |
| | | left join (select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode) as S on AA.step_code=S.step_code and AA.eqp_code=S.eqp_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode, |
| | | materiel_code = partcode, |
| | | routecode = routecode |
| | | wkshopcode = wkshopcode, |
| | | partcode = partcode, |
| | | routecode = routecode, |
| | | usercode = username |
| | | } |
| | | }); |
| | | |
| | |
| | | }); |
| | | //写入工单工艺路线工序工价复制表 |
| | | 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 |
| | | select distinct @mesordercode as wo,@partcode as materiel_code,AA.eqp_code,isnull(S.stand_value,0) as stand_value,isnull(S.opc_conver,0) as opc_conver,AA.rout_code, |
| | | isnull(S.unprice,0) as unprice,isnull(S.eqp_value,0) as eqp_value,isnull(S.cavity_qty,0) as cavity_qty,@wkshopcode as wkspcode,@usercode as lm_user, |
| | | getdate() as lm_date,S.torg_code,isnull(S.is_delete,0) as is_delete,AA.step_code from ( |
| | | select A.rout_code,A.step_code,C.eqp_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"; |
| | | where A.rout_code=@routecode |
| | | ) as AA |
| | | left join (select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@routecode) as S on AA.step_code=S.step_code and AA.eqp_code=S.eqp_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode, |
| | | materiel_code = partcode, |
| | | routecode = routecode |
| | | wkshopcode = wkshopcode, |
| | | partcode = partcode, |
| | | routecode = routecode, |
| | | usercode = username |
| | | } |
| | | }); |
| | | |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(自制)] |
| | | public static ToMessage MesOrderStepSearch(string stu_torgcode,string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | |
| | | } |
| | | //根据条件查询工单工序任务(自制工序) |
| | | sql = @"select A.status,A.wo_code,B.route_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.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date, |
| | | B.m_po,W.saleOrderCode |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | | left join TStep S on A.step_code=S.stepcode |
| | | left join TOrganization F on B.wkshp_code=F.org_code |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(外协)] |
| | | public static ToMessage MesOrderWxStepSearch(string stu_torgcode,string stu_torgtypecode,string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderWxStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | |
| | | } |
| | | //根据条件查询工单工序任务(外协工序) |
| | | sql = @"select A.status,A.wo_code,B.route_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.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date, |
| | | B.m_po,W.saleOrderCode |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | | left join TStep S on A.step_code=S.stepcode |
| | | left join TOrganization F on B.wkshp_code=F.org_code |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工扫码获取工单对应工序任务(不良)] |
| | | public static ToMessage MesOrderNgStepSearch(string stu_torgcode,string stu_torgtypecode,string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderNgStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | |
| | | } |
| | | //根据条件查询工单工序任务,且不良数量大于0 |
| | | sql = @"select 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.bad_qty,B.lm_date |
| | | S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,B.lm_date, |
| | | B.m_po,W.saleOrderCode |
| | | from TK_Wrk_Step A |
| | | left join TK_Wrk_Man B on A.wo_code=B.wo_code |
| | | left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code |
| | | left join TMateriel_Info M on B.materiel_code=M.partcode |
| | | left join TStep S on A.step_code=S.stepcode |
| | | left join TOrganization F on B.wkshp_code=F.org_code |
| | |
| | | } |
| | | } |
| | | //1.根据工单+工序查找当前工序是否首道工序 |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.isbott,A.isend |
| | | sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.isbott,A.isend, |
| | | M.m_po,W.saleOrderCode |
| | | from TK_Wrk_Step A |
| | | left join TStep T on A.step_code=T.stepcode |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TKimp_Ewo W on M.m_po=W.wo and M.materiel_code=W.materiel_code |
| | | left join TMateriel_Info P on M.materiel_code=P.partcode |
| | | where A.wo_code=@ordercode and A.step_code=@stepcode"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //工单号 |
| | | rt.saleOrderCode = data.Rows[0]["saleOrderCode"].ToString(); //销售订单号 |
| | | rt.m_po = data.Rows[0]["m_po"].ToString(); //订单号 |
| | | rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //产品编码 |
| | | rt.partname = data.Rows[0]["PARTNAME"].ToString(); //产品名称 |
| | | rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //产品规格 |
| | |
| | | #endregion |
| | | |
| | | #region [生产开报工:开工(开始/报工)/外协发料时条件判断及数据返回接口] |
| | | public static ToMessage MesOrderStepStart(string OperType,string stu_torgcode, string SelectType, string orderstepqrcode) |
| | | public static ToMessage MesOrderStepStart(string OperType, string stu_torgcode, string SelectType, string orderstepqrcode) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | |
| | | switch (OperType) |
| | | { |
| | | case "ZZ": |
| | | mes = ScanStartReport.ZZEncodingSeach(stu_torgcode, SelectType,ordercode, stepcode); |
| | | mes = ScanStartReport.ZZEncodingSeach(stu_torgcode, SelectType, ordercode, stepcode); |
| | | break; |
| | | case "WX": |
| | | mes = ScanStartReport.WXEncodingSeach(stu_torgcode,SelectType, ordercode, stepcode); |
| | | mes = ScanStartReport.WXEncodingSeach(stu_torgcode, SelectType, ordercode, stepcode); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | dynamicParams.Add("@wo_code", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前工序未关联生产设备!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | #endregion |
| | | |
| | | #region[生产开报工:报工时获取生产班组下拉框] |
| | | public static ToMessage MesOrderStepReportSelectUserGroup(string stu_torgcode,string stu_torgtypecode,string wkshopcode) |
| | | public static ToMessage MesOrderStepReportSelectUserGroup(string stu_torgcode, string stu_torgtypecode, string wkshopcode) |
| | | { |
| | | string sql = ""; |
| | | string search = ""; |
| | |
| | | sql = @"select group_code,group_name from TGroup A |
| | | left join TOrganization T on A.torg_code=T.org_code |
| | | left join TOrganization as L on T.parent_id=L.id |
| | | where 1=1 "+search; |
| | | where 1=1 " + search; |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(reportuser); |
| | | //判断是否有不良数据 |
| | | var groupedItems = defectobjs.GroupBy(item => item.defect_code) // 按编码code分组 |
| | | .Select(group => new { defect_code = group.Key, badqty = group.Sum(item =>Convert.ToDecimal(item.badqty)) }).ToList(); // 汇总数量qty |
| | | .Select(group => new { defect_code = group.Key, badqty = group.Sum(item => Convert.ToDecimal(item.badqty)) }).ToList(); // 汇总数量qty |
| | | if (groupedItems.Count <= 0) |
| | | { |
| | | ngqty = 0; |
| | |
| | | }); |
| | | |
| | | } |
| | | if (groupedItems.Count>0) |
| | | if (groupedItems.Count > 0) |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < groupedItems.Count; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty= groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = username, lm_date = date } }); |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty= groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = username, lm_date = date } }); |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "B", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | if (groupedItems.Count>0) |
| | | if (groupedItems.Count > 0) |
| | | { |
| | | //写入缺陷记录表 |
| | | for (int i = 0; i < groupedItems.Count; i++) |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty= groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = username, lm_date = date } }); |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | { |
| | | sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_pendqty,defect_code,remarks,style,lm_user,lm_date) |
| | | values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_pendqty,@defect_code,@remarks,@style,@lm_user,@lm_date)"; |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty= groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = username, lm_date = date } }); |
| | | list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = groupedItems[i].badqty, defect_pendqty = groupedItems[i].badqty, defect_code = groupedItems[i].defect_code, remarks = remarks, style = "S", lm_user = username, lm_date = date } }); |
| | | |
| | | } |
| | | } |
| | |
| | | #endregion |
| | | |
| | | #region[工序检验,提交] |
| | | public static ToMessage SaveMesOrderStepCheckItem(string stu_torgcode,string wocode, string partcode, string stepcode, string checkstandcode, string check_type, string sampmethod, string qualitystatus, string labqty, string sampleqty, string goodqty, string ngqty, string checkitemcont, string username) |
| | | public static ToMessage SaveMesOrderStepCheckItem(string stu_torgcode, string wocode, string partcode, string stepcode, string checkstandcode, string check_type, string sampmethod, string qualitystatus, string labqty, string sampleqty, string goodqty, string ngqty, string checkitemcont, string username) |
| | | { |
| | | var sql = ""; |
| | | string checktypename = ""; |
| | |
| | | |
| | | |
| | | #region[MES工单批量关闭查询] |
| | | public static ToMessage MesOrderBitchClosedSearch(string stu_torgcode,string stu_torgtypecode,string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | public static ToMessage MesOrderBitchClosedSearch(string stu_torgcode, string stu_torgtypecode, string mesorderstus, 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 = ""; |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | // --------------查询指定数据-------------- |
| | | 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.org_name as wkshp_name, |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,W.saleOrderCode,U.username as lm_user,A.lm_date |
| | | ,(select sum(S.good_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as good_qty |
| | | ,(select sum(S.ng_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as ng_qty |
| | | ,(select sum(S.bad_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as bad_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 TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code |