From 9c634fd767aec36ef97c3a814bf7a29c67d20ee1 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期五, 29 三月 2024 10:57:35 +0800
Subject: [PATCH] 修改单据重复显示问题,增加工单源单id关联
---
VueWebApi/DLL/DAL/ProductionManagementDAL.cs | 133 +++++++++++++++++++++++--------------------
1 files changed, 71 insertions(+), 62 deletions(-)
diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index 65a66de..6e4e477 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -579,7 +579,7 @@
var sql = @"select A.id, A.status,A.wotype,A.printcount,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,W.saleOrderCode,U.username as lm_user,A.lm_date
from TK_Wrk_Man A
- left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code
+ left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sourceid=W.id
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
@@ -662,7 +662,7 @@
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,W.saleOrderCode,U.username as lm_user,A.lm_date,S.bad_qty
from TK_Wrk_Man A
- left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code
+ left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sourceid=W.id
left join (select wo_code,sum(bad_qty) as bad_qty from TK_Wrk_Step where bad_qty>0 group by wo_code) S on A.wo_code=S.wo_code
left join TMateriel_Info B on A.materiel_code=B.partcode
left join TOrganization C on A.wkshp_code=C.org_code
@@ -1591,7 +1591,7 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(鑷埗)]
- public static ToMessage MesOrderStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ public static ToMessage MesOrderStepSearch(string stu_torgcode, string stu_torgtypecode, string wocode, string saleOrderCode, string partcode, string partname, string partspec, int startNum, int endNum, string prop, string order)
{
var sql = "";
string search = "";
@@ -1601,17 +1601,12 @@
var total = 0; //鎬绘潯鏁�
try
{
- if (orderstepqrcode != "" && orderstepqrcode != null)
+ if (wocode != "" && wocode != null)
{
- string[] arra = orderstepqrcode.Split(';');
+ string[] arra = wocode.Split(';');
if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
{
ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
- mes.code = "300";
- mes.count = 0;
- mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
- mes.data = null;
- return mes;
}
if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
{
@@ -1619,9 +1614,9 @@
stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
}
- if (ordercode != "" && stepcode == null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+ if (ordercode != "" && (stepcode == null || stepcode == "")) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
{
- search += "and A.wo_code=@ordercode ";
+ search += "and A.wo_code like '%'+@ordercode+'%' ";
dynamicParams.Add("@ordercode", ordercode);
}
if (ordercode != "" && stepcode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
@@ -1632,14 +1627,6 @@
dynamicParams.Add("@stepcode", stepcode);
}
}
- //else
- //{
- // mes.code = "300";
- // mes.count = 0;
- // mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
- // mes.data = null;
- // return mes;
- //}
if (stepcode != "")
{
//鏌ユ壘褰撳墠宸ュ簭灞炴��
@@ -1673,13 +1660,33 @@
default:
break;
}
+ if (saleOrderCode != "" && saleOrderCode != null)
+ {
+ search += "and W.saleOrderCode like '%'+@saleOrderCode+'%' ";
+ dynamicParams.Add("@saleOrderCode", saleOrderCode);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and M.partcode like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and M.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and M.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
//鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟(鑷埗宸ュ簭)
sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend,
- S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date,
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.start_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date,
B.m_po,W.saleOrderCode
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
- left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code
+ left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code and B.sourceid=W.id
left join TMateriel_Info M on B.materiel_code=M.partcode
left join TStep S on A.step_code=S.stepcode
left join TOrganization F on B.wkshp_code=F.org_code
@@ -1696,7 +1703,7 @@
}
else
{
- mes.code = "300";
+ mes.code = "200";
mes.count = 0;
mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
mes.data = null;
@@ -1802,7 +1809,7 @@
B.m_po,W.saleOrderCode
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
- left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code
+ left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code and B.sourceid=W.id
left join TMateriel_Info M on B.materiel_code=M.partcode
left join TStep S on A.step_code=S.stepcode
left join TOrganization F on B.wkshp_code=F.org_code
@@ -1915,7 +1922,7 @@
B.m_po,W.saleOrderCode
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
- left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code
+ left join TKimp_Ewo W on B.m_po=W.wo and B.materiel_code=W.materiel_code and B.sourceid=W.id
left join TMateriel_Info M on B.materiel_code=M.partcode
left join TStep S on A.step_code=S.stepcode
left join TOrganization F on B.wkshp_code=F.org_code
@@ -1988,7 +1995,7 @@
from TK_Wrk_Step A
left join TStep T on A.step_code=T.stepcode
left join TK_Wrk_Man M on A.wo_code=M.wo_code
- left join TKimp_Ewo W on M.m_po=W.wo and M.materiel_code=W.materiel_code
+ left join TKimp_Ewo W on M.m_po=W.wo and M.materiel_code=W.materiel_code and M.sourceid=W.id
left join TMateriel_Info P on M.materiel_code=P.partcode
where A.wo_code=@ordercode and A.step_code=@stepcode";
dynamicParams.Add("@ordercode", ordercode);
@@ -2418,34 +2425,36 @@
string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
list.Clear();
//鍒ゆ柇鏄惁鏈夊紑宸ヨ褰�
- sql = @"select * from TK_Wrk_Record where wo_code=@wo_code and step_code=@step_code and eqp_code=@eqpcode and style='S'";
+ sql = @"select * from TK_Wrk_Record where wo_code=@wo_code and step_code=@step_code and style='S'";
dynamicParams.Add("@wo_code", mesordercode);
dynamicParams.Add("@step_code", stepcode);
dynamicParams.Add("@eqpcode", eqpcode);
var data = DapperHelper.selectdata(sql, dynamicParams);
if (data.Rows.Count > 0)
{
- mes.code = "300";
- mes.count = 0;
- mes.Message = "褰撳墠宸ュ簭浠诲姟璁惧宸插紑宸�!";
- mes.data = null;
- return mes;
+ //淇敼寮�鎶ュ伐璁板綍琛�(寮�宸ユ暟閲�)
+ sql = @"update TK_Wrk_Record set start_qty=start_qty+@startqty where wo_code=@mesordercode and step_seq=@stepseq and step_code=@stepcode and materiel_code=@partcode and style=@style";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, partcode = partcode, startqty = startqty, style = "S" } });
+ //淇敼宸ュ崟宸ュ簭琛�(寮�宸ユ暟閲�)
+ sql = @"update TK_Wrk_Step set start_qty=start_qty+@startqty where wo_code=@mesordercode and step_code=@stepcode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, startqty = startqty } });
+ }
+ else
+ {
+ //鍐欏叆寮�鎶ュ伐璁板綍琛�
+ sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,open_person,open_time,task_qty,start_qty,style,lm_user,lm_date)
+ values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@username,@opentime,@taskqty,@startqty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, username = username, opentime = date, taskqty = taskqty, startqty = startqty, style = "S", lm_user = username, lm_date = date } });
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄧ姸鎬佷负START: 寮�宸�
+ sql = @"update TK_Wrk_Step set status='START',start_qty=@startqty where wo_code=@mesordercode and step_code=@stepcode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, startqty = startqty } });
+
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负锛� 寮�宸ワ細START
+ sql = @"update TK_Wrk_Man set status='START' where wo_code=@mesordercode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode } });
}
- //鍐欏叆寮�鎶ュ伐璁板綍琛�
- sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,open_person,open_time,task_qty,start_qty,style,lm_user,lm_date)
- values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@username,@opentime,@taskqty,@startqty,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, username = username, opentime = date, taskqty = taskqty, startqty = startqty, style = "S", lm_user = username, lm_date = date } });
- //鍥炲啓宸ュ崟宸ュ簭琛ㄧ姸鎬佷负START: 寮�宸�
- sql = @"update TK_Wrk_Step set status='START' where wo_code=@mesordercode and step_code=@stepcode";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } });
- //鍥炲啓宸ュ崟宸ュ簭琛ㄧ姸鎬佷负宸插紑宸�
- sql = @"update TK_Wrk_Step set status='START' where wo_code=@mesordercode and step_code=@stepcode";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } });
- //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负锛� 寮�宸ワ細START
- sql = @"update TK_Wrk_Man set status='START' where wo_code=@mesordercode";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode } });
bool aa = DapperHelper.DoTransaction(list);
if (aa)
@@ -2506,21 +2515,21 @@
dynamicParams.Add("@step_code", stepcode);
var data = DapperHelper.selectdata(sql, dynamicParams);
//鑾峰彇寮�宸ヨ褰曠殑榛樿閫変腑鐨勮澶�(浜х嚎)涓庢姤宸ユ椂鐨勮澶囦骇绾垮仛瀵规瘮鍒ゆ柇
- sql = @"select A.eqp_code,B.name from TK_Wrk_Record A
- inner join TEqpInfo B on A.eqp_code=B.code
- where A.wo_code=@wo_code and A.step_code=@step_code and eqp_code=@eqpcode and A.style='S'";
- dynamicParams.Add("@wo_code", mesordercode);
- dynamicParams.Add("@step_code", stepcode);
- dynamicParams.Add("@eqpcode", eqpcode);
- var da = DapperHelper.selectdata(sql, dynamicParams);
- if (da.Rows[0]["EQP_CODE"].ToString() != eqpcode)
- {
- mes.code = "300";
- mes.count = 0;
- mes.Message = "鎿嶄綔澶辫触,褰撳墠鎶ュ伐浜х嚎搴斾负锛�" + da.Rows[0]["NAME"].ToString() + "!";
- mes.data = null;
- return mes;
- }
+ //sql = @"select A.eqp_code,B.name from TK_Wrk_Record A
+ // inner join TEqpInfo B on A.eqp_code=B.code
+ // where A.wo_code=@wo_code and A.step_code=@step_code and eqp_code=@eqpcode and A.style='S'";
+ //dynamicParams.Add("@wo_code", mesordercode);
+ //dynamicParams.Add("@step_code", stepcode);
+ //dynamicParams.Add("@eqpcode", eqpcode);
+ //var da = DapperHelper.selectdata(sql, dynamicParams);
+ //if (da.Rows[0]["EQP_CODE"].ToString() != eqpcode)
+ //{
+ // mes.code = "300";
+ // mes.count = 0;
+ // mes.Message = "鎿嶄綔澶辫触,褰撳墠鎶ュ伐浜х嚎搴斾负锛�" + da.Rows[0]["NAME"].ToString() + "!";
+ // mes.data = null;
+ // return mes;
+ //}
if (data.Rows.Count > 0)
{
//鑾峰彇涓昏〃鏈�澶D
@@ -3528,7 +3537,7 @@
,(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 TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code
+ left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sourceid=W.id
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
@@ -5134,7 +5143,7 @@
inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
inner join TK_Wrk_Man M on S.wo_code=M.wo_code
inner join TMateriel_Info P on M.materiel_code=P.partcode
- left join TKimp_Ewo E on M.sourceid=E.id
+ left join TKimp_Ewo E on M.sourceid=E.id
left join T_Sec_Stck K on E.stck_code=K.code
where A.style='B' and S.isend='Y' and A.good_qty>0
union all
--
Gitblit v1.9.3