1
zrg
2024-11-25 59f31f0caeef6fb37f397646efbcd19738299122
WebAPI/Controllers/SCGL/Sc_MESTransFerWorkBillController.cs
@@ -530,7 +530,7 @@
            string sql =string.Format(@"select A.HInterID,b.HEntryID,A.HBillStatus,A.HBillNo,A.HDate,A.HContext,A.HDescription,A.HRemark,
                                      A.HQty,A.HSendType,a.HForm,a.HChangeNote,a.HNote,a.HBadProcMan,f1.HName HBadProcManName,
                              a.HQEMan,f2.HName HQEManName,a.HSourceID,s.HName HSourceName,a.HShiftsID,s1.HName HShiftsName,
                                        A.HDeptID,D.HName HDeptName, A.HSendMan,
                                        A.HDeptID,D.HName HDeptName, A.HSendMan,a.HCenterID HCenterID,wo.HName HCenterName,
                                        A.HReceiveMan,A.HCopyMan,A.HHasten,
                                        A.HLevel,A.HMaterNumber,A.HMaterName,A.HMaterModel,
                                        B.HReadFlag, A.HMaker,A.HMakeDate,A.HUpDater,A.HUpDateDate,A.HChecker,A.HCheckDate,A.HCloseMan,A.HCloseDate,A.HDeleteMan,A.HDeleteDate,
@@ -545,6 +545,7 @@
                              left join Gy_Employee f2 on a.HQEMan=f2.HItemID
                              left join Gy_Source s on a.HSourceID=s.HItemID
                              left join Gy_Shifts s1 on a.HShiftsID=s1.HItemID
                                        left join Gy_WorkCenter wo on a.HCenterID=wo.HItemID
                                        where A.HInterID='" + HID + "' and b.HEntryID='" + HEntryID + "'");
            var dataSet = oCN.RunProcReturn(sql, "OA_ErrMsgBackBillMain");
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
@@ -1839,7 +1840,7 @@
        [Route("OA_ErrMsgBackSignBill_BrushCard/ErrMsgBackReceive")]
        [HttpGet]
        public object ErrMsgBackReceive(string sWhere, string user)
        public object ErrMsgBackReceive(string sWhere,string num, string user)
        {
            try
            {
@@ -1854,18 +1855,38 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                if (num=="2")       //报工台获取刷卡签到数据
                {
                    string sql = "select * from h_v_OA_ErrMsgBackReceiveBillList_BrushCard order by 单据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillList_BrushCard");
                    if (sWhere == null || sWhere.Equals(""))
                    {
                        string sql = "select * from h_v_SingOA_ErrMsgBackList_BrushCard order by 单据号 desc";
                        ds = oCN.RunProcReturn(sql, "h_v_SingOA_ErrMsgBackList_BrushCard");
                    }
                    else
                    {
                        string sql1 = "select * from h_v_SingOA_ErrMsgBackList_BrushCard where 1 = 1 ";
                        string sql = sql1 + sWhere + " order by 单据号 desc";
                        ds = oCN.RunProcReturn(sql, "h_v_SingOA_ErrMsgBackList_BrushCard");
                    }
                }
                else
                else   //原有的刷卡签到获取数据
                {
                    string sql1 = "select * from h_v_OA_ErrMsgBackReceiveBillList_BrushCard where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by 单据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillList_BrushCard");
                    {
                        if (sWhere == null || sWhere.Equals(""))
                        {
                            string sql = "select * from h_v_OA_ErrMsgBackReceiveBillList_BrushCard order by 单据号 desc";
                            ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillList_BrushCard");
                        }
                        else
                        {
                            string sql1 = "select * from h_v_OA_ErrMsgBackReceiveBillList_BrushCard where 1 = 1 ";
                            string sql = sql1 + sWhere + " order by 单据号 desc";
                            ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillList_BrushCard");
                        }
                    }
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -2925,7 +2946,7 @@
                {
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    _ = SendDingDingAsync(oBill.omodel.HSendMan, 1, oBill.omodel.HDescription, oBill.omodel.HReceiveMan);
                    _ = SendDingDingAsync(oBill.omodel.HSendMan, 2, oBill.omodel.HDescription, oBill.omodel.HReceiveMan);
                }
                else if (refSav == "Update")
                {
@@ -6653,7 +6674,7 @@
            }
            if (HHandleEmpID==0) //异常反馈验收单保存  将消息 发送给 接收人,指派处理人,全部抄送人
            if (HHandleEmpID==0) //
            {
                string HReceiveMan = HSendMan;
                string[] names = HCopyMan.Split(',');
@@ -6674,13 +6695,14 @@
                }
                concatenatedNames = string.Join(",", HNames);
                HDescription = HDescription + "--已验收";
            }
            else if (HHandleEmpID==1)//异常反馈签到单,异常反馈处理单  将消息 发送给 发送人,接收人
            else if (HHandleEmpID==1)//异常反馈处理单  将消息 发送给 发送人,接收人
            {
                //获取发送人  接收人
                string HReceiveMan = HCopyMan;
                string sql1 = "select HDingDingUserID 钉钉id from Gy_Czygl where Czymc in ('" + HSendMan + "','" + HReceiveMan + "')";
                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
                List<string> HNames = new List<string>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
@@ -6689,16 +6711,13 @@
                }
                concatenatedNames = string.Join(",", HNames);
                HDescription = HDescription + "--已签到";
            }
            else
            else if (HHandleEmpID == 2)//异常反馈处理单  将消息 发送给 发送人,接收人
            {
                //查询指派处理人
                string sql = "select HName from Gy_Employee where HItemID='" + HHandleEmpID + "'";
                ds = oCN.RunProcReturn(sql, "Gy_Employee");
                string HHandleEmpName = ds.Tables[0].Rows[0]["HName"].ToString();
                //获取指派处理人,发送人的钉钉id
                string sql1 = "select HDingDingUserID 钉钉id from Gy_Czygl where Czymc in ('" + HSendMan + "','" + HHandleEmpName + "')";
                LogService.CustomWriteLog("10参数" + sql1, "异常罚款");
                //获取发送人  接收人
                string HReceiveMan = HCopyMan;
                string sql1 = "select HDingDingUserID 钉钉id from Gy_Czygl where Czymc in ('" + HSendMan + "','" + HReceiveMan + "')";
                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
                List<string> HNames = new List<string>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
@@ -6708,7 +6727,26 @@
                }
                concatenatedNames = string.Join(",", HNames);
                LogService.CustomWriteLog("9参数" + concatenatedNames, "异常罚款");
                HDescription = HDescription + "--已处理";
            }
            else
            {
                //查询指派处理人
                string sql = "select HName from Gy_Employee where HItemID='" + HHandleEmpID + "'";
                ds = oCN.RunProcReturn(sql, "Gy_Employee");
                string HHandleEmpName = ds.Tables[0].Rows[0]["HName"].ToString();
                //获取指派处理人,发送人的钉钉id
                string sql1 = "select HDingDingUserID 钉钉id from Gy_Czygl where Czymc in ('" + HSendMan + "','" + HHandleEmpName + "')";
                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
                List<string> HNames = new List<string>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string HName = ds.Tables[0].Rows[i]["钉钉id"].ToString();
                    HNames.Add(HName);
                }
                concatenatedNames = string.Join(",", HNames);
                HDescription = HDescription + "--已接收";
            }
          
            //获取企业的access_token的值
@@ -6733,13 +6771,21 @@
        [Route("Sc_MESTransFerWorkBill/GetSc_MESTransFerWorkBillQuery")]
        [HttpGet]
        public object GetSc_MESTransFerWorkBillQuery(string user)
        public object GetSc_MESTransFerWorkBillQuery(string sWhere, string user)
        {
            try
            {
                Dictionary<object, object> dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<object, object>>(sWhere);
                string HStatus = dic["HStatus"].ToString();//时间状态
                string HBeginDate = dic["HBeginDate"].ToString();//开始日期
                string HEndDate = dic["HEndDate"].ToString();//结束日期
                string HSourceID = dic["HSourceID"].ToString();//生产资源
                List<object> columnNameList = new List<object>();
                ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackSelfQuery " + user, "h_p_OA_ErrMsgBackSelfQuery");
                ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackSelfQuery  '" + HStatus + "','" + HBeginDate + "','" + HEndDate + "','" + HSourceID + "','" + user + "'"  , "h_p_OA_ErrMsgBackSelfQuery");
                if (ds.Tables[0].Rows.Count != 0 || ds != null)
                {
@@ -6788,7 +6834,8 @@
            {
                List<object> columnNameList = new List<object>();
                string sql = "select a.HSourceBillNo 流转卡号,a.HSourceBillType 流转卡类型,a.HSourceInterID 流转卡主内码,a.HSourceEntryID 流转卡子内码,b.HNumber 物料代码,b.HName 物料名称,b.HModel 规格型号,a.HPlanQty 计划数量 from Sc_ICMOBillStatus_Tmp a left join Gy_Material b on a.HMaterID=b.HItemID where HSourceBillNo='" + HSourceBill + "'";
                string sql = "select a.HSourceBillNo 流转卡号,a.HSourceBillType 流转卡类型,a.HSourceInterID 流转卡主内码,a.HSourceEntryID 流转卡子内码,b.HNumber 物料代码,b.HName 物料名称,b.HModel 规格型号,a.HDatePlanQty 计划数量,a.HSourceID,c.HName 生产资源 from Sc_ICMOBillStatus_Tmp a " +
                    "left join Gy_Material b on a.HMaterID=b.HItemID  left join Gy_Source c on a.HSourceID=c.HItemID where HSourceBillNo='" + HSourceBill + "'";
                ds = oCN.RunProcReturn(sql, "Sc_ICMOBillStatus_Tmp");
                //添加列名
@@ -6870,19 +6917,13 @@
                string sql = "select a.Czymc 用户名称,c.GroupName 职务 from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId left join System_UserGroup c on b.GroupId = c.GroupID  where a.Czymc = '"+HName+"'";
                ds = oCN.RunProcReturn(sql, "Gy_ErrMsgBackType");
                string Job = ds.Tables[0].Rows[0]["职务"].ToString();
                if (Job=="注塑班组长" || Job=="后处理班组长")
                {
                    //根据职务找到他的下级,给发送人默认为班组长之下
                    string sql1 = "select * from Gy_Duty where HParentID =(select HItemID from Gy_Duty group by HItemID, HName having HName = '"+Job+"' and count(*) = 1)";
                    ds = oCN.RunProcReturn(sql1, "Gy_Duty");
                }
                else
                {
                    //根据职务找到他的上级
                    string sql2 = "select * from Gy_Duty where HItemID =(select HParentID from Gy_Duty group by HParentID, HName having HName = '" + Job + "' and count(*) = 1)";
                    ds = oCN.RunProcReturn(sql2, "Gy_Duty");
                }
                //根据职务找到他的上级,给发送人默认为当前登录人
                string sql1 = "select * from Gy_Duty where HItemID =(select HParentID from Gy_Duty group by HParentID, HName having HName = '" + Job + "' and count(*) = 1))";
                ds = oCN.RunProcReturn(sql1, "Gy_Duty");
                string Job1= ds.Tables[0].Rows[0]["HName"].ToString(); 
                //用职务找到用户
                string sql3 = "select a.Czymc 用户名称,c.GroupName 职务  from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId left join System_UserGroup c on b.GroupId = c.GroupID  where c.GroupName = '" + Job1+"'";
                ds = oCN.RunProcReturn(sql3, "Gy_Czygl");