From 662c8acd89bdcbbd92d1b917d6128cbcce0134d7 Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期四, 04 十二月 2025 14:42:55 +0800
Subject: [PATCH] 三个检验增加钉钉推送
---
MES.Service/service/QC/XJService.cs | 165 +++++++++++++++++++++++++++++++++++--------------------
1 files changed, 105 insertions(+), 60 deletions(-)
diff --git a/MES.Service/service/QC/XJService.cs b/MES.Service/service/QC/XJService.cs
index d549e02..c2a58aa 100644
--- a/MES.Service/service/QC/XJService.cs
+++ b/MES.Service/service/QC/XJService.cs
@@ -15,7 +15,7 @@
private readonly BaseService _baseService = new();
- private readonly string[] statusArray = ["寮�宸�", "寰呭紑宸�","宸插紑宸�" ,"鏈紑宸�"];
+ private readonly string[] statusArray = ["寮�宸�", "寰呭紑宸�", "宸插紑宸�", "鏈紑宸�"];
//鐢熸垚鏈�鏂扮殑妫�楠屽崟鍙�
public string getMaxReleaseNo()
@@ -49,7 +49,7 @@
public decimal? Daa008 { get; set; }
public string? Daa015 { get; set; }
public string? Daa020 { get; set; }
- public string? ItemNo { get; set; } // 鏉ヨ嚜鍏宠仈琛�
+ public string? ItemNo { get; set; } // 鏉ヨ嚜鍏宠仈琛�
public string? ItemName { get; set; }
}
@@ -59,22 +59,22 @@
//in鐨勫啓娉� https://www.donet5.com/Home/Doc?typeId=1187
- return db.Queryable<Womdaa,MesItems>((a, b) => new JoinQueryInfos(
- JoinType.Inner, a.Daa002 == b.Id.ToString()))
+ return db.Queryable<Womdaa, MesItems>((a, b) => new JoinQueryInfos(
+ JoinType.Inner, a.Daa002 == b.Id.ToString()))
.Where(a =>
a.Daa001 == daa001 &&
statusArray.Contains(a.Daa018))
.Select((a, b) => new DaaInfoDto
{
- Daa001= daa001,
- Daa003=a.Daa003,
- Daa004=a.Daa004,
- Daa008=a.Daa008,
- Daa015=a.Daa015,
- Daa020=a.Daa020,
- ItemNo=b.ItemNo,
+ Daa001 = daa001,
+ Daa003 = a.Daa003,
+ Daa004 = a.Daa004,
+ Daa008 = a.Daa008,
+ Daa015 = a.Daa015,
+ Daa020 = a.Daa020,
+ ItemNo = b.ItemNo,
ItemName = b.ItemName,
- Id =a.Id
+ Id = a.Id
})
.ToList();
}
@@ -82,7 +82,7 @@
public List<QCUserLine> getLineAll(string UserNo)
{
var db = SqlSugarHelper.GetInstance();
-
+
return db.Queryable<QCUserLine>()
.Where(a => a.UserCode == UserNo)
.Select(a => new QCUserLine
@@ -93,7 +93,6 @@
}
-
public List<Womdaa> getDaa001(JObject data)
{
var daa020 = data["daa020"]?.ToString();
@@ -102,7 +101,8 @@
var db = SqlSugarHelper.GetInstance();
return db.Queryable<Womdaa, MesItems>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.Daa002 == b.Id.ToString()))
- .WhereIF(!string.IsNullOrEmpty(daa020), (a, b) => a.Daa015 == daa020)
+ .WhereIF(!string.IsNullOrEmpty(daa020),
+ (a, b) => a.Daa015 == daa020)
.WhereIF(!string.IsNullOrEmpty(item), (a, b) => b.ItemNo == item)
.Where((a, b) => statusArray.Contains(a.Daa018))
.Select<Womdaa>(a => new Womdaa
@@ -133,14 +133,16 @@
}
public List<string?> GetItemProj(string? itemNo)
- { //鑾峰彇鐗╂枡鎵�鏈夌殑妫�楠岃鍒掑悕绉�
+ {
+ //鑾峰彇鐗╂枡鎵�鏈夌殑妫�楠岃鍒掑悕绉�
var db = SqlSugarHelper.GetInstance();
- var plans = db.Queryable<MesQa>().Where(a => a.ItemNo == itemNo && a.QsType == "2")
- .Select(s => s.QaPlan)
- .Distinct()
- .ToList();
+ var plans = db.Queryable<MesQa>()
+ .Where(a => a.ItemNo == itemNo && a.QsType == "2")
+ .Select(s => s.QaPlan)
+ .Distinct()
+ .ToList();
return plans;
}
@@ -161,7 +163,8 @@
var query = db
.Queryable<QsQaItemXj, Womdaa, MesLine,
- MesItems, SysUser,Womcaa,SysDepartment, MesUserDepartmentQc,MesItems, SysUser>((s, a, c, b, us,ca,d,dq,i,us2) =>
+ MesItems, SysUser, Womcaa, SysDepartment, MesUserDepartmentQc,
+ MesItems, SysUser>((s, a, c, b, us, ca, d, dq, i, us2) =>
new JoinQueryInfos(
JoinType.Inner, s.BillNo == a.Daa001,
JoinType.Left, a.Daa015 == c.LineNo,
@@ -169,7 +172,8 @@
JoinType.Left, us.Fcode == s.CreateBy,
JoinType.Left, ca.Caa020 == a.Daa021,
JoinType.Left, d.Departmentcode == c.Departmentcode,
- JoinType.Left, dq.Departmentcode == d.Departmentcode,//鏌ヨ鐢ㄦ埛鏉冮檺
+ JoinType.Left,
+ dq.Departmentcode == d.Departmentcode, //鏌ヨ鐢ㄦ埛鏉冮檺
JoinType.Left, i.Id == Convert.ToDecimal(a.Daa002),
JoinType.Left, us2.Fcode == s.SubmitBy
)
@@ -185,22 +189,26 @@
StringUtil.IsNotNullOrEmpty(queryObj.result) &&
!"鏈畬鎴�".Equals(queryObj.result),
(s, a, c, b, us) => s.SubmitStatus == 1)
- .WhereIF(id > 0, (s, a, c, b, us,ca) => s.Id == id)
+ .WhereIF(id > 0, (s, a, c, b, us, ca) => s.Id == id)
.WhereIF(!string.IsNullOrEmpty(queryObj.LoginUser),
- (s, a, c, b, us, ca, d, dq) => dq.Usercode == queryObj.LoginUser)
+ (s, a, c, b, us, ca, d, dq) =>
+ dq.Usercode == queryObj.LoginUser)
.WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue),
- (s, a, c, b, us, ca, d, dq,i) =>
- s.ReleaseNo.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((s, a, c, b, us,ca,d,dq,i,us2) => new QsQaItemXj
+ (s, a, c, b, us, ca, d, dq, i) =>
+ s.ReleaseNo.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((s, a, c, b, us, ca, d, dq, i, us2) => new QsQaItemXj
{
Daa020 = c.LineNo,
Id = s.Id,
PlanQty = a.Daa008,
- LineName = d.Departmentname == "娉ㄥ杞﹂棿" ? a.Daa020:c.LineName,
- CreateUser = us.Fname==null ? s.CreateBy : us.Fname,
+ LineName = d.Departmentname == "娉ㄥ杞﹂棿" ? a.Daa020 : c.LineName,
+ CreateUser = us.Fname == null ? s.CreateBy : us.Fname,
CreateBy = s.CreateBy,
CreateDate = s.CreateDate,
ReleaseNo = s.ReleaseNo,
@@ -215,9 +223,8 @@
DepartName = d.Departmentname,
PlanName = s.PlanName,
fcheckBy = us2.Fname,
- SubmitDate= s.SubmitDate,
+ SubmitDate = s.SubmitDate,
SubmitStatus = s.SubmitStatus
-
}).OrderBy(s => s.CreateDate, OrderByType.Desc);
var items = query.ToPageList(queryObj.PageIndex, queryObj.Limit,
ref totalCount);
@@ -231,21 +238,22 @@
var db = SqlSugarHelper.GetInstance();
var count = db.Queryable<MesQa>().Where(s => s.QsType == "2"
- && s.ItemNo == itemNo && s.Fsubmit == 1 && s.QaPlan == planName).Count();
+ && s.ItemNo == itemNo && s.Fsubmit == 1 && s.QaPlan == planName)
+ .Count();
if (count <= 0) return new List<QsQaItemXj01>();
decimal? QsId = db.Queryable<MesQa>()
- .Where(s => s.QsType == "2"
- && s.ItemNo == itemNo
- && s.QaPlan == planName
- && s.Fsubmit == 1)
- .Select(s => s.Id)
- .First();
+ .Where(s => s.QsType == "2"
+ && s.ItemNo == itemNo
+ && s.QaPlan == planName
+ && s.Fsubmit == 1)
+ .Select(s => s.Id)
+ .First();
return db
.Queryable<MesQualityStandard>()
- .Where(b => b.Pid== QsId).Select(b => new QsQaItemXj01
+ .Where(b => b.Pid == QsId).Select(b => new QsQaItemXj01
{
ProjName = b.ProjName,
ItemMod = b.ItemMod,
@@ -381,14 +389,17 @@
var FID = new SugarParameter("P_ID", rkjDto.gid);
- var FRes = new SugarParameter("c_result", null, true); // 杈撳嚭鍙傛暟
+ var FRes = new SugarParameter("c_result", null, true); // 杈撳嚭鍙傛暟
var FMsg = new SugarParameter("c_msg", null, true);
// 鎵ц瀛樺偍杩囩▼
- db.Ado.UseStoredProcedure().GetDataTable("PRC_XJ_UPDATE_RES_JK", FID, FRes, FMsg);
+ db.Ado.UseStoredProcedure()
+ .GetDataTable("PRC_XJ_UPDATE_RES_JK", FID, FRes, FMsg);
int result = int.Parse((string)FRes.Value);
- string message = FMsg.Value == DBNull.Value ? string.Empty : (string)FMsg.Value;
+ string message = FMsg.Value == DBNull.Value
+ ? string.Empty
+ : (string)FMsg.Value;
if (result == 1)
{
//瀛樺偍杩囩▼澶辫触鍒欎簨鍔¤繘琛屽洖婊�
@@ -396,6 +407,40 @@
throw new Exception(message);
}
+ // 鎴愬姛鎻愪氦鍚庢帹閫侀拤閽夋秷鎭�
+ var qaXj = db.Queryable<QaXj>()
+ .Where(s => s.Id == rkjDto.gid)
+ .First();
+
+ if (qaXj != null)
+ {
+ try
+ {
+ var qaMsgDto = new
+ {
+ id = qaXj.Id,
+ lineName = qaXj.LineName,
+ workshopName = qaXj.Departmentname,
+ qaType = "宸℃妫�楠屽畬鎴�"
+ };
+
+ // 璋冪敤閽夐拤娑堟伅鎺ㄩ�佹帴鍙�
+ var client = new System.Net.Http.HttpClient();
+ var json =
+ Newtonsoft.Json.JsonConvert.SerializeObject(qaMsgDto);
+ var content = new System.Net.Http.StringContent(json,
+ System.Text.Encoding.UTF8, "application/json");
+ var response = client
+ .PostAsync(
+ "http://192.168.0.100:9096/MesQaDingtalk/sendQaMsgXJ",
+ content).Result;
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍閽夐拤鎺ㄩ�佸紓甯革紝浣嗕笉褰卞搷涓绘祦绋�
+ Console.WriteLine($"閽夐拤娑堟伅鎺ㄩ�佸け璐�: {ex.Message}");
+ }
+ }
return useTransactionWithOracle > 0;
}
@@ -800,7 +845,7 @@
.ExecuteCommand();
});
}
-
+
public int saveNotesPid(XJDto dto)
{
return SqlSugarHelper.UseTransactionWithOracle(db =>
@@ -830,17 +875,17 @@
{
var db = SqlSugarHelper.GetInstance();
- var count = db.Queryable<XJBadReason>().Where(s => s.BillNo == billNo).Count();
+ var count = db.Queryable<XJBadReason>().Where(s => s.BillNo == billNo)
+ .Count();
if (count <= 0) return null;
var reason = db
.Queryable<XJBadReason>()
- .Where(s => s.BillNo == billNo).Select(
- b => new XJBadReason
- {
- Reason = b.Reason
- }).ToList();
+ .Where(s => s.BillNo == billNo).Select(b => new XJBadReason
+ {
+ Reason = b.Reason
+ }).ToList();
return reason;
}
@@ -849,15 +894,15 @@
{
var db = SqlSugarHelper.GetInstance();
var res = db.Updateable<QsQaItemXj>()
- .SetColumns(a => a.PlanName == PlanName)
- .Where(a => a.Id == pid)
- .ExecuteCommand();
+ .SetColumns(a => a.PlanName == PlanName)
+ .Where(a => a.Id == pid)
+ .ExecuteCommand();
return res;
-
}
- public (decimal?, string?, string?) CreateNew(string? DaaNo, string? userNo, string? planName)
+ public (decimal?, string?, string?) CreateNew(string? DaaNo, string? userNo,
+ string? planName)
{
var db = SqlSugarHelper.GetInstance();
// 鍒涘缓鍙傛暟
@@ -866,12 +911,13 @@
var FplanName = new SugarParameter("P_PLAN_NAME", planName);
- var FRes = new SugarParameter("P_FLAG", null, true); // 杈撳嚭鍙傛暟
+ var FRes = new SugarParameter("P_FLAG", null, true); // 杈撳嚭鍙傛暟
var FMsg = new SugarParameter("P_TEXT", null, true);
var FBillNo = new SugarParameter("po_BILL_NO", null, true);
// 鎵ц瀛樺偍杩囩▼
- db.Ado.UseStoredProcedure().GetDataTable("PRC_XJ_GENERATE_JK", FitemNo, FuserNo, FplanName, FRes, FMsg, FBillNo);
+ db.Ado.UseStoredProcedure().GetDataTable("PRC_XJ_GENERATE_JK", FitemNo,
+ FuserNo, FplanName, FRes, FMsg, FBillNo);
// 鑾峰彇杈撳嚭缁撴灉
var Res = Convert.ToInt32(FRes.Value);
@@ -882,5 +928,4 @@
return (Res, Msg, BillNo);
}
-
}
\ No newline at end of file
--
Gitblit v1.9.3