| | |
| | | #endregion |
| | | |
| | | #region[存货档案关联工艺路线提交] |
| | | public static ToMessage SaveInventoryFile(string partcode,string defaultroute_code, string username, List<ObjectData> json) |
| | | public static ToMessage SaveInventoryFile(string partcode, string defaultroute_code, string username, List<ObjectData> json) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | } |
| | | //标记物料表关联工艺路线标识 |
| | | sql = @"update TMateriel_Info set proute_id='Y',default_route=@defaultroute_code where partcode=@partcode"; |
| | | list.Add(new { str = sql, parm = new { partcode = partcode, defaultroute_code= defaultroute_code } }); |
| | | list.Add(new { str = sql, parm = new { partcode = partcode, defaultroute_code = defaultroute_code } }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[物料清单主列表查询] |
| | | public static ToMessage BoIventorySelect(string parentpartcode, string parentpartname, string parentpartspec, string parttype, string status, string version, string createusername, string createopendate, string createclosedate, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (parentpartcode != "" && parentpartcode != null) |
| | | { |
| | | search += "and M.partcode like '%'+@parentpartcode+'%' "; |
| | | dynamicParams.Add("@parentpartcode", parentpartcode); |
| | | } |
| | | if (parentpartname != "" && parentpartname != null) |
| | | { |
| | | search += "and M.partname like '%'+@parentpartname+'%' "; |
| | | dynamicParams.Add("@parentpartname", parentpartname); |
| | | } |
| | | if (parentpartspec != "" && parentpartspec != null) |
| | | { |
| | | search += "and M.partspec like '%'+@parentpartspec+'%' "; |
| | | dynamicParams.Add("@parentpartspec", parentpartspec); |
| | | } |
| | | if (parttype != "" && parttype != null) |
| | | { |
| | | search += "and M.stocktype_code=@parttype "; |
| | | dynamicParams.Add("@parttype", parttype); |
| | | } |
| | | if (status != "" && status != null) |
| | | { |
| | | search += "and A.status=@status "; |
| | | dynamicParams.Add("@status", status); |
| | | } |
| | | if (version != "" && version != null) |
| | | { |
| | | search += "and A.version like '%'+@version+'%' "; |
| | | dynamicParams.Add("@version", version); |
| | | } |
| | | if (createusername != "" && createusername != null) |
| | | { |
| | | search += "and U.username like '%'+@createusername+'%' "; |
| | | dynamicParams.Add("@createusername", createusername); |
| | | } |
| | | if (createopendate != "" && createopendate != null) |
| | | { |
| | | search += "and A.lm_date between @createopendate and @createclosedate "; |
| | | dynamicParams.Add("@createopendate", createopendate + " 00:00:00"); |
| | | dynamicParams.Add("@createclosedate", createclosedate + " 23:59:59"); |
| | | } |
| | | if (search == "") |
| | | { |
| | | search = "and 1=1 "; |
| | | } |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.id, M.partcode,M.partname,M.partspec,M.stocktype_code,D.name as stocktype_name,M.uom_code,T.name as uom_name, |
| | | A.quantity,A.status,A.startdate,A.version,U.username,A.lm_date |
| | | from TBom_Main A |
| | | left join TMateriel_Info M on A.materiel_code=M.partcode |
| | | left join TUom T on M.uom_code=T.code |
| | | left join TUser U on A.lm_user=U.usercode |
| | | left join T_Dict D on M.stocktype_code=D.code |
| | | where A.is_delete<>'1' " + 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 MaterielDetailedVsion(string parentpartcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | sql = @"select substring(version,charindex('V',version)+1,len(version)-charindex('V',version))+1 as version |
| | | from TBom_Main where materiel_code=@parentpartcode"; |
| | | dynamicParams.Add("@parentpartcode", parentpartcode); |
| | | var data = DapperHelper.selecttable(sql); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "获取版本号成功!"; |
| | | mes.data = "V" + data.Rows[0]["version"].ToString(); |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | 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 AddUpdateBoIventory(string bomid, string parentpartcode, string parentpartname, string parentpartspec, string status, string uomcode, string quantity, string startdate, string version, string username, string opertype, List<BomSub> objs) |
| | | { |
| | | string sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | if (opertype == "Add") |
| | | { |
| | | //获取主表最大ID |
| | | string sql0 = @"select ISNULL(IDENT_CURRENT('TBom_Main')+1,1) as id"; |
| | | var dt = DapperHelper.selecttable(sql0); |
| | | //写入BOM主表 |
| | | sql = @"insert into TBom_Main(materiel_code,quantity,status,version,lm_user,lm_date) |
| | | values(@materiel_code,@quantity,@status,@version,@username,@CreateDate)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = parentpartcode, |
| | | quantity = quantity, |
| | | status = status, |
| | | version = version, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | //写入BOM子表 |
| | | for (int i = 0; i < objs.Count; i++) |
| | | { |
| | | sql = @"insert into TBom_Deta(m_id,seq,smateriel_code,base_quantity,loss_quantity,total_quantity,pn_type) |
| | | values(@m_id,@seq,@smateriel_code,@base_quantity,@loss_quantity,@total_quantity,@pn_type)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | m_id = dt.Rows[0]["id"].ToString(), |
| | | seq = objs[i].seq.ToString(), |
| | | smateriel_code = objs[i].smaterirl_code.ToString(), |
| | | base_quantity = objs[i].base_quantity.ToString(), |
| | | loss_quantity = objs[i].loss_quantity.ToString(), |
| | | total_quantity = objs[i].total_quantity.ToString(), |
| | | pn_type = objs[i].pn_type.ToString() |
| | | } |
| | | }); |
| | | } |
| | | 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; |
| | | } |
| | | } |
| | | if (opertype == "Update") |
| | | { |
| | | //修改BOM主表基本用量、启用状态 |
| | | sql = @"update TBom_Main set quantity=@quantity,status=@status,lm_user=@lm_user,lm_date=@lm_date where materiel_code=@materiel_code and id=@bomid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | id = bomid, |
| | | materiel_code = parentpartcode, |
| | | quantity = quantity, |
| | | status = status, |
| | | username = username, |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | //删除BOM子表 |
| | | sql = @"delete TBom_Deta where m_id=@bomid"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | id = bomid |
| | | } |
| | | }); |
| | | //写入BOM子表 |
| | | for (int i = 0; i < objs.Count; i++) |
| | | { |
| | | sql = @"insert into TBom_Deta(m_id,seq,smateriel_code,base_quantity,loss_quantity,total_quantity,pn_type) |
| | | values(@m_id,@seq,@smateriel_code,@base_quantity,@loss_quantity,@total_quantity,@pn_type)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | m_id = bomid, |
| | | seq = objs[i].seq.ToString(), |
| | | smateriel_code = objs[i].smaterirl_code.ToString(), |
| | | base_quantity = objs[i].base_quantity.ToString(), |
| | | loss_quantity = objs[i].loss_quantity.ToString(), |
| | | total_quantity = objs[i].total_quantity.ToString(), |
| | | pn_type = objs[i].pn_type.ToString() |
| | | } |
| | | }); |
| | | } |
| | | 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 BoIventorySelectView(string bomid) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //获取Bom子表数据 |
| | | sql = @"select A.seq,B.partcode,B.partname,B.partspec,B.uom_code,T.name as uom_name, |
| | | A.base_quantity,A.loss_quantity,A.total_quantity,A.pn_type |
| | | from TBom_Deta A |
| | | left join TMateriel_Info B on A.smateriel_code=B.partcode |
| | | left join TUom T on B.uom_code=T.code |
| | | where A.m_id=@bomid"; |
| | | dynamicParams.Add("@bomid", bomid); |
| | | 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[工艺路线查询] |
| | |
| | | var data_10 = DapperHelper.selectdata(sql_10, dynamicParams); |
| | | if (data_10.Rows.Count > 0) |
| | | { |
| | | if (data_10.Rows[0]["FLWTYPE"].ToString() != steptypecode) |
| | | if (data_10.Rows[0]["FLWTYPE"].ToString() != steptypecode) |
| | | { |
| | | //删除工序关联工作站表 |
| | | sql_1 = @"delete TFlw_Rteqp where step_code=@stepcode"; |
| | |
| | | |
| | | sql_1 = @"update TStep set stepname=@stepname,flwtype=@steptypecode,enable=@enable,descr=@description, |
| | | lm_user=@username,lm_date=@CreateDate where id=@stepid"; |
| | | list.Add(new { str = sql_1, parm = new { stepid = stepid, stepname= stepname, steptypecode = steptypecode, enable= enable, description = description, username= username, CreateDate= DateTime.Now.ToString() } }); |
| | | list.Add(new { str = sql_1, parm = new { stepid = stepid, stepname = stepname, steptypecode = steptypecode, enable = enable, description = description, username = username, CreateDate = DateTime.Now.ToString() } }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | string sql = ""; |
| | | try |
| | | { |
| | | //获取设备类型数据 |
| | | sql = @"select partcode,partname,partspec from TMateriel_Info where is_delete<>'1' "; |
| | | //获取物料数据 |
| | | sql = @"select M.partcode,M.partname,M.partspec,M.uom_code,T.name as uom_name, |
| | | M.stocktype_code,D.name as stocktype_name,M.stck_code,S.name as stck_name |
| | | from TMateriel_Info M |
| | | left join TUom T on M.uom_code=T.code |
| | | left join T_Dict D on M.stocktype_code=D.code |
| | | left join T_Sec_Stck S on M.stck_code=S.code |
| | | where M.is_delete<>'1' "; |
| | | var data = DapperHelper.selecttable(sql); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |