VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -700,7 +700,7 @@
        #endregion
        #region[MES工单关闭]
        public static ToMessage ClosedMesOrder(string wocode, string m_po)
        public static ToMessage ClosedMesOrder(string username,string wocode, string m_po)
        {
            var sql = "";
            List<object> list = new List<object>();
@@ -711,8 +711,8 @@
                sql = @"update TK_Wrk_Step set status='CLOSED'  where wo_code=@wocode";
                list.Add(new { str = sql, parm = new { wocode = wocode } });
                //回写工单表状态为(关闭)
                sql = @"update TK_Wrk_Man set status='CLOSED'  where wo_code=@wocode";
                list.Add(new { str = sql, parm = new { wocode = wocode } });
                sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate  where wo_code=@wocode";
                list.Add(new { str = sql, parm = new { wocode = wocode, username = username, closedate=DateTime.Now.ToString() } });
                bool aa = DapperHelper.DoTransaction(list);
                if (aa)
                {
@@ -1367,7 +1367,7 @@
                    dynamicParams.Add("@usercode", usercode);
                }
                //班组获取人员列表
                sql = @"select usercode,username  from TUser where is_delete<>'1' " + search;
                sql = @"select usercode,username  from TUser where is_delete<>'1' and usercode<>'9999'" + search;
                dynamicParams.Add("@usercode", usercode);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                mes.code = "200";
@@ -2342,5 +2342,182 @@
        }
        #endregion
        #region[MES工单批量关闭查询]
        public static ToMessage MesOrderBitchClosedSearch(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)
        {
            var dynamicParams = new DynamicParameters();
            string search = "";
            try
            {
                if (mesorderstus != "" && mesorderstus != null)
                {
                    search += "and A.status=@mesorderstus ";
                    dynamicParams.Add("@mesorderstus", mesorderstus);
                }
                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 (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.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
                            ,(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 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' " + 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[MES工单批量关闭提交]
        public static ToMessage MesOrderBitchClosedSeave(string username, DataTable dt)
        {
            var sql = "";
            List<object> list = new List<object>();
            var dynamicParams = new DynamicParameters();
            try
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //关闭工单对应工序任务
                    sql = @"update TK_Wrk_Step set status='CLOSED'  where wo_code=@wocode";
                    list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } });
                    //回写工单表状态为(关闭)
                    sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate  where wo_code=@wocode";
                    list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.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[MES工单批量反关闭]
        public static ToMessage MesOrderBitchAntiClosedSeave(string username, DataTable dt)
        {
            var sql = "";
            List<object> list = new List<object>();
            var dynamicParams = new DynamicParameters();
            try
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //关闭工单对应工序任务
                    sql = @"update TK_Wrk_Step set status='START'  where wo_code=@wocode";
                    list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } });
                    //回写工单表状态为(关闭)
                    sql = @"update TK_Wrk_Man set status='START',closeuser=@username,closedate=@closedate  where wo_code=@wocode";
                    list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.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
    }
}