From 0aae85d3e241b2aa415c96f12e9f6ac415cffa49 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 28 九月 2022 13:38:47 +0800
Subject: [PATCH] 登录redis存储判断是否失效过滤器修改 设备维修、维修验证接口来发
---
VueWebApi/DLL/DAL/ProductionManagementDAL.cs | 1138 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 1,020 insertions(+), 118 deletions(-)
diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index fef2858..1a51786 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -5,6 +5,7 @@
using System.Data.SqlClient;
using System.Linq;
using System.Web;
+using VueWebApi.Models;
using VueWebApi.Tools;
namespace VueWebApi.DLL.DAL
@@ -20,7 +21,7 @@
#region[ERP璁㈠崟鏌ヨ]
- public static ToMessage ErpOrderSearch(string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string creatuser, string createstartdate, string createenddate, int endNum, string prop, string order)
+ public static ToMessage ErpOrderSearch(string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string paydatestartdate1, string paydateenddate2, string creatuser, int endNum, string prop, string order)
{
var dynamicParams = new DynamicParameters();
string search = "";
@@ -53,19 +54,19 @@
}
if (paydatestartdate != "" && paydatestartdate != null)
{
- search += "and A.paydate between @paydatestartdate and @paydateenddate ";
- dynamicParams.Add("@paydatestartdate", paydatestartdate+" 00:00:00");
+ search += "and A.planstartdate between @paydatestartdate and @paydateenddate ";
+ dynamicParams.Add("@paydatestartdate", paydatestartdate + " 00:00:00");
dynamicParams.Add("@paydateenddate", paydateenddate + " 23:59:59");
}
- if (createstartdate != "" && createstartdate != null)
+ if (paydatestartdate1 != "" && paydatestartdate1 != null)
{
- search += "and A.createdate between @createstartdate and @createenddate ";
- dynamicParams.Add("@createstartdate", createstartdate);
- dynamicParams.Add("@createenddate", createenddate + " 23:59:59");
+ search += "and A.planenddate between @paydatestartdate1 and @paydateenddate2 ";
+ dynamicParams.Add("@paydatestartdate1", paydatestartdate1);
+ dynamicParams.Add("@paydateenddate2", paydateenddate2 + " 23:59:59");
}
if (creatuser != "" && creatuser != null)
{
- search += "and A.createuser like '%'+@creatuser+'%' ";
+ search += "and U.username like '%'+@creatuser+'%' ";
dynamicParams.Add("@creatuser", creatuser);
}
@@ -75,12 +76,14 @@
}
// --------------鏌ヨ鎸囧畾鏁版嵁--------------
var total = 0; //鎬绘潯鏁�
- var sql = @"select A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name,
- A.stck_code,D.name as stck_name,A.paydate,A.createuser,A.createdate
+ var sql = @"select A.id, A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name,
+ A.stck_code,D.name as stck_name,A.planstartdate,A.planenddate,U.username as createuser,A.createdate
from TKimp_Ewo A
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 where A.is_delete<>'1' " + search;
+ left join T_Sec_Stck D on A.stck_code=D.code
+ left join TUser U on A.createuser=U.usercode
+ where A.is_delete<>'1' " + search;
var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
mes.code = "200";
mes.Message = "鏌ヨ鎴愬姛!";
@@ -99,7 +102,7 @@
#endregion
#region[ERP璁㈠崟涓嬭揪]
- public static ToMessage MarkSaveErpOrder(string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string username)
+ public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string username)
{
var sql = "";
List<object> list = new List<object>();
@@ -135,18 +138,20 @@
}
if (i == Convert.ToInt32(ordernum)) //鏈�鍚庝竴鍗曟椂
{
- sql = @"insert into TK_Wrk_Man(wo_code,status,wkshp_code,plan_qty,stck_code,materiel_code,m_po,lm_user,lm_date) values(@wo_code,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@m_po,@username,@CreateDate)";
+ sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,materiel_code,sourceid,m_po,lm_user,lm_date) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate)";
list.Add(new
{
str = sql,
parm = new
{
wo_code = wo,
+ wotype="PO",
status = "NEW",
wkshp_code = wkshopcode,
plan_qty = cdqty + (decimal.Parse(markqty) - sumqty), //鏈崟涓嬪崟鏁伴噺=鍒囧垎鏁伴噺+(涓嬪崟鏁伴噺-绱鍒囧垎涓嬪崟鏁伴噺)
stck_code = warehousecode,
materiel_code = partcode,
+ sourceid=erporderid,
m_po = erpordercode,
username = username,
CreateDate = DateTime.Now.ToString()
@@ -157,18 +162,20 @@
else
{
- sql = @"insert into TK_Wrk_Man(wo_code,status,wkshp_code,plan_qty,stck_code,materiel_code,m_po,lm_user,lm_date) values(@wo_code,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@m_po,@username,@CreateDate)";
+ sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,materiel_code,sourceid,m_po,lm_user,lm_date) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate)";
list.Add(new
{
str = sql,
parm = new
{
wo_code = wo,
+ wotype = "PO",
status = "NEW",
wkshp_code = wkshopcode,
plan_qty = cdqty,
stck_code = warehousecode,
materiel_code = partcode,
+ sourceid = erporderid,
m_po = erpordercode,
username = username,
CreateDate = DateTime.Now.ToString()
@@ -178,26 +185,28 @@
}
if (decimal.Parse(erpqty) == decimal.Parse(markqty) + decimal.Parse(relse_qty)) //濡傛灉ERP璁㈠崟=涓嬪崟鏁伴噺+宸蹭笅鍗曟暟閲�,鍒欐洿鏂癊RP璁㈠崟琛ㄧ姸鎬佷负CREATED:宸插垱寤�
{
- sql = @"update TKimp_Ewo set status='CREATED',relse_qty=relse_qty+@sumqty where wo=@wo";
+ sql = @"update TKimp_Ewo set status='CREATED',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid";
list.Add(new
{
str = sql,
parm = new
{
wo = erpordercode,
+ erporderid = erporderid,
sumqty = sumqty
}
});
}
else //鏇存柊ERP璁㈠崟琛ㄧ姸鎬佷负CREATING:鍒涘缓涓�
{
- sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty+@sumqty where wo=@wo";
+ sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid";
list.Add(new
{
str = sql,
parm = new
{
wo = erpordercode,
+ erporderid = erporderid,
sumqty = sumqty
}
});
@@ -230,7 +239,7 @@
#endregion
#region[ERP璁㈠崟鍏抽棴]
- public static ToMessage ClosedErpOrder(string erpordercode, string username)
+ public static ToMessage ClosedErpOrder(string erporderid, string erpordercode, string username)
{
var sql = "";
List<object> list = new List<object>();
@@ -250,13 +259,14 @@
else
{
//鍏抽棴璁㈠崟
- sql = @"update TKimp_Ewo set status='CLOSED' where wo=@wo";
+ sql = @"update TKimp_Ewo set status='CLOSED' where wo=@wo and id=@erporderid";
list.Add(new
{
str = sql,
parm = new
{
- wo = erpordercode
+ wo = erpordercode,
+ erporderid = erporderid
}
});
}
@@ -290,7 +300,7 @@
#region[MES宸ュ崟鏌ヨ]
- public static ToMessage ErpOrderSearch(string mesorderstus, string mesordercode, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ public static ToMessage MesOrderSearch(string mesorderstus, string mesordercode,string sourceorder,string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
{
var dynamicParams = new DynamicParameters();
string search = "";
@@ -305,6 +315,16 @@
{
search += "and A.wo_code like '%'+@mesordercode+'%' ";
dynamicParams.Add("@mesordercode", mesordercode);
+ }
+ if (sourceorder != "" && sourceorder != null)
+ {
+ search += "and A.m_po like '%'+@sourceorder+'%' ";
+ dynamicParams.Add("@sourceorder", sourceorder);
+ }
+ if (ordertype != "" && ordertype != null)
+ {
+ search += "and A.wotype like '%'+@ordertype+'%' ";
+ dynamicParams.Add("@ordertype", ordertype);
}
if (partcode != "" && partcode != null)
{
@@ -328,7 +348,7 @@
}
if (creatuser != "" && creatuser != null)
{
- search += "and A.lm_user like '%'+@creatuser+'%' ";
+ search += "and U.username like '%'+@creatuser+'%' ";
dynamicParams.Add("@creatuser", creatuser);
}
@@ -338,14 +358,16 @@
}
// --------------鏌ヨ鎸囧畾鏁版嵁--------------
var total = 0; //鎬绘潯鏁�
- var sql = @"select A.status,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.m_po,A.lm_user,A.lm_date
+ 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,U.username as lm_user,A.lm_date
from TK_Wrk_Man A
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
left join TFlw_Rout E on A.route_code=E.code
- left join T_Sec_Stck F on A.stck_code=F.code where A.is_delete<>'1' " + search;
+ left join T_Sec_Stck F on A.stck_code=F.code
+ left join TUser U on A.lm_user=U.usercode
+ where A.is_delete<>'1' " + search;
var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
mes.code = "200";
mes.Message = "鏌ヨ鎴愬姛!";
@@ -371,7 +393,7 @@
try
{
//鑾峰彇杞﹂棿涓嬫媺妗嗘暟鎹�
- sql = @"select R.code,R.name from TMateriel_Info A
+ sql = @"select R.code,R.name,A.default_route from TMateriel_Info A
inner join TMateriel_Route M on A.partcode=M.materiel_code
inner join TFlw_Rout R on M.route_code=R.code
where A.partcode=@partcode ";
@@ -455,7 +477,7 @@
#endregion
#region[MES宸ュ崟鏂板銆佺紪杈戞彁浜
- public static ToMessage AddUpdateMesOrder(string mesorderstus, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype)
+ public static ToMessage AddUpdateMesOrder(string mesorderstus,string sourceorder,string ordertype, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype)
{
var sql = "";
var dynamicParams = new DynamicParameters();
@@ -465,14 +487,16 @@
if (opertype == "Add")
{
//鍐欏叆宸ュ崟琛�
- sql = @"insert into TK_Wrk_Man(wo_code,status,wkshp_code,plan_qty,plan_startdate,plan_enddate,route_code,stck_code,lm_user,lm_date,materiel_code,m_po,piroque)
- values(@mesordercode,@mesorderstus,@wkshopcode,@mesqty,@planstartdate,@planenddate,@routecode,@stck_code,@username,@CreateDate,@materiel_code,@m_po,@orderlev)";
+ sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,plan_startdate,plan_enddate,route_code,stck_code,lm_user,lm_date,materiel_code,m_po,piroque)
+ values(@mesordercode,@wotype,@mesorderstus,@wkshopcode,@mesqty,@planstartdate,@planenddate,@routecode,@stck_code,@username,@CreateDate,@materiel_code,@m_po,@orderlev)";
list.Add(new
{
str = sql,
parm = new
{
mesordercode = mesordercode,
+ wotype = ordertype,
+ m_po = sourceorder,
mesorderstus = "ALLO", //娲惧彂
wkshopcode = wkshopcode,
mesqty = mesqty,
@@ -483,7 +507,6 @@
username = username,
CreateDate = DateTime.Now.ToString(),
materiel_code = partcode,
- m_po = "",
orderlev = orderlev
}
});
@@ -567,7 +590,7 @@
planenddate = planenddate,
status = "ALLO", //娲惧彂
username = username,
- routecode= routecode,
+ routecode = routecode,
CreateDate = DateTime.Now.ToString()
}
});
@@ -600,7 +623,7 @@
#endregion
#region[MES宸ュ崟鍒犻櫎]
- public static ToMessage DeleteMesOrder(string wocode, string m_po, string orderqty)
+ public static ToMessage DeleteMesOrder(string souceid, string wocode, string m_po, string orderqty)
{
var sql = "";
List<object> list = new List<object>();
@@ -616,21 +639,22 @@
if (m_po != "" && m_po != null)
{
//鏌ヨ鐢熶骇璁㈠崟琛ㄦ暟鎹�
- sql = @"select * from TKimp_Ewo where wo=@m_po";
+ sql = @"select * from TKimp_Ewo where wo=@m_po and id=@souceid";
dynamicParams.Add("@m_po", m_po);
+ dynamicParams.Add("@souceid", souceid);
var data0 = DapperHelper.selectdata(sql, dynamicParams);
decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//浠ヤ笅鍗曟暟閲�
if ((relse_qty - decimal.Parse(orderqty)) == 0) //鍏ㄩ儴鎾ら攢 璁㈠崟鐘舵�佸洖鍐欐湭寮�濮�,宸蹭笅鍗曟暟閲忎负0
{
//鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
- sql = @"update TKimp_Ewo set status='NEW',relse_qty=0 where wo=@m_po";
- list.Add(new { str = sql, parm = new { m_po = m_po } });
+ sql = @"update TKimp_Ewo set status='NEW',relse_qty=0 where wo=@m_po and id=@souceid";
+ list.Add(new { str = sql, parm = new { m_po = m_po, souceid= souceid } });
}
else
{
//鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
- sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty where wo=@m_po";
- list.Add(new { str = sql, parm = new { m_po = m_po, orderqty = decimal.Parse(orderqty) } });
+ sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty where wo=@m_po and id=@souceid";
+ list.Add(new { str = sql, parm = new { m_po = m_po, souceid= souceid, orderqty = decimal.Parse(orderqty) } });
}
}
//鍒犻櫎宸ュ崟宸ュ簭琛�
@@ -676,7 +700,7 @@
#endregion
#region[MES宸ュ崟鍏抽棴]
- public static ToMessage ClosedMesOrder(string wocode, string m_po)
+ public static ToMessage ClosedMesOrder(string username,string wocode, string m_po)
{
var sql = "";
List<object> list = new List<object>();
@@ -687,8 +711,8 @@
sql = @"update TK_Wrk_Step set status='CLOSED' where wo_code=@wocode";
list.Add(new { str = sql, parm = new { wocode = wocode } });
//鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
- sql = @"update TK_Wrk_Man set status='CLOSED' where wo_code=@wocode";
- list.Add(new { str = sql, parm = new { wocode = wocode } });
+ sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode, username = username, closedate=DateTime.Now.ToString() } });
bool aa = DapperHelper.DoTransaction(list);
if (aa)
{
@@ -724,8 +748,10 @@
try
{
//鑾峰彇宸ュ簭浠诲姟淇℃伅
- sql = @"select A.wo_code,A.seq,B.stepcode,B.stepname,A.plan_qty,A.good_qty,A.ng_qty from TK_Wrk_Step A
- left join TStep B on A.step_code=B.stepcode
+ sql = @"select A.wo_code,P.partcode,P.partname,P.partspec,A.seq,B.stepcode,B.stepname,A.plan_qty,A.good_qty,A.ng_qty from TK_Wrk_Step A
+ left join TStep B on A.step_code=B.stepcode
+ left join TK_Wrk_Man M on A.wo_code=M.wo_code
+ left join TMateriel_Info P on M.materiel_code=P.partcode
where A.wo_code=@wo_code";
dynamicParams.Add("@wo_code", wo_code);
var data = DapperHelper.selectdata(sql, dynamicParams);
@@ -802,9 +828,9 @@
sql = @"select * from TStep where stepcode=@stepcode";
dynamicParams.Add("@stepcode", stepcode);
var data0 = DapperHelper.selectdata(sql, dynamicParams);
- if (data0.Rows.Count > 0)
+ if (data0.Rows.Count > 0)
{
- if (data0.Rows[0]["FLWTYPE"].ToString() == "W")
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W")
{
mes.code = "300";
mes.count = 0;
@@ -816,7 +842,7 @@
}
//鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟(鑷埗宸ュ簭)
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.plan_startdate
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
left join TMateriel_Info M on B.materiel_code=M.partcode
@@ -920,7 +946,7 @@
}
//鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟(鑷埗宸ュ簭)
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.plan_startdate
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
left join TMateriel_Info M on B.materiel_code=M.partcode
@@ -942,6 +968,217 @@
mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
mes.data = null;
return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(涓嶈壇)]
+ public static ToMessage MesOrderNgStepSearch(string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ var total = 0; //鎬绘潯鏁�
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.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) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ if (ordercode != "" && ordercode != null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ }
+ if (ordercode != "" && stepcode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ search += "and S.stepcode=@stepcode ";
+ dynamicParams.Add("@stepcode", stepcode);
+ }
+ }
+ if (stepcode != "")
+ {
+ //鏌ユ壘褰撳墠宸ュ簭浠诲姟
+ sql = @"select * from TK_Wrk_Step where step_code=@stepcode and wo_code=@ordercode";
+ dynamicParams.Add("@stepcode", stepcode);
+ dynamicParams.Add("@ordercode", ordercode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟涓嶅瓨鍦�,鏃犳晥鏉$爜!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟,涓斾笉鑹暟閲忓ぇ浜�0
+ sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,A.seq,A.isend,
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty
+ from TK_Wrk_Step A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ left join TMateriel_Info M on B.materiel_code=M.partcode
+ left join TStep S on A.step_code=S.stepcode
+ where A.status<>'CLOSED' and A.ng_qty>0 " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ if (data.ToList().Count > 0)
+ {
+ mes.code = "200";
+ mes.count = total;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data.ToList();
+ return mes;
+ }
+ else
+ {
+ mes.code = "301";
+ mes.count = 0;
+ mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(涓嶈壇鏄庣粏)]
+ public static ToMessage MesOrderNgSubStepSearch(string orderstepqrcode)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ var dynamicParams1 = new DynamicParameters();
+ Dictionary<string, object> list = new Dictionary<string, object>();
+ ScanStartReportData rt = new ScanStartReportData();
+ var total = 0; //鎬绘潯鏁�
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.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) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ }
+ //1.鏍规嵁宸ュ崟+宸ュ簭鏌ユ壘褰撳墠宸ュ簭鏄惁棣栭亾宸ュ簭
+ sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.isbott,A.isend
+ 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 TMateriel_Info P on M.materiel_code=P.partcode
+ where A.wo_code=@ordercode and A.step_code=@stepcode";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //宸ュ崟鍙�
+ rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //浜у搧缂栫爜
+ rt.partname = data.Rows[0]["PARTNAME"].ToString(); //浜у搧鍚嶇О
+ rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //浜у搧瑙勬牸
+ rt.stepcode = data.Rows[0]["STEPCODE"].ToString(); //宸ュ簭缂栫爜
+ rt.stepname = data.Rows[0]["STEPNAME"].ToString(); //宸ュ簭鍚嶇О
+ rt.stepdesc = data.Rows[0]["DESCR"].ToString(); //宸ュ簭鎻忚堪
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = decimal.Parse(data.Rows[0]["GOOD_QTY"].ToString()); //鎶ュ伐鏁伴噺
+ rt.noputqty = decimal.Parse(data.Rows[0]["NG_QTY"].ToString()); //涓嶈壇鏁伴噺
+ string isend = data.Rows[0]["ISEND"].ToString();//鏈亾宸ュ簭
+ rt.seq = data.Rows[0]["SEQ"].ToString();//宸ュ簭搴忓彿
+
+ //鑾峰彇褰撳墠宸ュ簭涓嬮亾宸ュ簭
+ sql = @"select A.isbott,A.isend,T.stepcode,T.stepname from TK_Wrk_Step A
+ left join TStep T on A.step_code=T.stepcode
+ where A.wo_code=@ordercode and A.seq=@seq+1 ";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0) //鏈変笅閬撳伐搴�
+ {
+ rt.nextstepcode = dt0.Rows[0]["STEPCODE"].ToString();//涓嬮亾宸ュ簭缂栫爜
+ rt.nextstepname = dt0.Rows[0]["STEPNAME"].ToString();//涓嬮亾宸ュ簭鍚嶇О
+ }
+ if (isend == "Y") //褰撳墠宸ュ簭鏄湯閬撳伐搴�
+ {
+ rt.nextstepcode ="";//璧嬬┖
+ rt.nextstepname = "";//璧嬬┖
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎵爜宸ュ簭浠诲姟涓嶅瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭鎶ュ伐(鏀舵枡)璁板綍,涓斾笉鑹暟閲忓ぇ浜�0
+ //瀛樺偍杩囩▼鍚�
+ sql = @"h_p_IFCLD_MesReportDefectHandleSelect";
+ dynamicParams1.Add("@ordercode", ordercode);
+ dynamicParams1.Add("@stepcode", stepcode);
+ DataTable dt = DapperHelper.selectProcedure(sql, dynamicParams1);
+ if (dt.Rows.Count > 0)
+ {
+ list.Add("data1", rt);
+ list.Add("data2", dt);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
+ mes.data = null;
}
}
catch (Exception e)
@@ -1130,7 +1367,7 @@
dynamicParams.Add("@usercode", usercode);
}
//鐝粍鑾峰彇浜哄憳鍒楄〃
- sql = @"select usercode,username from TUser where is_delete<>'1' "+search;
+ sql = @"select usercode,username from TUser where is_delete<>'1' and usercode<>'9999'" + search;
dynamicParams.Add("@usercode", usercode);
var data = DapperHelper.selectdata(sql, dynamicParams);
mes.code = "200";
@@ -1183,7 +1420,7 @@
left join TCustomer C on A.eqp_code=C.code
where A.step_code=@stepcode and A.style='W'";
dynamicParams.Add("@stepcode", stepcode);
- var data = DapperHelper.selectdata(sql,dynamicParams);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
mes.code = "200";
mes.Message = "鏌ヨ鎴愬姛!";
mes.data = data;
@@ -1282,7 +1519,9 @@
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 } });
@@ -1315,7 +1554,7 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐,鎶ュ伐鎻愪氦]
- public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string username)
+ public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode,string remarks, string username)
{
var sql = "";
string[] arra = new string[] { };
@@ -1337,38 +1576,27 @@
//鍒ゆ柇鏄惁鏈夋姤宸ヨ褰�(鏈夛細淇敼 鏃狅細鏂板)
sql = @"select * from TK_Wrk_Record where wo_code=@wo_code and step_code=@step_code and style='B'";
dynamicParams.Add("@wo_code", mesordercode);
- dynamicParams.Add("@stepcode", stepcode);
+ 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 A.style='S'";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ 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)
{
- //淇敼鎶ュ伐璁板綍
- sql = @"update TK_Wrk_Record set good_qty=good+@reportqty,ng_qty=ng_qty+@ngqty
- lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode and step_code=@stepcode";
- list.Add(new { str = sql, parm = new { reportqty = decimal.Parse(reportqty), ngqty = decimal.Parse(ngqty), mesordercode = mesordercode, stepcode = stepcode, username = username, CreateDate = date } });
- //鍐欏叆瀛愯〃
- for (int i = 0; i < arra.Length; i++)
- {
- sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,usergroup_code,ng_qty,style,lm_user,lm_date)
- values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@usergroup_code,@ng_qty,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } });
-
- }
- if (badcode != "" || badcode != null)
- {
- //鍐欏叆缂洪櫡璁板綍琛�
- for (int i = 0; i < arra1.Length; i++)
- {
- sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
- values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "B", lm_user = username, lm_date = date } });
-
- }
- }
- }
- else
- {
//鑾峰彇涓昏〃鏈�澶D
- sql = @"select IDENT_CURRENT('TK_Wrk_Record')+1 as id";
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id";
var dt = DapperHelper.selecttable(sql);
//鍐欏叆寮�鎶ュ伐璁板綍琛�
sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date)
@@ -1383,14 +1611,67 @@
list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } });
}
- if (badcode != "" || badcode != null)
+ if (badcode != "" && ngqty != "0")
{
//鍐欏叆缂洪櫡璁板綍琛�
for (int i = 0; i < arra1.Length; i++)
{
- sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
- values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "B", lm_user = username, lm_date = date } });
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i],remarks=remarks,style = "B", lm_user = username, lm_date = date } });
+
+ }
+ }
+ ////淇敼鎶ュ伐璁板綍
+ //sql = @"update TK_Wrk_Record set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty,
+ // lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode and step_code=@stepcode and style='B'";
+ //list.Add(new { str = sql, parm = new { reportqty = decimal.Parse(reportqty), ngqty = decimal.Parse(ngqty), mesordercode = mesordercode, stepcode = stepcode, username = username, CreateDate = date } });
+ ////鍐欏叆瀛愯〃
+ //for (int i = 0; i < arra.Length; i++)
+ //{
+ // sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,usergroup_code,ng_qty,style,lm_user,lm_date)
+ // values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@usergroup_code,@ng_qty,@style,@lm_user,@lm_date)";
+ // list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } });
+
+ //}
+ //if (badcode != "" && ngqty != "0")
+ //{
+ // //鍐欏叆缂洪櫡璁板綍琛�
+ // for (int i = 0; i < arra1.Length; i++)
+ // {
+ // sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
+ // values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)";
+ // list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "B", lm_user = username, lm_date = date } });
+
+ // }
+ //}
+ }
+ else
+ {
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ //鍐欏叆寮�鎶ュ伐璁板綍琛�
+ sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date)
+ values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date } });
+
+ //鍐欏叆瀛愯〃
+ for (int i = 0; i < arra.Length; i++)
+ {
+ sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,usergroup_code,ng_qty,style,lm_user,lm_date)
+ values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@usergroup_code,@ng_qty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } });
+
+ }
+ if (badcode != "" && ngqty != "0")
+ {
+ //鍐欏叆缂洪櫡璁板綍琛�
+ for (int i = 0; i < arra1.Length; i++)
+ {
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks= remarks, style = "B", lm_user = username, lm_date = date } });
}
}
@@ -1399,11 +1680,11 @@
//鍥炲啓宸ュ崟宸ュ簭琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
sql = @"update TK_Wrk_Step set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode and step_code=@stepcode";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode,reportqty=reportqty,ngqty=ngqty } });
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, reportqty = reportqty, ngqty = ngqty } });
//鍥炲啓宸ュ崟琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
- sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } });
+ //sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
+ //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } });
bool aa = DapperHelper.DoTransaction(list);
if (aa)
@@ -1452,17 +1733,17 @@
{
//淇敼鍙戞枡璁板綍
sql = @"update TK_Wrk_OutRecord set fqty=fqty+@fqty,lm_user=@username,lm_date=@CreateDate
- where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code";
+ where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='F'";
list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, fqty = decimal.Parse(fqty), username = username, CreateDate = date } });
//鍐欏叆瀛愯〃
- sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,syle,lm_user,lm_date)
- values(@m_id,@wx_code,@out_person,@out_time,@fqty,@lm_user,@lm_date)";
+ sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date)
+ values(@m_id,@wx_code,@out_person,@out_time,@fqty,@style,@lm_user,@lm_date)";
list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } });
}
else
{
//鑾峰彇涓昏〃鏈�澶D
- sql = @"select IDENT_CURRENT('TK_Wrk_OutRecord')+1 as id";
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
var dt = DapperHelper.selecttable(sql);
//鍐欏叆澶栧崗璁板綍涓昏〃
sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,fqty,lm_user,lm_date)
@@ -1510,7 +1791,7 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐, 鏀舵枡鎻愪氦]
- public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string username)
+ public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inuser, string taskqty, string sqty, string ngqty, string badcode,string remarks, string username)
{
var sql = "";
string[] arra1 = new string[] { };
@@ -1528,38 +1809,67 @@
list.Clear();
//鍒ゆ柇鏄惁鏈夋敹鏂欒褰�(鏈夛細锛堝悓宸ュ崟+宸ュ簭+澶栧崗渚涙柟淇敼锛� 鏃狅細鏂板)
- sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wxcode and style='F'";
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wx_code and style='S'";
dynamicParams.Add("@wo_code", mesordercode);
dynamicParams.Add("@step_code", stepcode);
dynamicParams.Add("@wx_code", wxcode);
var data = DapperHelper.selectdata(sql, dynamicParams);
+ //鑾峰彇鍙戞枡璁板綍鐨勯粯璁ら�変腑鐨勫鍗忎緵搴斿晢涓庢敹鏂欐椂鐨勫鍗忎緵搴斿晢鍋氬姣斿垽鏂�
+ sql = @"select A.wx_code,B.name,A.fqty from TK_Wrk_OutRecord A
+ inner join TCustomer B on A.wx_code=B.code
+ where A.wo_code=@wo_code and A.step_code=@step_code and wx_code=@wx_code and A.style='F' ";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ dynamicParams.Add("@wx_code", wxcode);
+ var da = DapperHelper.selectdata(sql, dynamicParams);
+ if (da.Rows.Count<=0)
+ {
+ sql = @"select A.wx_code,B.name,A.fqty from TK_Wrk_OutRecord A
+ inner join TCustomer B on A.wx_code=B.code
+ where A.wo_code=@wo_code and A.step_code=@step_code and A.style='F' ";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ var da1 = DapperHelper.selectdata(sql, dynamicParams);
+ var dr = da1.AsEnumerable().ToList().Select(x => x.Field<string>("NAME")).ToList();
+ string wxstring = (string.Join(",", dr.Select(x => x.ToString()).ToArray()));
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡澶栧崗渚涙柟涓庡彂鏂欏鍗忎緵搴斿晢涓嶅尮閰�,搴斾负锛氥��"+wxstring+"銆�!";
+ mes.data = null;
+ return mes;
+ }
+ if ((decimal.Parse(sqty) + decimal.Parse(ngqty)) > decimal.Parse(da.Rows[0]["FQTY"].ToString())) //鏀舵枡鏁伴噺+涓嶈壇鏁伴噺>鍙戞枡鏁伴噺
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺,涓嶈兘澶т簬鍙戞枡鏁伴噺:"+da.Rows[0]["FQTY"].ToString()+"!";
+ mes.data = null;
+ return mes;
+ }
+ //if (da.Rows[0]["WX_CODE"].ToString() != wxcode)
+ //{
+ // mes.code = "300";
+ // mes.count = 0;
+ // mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡澶栧崗渚涙柟搴斾负锛�" + da.Rows[0]["NAME"].ToString() + "!";
+ // mes.data = null;
+ // return mes;
+ //}
if (data.Rows.Count > 0)
{
- //淇敼澶栧崗璁板綍涓昏〃
- sql = @"update TK_Wrk_OutRecord set sqty=sqty+@sqty,ng_qty=@ngqty,lm_user=@username,lm_date=@CreateDate
- where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } });
- //鍐欏叆澶栧崗璁板綍瀛愯〃
- sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,syle,lm_user,lm_date)
- values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } });
-
- if (badcode != "" || badcode != null)
+ decimal sum_sqty = data.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum(); //鑾峰彇鍚屽崟鍙�,鍚屽伐搴�,鍚屽鍗忎緵搴斿晢鏀舵枡鎬绘暟閲�
+ decimal sum_fqty = da.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum(); //鑾峰彇鍚屽崟鍙�,鍚屽伐搴�,鍚屽鍗忎緵搴斿晢鍙戞枡鎬绘暟閲�
+ if ((sum_sqty + decimal.Parse(sqty) + decimal.Parse(ngqty)) > sum_fqty) //宸叉敹鏂欐�绘暟+褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺>鎬诲彂鏂欐暟閲�
{
- //鍐欏叆缂洪櫡璁板綍琛�
- for (int i = 0; i < arra1.Length; i++)
- {
- sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
- values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@stepcode,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } });
-
- }
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺,涓嶈兘澶т簬寰呮敹鏁伴噺:" + (sum_fqty- sum_sqty) + "!";
+ mes.data = null;
+ return mes;
}
- }
- else
- {
+
+
//鑾峰彇涓昏〃鏈�澶D
- sql = @"select IDENT_CURRENT('TK_Wrk_OutRecord')+1 as id";
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
var dt = DapperHelper.selecttable(sql);
//鍐欏叆澶栧崗璁板綍涓昏〃
sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date)
@@ -1571,14 +1881,63 @@
values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)";
list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } });
- if (badcode != "" || badcode != null)
+ if (badcode != "" && ngqty != "0")
{
//鍐欏叆缂洪櫡璁板綍琛�
for (int i = 0; i < arra1.Length; i++)
{
- sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
- values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@stepcode,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } });
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks= remarks, style = "S", lm_user = username, lm_date = date } });
+
+ }
+ }
+
+
+ ////淇敼澶栧崗璁板綍涓昏〃
+ //sql = @"update TK_Wrk_OutRecord set sqty=sqty+@sqty,ng_qty=ng_qty+@ngqty,lm_user=@username,lm_date=@CreateDate
+ // where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='S'";
+ //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } });
+ ////鍐欏叆澶栧崗璁板綍瀛愯〃
+ //sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
+ // values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@style,@lm_user,@lm_date)";
+ //list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } });
+
+ //if (badcode != "" && ngqty != "0")
+ //{
+ // //鍐欏叆缂洪櫡璁板綍琛�
+ // for (int i = 0; i < arra1.Length; i++)
+ // {
+ // sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
+ // values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)";
+ // list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } });
+
+ // }
+ //}
+ }
+ else
+ {
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ //鍐欏叆澶栧崗璁板綍涓昏〃
+ sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date)
+ values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } });
+
+ //鍐欏叆澶栧崗璁板綍瀛愯〃
+ sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
+ values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } });
+
+ if (badcode != "" && ngqty != "0")
+ {
+ //鍐欏叆缂洪櫡璁板綍琛�
+ for (int i = 0; i < arra1.Length; i++)
+ {
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks= remarks, style = "S", lm_user = username, lm_date = date } });
}
}
@@ -1588,8 +1947,8 @@
list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, sqty = sqty, ngqty = ngqty } });
//鍥炲啓宸ュ崟琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
- sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } });
+ //sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
+ //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } });
bool aa = DapperHelper.DoTransaction(list);
if (aa)
{
@@ -1617,5 +1976,548 @@
}
#endregion'
+ #region[涓嶈壇澶勭悊,鎻愪氦]
+ public static ToMessage EditOrderNgStepSeave(ReportDefectHandle json, string username)
+ {
+ var sql = "";
+ string[] arra1 = new string[] { };
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ decimal sumrepair_qty = 0, sumbad_qty = 0; //绱缁翠慨鏁伴噺銆佺疮璁℃姤搴熸暟閲�
+ try
+ {
+ string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ list.Clear();
+
+
+ //寰幆json鏁版嵁
+ for (int i = 0; i < json.Data.Rows.Count; i++)
+ {
+ //鑷埗宸ュ簭
+ if (json.Data.Rows[i]["STYLE"].ToString() == "Z")
+ {
+ //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曞瓙琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_RecordSub set report_qty=report_qty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where m_id=@m_id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(json.Data.Rows[i]["ID"].ToString()),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString())
+ }
+ });
+ //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曚富琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_Record set good_qty=good_qty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where wo_code=@wo_code and step_code=@step_code and id=@id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ step_code = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ id = int.Parse(json.Data.Rows[i]["ID"].ToString())
+ }
+ });
+ //鍐欏叆鎶ュ伐缂洪櫡澶勭悊璁板綍琛�
+ sql = @"insert into CSR_WorkRecord_DefectHandle(record_subid,wo_code,partnumber,step_seq,step_code,repair_qty,bad_qty,defect_code,style,lm_user,lm_date)
+ values(@record_subid,@wo_code,@partcode,@stepseq,@stepcode,@repair_qty,@bad_qty,@defect_code,@style,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ record_subid = int.Parse(json.Data.Rows[i]["M_ID"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ partcode = json.Data.Rows[i]["MATERIEL_CODE"].ToString(),
+ stepseq = json.Data.Rows[i]["SEQ"].ToString(),
+ stepcode = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ defect_code = json.Data.Rows[i]["DEFECT_CODE"].ToString(),
+ style = "B",
+ lm_user = username,
+ lm_date = date
+ }
+ });
+
+ sumrepair_qty = sumrepair_qty + decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString());
+ sumbad_qty = sumbad_qty + decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString());
+ }
+ //澶栧崗宸ュ簭
+ if (json.Data.Rows[i]["STYLE"].ToString() == "S")
+ {
+ //鍥炲啓瀵瑰簲鐨勬敹鏂欒褰曞瓙琛ㄦ敹鏂欐暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where m_id=@m_id and style='S'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(json.Data.Rows[i]["ID"].ToString()),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString())
+ }
+ });
+ //鍥炲啓瀵瑰簲鐨勬敹鏂欒褰曚富琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_OutRecord set sqty=sqty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where wo_code=@wo_code and step_code=@step_code and id=@id and style='S'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ step_code = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ id = int.Parse(json.Data.Rows[i]["ID"].ToString())
+ }
+ });
+ //鍐欏叆鎶ュ伐缂洪櫡澶勭悊璁板綍琛�
+ sql = @"insert into CSR_WorkRecord_DefectHandle(record_subid,wo_code,partnumber,step_seq,step_code,repair_qty,bad_qty,defect_code,style,lm_user,lm_date)
+ values(@record_subid,@wo_code,@partcode,@stepseq,@stepcode,@repair_qty,@bad_qty,@defect_code,@style,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ record_subid = int.Parse(json.Data.Rows[i]["M_ID"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ partcode = json.Data.Rows[i]["MATERIEL_CODE"].ToString(),
+ stepseq = json.Data.Rows[i]["SEQ"].ToString(),
+ stepcode = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ defect_code = json.Data.Rows[i]["DEFECT_CODE"].ToString(),
+ style = "S",
+ lm_user = username,
+ lm_date = date
+ }
+ });
+ sumrepair_qty = sumrepair_qty + decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString());
+ sumbad_qty = sumbad_qty + decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString());
+ }
+ }
+
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
+ sql = @"update TK_Wrk_Step set good_qty=good_qty+@sumrepair_qty,ng_qty=ng_qty-@sumrepair_qty-@sumbad_qty,bad_qty=bad_qty+@sumbad_qty where wo_code=@wo_code and step_code=@stepcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo_code = json.Data.Rows[0]["WO_CODE"].ToString(),
+ stepcode = json.Data.Rows[0]["STEP_CODE"].ToString(),
+ sumrepair_qty = sumrepair_qty,
+ sumbad_qty = sumbad_qty
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾壂鐮佽幏鍙栦换鍔′俊鎭痌
+ public static ToMessage MesOrderStepCheckSearch(string orderstepqrcode)
+ {
+ var sql = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忔潯鐮�!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ //閫氳繃鎵弿浜岀淮鐮佷俊鎭煡鎵句换鍔′俊鎭�
+ sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,S.stepcode,S.stepname
+ from TK_Wrk_Step A
+ inner join TK_Wrk_Man P on A.wo_code=P.wo_code
+ left join TMateriel_Info M on P.materiel_code=M.partcode
+ left join TStep S on A.step_code=S.stepcode
+ where A.wo_code=@wo_code and A.step_code=@stepcode";
+ dynamicParams.Add("@wo_code", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鐢熶骇浠诲姟涓嶅瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠岃幏鍙栨楠屾爣鍑嗕笅鎷夋鏁版嵁]
+ public static ToMessage MesOrderStepCheckSelect()
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇宸ュ簭妫�楠屾爣鍑�
+ sql = @"select code,name from TStepCheckStandard where is_delete<>'1'";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾牴鎹楠屾爣鍑嗚幏鍙栨楠岄」鐩垪琛╙
+ public static ToMessage MesOrderStepCheckItemList(string checkstandcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鏍规嵁妫�楠屾爣鍑嗙紪鐮佽幏鍙栧伐搴忔楠岄」鐩�
+ sql = @"select B.code,B.name,A.stepcheckitem_desc,A.stepcheckitem_seq from TStepCheckStandardSub A
+ left join TStepCheckItem B on A.stepcheckitem_code=B.code
+ where B.is_delete<>'1' and A.stepstaned_code=@checkstandcode";
+ dynamicParams.Add("@checkstandcode", checkstandcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾彁浜や繚瀛榏
+ public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkusercode, string checktypecode, string checkresult, string checkdescr,string checkqty, string username, List<StepCheck> json)
+ {
+ var sql = "";
+ string[] arra = new string[] { };
+ string[] arra1 = new string[] { };
+ List<object> list = new List<object>();
+ string checktypename = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+
+ list.Clear();
+ switch (checktypecode)
+ {
+ case "FirstCheck":
+ checktypename = "棣栨";
+ break;
+ case "PatroCheck":
+ checktypename = "宸℃";
+ break;
+ case "EndCheck":
+ checktypename = "瀹屽伐妫�楠�";
+ break;
+ default:
+ break;
+ }
+ //鍐欏叆宸ュ簭妫�楠岃褰曚富琛�
+ sql = @"insert into TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_typename,check_result,check_descr,check_qty,lm_user,lm_date)
+ values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkusercode,@checktypecode,@checktypename,@checkresult,@checkdescr,@check_qty,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkusercode = checkusercode, checktypecode = checktypecode, checktypename = checktypename, checkresult = checkresult, checkdescr = checkdescr, check_qty=checkqty, lm_user = username, lm_date = date } });
+ //鍐欏叆宸ュ簭妫�楠岃褰曞瓙琛�
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TStepCheckRecord')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ for (int i = 0; i < json.Count; i++)
+ {
+ sql = @"insert into TStepCheckRecordSub(m_id,checkitem_seq,checkitem_code,checkitem_name,checkitem_descr,check_result,lm_user,lm_date)
+ values(@m_id,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_result,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), checkiem_seq = int.Parse(json[i].seq), checkitem_code = json[i].code, checkitem_name = json[i].name, checkitem_descr = json[i].descr, check_result = json[i].checkresult, lm_user = username, lm_date = date } });
+
+ }
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "妫�楠屾垚鍔�!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "妫�楠屽け璐�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[MES宸ュ崟鎵归噺鍏抽棴鏌ヨ]
+ public static ToMessage MesOrderBitchClosedSearch(string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (mesorderstus != "" && mesorderstus != null)
+ {
+ search += "and A.status=@mesorderstus ";
+ dynamicParams.Add("@mesorderstus", mesorderstus);
+ }
+ if (mesordercode != "" && mesordercode != null)
+ {
+ search += "and A.wo_code like '%'+@mesordercode+'%' ";
+ dynamicParams.Add("@mesordercode", mesordercode);
+ }
+ if (sourceorder != "" && sourceorder != null)
+ {
+ search += "and A.m_po like '%'+@sourceorder+'%' ";
+ dynamicParams.Add("@sourceorder", sourceorder);
+ }
+ if (ordertype != "" && ordertype != null)
+ {
+ search += "and A.wotype like '%'+@ordertype+'%' ";
+ dynamicParams.Add("@ordertype", ordertype);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and A.materiel_code like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and B.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and B.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
+ if (createdate != "" && createdate != null)
+ {
+ search += "and CONVERT(varchar(100),A.lm_date,23)=@createdate ";
+ dynamicParams.Add("@createdate", createdate);
+ }
+ if (creatuser != "" && creatuser != null)
+ {
+ search += "and U.username like '%'+@creatuser+'%' ";
+ dynamicParams.Add("@creatuser", creatuser);
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ 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,U.username as lm_user,A.lm_date
+ ,(select sum(S.good_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as good_qty
+ ,(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 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
+ left join TFlw_Rout E on A.route_code=E.code
+ left join T_Sec_Stck F on A.stck_code=F.code
+ left join TUser U on A.lm_user=U.usercode
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鎵归噺鍏抽棴鎻愪氦]
+ public static ToMessage MesOrderBitchClosedSeave(string username, DataTable dt)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ for (int i = 0; i < dt.Rows.Count; i++)
+ {
+ //鍏抽棴宸ュ崟瀵瑰簲宸ュ簭浠诲姟
+ sql = @"update TK_Wrk_Step set status='CLOSED' where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } });
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
+ sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.ToString() } });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鎵归噺鍙嶅叧闂璢
+ public static ToMessage MesOrderBitchAntiClosedSeave(string username, DataTable dt)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ for (int i = 0; i < dt.Rows.Count; i++)
+ {
+ //鍏抽棴宸ュ崟瀵瑰簲宸ュ簭浠诲姟
+ sql = @"update TK_Wrk_Step set status='START' where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } });
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
+ sql = @"update TK_Wrk_Man set status='START',closeuser=@username,closedate=@closedate where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.ToString() } });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
}
}
\ No newline at end of file
--
Gitblit v1.9.3