| | |
| | | //获取最大单据号 |
| | | if (i == 1) //首单获取工单号 |
| | | { |
| | | sql = @"select isnull(max(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code))),0)+1 as worknumb from TK_Wrk_Man where m_po=@erpordercode"; |
| | | sql = @"select isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0)+1 as worknumb |
| | | from TK_Wrk_Man where m_po=@erpordercode"; |
| | | dynamicParams.Add("@erpordercode", erpordercode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | num = Convert.ToInt32(data.Rows[0]["WORKNUMB"].ToString()); |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES报废补单工单查询] |
| | | public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | 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 (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.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,S.bad_qty |
| | | from TK_Wrk_Man A |
| | | left join (select wo_code,sum(bad_qty) as bad_qty from TK_Wrk_Step where bad_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.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code |
| | | left join TFlw_Rout E on A.route_code=E.code |
| | | left join T_Sec_Stck F on A.stck_code=F.code |
| | | left join TUser U on A.lm_user=U.usercode |
| | | where A.is_delete<>'1' and A.status='START' and A.wotype='PO' and S.bad_qty>0 " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.count = total; |
| | | mes.data = data.ToList(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[产品编码查找工艺路线下拉接口] |
| | | public static ToMessage PartSelectRoute(string partcode) |
| | | { |
| | |
| | | inner join TFlw_Rteqp D on C.stepcode=D.step_code |
| | | inner join TEqpInfo E on D.eqp_code=E.code |
| | | left join TOrganization F on E.wksp_code=F.org_code |
| | | where A.code=@routecode and M.materiel_code=@partcode "; |
| | | where A.code=@routecode and M.materiel_code=@partcode and E.enable='Y'"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@routecode", routecode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region【生产管理、工单新增、编辑时,选择排程是时获取物料清单版本号】 |
| | | public static ToMessage JobCreationSonAddVison(string partnumber) |
| | |
| | | return mes; |
| | | } |
| | | } |
| | | //判断工作站(设备)是否可用 |
| | | sql = @"select B.step_code from TFlw_Rout A |
| | | inner join TFlw_Rtdt B on A.code=B.rout_code |
| | | where A.code=@routecode"; |
| | | dynamicParams.Add("@routecode", routecode); |
| | | var dtck1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dtck1.Rows.Count; i++) |
| | | { |
| | | //工序查找设备 |
| | | sql = @"select E.code,E.name,E.enable |
| | | from TFlw_Rteqp C |
| | | left join TEqpInfo E on C.eqp_code=E.code |
| | | where C.step_code=@step_code"; |
| | | dynamicParams.Add("@step_code", dtck1.Rows[i]["step_code"].ToString()); |
| | | var dtck2 = DapperHelper.selectdata(sql, dynamicParams); |
| | | int query = dtck2.AsEnumerable().Where<DataRow>(a => a["enable"].ToString() =="N").Count(); |
| | | if (dtck2.Rows.Count == query) |
| | | { |
| | | 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 |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单新增、获取工单号] |
| | | public static ToMessage AddMesOrderCodeSearch() |
| | | { |
| | | string sql = ""; |
| | | string wo_code = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取单据号 |
| | | sql = @"SELECT 'SGPO'+CONVERT(varchar(12) , getdate(), 112 )+'_'+cast(isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0)+1 as varchar) as numct |
| | | FROM TK_Wrk_Man where wo_code like '%SGPO%'"; |
| | | var data = DapperHelper.selecttable(sql); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data.Rows[0]["numct"].ToString(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | #endregion |
| | | |
| | | |
| | | #region[生产开报工扫码获取当前工序对应的设备(自制)] |
| | | public static ToMessage MesOrderStepEqpSearch(string orderstepqrcode) |
| | | { |
| | | var sql = ""; |
| | | string search = "";//定义一个查询参数,查询条件有前端传入 |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | | { |
| | | string[] arra = orderstepqrcode.Split(';'); |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序二维码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | } |
| | | if (stepcode != "") |
| | | { |
| | | //查找当前工序属性 |
| | | sql = @"select * from TStep where stepcode=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "W") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序任务为外协工序任务,请前往外协操作页签执行!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | //根据条件查询工单工序设备(自制工序) |
| | | sql = @"select B.eqp_code,E.name as eqp_name from TK_Wrk_Step A |
| | | inner join TFlw_Rteqp B on A.step_code=B.step_code |
| | | left join TEqpInfo E on B.eqp_code=E.code |
| | | where B.style='E' and A.wo_code=@ordercode and A.step_code=@stepcode |
| | | order by B.eqp_code"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序任务无可执行设备!"; |
| | | 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[生产开报工扫码获取当前工序对应的供方(外协)] |
| | | public static ToMessage MesOrderWxStepEqpSearch(string orderstepqrcode) |
| | | { |
| | | var sql = ""; |
| | | string search = ""; |
| | | string ordercode = ""; |
| | | string stepcode = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (orderstepqrcode != "" && orderstepqrcode != null) |
| | | { |
| | | string[] arra = orderstepqrcode.Split(';'); |
| | | if (arra.Length == 1) //工单号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "请扫描工序二维码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | if (arra.Length == 2) //工单号+工序号二维码 |
| | | { |
| | | ordercode = arra[0]; //获取指定字符串前面的字符 |
| | | stepcode = arra[1]; //获取指定字符串前面的字符 |
| | | } |
| | | } |
| | | if (stepcode != "") |
| | | { |
| | | //查找当前工序属性 |
| | | sql = @"select * from TStep where stepcode=@stepcode"; |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序任务为自制工序任务,请前往自制操作页签执行!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | //根据条件查询工单工序外协供方(外协工序) |
| | | sql = @"select B.eqp_code as customercode,C.name as customername from TK_Wrk_Step A |
| | | inner join TFlw_Rteqp B on A.step_code=B.step_code |
| | | left join TCustomer C on B.eqp_code=C.code |
| | | where B.style='W' and A.wo_code=@ordercode and A.step_code=@stepcode |
| | | order by B.eqp_code"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工序无可执行外协供方!"; |
| | | 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[生产开报工扫码获取工单对应工序任务(自制)] |
| | | public static ToMessage MesOrderStepSearch(string orderstepqrcode, int startNum, int endNum, string prop, string order) |
| | |
| | | //获取工序关联的设备 |
| | | sql = @"select B.code,B.name from TFlw_Rteqp A |
| | | left join TEqpInfo B on A.eqp_code=B.code |
| | | where A.style='E' and A.step_code=@stepcode"; |
| | | where A.style='E' and A.step_code=@stepcode and B.enable='Y'"; |
| | | dynamicParams.Add("@wo_code", ordercode); |
| | | dynamicParams.Add("@stepcode", stepcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | |
| | | //sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } }); |
| | | |
| | | //判断是否末道工序完工报工(自动关闭工单及工序任务) |
| | | //list = AutosCloseOrder.AutosColseOrderReport(list,mesordercode, partcode, stepseq,stepcode,reportqty,ngqty); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | //回写工单表合格数量、不良数量 |
| | | //sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode"; |
| | | //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } }); |
| | | |
| | | //判断是否末道工序完工报工(自动关闭工单及工序任务) |
| | | //list = AutosCloseOrder.AutosColseOrderReport(list, mesordercode, partcode, stepseq, stepcode, sqty, ngqty); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | return list; |
| | | } |
| | | bool IsCap = false; //是否设置产能 |
| | | //通过工单查找工艺路线对应关键工序所关联的设备是否可用 |
| | | //通过工单查找对应车间工艺路线下关键工序所关联的设备是否可用 |
| | | sql = @"select distinct C.eqp_code ,D.Enable from TK_Wrk_Man A |
| | | left join TFlw_Rout K on A.route_code=K.code |
| | | left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y' |
| | | left join TFlw_Rteqp C on B.step_code= C.step_code |
| | | left join TEqpInfo D on C.eqp_code=D.code |
| | | where A.wo_code=@wocode and A.materiel_code=@partcode"; |
| | | where A.wo_code=@wocode and A.materiel_code=@partcode and D.wksp_code=@wkshpcode"; |
| | | dynamicParams.Add("@wocode", wocode); |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@wkshpcode", wkshpcode); |
| | | var dt_0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt_0.Rows.Count > 0) |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[NEW排产设备信息] |
| | | public static List<AdvancedSchedulingDevice> NewOnclickAdvancedSchedulingDevice(List<ApsOrderSerch> json, ref ToMessage mes) |
| | | { |
| | | string sql = "", sql0 = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<AdvancedSchedulingDevice> list = new List<AdvancedSchedulingDevice>(); |
| | | DataTable dt, dt1; |
| | | //List<ApsOrderSerch> json = new List<ApsOrderSerch>(); |
| | | try |
| | | { |
| | | for (int w = 0; w < json.Count; w++) |
| | | { |
| | | |
| | | |
| | | DateTime beginDate = Convert.ToDateTime(json[w].startdate); |
| | | DateTime endDate = DateTime.Parse(json[w].enddate); |
| | | if (beginDate > endDate) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "要求交付时间不能小于当前系统时间!"; |
| | | mes.data = null; |
| | | return list; |
| | | } |
| | | bool IsCap = false; //是否设置产能 |
| | | //通过工单查找对应车间工艺路线下关键工序所关联的设备是否可用 |
| | | sql = @"select distinct C.eqp_code ,D.Enable from TK_Wrk_Man A |
| | | left join TFlw_Rout K on A.route_code=K.code |
| | | left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y' |
| | | left join TFlw_Rteqp C on B.step_code= C.step_code |
| | | left join TEqpInfo D on C.eqp_code=D.code |
| | | where A.wo_code=@wocode and A.materiel_code=@partcode and D.wksp_code=@wkshpcode"; |
| | | dynamicParams.Add("@wocode", json[w].wocode); |
| | | dynamicParams.Add("@partcode", json[w].partcode); |
| | | dynamicParams.Add("@wkshpcode", json[w].wkshpcode); |
| | | var dt_0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt_0.Rows.Count > 0) |
| | | { |
| | | int cout = dt_0.Rows.Count; |
| | | int num = 0; |
| | | for (int m = 0; m < dt_0.Rows.Count; m++) |
| | | { |
| | | if (dt_0.Rows[m]["Enable"].ToString() == "N") |
| | | { |
| | | num = num + 1; |
| | | } |
| | | } |
| | | if (num == cout) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "设备不可用!"; |
| | | mes.data = null; |
| | | return list; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "工艺路线未关联设备!"; |
| | | mes.data = null; |
| | | return list; |
| | | } |
| | | |
| | | //通过工单查找工艺路线对应关键工序所关联的设备所属车间 |
| | | sql0 = @"select distinct D.wksp_code from TK_Wrk_Man A |
| | | left join TFlw_Rout K on A.route_code=K.code |
| | | left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y' |
| | | left join TFlw_Rteqp C on B.step_code= C.step_code |
| | | left join TEqpInfo D on C.eqp_code=D.code |
| | | where A.wo_code=@wocode and A.materiel_code=@partcode "; |
| | | dynamicParams.Add("@wocode", json[w].wocode); |
| | | dynamicParams.Add("@partcode", json[w].partcode); |
| | | var dt0 = DapperHelper.selectdata(sql0, dynamicParams); |
| | | if (dt0.Rows.Count > 0) |
| | | { |
| | | string sy = "0"; |
| | | for (int i = 0; i < dt0.Rows.Count; i++) |
| | | { |
| | | if (dt0.Rows[i]["WKSP_CODE"].ToString() == json[w].wkshpcode) //工单创建车间是否等于排产设备 车间 |
| | | { |
| | | sy = "1"; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | sy = "0"; |
| | | } |
| | | } |
| | | if (sy == "0") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "排产设备车间与工单创建的车间不同!"; |
| | | mes.data = null; |
| | | return list; |
| | | } |
| | | else |
| | | { |
| | | List<APSList> listData = SchedulingMethod.SchedulingMethodTF(json[w].wocode, json[w].wkshpcode, json[w].partcode); |
| | | for (DateTime date = beginDate; date <= endDate; date = date.AddDays(1)) |
| | | { |
| | | AdvancedSchedulingDevice tbj = new AdvancedSchedulingDevice(); |
| | | tbj.wo_code = json[w].wocode; |
| | | tbj.YearDate = date.ToString("yyyy-MM-dd"); |
| | | tbj.children = new List<AdvancedSchedulingDeviceCont>(); |
| | | for (int j = 0; j < listData.Count; j++) |
| | | { |
| | | if (listData[j].AdvaDevicCropMob.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "排程设备" + listData[j].eqp_id.ToString() + "稼动率不能为0或为空!"; |
| | | mes.data = null; |
| | | return list; |
| | | } |
| | | if (listData[j].AdvaDevicRhythm.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "") |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "排程设备" + listData[j].eqp_id.ToString() + "未设置节拍!"; |
| | | mes.data = null; |
| | | return list; |
| | | } |
| | | string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start,G.name |
| | | from TWkm_capac_plan E |
| | | left join TWkm_capac_plan_sub F on E.id=F.m_id |
| | | left join TBas_wkshift_info G on F.wkshift_code=G.code |
| | | where E.wkshop=@wkshop and E.eqp_typecode=@eqp_typecode and E.ClassType=@classtype |
| | | and CONVERT(varchar(100), F.wkdate, 23)=@wkdate and E.enable='Y'"; |
| | | dynamicParams.Add("@wkshop", json[w].wkshpcode); |
| | | dynamicParams.Add("@eqp_typecode", listData[j].Style.ToString()); |
| | | dynamicParams.Add("@classtype", listData[j].ClassType.ToString()); |
| | | dynamicParams.Add("@wkdate", date.ToString("yyyy-MM-dd")); |
| | | dt1 = DapperHelper.selectdata(sql1, dynamicParams); |
| | | |
| | | AdvancedSchedulingDeviceCont tbjson = new AdvancedSchedulingDeviceCont(); |
| | | tbjson.AdvaDevicNumber = listData[j].eqp_id.ToString(); |
| | | tbjson.AdvaDevicName = listData[j].name.ToString(); |
| | | tbjson.AdvaDevicCropMob = listData[j].AdvaDevicCropMob.ToString(); //稼动率 |
| | | tbjson.AdvaDevicRhythm = listData[j].AdvaDevicRhythm.ToString(); //生产节拍 |
| | | if (dt1.Rows.Count > 0) |
| | | { |
| | | tbjson.OneStartDate = dt1.Rows[0]["wktme1_start"].ToString(); |
| | | tbjson.TwoStartDate = dt1.Rows[0]["wktme2_start"].ToString(); |
| | | tbjson.ThreeStartDate = dt1.Rows[0]["wktme3_start"].ToString(); |
| | | tbjson.FourStartDate = dt1.Rows[0]["wktme4_start"].ToString(); |
| | | tbjson.FiveStartDate = dt1.Rows[0]["wktme5_start"].ToString(); |
| | | tbj.children.Add(tbjson); |
| | | IsCap = true; |
| | | } |
| | | else |
| | | { |
| | | |
| | | tbjson.OneStartDate = ""; |
| | | tbjson.TwoStartDate = ""; |
| | | tbjson.ThreeStartDate = ""; |
| | | tbjson.FourStartDate = ""; |
| | | tbjson.FiveStartDate = ""; |
| | | tbj.children.Add(tbjson); |
| | | } |
| | | } |
| | | |
| | | list.Add(tbj); |
| | | } |
| | | if (list.Select(p => p.children).ToList().Count > 0) |
| | | { |
| | | int one = list.Where(t => t.children.Select(s => s.OneStartDate).Any(x => x != "")).ToList().Count; |
| | | int two = list.Where(t => t.children.Select(s => s.TwoStartDate).Any(x => x != "")).ToList().Count; |
| | | int three = list.Where(t => t.children.Select(s => s.ThreeStartDate).Any(x => x != "")).ToList().Count; |
| | | int four = list.Where(t => t.children.Select(s => s.FourStartDate).Any(x => x != "")).ToList().Count; |
| | | int five = list.Where(t => t.children.Select(s => s.FiveStartDate).Any(x => x != "")).ToList().Count; |
| | | if (one <= 0 && two <= 0 && three <= 0 && four <= 0 && five <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工单加工产品对应工艺路线设备未设置产能或未设置生产节拍!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "设备没有关联车间!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return list; |
| | | } |
| | | #endregion |
| | | |
| | | #region[New设备已排程信息] |
| | | public static List<DataTable> NewAlreadyScheduling(List<ApsOrderSerch> json) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | DataTable dt; |
| | | List<DataTable> list = new List<DataTable>(); |
| | | try |
| | | { |
| | | for (int i = 0; i < json.Count; i++) |
| | | { |
| | | List<APSList> listData = SchedulingMethod.SchedulingMethodTF(json[i].wocode, json[i].wkshpcode, json[i].partcode); |
| | | string[] empIds = listData.Select(a => a.eqp_id).ToArray(); |
| | | string str = string.Join(",", empIds); |
| | | 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.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 = json[i].startdate + " 00:00:00", enddate = json[i].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"); |
| | | //var dt_0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dt == null || dt.Rows.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | list.Add(dt); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | #endregion |
| | | |
| | | #region[排程数据提交] |
| | | public static ToMessage SubmitAlreadyScheduling(string username, string wocode, string botprocecode, List<AlreadyScheduling> objs) |
| | | { |