| | |
| | | // --------------查询指定数据-------------- |
| | | 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.org_name as wkshp_name, |
| | | A.stck_code,D.name as stck_name,A.planstartdate,A.planenddate,U.username as createuser,A.createdate |
| | | A.stck_code,D.name as stck_name,saleOrderDeliveryDate,A.planstartdate,A.planenddate,U.username as createuser,A.createdate |
| | | from TKimp_Ewo A |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | |
| | | #endregion |
| | | |
| | | #region[ERP订单下达] |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string username) |
| | | public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, 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>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | |
| | | try |
| | | { |
| | | list.Clear(); |
| | |
| | | } |
| | | if (decimal.Parse(erpqty) == decimal.Parse(markqty) + decimal.Parse(relse_qty)) //如果ERP订单=下单数量+已下单数量,则更新ERP订单表状态为CREATED:已创建 |
| | | { |
| | | sql = @"update TKimp_Ewo set status='CREATED',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid"; |
| | | 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, |
| | |
| | | { |
| | | wo = erpordercode, |
| | | erporderid = erporderid, |
| | | sumqty = sumqty |
| | | sumqty = sumqty, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | | } |
| | | else //更新ERP订单表状态为CREATING:创建中 |
| | | { |
| | | sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid"; |
| | | sql = @"update TKimp_Ewo set status='CREATING',saleOrderDeliveryDate=@saleOrderDeliveryDate,relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | { |
| | | wo = erpordercode, |
| | | erporderid = erporderid, |
| | | sumqty = sumqty |
| | | sumqty = sumqty, |
| | | saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate) |
| | | } |
| | | }); |
| | | } |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单新增、编辑提交] |
| | | public static ToMessage AddUpdateMesOrder(string mesorderstus, string sourceorder, string ordertype, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype,string is_aps) |
| | | |
| | | #region【生产管理、工单新增、编辑时,选择排程是时获取物料清单版本号】 |
| | | public static ToMessage JobCreationSonAddVison(string partnumber) |
| | | { |
| | | var sql = ""; |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | sql = @" select id,version from TBom_Main where materiel_code=@partnumber and status='Y' order by version desc "; |
| | | dynamicParams.Add("@partnumber", partnumber); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单新增、编辑提交] |
| | | public static ToMessage AddUpdateMesOrder(string mesorderstus, string sourceorder, string ordertype, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype, string is_aps, string bom_id) |
| | | { |
| | | string sql = "", wo_status = "", wrk_status = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<object> list = new List<object>(); |
| | | try |
| | | { |
| | | //获取工艺路线首道工序ID |
| | | sql = @"select distinct B.id from TFlw_Rout A |
| | | left join TFlw_Rtdt B on A.code=B.rout_code and b.first_choke='Y' |
| | | where A.code=@routecode"; |
| | | dynamicParams.Add("@routecode", routecode); |
| | | var dtck = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (dtck.Rows.Count <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "工单对应工艺路线没有绑定工序!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | |
| | | if (opertype == "Add") |
| | | { |
| | | if (is_aps == "Y") //是否排程(是) |
| | | { |
| | | //判断物料清单 |
| | | sql = "select id from TBom_Main where materiel_code=@partcode and status='Y' and id=@bom_id"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@bom_id", bom_id); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "工单对应的产品没有建立BOM或BOM未审核!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //增加工单用料表(子件) |
| | | sql = @"insert into TK_Wrk_Allo(wo_code, seq, materiel_code, basqty, qty,bom_id,materieltype,stck_code,stopfeed,base_quantity,loss_quantity,m_quantity) |
| | | select @wocode,A.seq,A.smateriel_code,A.total_quantity,(convert(decimal(18, 0), @uomqty)*A.Base_Quantity*(1+A.LOSS_QUANTITY/100))/C.quantity, |
| | | A.m_id,A.pn_type,'','N',A.base_quantity,A.loss_quantity,C.quantity |
| | | from TBom_Deta A left join TBom_Main C on A.m_Id=C.id |
| | | left join TMateriel_Info B on A.smateriel_code = B.partcode |
| | | where A.m_id=@bom_id"; |
| | | list.Add(new { str = sql, parm = new { wocode = mesordercode, uomqty = mesqty, bom_id = bom_id } }); |
| | | |
| | | wo_status = "NOSCHED"; |
| | | wrk_status = "NOSCHED"; |
| | | } |
| | | else //否 |
| | | { |
| | | wo_status = "ALLO"; |
| | | wrk_status = "ALLO"; |
| | | } |
| | | //写入工单表 |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,plan_startdate,plan_enddate,route_code,stck_code,lm_user,lm_date,materiel_code,m_po,piroque) |
| | | values(@mesordercode,@wotype,@mesorderstus,@wkshopcode,@mesqty,@planstartdate,@planenddate,@routecode,@stck_code,@username,@CreateDate,@materiel_code,@m_po,@orderlev)"; |
| | | sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,plan_startdate,plan_enddate,route_code,stck_code,lm_user,lm_date,materiel_code,m_po,piroque,isaps) |
| | | values(@mesordercode,@wotype,@mesorderstus,@wkshopcode,@mesqty,@planstartdate,@planenddate,@routecode,@stck_code,@username,@CreateDate,@materiel_code,@m_po,@orderlev,@isaps)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | mesordercode = mesordercode, |
| | | wotype = ordertype, |
| | | m_po = sourceorder, |
| | | mesorderstus = "ALLO", //派发 |
| | | mesorderstus = wo_status, //单据状态 |
| | | wkshopcode = wkshopcode, |
| | | mesqty = mesqty, |
| | | planstartdate = planstartdate, |
| | |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | materiel_code = partcode, |
| | | orderlev = orderlev |
| | | orderlev = orderlev, |
| | | isaps = is_aps |
| | | } |
| | | }); |
| | | //写入工序任务表 |
| | |
| | | planstartdate = planstartdate, |
| | | planenddate = planenddate, |
| | | routecode = routecode, |
| | | status = "ALLO", //派发 |
| | | status = wrk_status, //工序状态 |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | if (is_aps == "Y") //是否排程 |
| | | { |
| | | //string sql1 = "select id from TBom_Main where materiel_code='" + PartNumber + "' and status='Y' and version='" + VsionId + "'"; |
| | | //DataTable dt1 = DBHelper.GetTable(sql1); |
| | | } |
| | | |
| | | //增加工单用料表(子件) |
| | | |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | |
| | | } |
| | | if (opertype == "Update") |
| | | { |
| | | sql = @"update TK_Wrk_Man set route_code=@routecode,wkshp_code=@wkshopcode,plan_startdate=@planstartdate,plan_enddate=@planenddate,status=@status,piroque=@orderlev,lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode"; |
| | | if (is_aps == "Y") //是否排程(是) |
| | | { |
| | | //判断物料清单 |
| | | sql = "select id from TBom_Main where materiel_code=@partcode and status='Y' and id=@bom_id"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@bom_id", bom_id); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "工单对应的产品没有建立BOM或BOM未审核!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //增加工单用料表(子件) |
| | | sql = @"insert into TK_Wrk_Allo(wo_code, seq, materiel_code, basqty, qty,bom_id,materieltype,stck_code,stopfeed,base_quantity,loss_quantity,m_quantity) |
| | | select @wocode,A.seq,A.smateriel_code,A.total_quantity,(convert(decimal(18, 0), @uomqty)*A.Base_Quantity*(1+A.LOSS_QUANTITY/100))/C.quantity, |
| | | A.m_id,A.pn_type,'','N',A.base_quantity,A.loss_quantity,C.quantity |
| | | from TBom_Deta A left join TBom_Main C on A.m_Id=C.id |
| | | left join TMateriel_Info B on A.smateriel_code = B.partcode |
| | | where A.m_id=@bom_id"; |
| | | list.Add(new { str = sql, parm = new { wocode = mesordercode, uomqty = mesqty, bom_id = bom_id } }); |
| | | |
| | | wo_status = "NOSCHED"; |
| | | wrk_status = "NOSCHED"; |
| | | } |
| | | else //否 |
| | | { |
| | | wo_status = "ALLO"; |
| | | wrk_status = "ALLO"; |
| | | } |
| | | sql = @"update TK_Wrk_Man set route_code=@routecode,wkshp_code=@wkshopcode,plan_startdate=@planstartdate,plan_enddate=@planenddate,status=@status,piroque=@orderlev,lm_user=@username,lm_date=@CreateDate,isaps=@isaps where wo_code=@mesordercode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | wkshopcode = wkshopcode, |
| | | planstartdate = planstartdate, |
| | | planenddate = planenddate, |
| | | status = "ALLO", //派发 |
| | | status = wo_status, |
| | | routecode = routecode, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | orderlev = orderlev |
| | | orderlev = orderlev, |
| | | isaps= is_aps |
| | | } |
| | | }); |
| | | //写入工序任务表 |
| | |
| | | mesqty = mesqty, |
| | | planstartdate = planstartdate, |
| | | planenddate = planenddate, |
| | | status = "ALLO", //派发 |
| | | status = wo_status, |
| | | username = username, |
| | | routecode = routecode, |
| | | CreateDate = DateTime.Now.ToString() |
| | |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //判断工单是否为未开始状态或者已派发状态(满足其中一种都可删除,否则不允许删除) |
| | | sql = @"select * from TK_Wrk_Man where wo_code=@wocode and status='NEW' or status='ALLO'"; |
| | | //判断工单是否为未开始状态或者已派发或待排程状态(满足其中一种都可删除,否则不允许删除) |
| | | sql = @"select * from TK_Wrk_Man where wo_code=@wocode and status in('NEW','ALLO','NOSCHED')"; |
| | | dynamicParams.Add("@wocode", wocode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | |
| | | } |
| | | //删除工单工序表 |
| | | sql = @"delete TK_Wrk_Step where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocode } }); |
| | | |
| | | //删除加工单用料表(子件) |
| | | sql = @"delete TK_Wrk_Allo where wo_code=@wocode"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocode } }); |
| | | |
| | | //删除工单表 |
| | |
| | | left join TStep B on A.step_code=B.stepcode |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TMateriel_Info P on M.materiel_code=P.partcode |
| | | where A.wo_code=@wo_code"; |
| | | where A.wo_code=@wo_code order by A.seq"; |
| | | dynamicParams.Add("@wo_code", wo_code); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | |
| | | |
| | | |
| | | |
| | | #region[产能规划设置查询] |
| | | public static ToMessage CapacityPlanningSetupSearch() |
| | | { |
| | | string sql = ""; |
| | | try |
| | | { |
| | | sql = @"select code,name,wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start, |
| | | lm_user,lm_date,duration |
| | | from TBas_wkshift_info"; |
| | | var data = DapperHelper.selecttable(sql); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[产能规划设置新增] |
| | | public static ToMessage CapacityPlanningSetupAddUpdate(string username, List<CapacityPlanningSetup> objs) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //判断编码是否重复 |
| | | sql = @"select * from TBas_wkshift_info where code=@code"; |
| | | dynamicParams.Add("@code", objs[0].CapSetupCode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "编码已存在,不能重复!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //判断名称是否重复 |
| | | sql = @"select * from TBas_wkshift_info where name=@name"; |
| | | dynamicParams.Add("@name", objs[0].CapSetupName); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "名称已存在,不能重复!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | list.Clear(); |
| | | //循环写入设备类型表 |
| | | for (int i = 0; i < objs.Count; i++) |
| | | { |
| | | sql = @"insert into TBas_wkshift_info(code, name, wktme1_start, wktme2_start, wktme3_start, wktme4_start, wktme5_start, lm_user, lm_date, duration) |
| | | values(@code,@name,@wktme1_start,@wktme2_start,@wktme3_start,@wktme4_start,@wktme5_start,@lm_user,@lm_date,@duration)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | code = objs[i].CapSetupCode, |
| | | name = objs[i].CapSetupName, |
| | | wktme1_start = objs[i].OneStartDate, |
| | | wktme2_start = objs[i].TwoStartDate, |
| | | wktme3_start = objs[i].ThreeStartDate, |
| | | wktme4_start = objs[i].FourStartDate, |
| | | wktme5_start = objs[i].FiveStartDate, |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString(), |
| | | duration = objs[i].Duration |
| | | } |
| | | }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "操作成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[产能规划方案设置删除] |
| | | public static ToMessage CapacityPlanningSetupDelete(string username, string capsetupcode) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //判断方案是否被引用 |
| | | sql = @"select * from TWkm_capac_plan where wkshift_code=@capsetupcode"; |
| | | dynamicParams.Add("@capsetupcode", capsetupcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "删除失败!,该方案已经被产能规划资源引用!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | list.Clear(); |
| | | //删除方案 |
| | | |
| | | sql = @"delete TBas_wkshift_info where code=@code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | code = capsetupcode |
| | | } |
| | | }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "删除成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "删除失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[产能规划查询] |
| | | public static ToMessage CapacityPlanningSearch(string workshop, string devicetype, string stustype, int startNum, int endNum, string prop, string order) |
| | | { |
| | |
| | | { |
| | | if (type == "Add") |
| | | { |
| | | var sql = @"insert into TWkm_capac_plan(wkshop, eqp_typecode, wkshift_code, enable, lm_user, lm_time,classtype) |
| | | values(@wkshop,@eqp_typecode,@wkshift_code,@enable,@lm_user,@lm_time,@classtype)"; |
| | | var sql = @"insert into TWkm_capac_plan(wkshop, eqp_typecode, wkshift_code, enable, lm_user, lm_date,classtype) |
| | | values(@wkshop,@eqp_typecode,@wkshift_code,@enable,@lm_user,@lm_date,@classtype)"; |
| | | dynamicParams.Add("@wkshop", wkshopcode); |
| | | dynamicParams.Add("@eqp_typecode", capunitcode); |
| | | dynamicParams.Add("@wkshift_code", capsetupcode); |
| | | dynamicParams.Add("@enable", "Y"); |
| | | dynamicParams.Add("@lm_user", username); |
| | | dynamicParams.Add("@lm_time", DateTime.Now.ToString()); |
| | | dynamicParams.Add("@lm_date", DateTime.Now.ToString()); |
| | | dynamicParams.Add("@classtype", captplantype); |
| | | int cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | |
| | | sql = @"select CONVERT(varchar(100), wkdate, 23) DataTime,wkshift_code from TWkm_capac_plan_sub where m_id=@captplanid"; |
| | | dynamicParams.Add("@captplanid", captplanid); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | for (int i = 0; i < data.Rows.Count; i++) |
| | | { |
| | | string DataTime = dt.Rows[i]["DataTime"].ToString();//日期 |
| | | string key = dt.Rows[i]["wkshift_code"].ToString(); //方案编码 |
| | | string DataTime = data.Rows[i]["DataTime"].ToString();//日期 |
| | | string key = data.Rows[i]["wkshift_code"].ToString(); //方案编码 |
| | | CapaPlan cmp = new CapaPlan(); |
| | | cmp.name = DataTime; |
| | | cmp.key = key; |
| | |
| | | dynamicParams.Add("@captplanid", captplanid); |
| | | dynamicParams.Add("@datetime", datetime); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | for (int i = 0; i < data.Rows.Count; i++) |
| | | { |
| | | string code = dt.Rows[i]["code"].ToString();//方案编码 |
| | | string name = dt.Rows[i]["name"].ToString();//方案名称 |
| | | string flag = dt.Rows[i]["flag"].ToString(); //选中方案标识 |
| | | string code = data.Rows[i]["code"].ToString();//方案编码 |
| | | string name = data.Rows[i]["name"].ToString();//方案名称 |
| | | string flag = data.Rows[i]["flag"].ToString(); //选中方案标识 |
| | | CapacityPlanSect cmp = new CapacityPlanSect(); |
| | | cmp.CapCode = code; |
| | | cmp.CapName = name; |
| | |
| | | |
| | | string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start from TBas_wkshift_info where code=@code"; |
| | | dynamicParams.Add("@code", code); |
| | | var db = DapperHelper.selectdata(sql, dynamicParams); |
| | | var db = DapperHelper.selectdata(sql1, dynamicParams); |
| | | |
| | | for (int j = 0; j < db.Columns.Count; j++) //时间段 |
| | | { |
| | |
| | | List<CapaPlan> list4 = ids1.Except(ids).ToList(); //表示ids1中哪些值是ids中所不存在的; |
| | | list4 = list3.Union(list4).ToList(); |
| | | //查找关键工序设备、工位群组的所有设备 |
| | | string sql3 = @"select * from( |
| | | select distinct A.code,A.name from TEqpInfo A |
| | | string sql3 = @"select distinct A.code,A.name from TEqpInfo A |
| | | left join TFlw_Rteqp B on A.code=B.eqp_code |
| | | left join TFlw_Rtdt D on B.step_code=D.step_code |
| | | where A.wksp_code=@wkshopcode and D.first_choke='Y' order by A.code)"; |
| | | where A.wksp_code=@wkshopcode and D.first_choke='Y' order by A.code"; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | var dt3 = DapperHelper.selectdata(sql3, dynamicParams); |
| | | if (list4.Count > 0) //如果日期有变动 |
| | |
| | | } |
| | | } |
| | | //更新排产生产资源主表 |
| | | sql = @"update gn_wkm_capac_plan set wkshift_code=@wkshift_code,classtype=@classtype,lm_user=@lm_user,lm_time=@lm_time where id=@id"; |
| | | sql = @"update TWkm_capac_plan set wkshift_code=@wkshift_code,classtype=@classtype,lm_user=@lm_user,lm_date=@lm_time where id=@id"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | //循环写入排产生产资源子表 |
| | | for (int i = 0; i < objs.Count; i++) |
| | | { |
| | | sql = @"insert into TWkm_capac_plan_sub(m_id,wkdate,wkshift_code) values()"; |
| | | sql = @"insert into TWkm_capac_plan_sub(m_id,wkdate,wkshift_code) values(@m_id,@wkdate,@wkshift_code)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | left join (select wo_code, max(TIME_END) MAXTime,min(time_start) MINTime from TK_Wrk_EqpAps group by wo_code) H on A.wo_code=H.wo_code |
| | | left join TUom U on C.uom_code=U.code |
| | | left join TOrganization M on A.wkshp_code=M.org_code |
| | | where E.isbott = 'Y' and A.status='NEW' and A.isaps='Y'"; |
| | | where E.isbott = 'Y' and A.status='NOSCHED' and A.isaps='Y' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | string sy = "0"; |
| | | for (int i = 0; i < dt0.Rows.Count; i++) |
| | | { |
| | | if (dt0.Rows[i]["WKSHOP"].ToString() == wkshpcode) //工单创建车间是否等于排产设备 车间 |
| | | if (dt0.Rows[i]["WKSP_CODE"].ToString() == wkshpcode) //工单创建车间是否等于排产设备 车间 |
| | | { |
| | | sy = "1"; |
| | | break; |
| | |
| | | mes.count = 0; |
| | | mes.Message = "排产设备车间与工单创建的车间不同!"; |
| | | mes.data = null; |
| | | return list; |
| | | } |
| | | else |
| | | { |
| | |
| | | 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='CJ001'and E.eqp_typecode='SBLX001' and E.ClassType='D' |
| | | and CONVERT(varchar(100), F.wkdate, 23)='2022-10-11' and E.enable='Y'"; |
| | | 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", wkshpcode); |
| | | dynamicParams.Add("@eqp_typecode", listData[j].Style.ToString()); |
| | | dynamicParams.Add("@classtype", listData[j].ClassType.ToString()); |
| | |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "排程设备未设置产能!"; |
| | | mes.Message = "当前工单加工产品对应工艺路线设备未设置产能或未设置生产节拍!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | |
| | | string status = dt.Rows[0]["STATUS"].ToString(); |
| | | Decimal nm = 0; //瓶径工序的前置天数 |
| | | Decimal nn = Decimal.Parse(dt.Rows[0]["BottFrointv"].ToString()); //瓶径工序的后置天数 |
| | | if (status != "NEW" && status != "SCHED") //工序任务的状态已经派发(审核) |
| | | if (status != "NEW" && status != "SCHED" && status != "NOSCHED") //工序任务的状态已经派发(审核) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | |
| | | { |
| | | sql = @"insert into TK_Wrk_EqpApsSum (wo_code,eqp_code,step_taid,p_date, t_date, qty,status) |
| | | select min(wo_code),min(eqp_code),min(step_taid),min(time_start),max(time_end),sum(Alloc_Qty),'NEW' from TK_Wrk_EqpAps |
| | | where wo_code=@wocode and eqp_code=''"; |
| | | where wo_code=@wocode and eqp_code=@eqp_code"; |
| | | list.Add(new { str = sql, parm = new { wocode = wocode, eqp_code = dt1.Rows[i]["EQP_CODE"].ToString() } }); |
| | | } |
| | | |
| | |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | |
| | | list.Clear(); |
| | | //写入设备任务(汇总表)用料 计划数量*子件基本用量*(1+损耗率)/母件基本用量 |
| | | sql = @"insert into TK_Wrk_EqpSum_Allo(m_id, seq, invcode, qty,wo_code,pn_type) |
| | | sql = @"insert into TK_Wrk_EqpSum_Allo(m_id, seq, materiel_code, qty,wo_code,materieltype) |
| | | select A.id M_id, B.seq,B.materiel_code,(round(A.qty,2)*BE.Base_Quantity*(1+BE.LOSS_QUANTITY/100))/BM.quantity qty,A.wo_code,B.materieltype |
| | | from TK_Wrk_EqpApsSum A |
| | | left join TK_Wrk_Allo B on A.Wo_Code= B.Wo_Code |
| | |
| | | } |
| | | }); |
| | | //主工单的“计划开机日期 = 瓶径工序的预开工日期 - 瓶径工序的前置日期) 主工单:计划完工日期 = 瓶径工序的预完工日期 + 瓶径工序的后置日期 |
| | | sql = @"update mes_tk_wrk_man set status='SCHED',plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), exchag='Y',allocfag='N' where wo_code =@wocode"; |
| | | sql = @"update TK_Wrk_Man set status='SCHED',plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), exchag='Y',allocfag='N' where wo_code =@wocode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |