duhe
2024-09-09 be28a6a14688557cd12b3fdb97b117cd4cb52fde
WebAPI/Controllers/SCGL/Sc_MESTransFerWorkBillController.cs
@@ -528,7 +528,8 @@
                return new ApiResult<DataSet> { code = -1, msg = "ID不能为空" };
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            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.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.HReceiveMan,A.HCopyMan,A.HHasten,
                                        A.HLevel,A.HMaterNumber,A.HMaterName,A.HMaterModel,
@@ -540,6 +541,10 @@
                                        left join Gy_Department D on A.HDeptID=D.HItemID
                              left join Gy_Employee f on A.HHandleEmpID=f.HItemID     
                                        left join Gy_ErrMsgBackType g on A.HErrMsgBackTypeID=g.HItemID
                                        left join Gy_Employee f1 on a.HBadProcMan=f1.HItemID
                              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
                                        where A.HInterID='" + HID + "' and b.HEntryID='" + HEntryID + "'");
            var dataSet = oCN.RunProcReturn(sql, "OA_ErrMsgBackBillMain");
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
@@ -4814,8 +4819,8 @@
            {
                List<object> columnNameList = new List<object>();
                string sql = "select * from h_v_OA_AndengFlowRuleBillMainList where hmainid='" + HID + "'";
                ds = oCN.RunProcReturn(sql, "h_v_OA_AndengFlowRuleBillMainList");
                string sql = "select * from h_v_OA_AndengFlowRuleBillMainEdit where hmainid='" + HID + "'";
                ds = oCN.RunProcReturn(sql, "h_v_OA_AndengFlowRuleBillMainEdit");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -6623,10 +6628,31 @@
        /// <returns></returns>
        public async Task<object> SendDingDingAsync(string HSendMan, int HHandleEmpID,string HDescription,string HCopyMan)
        {
            string concatenatedNames = "";
            string appKey = "";
            string appSecret = "";
            string sReturn = "";
            string agentIds = "";
            Cls_DDMsg msg = new Cls_DDMsg();
            string appKey = "dingrsrzhdyn3mlaof95";
            string appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq";
            if (oSystemParameter.ShowBill(ref sReturn) == true)
            {
                //系统参数是否 N为本地,Y为斯莫尔
                if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "N")
                {
                    appKey = "dingrsrzhdyn3mlaof95";
                     appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq";
                    agentIds = "3118119317";
                }
                else if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "Y")
                {
                    appKey = "dingkdddbhdcssk7jduw";
                    appSecret = "iv07c-GLfJPnzfJaNAAOfJDl3Z-eODvDAhlInMZCZhGorkle5Evbaxx3ImylvdjQ";
                    agentIds = "3151454458";
                }
            }
            if (HHandleEmpID==0) //异常反馈验收单保存  将消息 发送给 接收人,指派处理人,全部抄送人 
            {
                string HReceiveMan = HSendMan;
@@ -6654,7 +6680,7 @@
                //获取发送人  接收人
                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++)
                {
@@ -6672,6 +6698,7 @@
                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, "异常罚款");
                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
                List<string> HNames = new List<string>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
@@ -6681,6 +6708,7 @@
                }
                concatenatedNames = string.Join(",", HNames);
                LogService.CustomWriteLog("9参数" + concatenatedNames, "异常罚款");
            }
          
            //获取企业的access_token的值
@@ -6690,7 +6718,7 @@
            string accessToken = responseJson["accessToken"].ToString();
            //调用方法发送消息           
            string agentId = "3118119317";//钉钉后台建立的小程序id
            string agentId = agentIds;//钉钉后台建立的小程序id
            string userIdList = concatenatedNames;//钉钉人员的id
            string deptIdList = "0"; // 空字符串表示不指定部门
            string toAllUser = "false";
@@ -6760,7 +6788,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.HPlanQty 计划数量,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");
                //添加列名
@@ -6836,18 +6865,67 @@
        {
            try
            {
                //string sReturn = "";
                List<object> columnNameList = new List<object>();
                //根据当前人获取职务
                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();
                //根据职务找到他的上级
                string sql1 = "select *  from Gy_Duty where HParentID=(select HParentID 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");
                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 Job1= ds.Tables[0].Rows[0]["HName"].ToString(); 
                //用上级的职务找到用户
                string sql2 = "select a.Czymc 用户名称  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(sql2, "Gy_Czygl");
                //用职务找到用户
                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");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 报工台跳转异常反馈单 弹窗获取 设备编码
        [Route("Sc_MESTransFerWorkBill/set_EquipFile")]
        [HttpGet]
        public object set_EquipFile(string HSourceName)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql = "select a.HEquipFileNumber 设备编码 ,a.HName 设备名称 from Gy_EquipFileBillMain a left join Gy_Source b on a.HSourceID = b.HItemID where b.HName ='" + HSourceName   + "'";
                ds = oCN.RunProcReturn(sql, "Gy_ErrMsgBackType");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {