| | |
| | | using DbType = System.Data.DbType; |
| | | using System.Data; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory; |
| | | using AlibabaCloud.TeaUtil.Models; |
| | | using MES.Service.Modes.QcIssueResult; |
| | | using Newtonsoft.Json; |
| | | using System.Diagnostics; |
| | | using Tea; |
| | | using MES.Service.Modes.DingAPI; |
| | | using static System.Runtime.InteropServices.JavaScript.JSType; |
| | | using System; |
| | | using System.Security.Cryptography; |
| | | using SqlSugar.Extensions; |
| | | using Masuit.Tools.Reflection; |
| | | |
| | | namespace MES.Service.service.QC; |
| | | |
| | |
| | | //if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) |
| | | // lineNo = _baseService.getUserLineNo(queryObj.StatusUser); |
| | | |
| | | var data = db.Queryable<SJPageResult>() |
| | | var data = db.Queryable<SJPageResult, Womdaa, Womcaa, SysDepartment, MesUserDepartmentQc,MesItems> ((a, |
| | | da,ca,d,dq,i) => |
| | | new JoinQueryInfos( |
| | | JoinType.Left, Convert.ToDecimal(a.Pbaid) == da.Id, // 关联工单信息 |
| | | JoinType.Left, da.Daa021 == ca.Caa020,//任务单,用于查询销售订单号 |
| | | JoinType.Left, d.Departmentid == Convert.ToDecimal(da.Daa013),//查询车间 |
| | | JoinType.Left, dq.Departmentcode == d.Departmentcode,//查询用户权限 |
| | | JoinType.Left, i.Id == Convert.ToDecimal(da.Daa002)//查询用户权限 |
| | | )) |
| | | //.WhereIF(lineNo != null && lineNo.Length > 0, |
| | | // a => lineNo.Contains(a.line)) |
| | | .WhereIF(queryObj.Id != null, a => a.Id == queryObj.Id) |
| | |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | !"未完成".Equals(queryObj.Result), |
| | | a => a.FSubmit == "1") |
| | | //匹配权限 |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.LoginUser), |
| | | (a, da, ca, d, dq) => dq.Usercode == queryObj.LoginUser) |
| | | //匹配搜索字符串 |
| | | .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue), |
| | | (a, da, ca, d, dq,i) => |
| | | a.BillNo.ToLower().Contains(queryObj.SearchValue.ToLower())|| |
| | | i.ItemName.ToLower() .Contains(queryObj.SearchValue.ToLower()) || |
| | | ca.Caa015.ToLower().Contains(queryObj.SearchValue.ToLower()) || |
| | | i.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower())) |
| | | .Select((a, da, ca, d, dq) => new SJPageResult |
| | | { |
| | | Id = a.Id, |
| | | BillNo = a.BillNo, |
| | | StatusDate = a.StatusDate, |
| | | FName = a.FName, |
| | | Result = a.Result, |
| | | FSubmit = a.FSubmit, |
| | | FSubmitBy = a.FSubmitBy, |
| | | FSubmitDate = a.FSubmitDate, |
| | | MoidNum = a.MoidNum, |
| | | StatusUser = a.StatusUser, |
| | | Pbaid = a.Pbaid, |
| | | CreateTime = a.CreateTime, |
| | | Comments = a.Comments, |
| | | ItemMod = a.ItemMod, |
| | | ItemNo = a.ItemNo, |
| | | daa001 = a.daa001, |
| | | line = a.line, |
| | | Remarks = a.Remarks, |
| | | Daa003 = a.Daa003, |
| | | Daa004 = a.Daa004, |
| | | Daa008 = a.Daa008, |
| | | LineName = a.LineName, |
| | | SaleOrder = ca.Caa015, |
| | | DepartName = d.Departmentname, |
| | | PlanName = a.PlanName |
| | | }) |
| | | .OrderBy(a => a.CreateTime, OrderByType.Desc); |
| | | var items = data.ToPageList(queryObj.PageIndex, queryObj.Limit,ref totalCount); |
| | | |
| | |
| | | // result = "未检测" |
| | | // }).ToList(); |
| | | // } |
| | | public List<QsItemIpiItem> SetQSItems(string itemNo) |
| | | public List<QsItemIpiItem> SetQSItems(string itemNo,string planName) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var count = db.Queryable<MesQa>().Where(s => s.QsType == "1" |
| | | && s.ItemNo == itemNo && s.Fsubmit == 1).Count(); |
| | | && s.ItemNo == itemNo &&s.QaPlan == planName && s.Fsubmit == 1).Count(); |
| | | |
| | | if (count <= 0) return []; |
| | | |
| | | return db |
| | | .Queryable<MesQualityStandard>() |
| | | .Where(b => b.QsType == "1" && b.ItemNo == itemNo).Select( |
| | | //新增根据计划名称查询ID |
| | | decimal? QsId = db.Queryable<MesQa>() |
| | | .Where(s => s.QsType == "1" |
| | | && s.ItemNo == itemNo |
| | | && s.QaPlan == planName |
| | | && s.Fsubmit == 1) |
| | | .Select(s => s.Id) |
| | | .First(); |
| | | |
| | | return db //根据主表ID查询 |
| | | .Queryable<MesQualityStandard>() |
| | | .Where(b => b.Pid == QsId).Select( |
| | | b => new QsItemIpiItem |
| | | { |
| | | ProjName = b.ProjName, |
| | |
| | | }).ToList(); |
| | | } |
| | | |
| | | public List<SJBadReason>? GetReason(string billNo)//纠正措施单获取不良信息 |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var count = db.Queryable<SJBadReason>().Where(s => s.BillNo == billNo).Count(); |
| | | |
| | | if (count <= 0) return null; |
| | | |
| | | var reason = db |
| | | .Queryable<SJBadReason>() |
| | | .Where(s => s.BillNo == billNo).Select( |
| | | b => new SJBadReason |
| | | { |
| | | Reason =b.Reason |
| | | }).ToList(); |
| | | |
| | | return reason; |
| | | } |
| | | |
| | | public List<QsItemIpiItem> getQSItems(decimal? pid, decimal? id) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | var qsItemIpiItems = db |
| | | .Queryable<QsItemIpiItem>() |
| | | .WhereIF(pid > 0, a => a.Pid == pid) |
| | | .WhereIF(id > 0, a => a.Id == id).ToList(); |
| | | var qsItemIpiItems = db.Queryable<QsItemIpiItem>().WhereIF(pid > 0, a => a.Pid == pid).WhereIF(id > 0, a => a.Id == id).ToList(); |
| | | |
| | | var array = qsItemIpiItems.Select(s => s.Id).ToArray(); |
| | | var qsItemIpiItemDetails = db.Queryable<QsItemIpiItemDetail>() |
| | | .Where(s => array.Contains(s.Pid)) |
| | | .GroupBy(s => s.Pid) |
| | | var qsItemIpiItemDetails = db.Queryable<QsItemIpiItemDetail>().Where(s => array.Contains(s.Pid)).GroupBy(s => s.Pid) |
| | | .Select(s => new |
| | | { |
| | | s.Pid, |
| | |
| | | }); |
| | | |
| | | //使用linq表达式过滤出图片id不为空的数据 |
| | | var itemIpiItems = |
| | | qsItemIpiItems.Where(s => s.Picture is { Length: > 0 }) |
| | | .ToList(); |
| | | var itemIpiItems =qsItemIpiItems.Where(s => s.Picture is { Length: > 0 }).ToList(); |
| | | if (itemIpiItems.Count > 0) |
| | | itemIpiItems.ForEach(s => |
| | | { |
| | |
| | | db => |
| | | { |
| | | qsItemIpiReq.StatusDate = DateTime.Now; |
| | | var pid = db.Insertable(qsItemIpiReq) |
| | | .ExecuteReturnIdentity(); |
| | | var pid = db.Insertable(qsItemIpiReq).ExecuteReturnIdentity(); |
| | | qsItemIpiReq.Id = pid; |
| | | |
| | | item.gid = pid; |
| | | |
| | | qsItemIpiItems.ForEach(s => s.Pid = pid); |
| | | |
| | | return db.Insertable(qsItemIpiItems) |
| | | .ExecuteCommand(); |
| | | return db.Insertable(qsItemIpiItems).ExecuteCommand(); |
| | | }); |
| | | item.Items = getQSItems(qsItemIpiReq.Id, null); |
| | | |
| | |
| | | |
| | | public QsItem SaveItem(QsItem item) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var del = db.Deleteable<QsItemIpiItem>() |
| | | .Where(s=>s.Pid == item.gid) |
| | | .ExecuteCommand(); |
| | | |
| | | //QsItemIpiItemDetail |
| | | var del1 = db.Deleteable<QsItemIpiItemDetail>() |
| | | .Where(s => s.Gid == item.gid) |
| | | .ExecuteCommand(); |
| | | |
| | | |
| | | var qsItemIpiItems = item.Items; |
| | | SqlSugarHelper.UseTransactionWithOracle( |
| | | db => |
| | | { |
| | | // 1. 设置父级ID |
| | | qsItemIpiItems.ForEach(s => s.Pid = item.gid); |
| | | |
| | | return db.Insertable(qsItemIpiItems) |
| | | .ExecuteCommand(); |
| | | // 2. 插入 |
| | | db.Insertable(qsItemIpiItems).ExecuteCommand(); |
| | | |
| | | // 3. 重新从数据库查询插入后的记录(按 pid 查询) 防止检验结果更新到旧项目上 |
| | | qsItemIpiItems = db.Queryable<QsItemIpiItem>() |
| | | .Where(x => x.Pid == item.gid) |
| | | .ToList(); |
| | | |
| | | // ✅ 返回值不重要,只要保证事务提交即可 |
| | | return 1; |
| | | }); |
| | | item.Items = getQSItems(item.gid, null); |
| | | |
| | | |
| | | |
| | | |
| | | //item.Items = getQSItems(item.gid, null); |
| | | |
| | | //没有上下限的检验项目自动盘点为合格 |
| | | item.Items.ForEach(s => |
| | | qsItemIpiItems.ForEach(s => |
| | | { |
| | | if (s.MaxValue != null || s.StandardValue != null || |
| | | s.MinValue != null) return; |
| | | if (s.MaxValue != null || s.StandardValue != null || s.MinValue != null) |
| | | { |
| | | return; |
| | | } |
| | | var detail = new QsItemIpiItemDetail(); |
| | | detail.Pid = s.Id; |
| | | detail.Gid = item.gid; |
| | |
| | | item.Items = getQSItems(item.gid, null); |
| | | |
| | | return item; |
| | | } |
| | | |
| | | public decimal SavePlan(decimal pid,string PlanName) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | var res = db.Updateable<QsItemIpiReq>() |
| | | .SetColumns(a => a.QaPlan == PlanName) |
| | | .Where(a => a.Id == pid) |
| | | .ExecuteCommand(); |
| | | |
| | | return res; |
| | | |
| | | } |
| | | |
| | | public List<string?> GetItemProj(string? itemNo) |
| | | { //获取物料所有的检验计划名称 |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | var plans = db.Queryable<MesQa>().Where(a => a.ItemNo == itemNo && a.QsType == "1") |
| | | .Select(s => s.QaPlan) |
| | | .Distinct() |
| | | .ToList(); |
| | | |
| | | return plans; |
| | | } |
| | | |
| | | public (decimal?,string?, string?) CreateNew(string? DaaNo,string? userNo,string? planName) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | // 创建参数 |
| | | var FitemNo = new SugarParameter("PI_NO", DaaNo); |
| | | var FuserNo = new SugarParameter("PI_USER", userNo); |
| | | var FplanName = new SugarParameter("P_PLAN_NAME", planName); |
| | | |
| | | |
| | | var FRes = new SugarParameter("po_result", null, true); // 输出参数 |
| | | var FMsg = new SugarParameter("po_Message", null, true); |
| | | var FBillNo = new SugarParameter("po_BILL_NO", null, true); |
| | | |
| | | // 执行存储过程 |
| | | db.Ado.UseStoredProcedure().GetDataTable("PRC_PQC_ITEM_INSERT_JK", FitemNo, FuserNo, FplanName, FRes, FMsg, FBillNo); |
| | | |
| | | // 获取输出结果 |
| | | var Res = Convert.ToInt32(FRes.Value); |
| | | var Msg = FMsg.Value?.ToString(); |
| | | var BillNo = FBillNo.Value?.ToString(); |
| | | |
| | | Console.WriteLine($"结果: {Res}, 返回消息: {Msg},单据号:{BillNo}"); |
| | | |
| | | return (Res,Msg, BillNo); |
| | | } |
| | | |
| | | public int SetQSItemDetail(QsItemIpiItemDetail detail) |
| | |
| | | item.CreateDate = DateTime.Now; |
| | | result.Add(item); |
| | | } |
| | | |
| | | return db.Insertable(result).ExecuteCommand(); |
| | | }); |
| | | |
| | |
| | | .ExecuteCommand(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | //NOTES |
| | | public int saveNotesPid(QsItem dto) |
| | | { |
| | | return SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | return db.Updateable<QsItemIpiItem>() |
| | | .SetColumns(it =>it.Notes == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值 |
| | | .Where(it => it.Id == dto.pid) |
| | | .ExecuteCommand(); |
| | | }); |
| | | } |
| | | |
| | | //孙表修改备注字段 |
| | | public int saveRemarksById(QsItem dto) |
| | |
| | | return SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | return db.Updateable<QsItemIpiItemDetail>() |
| | | .SetColumns(it => |
| | | it.Remarks == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值 |
| | | .SetColumns(it =>it.Remarks == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值 |
| | | .Where(it => it.Id == dto.id) |
| | | .ExecuteCommand(); |
| | | }); |
| | |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取钉钉部门 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<DingDept> getDingDept() |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | return db.Queryable<DingDept>() |
| | | .Where(b => b.NoChild== 1) |
| | | .Select(b => new DingDept |
| | | { |
| | | Id=b.Id, |
| | | Name=b.Name |
| | | }) |
| | | .ToList(); |
| | | } |
| | | |
| | | public List<DeptNode> BuildDeptTree() |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | var flatList = db.Queryable<DingDept>() |
| | | .ToList(); |
| | | var lookup = flatList.ToDictionary( |
| | | d => d.Id, |
| | | d => new DeptNode |
| | | { |
| | | Id = d.Id, |
| | | Label = d.Name, |
| | | Value = d.Id |
| | | }); |
| | | |
| | | List<DeptNode> roots = new(); |
| | | |
| | | foreach (var dept in flatList) |
| | | { |
| | | if ((dept.Pid > 0 && lookup.ContainsKey(dept.Pid))) |
| | | { |
| | | lookup[dept.Pid].Children.Add(lookup[dept.Id]); |
| | | } |
| | | else |
| | | { |
| | | // parentId 为 null 的就是根节点 |
| | | roots.Add(lookup[dept.Id]); |
| | | } |
| | | } |
| | | |
| | | return roots; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取钉钉员工 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<DingStaff> getDingUser() |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | return db.Queryable<DingStaff>() |
| | | .Select(b => new DingStaff |
| | | { |
| | | StaffName=b.StaffName, |
| | | Id=b .Id |
| | | }) |
| | | .ToList(); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 异常处置单推送钉钉 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client CreateClient() |
| | | { |
| | | AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config(); |
| | | config.Protocol = "https"; |
| | | config.RegionId = "central"; |
| | | return new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client(config); |
| | | } |
| | | |
| | | public static AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client CreateClient1() |
| | | { |
| | | AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config(); |
| | | config.Protocol = "https"; |
| | | config.RegionId = "central"; |
| | | return new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client(config); |
| | | } |
| | | |
| | | |
| | | public string GetToken() |
| | | { |
| | | AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client client = CreateClient1(); |
| | | AlibabaCloud.SDK.Dingtalkoauth2_1_0.Models.GetAccessTokenRequest getAccessTokenRequest = new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Models.GetAccessTokenRequest |
| | | { |
| | | AppKey = "dingyzos0r1bizj7g6lr", |
| | | AppSecret = "-HP4RvK2OUbqhG3iBUpd_TPe5MZRj8cfLc0b8Skt8rhC3I38kVLY9SS8P3kLWFcH", |
| | | }; |
| | | |
| | | try |
| | | { |
| | | var response = client.GetAccessToken(getAccessTokenRequest); |
| | | return response.Body.AccessToken; // 返回获取到的 Access Token |
| | | } |
| | | catch (TeaException err) |
| | | { |
| | | Console.WriteLine($"TeaException: Code={err.Code}, Message={err.Message}"); |
| | | return null; |
| | | } |
| | | catch (Exception _err) |
| | | { |
| | | Console.WriteLine($"Exception: {_err.Message}"); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public bool DingJZCSD(JzcsdData InData) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(InData.Imodel)) |
| | | throw new Exception( "产品型号不能为空"); |
| | | |
| | | if (string.IsNullOrWhiteSpace(InData.selectedDeptID)) |
| | | throw new Exception("请选择接收部门"); |
| | | |
| | | if (string.IsNullOrWhiteSpace(InData.selectedUserID)) |
| | | throw new Exception("请选择负责人"); |
| | | |
| | | if (string.IsNullOrWhiteSpace(InData.ReplyDate)) |
| | | throw new Exception("回复日期不能为空"); |
| | | |
| | | if (string.IsNullOrWhiteSpace(InData.Reason)) |
| | | throw new Exception("问题描述不能为空"); |
| | | |
| | | if (string.IsNullOrWhiteSpace(InData.selectedADept)) |
| | | throw new Exception("审批部门不能为空"); |
| | | |
| | | |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | decimal numUserId = db.Queryable<DingStaff>() |
| | | .Where(t => t.StaffName == InData.Fname) |
| | | .Select(t => t.Id) |
| | | .First(); |
| | | if (numUserId > 0) |
| | | { |
| | | string UserId = Convert.ToString(numUserId); |
| | | |
| | | |
| | | // 使用 JSON 序列化输出对象的详细内容 |
| | | string InDataJson = JsonConvert.SerializeObject(InData, Formatting.Indented); |
| | | Debug.WriteLine("InDataDetail: " + InDataJson); |
| | | |
| | | // 获取 Access Token |
| | | string accessToken = GetToken(); |
| | | if (string.IsNullOrEmpty(accessToken)) |
| | | { |
| | | throw new Exception("获取 Access Token 失败"); |
| | | } |
| | | |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClient(); |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceHeaders startProcessInstanceHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceHeaders(); |
| | | Debug.WriteLine(accessToken); |
| | | startProcessInstanceHeaders.XAcsDingtalkAccessToken = accessToken; // 使用获取到的 Access Token |
| | | /* |
| | | 产品型号 TextField-K2AD4O5B |
| | | 纠正事项来源 DDMultiSelectField_19MZJHE2ZWM80 |
| | | 提出人员 InnerContactField_WY9BZDYT7W00 |
| | | 提出日期 DDDateField_JD4ISXXCNLS0 |
| | | 接收部门 DepartmentField_SLLT1GL6RC00 |
| | | 负责人 InnerContactField_1I3FYOICN4N40 |
| | | 回复日期 DDDateField_1NPTPIPNEI1S0 |
| | | 问题描述 TextareaField_1FUN513WLK4G0 |
| | | 审批选择 DDSelectField_WE67NWABXM80 |
| | | */ |
| | | |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues1 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //纠正事项来源 |
| | | Name = "DDMultiSelectField_19MZJHE2ZWM80", |
| | | Value = InData.Source |
| | | /* Value = JsonConvert.SerializeObject(new[] { |
| | | new { value = InData.Source, label = "内部审核" } |
| | | })*/ |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues2 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //提出人员 |
| | | Name = "InnerContactField_WY9BZDYT7W00", |
| | | Value = "[\"" + string.Join("\",\"", UserId) + "\"]", |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues3 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //提出日期 |
| | | Name = "DDDateField_JD4ISXXCNLS0", |
| | | Value = DateTime.Now.ToString("yyyy-MM-dd"), |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues4 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //接收部门 |
| | | Name = "DepartmentField_SLLT1GL6RC00", |
| | | Value = InData.selectedDeptID, |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues5 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //负责人 |
| | | Name = "InnerContactField_1I3FYOICN4N40", |
| | | Value = "[\"" + string.Join("\",\"", InData.selectedUserID) + "\"]" |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues6 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //回复日期 |
| | | Name = "DDDateField_1NPTPIPNEI1S0", |
| | | Value = InData.ReplyDate, |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues7 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //问题描述 |
| | | Name = "TextareaField_1FUN513WLK4G0", |
| | | Value = InData.Reason, |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues8 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //审批选择 |
| | | Name = "DDSelectField_WE67NWABXM80", |
| | | Value = InData.selectedADept, |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues9 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //提出部门 |
| | | Name = "DepartmentField_184EOWTFMJUK0", |
| | | Value = "975745197",//固定为MES部门 |
| | | }; |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues formComponentValues10 = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues |
| | | { |
| | | //产品型号 |
| | | Name = "TextField-K2AD4O5B", |
| | | Value = InData.Imodel, |
| | | }; |
| | | |
| | | |
| | | AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest startProcessInstanceRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest |
| | | { |
| | | OriginatorUserId = UserId, |
| | | ProcessCode = "PROC-2752201A-3896-4CA7-82A1-ADBBE9F1B36A", |
| | | DeptId = 987012076, |
| | | FormComponentValues = new List<AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestFormComponentValues> |
| | | { |
| | | formComponentValues1,formComponentValues2,formComponentValues3, formComponentValues4, formComponentValues5, formComponentValues6, formComponentValues7, formComponentValues8, |
| | | formComponentValues9,formComponentValues10//, formComponentValues11, formComponentValues12, formComponentValues13, formComponentValues14 |
| | | }, |
| | | // TargetSelectActioners = new List<AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestTargetSelectActioners> |
| | | //{ |
| | | // targetSelectActioners0 |
| | | //}, |
| | | // Approvers = new List<AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.StartProcessInstanceRequest.StartProcessInstanceRequestApprovers> |
| | | //{ |
| | | // approvers0 |
| | | //}, |
| | | CcList = new List<string> |
| | | { |
| | | UserId |
| | | }, |
| | | CcPosition = "START", |
| | | |
| | | }; |
| | | // 序列化 FormComponentValues 列表为 JSON 格式 |
| | | string formComponentValuesJson = JsonConvert.SerializeObject(startProcessInstanceRequest.FormComponentValues, Formatting.Indented); |
| | | Debug.WriteLine("FormComponentValues: " + formComponentValuesJson); |
| | | try |
| | | { |
| | | string requestContent = Newtonsoft.Json.JsonConvert.SerializeObject(startProcessInstanceRequest); |
| | | Debug.WriteLine("startProcessInstanceRequest内容:"); |
| | | Debug.WriteLine(requestContent); |
| | | //var response = client.StartProcessInstanceWithOptions(startProcessInstanceRequest, startProcessInstanceHeaders, new RuntimeOptions()); |
| | | //return $"钉钉工作流实例启动成功: {Newtonsoft.Json.JsonConvert.SerializeObject(response.Body)}"; |
| | | return true; |
| | | } |
| | | catch (TeaException err) |
| | | { |
| | | string requestContent = Newtonsoft.Json.JsonConvert.SerializeObject(startProcessInstanceRequest); |
| | | Debug.WriteLine("startProcessInstanceRequest内容:"); |
| | | Debug.WriteLine(startProcessInstanceRequest); |
| | | |
| | | throw new Exception(err.Message); |
| | | //return $"TeaException: Code={err.Code}, Message={err.Message}"; |
| | | } |
| | | //catch (Exception _err) |
| | | //{ |
| | | // return $"Exception: {_err.Message}"; |
| | | //} |
| | | |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("您不是公司成员或还未被加入到数据库中或名字填写错误,未找到匹配的用户信息"); |
| | | //return "您不是公司成员或还未被加入到数据库中或名字填写错误,未找到匹配的用户信息"; |
| | | } |
| | | } |
| | | |
| | | } |