From 88cf209956e5cb2bf5e4048c793c8bb5048808d4 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期一, 06 三月 2023 17:53:32 +0800
Subject: [PATCH] 新增MES工单报废补单选源单接口
---
VueWebApi/DLL/DAL/ProductionManagementDAL.cs | 2036 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 1,934 insertions(+), 102 deletions(-)
diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index 8041161..583d18b 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -76,7 +76,7 @@
}
// --------------鏌ヨ鎸囧畾鏁版嵁--------------
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,
+ 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
@@ -102,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>();
@@ -138,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()
@@ -160,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()
@@ -181,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
}
});
@@ -233,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>();
@@ -253,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
}
});
}
@@ -293,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 = "";
@@ -308,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)
{
@@ -341,8 +358,8 @@
}
// --------------鏌ヨ鎸囧畾鏁版嵁--------------
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,U.username as 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
@@ -351,6 +368,82 @@
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 MesBadOrderSearch(string mesordercode, string sourceorder, 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 (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 (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
+ 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' and A.status='START' and A.wotype='PO' " + search;
var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
mes.code = "200";
mes.Message = "鏌ヨ鎴愬姛!";
@@ -459,8 +552,75 @@
}
#endregion
+ #region[宸ュ崟娲惧彂閫夋嫨宸ヨ壓璺嚎鎴栭�夋嫨鐢熶骇杞﹂棿鏃跺垽鏂粦瀹氭潯浠禲
+ public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ mes.code = "200";
+ mes.Message = "";
+ mes.data = null;
+ //鍒ゆ柇宸ヨ壓璺嚎瀵瑰簲宸ュ簭鏄惁閮芥湁鍏宠仈宸ヤ綔绔�
+ sql = @"select B.step_code,C.eqp_code from TFlw_Rout A
+ inner join TFlw_Rtdt B on A.code=B.rout_code
+ left join TFlw_Rteqp C on B.step_code=C.step_code
+ where A.code=@routecode";
+ dynamicParams.Add("@routecode", routecode);
+ var dtck = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < dtck.Rows.Count; i++)
+ {
+ if (dtck.Rows[i].IsNull("eqp_code"))
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ヨ壓璺嚎瀵瑰簲宸ュ簭銆�" + dtck.Rows[i]["step_code"].ToString() + "銆戯紝鏈叧鑱旇澶囷紝璇峰叧鑱旀墍鏈夊伐搴忓搴旇澶�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ //鍒ゆ柇宸ヨ壓璺嚎瀵瑰簲宸ュ簭鍏宠仈鐨勫伐浣滅珯鏄惁鏈夎缃妭鎷嶅伐浠�
+ sql = @"select AA.step_code,AA.eqp_code,AA.flwtype,S.unprice from (
+ select A.code,B.step_code,C.eqp_code,S.flwtype from TFlw_Rout A
+ inner join TFlw_Rtdt B on A.code=B.rout_code
+ left join TFlw_Rteqp C on B.step_code=C.step_code
+ left join TStep S on B.step_code=S.stepcode
+ where A.code=@route_code
+ ) as AA
+ left join (select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@route_code) as S on
+ AA.code=S.route_code and AA.step_code=S.step_code and AA.eqp_code=S.eqp_code";
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@route_code", routecode);
+ var dtc = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < dtc.Rows.Count; i++)
+ {
+ if (dtc.Rows[i]["flwtype"].ToString() == "Z") //鍒ゆ柇宸ュ簭鏄惁涓鸿嚜鍒�
+ {
+ if (dtc.Rows[i].IsNull("unprice") || decimal.Parse(dtc.Rows[i]["unprice"].ToString()) == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鑺傛媿宸ヤ环涓細褰撳墠浜у搧銆�" + partcode + "銆戯紝瀵瑰簲宸ヨ壓璺嚎銆�" + routecode + "銆戞湭璁剧疆(鎴栨湭璁剧疆鍏�)鎴栧伐浠峰皬浜庣瓑浜�0!";
+ 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[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();
@@ -470,14 +630,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,
@@ -488,7 +650,6 @@
username = username,
CreateDate = DateTime.Now.ToString(),
materiel_code = partcode,
- m_po = "",
orderlev = orderlev
}
});
@@ -516,6 +677,32 @@
CreateDate = DateTime.Now.ToString()
}
});
+
+ //鍐欏叆宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+ sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code)
+ select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice,
+ S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code
+ from TFlw_Rtdt A
+ inner join TFlw_Rteqp C on A.step_code=C.step_code
+ inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ materiel_code = partcode,
+ routecode = routecode
+ }
+ });
+
+ //if (is_aps == "Y") //鏄惁鎺掔▼
+ //{
+ // string sql1 = "select id from TBom_Main where materiel_code='" + PartNumber + "' and status='Y' and version='" + VsionId + "'";
+ // DataTable dt1 = DBHelper.GetTable(sql1);
+ //}
+
+ //澧炲姞宸ュ崟鐢ㄦ枡琛紙瀛愪欢锛�
bool aa = DapperHelper.DoTransaction(list);
if (aa)
@@ -576,6 +763,35 @@
CreateDate = DateTime.Now.ToString()
}
});
+
+ //鍒犻櫎宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+ sql = @"delete TWoPrteEqp_Stad where wo=@mesordercode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode
+ }
+ });
+ //鍐欏叆宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+ sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code)
+ select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice,
+ S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code
+ from TFlw_Rtdt A
+ inner join TFlw_Rteqp C on A.step_code=C.step_code
+ inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ materiel_code = partcode,
+ routecode = routecode
+ }
+ });
+
bool aa = DapperHelper.DoTransaction(list);
if (aa)
{
@@ -605,7 +821,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>();
@@ -613,7 +829,7 @@
try
{
//鍒ゆ柇宸ュ崟鏄惁涓烘湭寮�濮嬬姸鎬佹垨鑰呭凡娲惧彂鐘舵��(婊¤冻鍏朵腑涓�绉嶉兘鍙垹闄わ紝鍚﹀垯涓嶅厑璁稿垹闄�)
- sql = @"select * from TK_Wrk_Man where wo_code=@wocode and status='NEW' or status='ALLO'";
+ sql = @"select * from TK_Wrk_Man where wo_code=@wocode and status in('NEW','ALLO')";
dynamicParams.Add("@wocode", wocode);
var data = DapperHelper.selectdata(sql, dynamicParams);
if (data.Rows.Count > 0)
@@ -621,21 +837,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) } });
}
}
//鍒犻櫎宸ュ崟宸ュ簭琛�
@@ -681,7 +898,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>();
@@ -692,8 +909,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)
{
@@ -729,9 +946,11 @@
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
- where A.wo_code=@wo_code";
+ 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 order by A.seq";
dynamicParams.Add("@wo_code", wo_code);
var data = DapperHelper.selectdata(sql, dynamicParams);
mes.code = "200";
@@ -821,7 +1040,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
@@ -925,7 +1144,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
@@ -947,6 +1166,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)
@@ -1135,7 +1565,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";
@@ -1287,7 +1717,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 } });
@@ -1320,7 +1752,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[] { };
@@ -1344,36 +1776,25 @@
dynamicParams.Add("@wo_code", mesordercode);
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_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 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)
@@ -1393,9 +1814,62 @@
//鍐欏叆缂洪櫡璁板綍琛�
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 } });
}
}
@@ -1407,8 +1881,8 @@
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)
@@ -1467,7 +1941,7 @@
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)
@@ -1515,7 +1989,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[] { };
@@ -1538,33 +2012,62 @@
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=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")
+ 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,@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)
@@ -1581,9 +2084,58 @@
//鍐欏叆缂洪櫡璁板綍琛�
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 = "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 } });
}
}
@@ -1593,8 +2145,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)
{
@@ -1621,6 +2173,176 @@
return mes;
}
#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)
@@ -1748,30 +2470,44 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾彁浜や繚瀛榏
- public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkuser, string checktypecode, string checkresult, string checkdescr, string username, List<StepCheck> json)
+ 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,part_code,step_code,checkstaned_code,check_user,check_type,check_result,check_descr,lm_user,lm_date)
- values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkuser,@checktypecode,@checkresult,@checkdescr,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkuser = checkuser, checktypecode = checktypecode, checkresult = checkresult, checkdescr = checkdescr, lm_user = username, lm_date = date } });
+ 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 IDENT_CURRENT('TStepCheckRecord')+1 as id";
+ 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,checkiem_seq,checkitem_code,checkitem_name,checkitem_descr,check_result,lm_user,lm_date)
+ 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 } });
@@ -1804,5 +2540,1101 @@
}
#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
+
+
+
+ #region[浜ц兘瑙勫垝鏌ヨ]
+ public static ToMessage CapacityPlanningSearch(string workshop, string devicetype, string stustype, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (workshop != "" && workshop != null)
+ {
+ search += "and A.wksp_code=@workshop ";
+ dynamicParams.Add("@workshop", workshop);
+ }
+ if (devicetype != "" && devicetype != null)
+ {
+ search += "and A.code=@devicetype ";
+ dynamicParams.Add("@devicetype", devicetype);
+ }
+ if (stustype != "" && stustype != null)
+ {
+ search += "and B.enable=@stustype ";
+ dynamicParams.Add("@stustype", stustype);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select
+ B.id CaptPlanId,
+ A.wksp_code CaptPlanWorkShopid,
+ C.org_name CaptPlanWorkShop,
+ A.code CaptPlanDeviceTypeid,
+ A.name CaptPlanDeviceType,
+ A.ClassType CaptPlanType,
+ E.aa CaptPlanShopCalendar,
+ E.RR CaptPlanShopMaxDate,
+ E.TT CaptPlanShopCalendarList,
+ B.wkshift_code CaptPlanWorkShiftCode,
+ D.name CaptPlanWorkShift,
+ D.duration CaptPlanDuration,
+ B.lm_date CaptPlanDate,
+ B.ENABLE CaptPlanStus,
+ G.username CaptPlanUser
+ FROM(
+ select distinct B.wksp_code,A.code,A.name,'D' ClassType from TEqpType A
+ left join TEqpInfo B on A.code=B.eqptype_code
+ left join TFlw_Rteqp C on B.code=C.eqp_code
+ left join TFlw_Rtdt D on C.step_code=D.step_code
+ where D.first_choke='Y' --order by A.code
+ )A
+ left join TOrganization C on A.wksp_code=C.org_code
+ left join TWkm_capac_plan B ON A.wksp_code=B.wkshop and A.code=B.eqp_typecode
+ left join TBas_wkshift_info D on B.wkshift_code=D.code
+ left join TUser G on B.lm_user=G.usercode
+ left join (
+ select m_id,
+ min(CONVERT(varchar(100), wkdate, 23))+'~'+max(CONVERT(varchar(100), wkdate, 23)) aa,
+ max(CONVERT(varchar(100), wkdate, 23))RR,
+ STUFF((
+ SELECT ',' + CONVERT(varchar(100),t1.wkdate, 23)
+ FROM TWkm_capac_plan_sub t1
+ WHERE t1.m_id = t0.m_id
+ ORDER BY t1.m_id
+ FOR XML PATH('')), 1, LEN(','), '') AS TT
+ FROM TWkm_capac_plan_sub t0 where CONVERT(varchar(100), wkdate, 23)>=CONVERT(varchar(100),getdate(), 23)
+ GROUP BY t0.m_id
+ ) E on B.id=E.m_id
+ where C.description='W' " + 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[浜ц兘瑙勫垝榛樿鏂规淇濆瓨鎻愪氦]
+ public static ToMessage CapacityPlanSubmit(string type, string captplanid, string wkshopcode, string capunitcode, string capsetupcode, string captplantype, string username)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (type == "Add")
+ {
+ var sql = @"insert into TWkm_capac_plan(wkshop, eqp_typecode, wkshift_code, enable, lm_user, lm_date,classtype)
+ values(@wkshop,@eqp_typecode,@wkshift_code,@enable,@lm_user,@lm_date,@classtype)";
+ dynamicParams.Add("@wkshop", wkshopcode);
+ dynamicParams.Add("@eqp_typecode", capunitcode);
+ dynamicParams.Add("@wkshift_code", capsetupcode);
+ dynamicParams.Add("@enable", "Y");
+ dynamicParams.Add("@lm_user", username);
+ dynamicParams.Add("@lm_date", DateTime.Now.ToString());
+ dynamicParams.Add("@classtype", captplantype);
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (type == "Update")
+ {
+ var sql = @"update TWkm_capac_plan set wkshift_code=@wkshift_code,lm_user=@username,lm_date=@CreateDate where id=@captplanid";
+ dynamicParams.Add("@captplanid", captplanid);
+ dynamicParams.Add("@wkshift_code", capsetupcode);
+ dynamicParams.Add("@username", username);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ 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 CapacityPlanningCalendar(string captplanid)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<CapaPlan> list = new List<CapaPlan>();
+ try
+ {
+ sql = @"select CONVERT(varchar(100), wkdate, 23) DataTime,wkshift_code from TWkm_capac_plan_sub where m_id=@captplanid";
+ dynamicParams.Add("@captplanid", captplanid);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ string DataTime = data.Rows[i]["DataTime"].ToString();//鏃ユ湡
+ string key = data.Rows[i]["wkshift_code"].ToString(); //鏂规缂栫爜
+ CapaPlan cmp = new CapaPlan();
+ cmp.name = DataTime;
+ cmp.key = key;
+ list.Add(cmp);
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鏃ュ巻鍙屽嚮鏃跺甫鍑哄搴旂殑鏂规]
+ public static ToMessage CapacityPlanningOnclickSelect(string captplanid, string datetime)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<CapacityPlanSect> list = new List<CapacityPlanSect>();
+ try
+ {
+ sql = @"select distinct AA.code,AA.name,(case when AA.Stus is null then 'N' else 'Y' end) flag
+ from
+ (
+ select A.code,A.name,B.wkshift_code Stus from TBas_wkshift_info A
+ left join TWkm_capac_plan_sub B on A.code= B.wkshift_code and B.m_id=@captplanid and CONVERT(varchar(100), wkdate, 23)=@datetime
+ ) AA order by code";
+ dynamicParams.Add("@captplanid", captplanid);
+ dynamicParams.Add("@datetime", datetime);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ string code = data.Rows[i]["code"].ToString();//鏂规缂栫爜
+ string name = data.Rows[i]["name"].ToString();//鏂规鍚嶇О
+ string flag = data.Rows[i]["flag"].ToString(); //閫変腑鏂规鏍囪瘑
+ CapacityPlanSect cmp = new CapacityPlanSect();
+ cmp.CapCode = code;
+ cmp.CapName = name;
+ cmp.CapStus = flag;
+ cmp.list = new List<object>();
+
+ string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start from TBas_wkshift_info where code=@code";
+ dynamicParams.Add("@code", code);
+ var db = DapperHelper.selectdata(sql1, dynamicParams);
+
+ for (int j = 0; j < db.Columns.Count; j++) //鏃堕棿娈�
+ {
+ if (db.Rows[0][j].ToString().Trim() != null && db.Rows[0][j].ToString().Trim() != "")
+ {
+ cmp.list.Add(db.Rows[0][j].ToString());
+ }
+ }
+ list.Add(cmp);
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝宸ヤ綔鏃ュ巻閫夋嫨鎻愪氦]
+ public static ToMessage CapacityPlanningGivePlanSubmit(string captplanid, string wkshopcode, string capunitcode, string capsetupcode, string captplantype, List<CapaPlan> objs, string type, string username)
+ {
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ if (capsetupcode == "" || capsetupcode == null)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "榛樿鏂规閫夋嫨涓嶈兘涓虹┖!";
+ mes.data = null;
+ return mes;
+ }
+ if (objs.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ヤ綔鏃ュ巻閫夋嫨涓嶈兘涓虹┖!";
+ mes.data = null;
+ return mes;
+ }
+ if (type == "Add")
+ {
+ for (int i = 0; i < objs.Count; i++)
+ {
+ sql = @"insert into TWkm_capac_plan_sub(m_id, wkdate,wkshift_code)
+ values(@m_id,@wkdate,@wkshift_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = captplanid,
+ wkdate = objs[i].name,
+ wkshift_code = objs[i].key
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ if (type == "Update")
+ {
+ //瀹氫箟涓や釜鏁扮粍鐢ㄦ潵瀵规瘮淇敼鍓嶅悗鏃ユ湡鍙婃柟妗堢殑鍙樺寲
+ List<CapaPlan> ids = new List<CapaPlan>();
+ List<CapaPlan> ids1 = new List<CapaPlan>();
+ for (int i = 0; i < objs.Count; i++)
+ {
+ ids.Add(objs[i]);
+ }
+
+ //鏍规嵁id鏌ユ壘鏃ュ巻鏃堕棿
+ string sql2 = @"select CONVERT(varchar(100), wkdate, 23) wkdate,wkshift_code from TWkm_capac_plan_sub where m_id=@m_id";
+ dynamicParams.Add("@m_id", captplanid);
+ var dt2 = DapperHelper.selectdata(sql2, dynamicParams);
+ if (dt2.Rows.Count > 0)
+ {
+ for (int k = 0; k < dt2.Rows.Count; k++)
+ {
+ CapaPlan ids2 = new CapaPlan();
+ ids2.name = dt2.Rows[k]["wkdate"].ToString();
+ ids2.key = dt2.Rows[k]["wkshift_code"].ToString();
+ ids1.Add(ids2);
+ }
+ }
+
+ List<CapaPlan> list3 = ids.Except(ids1).ToList(); //琛ㄧずids涓摢浜涘�兼槸ids1涓墍涓嶅瓨鍦ㄧ殑;
+ List<CapaPlan> list4 = ids1.Except(ids).ToList(); //琛ㄧずids1涓摢浜涘�兼槸ids涓墍涓嶅瓨鍦ㄧ殑;
+ list4 = list3.Union(list4).ToList();
+ //鏌ユ壘鍏抽敭宸ュ簭璁惧銆佸伐浣嶇兢缁勭殑鎵�鏈夎澶�
+ string sql3 = @"select distinct A.code,A.name from TEqpInfo A
+ left join TFlw_Rteqp B on A.code=B.eqp_code
+ left join TFlw_Rtdt D on B.step_code=D.step_code
+ where A.wksp_code=@wkshopcode and D.first_choke='Y' order by A.code";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ var dt3 = DapperHelper.selectdata(sql3, dynamicParams);
+ if (list4.Count > 0) //濡傛灉鏃ユ湡鏈夊彉鍔�
+ {
+ if (dt3.Rows.Count > 0)
+ {
+ for (int m = 0; m < list4.Count; m++)
+ {
+ for (int n = 0; n < dt3.Rows.Count; n++)
+ {
+ string sql4 = @"select A.wo_code,A.eqp_code,A.Time_Start,A.time_end,
+ (case B.Status when 'SCHED' then '宸叉帓绋�' when 'ALLOC' then '宸叉淳鍙�' when 'START' then '宸插紑宸�' end ) status
+ from TK_Wrk_EqpAps A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ left join TEqpInfo C on A.eqp_code=C.code
+ where CONVERT(varchar(100), time_start, 23)=@time_start and A.eqp_code=@eqp_code and B.isaps='Y' and B.status IN('SCHED','ALLOC','START')";
+ dynamicParams.Add("@time_start", list4[m].name);
+ dynamicParams.Add("@eqp_code", dt3.Rows[n]["CODE"]);
+ var dt4 = DapperHelper.selectdata(sql4, dynamicParams);
+ if (dt4.Rows.Count > 0)
+ {
+ for (int g = 0; g < dt4.Rows.Count; g++)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼澶辫触锛�,鏃ユ湡锛�" + dt4.Rows[g]["TIME_START"] + "鏈夈��" + dt4.Rows[g]["STATUS"] + "銆戝伐鍗曪細" + dt4.Rows[g]["WO_CODE"] + "";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ }
+ }
+ //鏇存柊鎺掍骇鐢熶骇璧勬簮涓昏〃
+ sql = @"update TWkm_capac_plan set wkshift_code=@wkshift_code,classtype=@classtype,lm_user=@lm_user,lm_date=@lm_time where id=@id";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ id = captplanid,
+ wkshift_code = capsetupcode,
+ classtype = captplantype,
+ lm_user = username,
+ lm_time = DateTime.Now.ToString()
+ }
+ });
+ //鍒犻櫎鎺掍骇鐢熶骇璧勬簮瀛愯〃
+ sql = @"delete TWkm_capac_plan_sub where m_id=@id";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ id = captplanid
+ }
+ });
+ //寰幆鍐欏叆鎺掍骇鐢熶骇璧勬簮瀛愯〃
+ for (int i = 0; i < objs.Count; i++)
+ {
+ sql = @"insert into TWkm_capac_plan_sub(m_id,wkdate,wkshift_code) values(@m_id,@wkdate,@wkshift_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = captplanid,
+ wkdate = objs[i].name,
+ wkshift_code = objs[i].key
+ }
+ });
+ }
+ 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 AdvancedSchedulingSearch(string workshop, string wocode, string partcode, string partname, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (workshop != "" && workshop != null)
+ {
+ search += "and A.wkshp_code=@workshop ";
+ dynamicParams.Add("@workshop", workshop);
+ }
+ if (wocode != "" && wocode != null)
+ {
+ search += "and A.wo_code like '%'+@wocode+'%' ";
+ dynamicParams.Add("@wocode", wocode);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and A.materiel_code like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and C.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select
+ A.id AdvaScheId,
+ A.status AdvaScheStus,
+ A.wo_code AdvaScheWorkCode,
+ A.wkshp_code AdvaScheWorkShopid,
+ M.org_name AdvaScheWorkShop,
+ A.materiel_code AdvaSchePartNumber,
+ C.partname AdvaSchePartName,
+ C.partspec AdvaSchePartSpec,
+ D.name AdvaSchePartModel,
+ A.plan_qty AdvaScheQty,
+ U.name AdvaScheUom,
+ isnull(E.sched_qty,0) AdvaScheYPQty,
+ CONVERT(varchar(100), B.planenddate, 23) AdvaScheEndDate,
+ convert(varchar(20),isnull(E.sched_qty,0))+'/'+convert(varchar(20),isnull(A.plan_qty,0)) AdvaScheSpeed,
+ A.route_code AdvaScheRoutid,
+ F.name AdvaScheRoutName,
+ E.step_code AdvaScheBotProcid,
+ G.stepname AdvaScheBotProcName,
+ CONVERT(varchar(100), H.maxtime, 23) AdvaSchePCEndDate,
+ CONVERT(varchar(100), H.mintime, 23) AdvaSchePCStartDate,
+ (case when CONVERT(varchar(100), H.maxtime, 23)<=CONVERT(varchar(100), E.plan_enddate, 23) then 'Y' when H.MAXTime is null then 'Y' else 'N' end) Flag,
+ (case when A.PiroQue='1' then '鐗规��' when A.PiroQue='2' then '绱ф��' when A.PiroQue='3' then '姝e父' end) AdvaSchePiroQue
+ from TK_Wrk_Man A
+ left join TKimp_Ewo B on A.m_po=B.wo
+ left join TMateriel_Info C on C.partcode= A.materiel_code
+ left join T_Dict D on C.stocktype_code= d.code
+ left join TK_Wrk_Step E on E.wo_code=A.wo_code
+ left join TFlw_Rout F on A.route_code=F.code
+ left join TStep G on E.step_code=G.stepcode
+ left join (select wo_code, max(TIME_END) MAXTime,min(time_start) MINTime from TK_Wrk_EqpAps group by wo_code) H on A.wo_code=H.wo_code
+ left join TUom U on C.uom_code=U.code
+ left join TOrganization M on A.wkshp_code=M.org_code
+ where E.isbott = 'Y' and A.status='NEW' and A.isaps='Y'";
+ 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[鎺掍骇璁惧淇℃伅]
+ public static List<AdvancedSchedulingDevice> OnclickAdvancedSchedulingDevice(string wocode, string wkshpcode, string partcode, string startdate, string enddate, ref ToMessage mes)
+ {
+ string sql = "", sql0 = "";
+ var dynamicParams = new DynamicParameters();
+ List<AdvancedSchedulingDevice> list = new List<AdvancedSchedulingDevice>();
+ DataTable dt, dt1;
+
+ DateTime beginDate = Convert.ToDateTime(startdate);
+ DateTime endDate = DateTime.Parse(enddate);
+ try
+ {
+ if (beginDate > endDate)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "瑕佹眰浜や粯鏃堕棿涓嶈兘灏忎簬褰撳墠绯荤粺鏃堕棿锛�";
+ mes.data = null;
+ return list;
+ }
+ bool IsCap = false; //鏄惁璁剧疆浜ц兘
+ //閫氳繃宸ュ崟鏌ユ壘宸ヨ壓璺嚎瀵瑰簲鍏抽敭宸ュ簭鎵�鍏宠仈鐨勮澶囨槸鍚﹀彲鐢�
+ sql = @"select distinct C.eqp_code ,D.Enable from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@partcode", partcode);
+ var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt_0.Rows.Count > 0)
+ {
+ int cout = dt_0.Rows.Count;
+ int num = 0;
+ for (int m = 0; m < dt_0.Rows.Count; m++)
+ {
+ if (dt_0.Rows[m]["Enable"].ToString() == "N")
+ {
+ num = num + 1;
+ }
+ }
+ if (num == cout)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧涓嶅彲鐢紒";
+ mes.data = null;
+ return list;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ヨ壓璺嚎鏈叧鑱旇澶囷紒";
+ mes.data = null;
+ return list;
+ }
+
+ //閫氳繃宸ュ崟鏌ユ壘宸ヨ壓璺嚎瀵瑰簲鍏抽敭宸ュ簭鎵�鍏宠仈鐨勮澶囨墍灞炶溅闂�
+ sql0 = @"select distinct D.wksp_code from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode ";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@partcode", partcode);
+ var dt0 = DapperHelper.selectdata(sql0, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ string sy = "0";
+ for (int i = 0; i < dt0.Rows.Count; i++)
+ {
+ if (dt0.Rows[i]["WKSHOP"].ToString() == wkshpcode) //宸ュ崟鍒涘缓杞﹂棿鏄惁绛変簬鎺掍骇璁惧 杞﹂棿
+ {
+ sy = "1";
+ break;
+ }
+ else
+ {
+ sy = "0";
+ }
+ }
+ if (sy == "0")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掍骇璁惧杞﹂棿涓庡伐鍗曞垱寤虹殑杞﹂棿涓嶅悓锛�";
+ mes.data = null;
+ }
+ else
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(wocode, wkshpcode, partcode);
+ for (DateTime date = beginDate; date <= endDate; date = date.AddDays(1))
+ {
+ AdvancedSchedulingDevice tbj = new AdvancedSchedulingDevice();
+ tbj.YearDate = date.ToString("yyyy-MM-dd");
+ tbj.children = new List<AdvancedSchedulingDeviceCont>();
+ for (int j = 0; j < listData.Count; j++)
+ {
+ if (listData[j].AdvaDevicCropMob.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "绋煎姩鐜囦笉鑳戒负0鎴栦负绌猴紒";
+ mes.data = null;
+ return list;
+ }
+ if (listData[j].AdvaDevicRhythm.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "鏈缃妭鎷嶏紒";
+ mes.data = null;
+ return list;
+ }
+ string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start,G.name
+ from TWkm_capac_plan E
+ left join TWkm_capac_plan_sub F on E.id=F.m_id
+ left join TBas_wkshift_info G on F.wkshift_code=G.code
+ where E.wkshop='CJ001'and E.eqp_typecode='SBLX001' and E.ClassType='D'
+ and CONVERT(varchar(100), F.wkdate, 23)='2022-10-11' and E.enable='Y'";
+ dynamicParams.Add("@wkshop", wkshpcode);
+ dynamicParams.Add("@eqp_typecode", listData[j].Style.ToString());
+ dynamicParams.Add("@classtype", listData[j].ClassType.ToString());
+ dynamicParams.Add("@wkdate", date.ToString("yyyy-MM-dd"));
+ dt1 = DapperHelper.selectdata(sql1, dynamicParams);
+
+ AdvancedSchedulingDeviceCont tbjson = new AdvancedSchedulingDeviceCont();
+ tbjson.AdvaDevicNumber = listData[j].eqp_id.ToString();
+ tbjson.AdvaDevicName = listData[j].name.ToString();
+ tbjson.AdvaDevicCropMob = listData[j].AdvaDevicCropMob.ToString(); //绋煎姩鐜�
+ tbjson.AdvaDevicRhythm = listData[j].AdvaDevicRhythm.ToString(); //鐢熶骇鑺傛媿
+ if (dt1.Rows.Count > 0)
+ {
+ tbjson.OneStartDate = dt1.Rows[0]["wktme1_start"].ToString();
+ tbjson.TwoStartDate = dt1.Rows[0]["wktme2_start"].ToString();
+ tbjson.ThreeStartDate = dt1.Rows[0]["wktme3_start"].ToString();
+ tbjson.FourStartDate = dt1.Rows[0]["wktme4_start"].ToString();
+ tbjson.FiveStartDate = dt1.Rows[0]["wktme5_start"].ToString();
+ tbj.children.Add(tbjson);
+ IsCap = true;
+ }
+ else
+ {
+
+ tbjson.OneStartDate = "";
+ tbjson.TwoStartDate = "";
+ tbjson.ThreeStartDate = "";
+ tbjson.FourStartDate = "";
+ tbjson.FiveStartDate = "";
+ tbj.children.Add(tbjson);
+ }
+ }
+
+ list.Add(tbj);
+ }
+ if (list.Select(p => p.children).ToList().Count > 0)
+ {
+ int one = list.Where(t => t.children.Select(s => s.OneStartDate).Any(x => x != "")).ToList().Count;
+ int two = list.Where(t => t.children.Select(s => s.TwoStartDate).Any(x => x != "")).ToList().Count;
+ int three = list.Where(t => t.children.Select(s => s.ThreeStartDate).Any(x => x != "")).ToList().Count;
+ int four = list.Where(t => t.children.Select(s => s.FourStartDate).Any(x => x != "")).ToList().Count;
+ int five = list.Where(t => t.children.Select(s => s.FiveStartDate).Any(x => x != "")).ToList().Count;
+ if (one <= 0 && two <= 0 && three <= 0 && four <= 0 && five <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧鏈缃骇鑳斤紒";
+ mes.data = null;
+ }
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧娌℃湁鍏宠仈杞﹂棿锛�";
+ mes.data = null;
+ }
+ return list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return list;
+ }
+ #endregion
+
+ #region[璁惧宸叉帓绋嬩俊鎭痌
+ public static DataTable AlreadyScheduling(string wocode, string wkshpcode, string partcode, string botproccode, string startdate, string enddate)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(wocode, wkshpcode, partcode);
+ string[] empIds = listData.Select(a => a.eqp_id).ToArray();
+ string str = string.Join(",", empIds);
+ string s1 = string.Format("'{0}'", str.Replace(",", "','"));
+
+ string sql = @"select B.wo_code, B.eqp_code,B.time_start,B.time_end, 'S' status , B.alloc_qty,D.partname as part_name
+ from TK_Wrk_EqpAps B
+ left join TK_Wrk_Man C on B.wo_code=C.wo_code
+ left join TMateriel_Info D on C.materiel_code=D.partcode
+ where B.eqp_code in(@s1)
+ and convert(varchar(100),B.Time_Start,21)>=@startdate and convert(varchar(100),B.Time_End,21)<=@enddate order by time_end";
+ dynamicParams.Add("@s1", s1);
+ dynamicParams.Add("@startdate", startdate + " 00:00:00");
+ dynamicParams.Add("@enddate", enddate + " 23:59:59");
+ var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt == null || dt.Rows.Count == 0)
+ {
+ return null;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+ return dt;
+ }
+ #endregion
+
+ #region[鎺掔▼鏁版嵁鎻愪氦]
+ public static ToMessage SubmitAlreadyScheduling(string username, string wocode, string botprocecode, List<AlreadyScheduling> objs)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string maxTime = objs.Max(t => Convert.ToDateTime(t.AlreEndDate).ToString("yyyy-MM-dd HH:mm")); //鏈�澶у��
+ string minTime = objs.Min(t => Convert.ToDateTime(t.AlreEndDate).ToString("yyyy-MM-dd HH:mm")); //鏈�灏忓��
+ sql = @"select
+ A.id, A.status,
+ '0' BottFrointv, convert(varchar(100),B.plan_enddate-0,21) Plan_end ,
+ convert(varchar(100),B.plan_startdate+0,21) plan_start
+ from TK_Wrk_Step A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ where A.wo_code=@wocode and A.step_code=@botprocecode and A.isbott='Y'";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@botprocecode", botprocecode);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ string ID = dt.Rows[0]["ID"].ToString(); // mes_tk_wrk_step 琛� 鐡跺緞宸ュ簭琛孖D
+ string status = dt.Rows[0]["STATUS"].ToString();
+ Decimal nm = 0; //鐡跺緞宸ュ簭鐨勫墠缃ぉ鏁�
+ Decimal nn = Decimal.Parse(dt.Rows[0]["BottFrointv"].ToString()); //鐡跺緞宸ュ簭鐨勫悗缃ぉ鏁�
+ if (status != "NEW" && status != "SCHED") //宸ュ簭浠诲姟鐨勭姸鎬佸凡缁忔淳鍙戯紙瀹℃牳锛�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎺掔▼浠诲姟宸茬粡娲惧彂,鎻愪氦鍙栨秷锛�";
+ mes.data = null;
+ return mes;
+ }
+ if (status == "SCHED") //宸ュ簭浠诲姟鐨勭姸鎬佸凡缁忔帓绋�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎺掔▼浠诲姟宸茬粡鎺掔▼,鎻愪氦鍙栨秷锛�";
+ mes.data = null;
+ return mes;
+ }
+
+ list.Clear();
+ //鎸夊伐鍗曞垹闄よ澶囦换鍔¤〃(鏃ヤ换鍔¤〃锛�
+ sql = @"delete TK_Wrk_EqpAps where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+ //鎸夊伐鍗曞垹闄よ澶囦换鍔¤〃(姹囨�昏〃锛�
+ sql = @"delete TK_Wrk_EqpApsSum where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+ //鎸夊伐鍗曞垹闄よ澶囦换鍔¤〃(姹囨�昏〃锛夌墿鏂欒〃
+ sql = @"delete TK_Wrk_EqpSum_Allo where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+
+ float n = 0; //绱鎺掍骇鎬绘暟
+
+ for (int i = 0; i < objs.Count; i++) //寰幆娣诲姞姣忎釜璁惧鐨勬満鍙颁换鍔�
+ {
+ sql = @"insert into TK_Wrk_EqpAps (wo_code,step_taid,eqp_code,time_start,time_end,alloc_qty,status)
+ values(@wo_code,@step_taid,@eqp_code,@time_start,@time_end,@alloc_qty,@status)";
+ list.Add(new { str = sql, parm = new { wo_code = wocode, step_taid = ID, eqp_code = objs[i].AlreDevicNumber, time_start = objs[i].AlreStartDate, time_end = objs[i].AlreEndDate, alloc_qty = objs[i].AlreQty, status = "NEW" } });
+ n = n + float.Parse(objs[i].AlreQty.ToString());
+ }
+
+ bool aa = DapperHelper.DoTransaction(list); //鎻愪氦璁惧浠诲姟
+ if (!aa)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍏堥鎺�,鍐嶇偣鍑绘彁浜わ紒";
+ mes.data = null;
+ return mes;
+ }
+ list.Clear();
+ //鐢熸垚璁惧浠诲姟姹囨�昏〃 锛堟牴鎹澶囨棩浠诲姟琛級
+ sql = "select distinct eqp_code from TK_Wrk_EqpAps where wo_code=@wocode";
+ dynamicParams.Add("@wocode", wocode);
+ var dt1 = DapperHelper.selectdata(sql, dynamicParams);
+
+ for (int i = 0; i < dt1.Rows.Count; i++)
+ {
+ sql = @"insert into TK_Wrk_EqpApsSum (wo_code,eqp_code,step_taid,p_date, t_date, qty,status)
+ select min(wo_code),min(eqp_code),min(step_taid),min(time_start),max(time_end),sum(Alloc_Qty),'NEW' from TK_Wrk_EqpAps
+ where wo_code=@wocode and eqp_code=''";
+ list.Add(new { str = sql, parm = new { wocode = wocode, eqp_code = dt1.Rows[i]["EQP_CODE"].ToString() } });
+ }
+
+ bool aa1 = DapperHelper.DoTransaction(list); //鎻愪氦璁惧浠诲姟
+ if (!aa1)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鐢熸垚璁惧浠诲姟姹囨�昏〃鍑洪敊锛屾帓浜уけ璐ワ紒";
+ mes.data = null;
+ return mes;
+ }
+
+ list.Clear();
+ //鍐欏叆璁惧浠诲姟(姹囨�昏〃)鐢ㄦ枡 璁″垝鏁伴噺*瀛愪欢鍩烘湰鐢ㄩ噺*锛�1+鎹熻�楃巼锛�/姣嶄欢鍩烘湰鐢ㄩ噺
+ sql = @"insert into TK_Wrk_EqpSum_Allo(m_id, seq, invcode, qty,wo_code,pn_type)
+ select A.id M_id, B.seq,B.materiel_code,(round(A.qty,2)*BE.Base_Quantity*(1+BE.LOSS_QUANTITY/100))/BM.quantity qty,A.wo_code,B.materieltype
+ from TK_Wrk_EqpApsSum A
+ left join TK_Wrk_Allo B on A.Wo_Code= B.Wo_Code
+ left join TBom_Deta BE ON B.bom_id=BE.m_id and B.materiel_code=BE.smateriel_code
+ left join TBom_Main BM on BE.m_Id=BM.id where A.wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+
+ //鏇存柊 宸ュ簭浠诲姟鍗曠殑銆愮摱寰勫伐搴忋�� 鎺掍骇棰勫紑宸ユ棩鏈熴�佹帓浜ч瀹屽伐鏃ユ湡銆佺姸鎬侊細NEW===>SCHED 銆佸凡鎺掍骇鏁伴噺
+ sql = @"update TK_Wrk_Step set plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), status = 'SCHED', sched_qty =@sched_qty where id =@id";
+ list.Add(new { str = sql, parm = new { plan_startdate = minTime, plan_enddate = maxTime, sched_qty = n, id = ID } });
+
+ //宸ュ崟宸ュ簭鐨勨�滆鍒掑紑鏈烘棩鏈� = 鐡跺緞宸ュ簭鐨勯寮�宸ユ棩鏈� - 鐡跺緞宸ュ簭鐨勫墠缃棩鏈燂級 涓诲伐鍗曪細璁″垝瀹屽伐鏃ユ湡 = 鐡跺緞宸ュ簭鐨勯瀹屽伐鏃ユ湡 + 鐡跺緞宸ュ簭鐨勫悗缃棩鏈�
+ sql = @"update TK_Wrk_Step set plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), status = 'SCHED', sched_qty =@sched_qty where wo_code =@wocode and isbott='N'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ plan_startdate = Convert.ToDateTime(minTime).AddDays(Convert.ToDouble(-nm)).ToString("yyyy-MM-dd"),
+ plan_enddate = Convert.ToDateTime(maxTime).AddDays(Convert.ToDouble(nn)).ToString("yyyy-MM-dd"),
+ sched_qty = n,
+ wocode = wocode
+ }
+ });
+ //涓诲伐鍗曠殑鈥滆鍒掑紑鏈烘棩鏈� = 鐡跺緞宸ュ簭鐨勯寮�宸ユ棩鏈� - 鐡跺緞宸ュ簭鐨勫墠缃棩鏈燂級 涓诲伐鍗曪細璁″垝瀹屽伐鏃ユ湡 = 鐡跺緞宸ュ簭鐨勯瀹屽伐鏃ユ湡 + 鐡跺緞宸ュ簭鐨勫悗缃棩鏈�
+ sql = @"update mes_tk_wrk_man set status='SCHED',plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), exchag='Y',allocfag='N' where wo_code =@wocode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ plan_startdate = Convert.ToDateTime(minTime).AddDays(Convert.ToDouble(-nm)).ToString("yyyy-MM-dd"),
+ plan_enddate = Convert.ToDateTime(maxTime).AddDays(Convert.ToDouble(nn)).ToString("yyyy-MM-dd"),
+ sched_qty = n,
+ wocode = wocode
+ }
+ });
+ bool aa2 = DapperHelper.DoTransaction(list); //鎻愪氦璁惧浠诲姟
+ if (aa2)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎻愪氦鎺掔▼鎴愬姛锛�";
+ }
+ 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