From 2264c47cff7ab5ce52d7c158ac0eb941e7b46506 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 31 八月 2022 23:50:53 +0800
Subject: [PATCH] 大岛测试bug修改
---
VueWebApi/DLL/DAL/ProductionManagementDAL.cs | 263 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 191 insertions(+), 72 deletions(-)
diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index f427a62..848865f 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -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()
@@ -296,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 = "";
@@ -311,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)
{
@@ -344,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
@@ -463,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();
@@ -473,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,
@@ -491,7 +507,6 @@
username = username,
CreateDate = DateTime.Now.ToString(),
materiel_code = partcode,
- m_po = "",
orderlev = orderlev
}
});
@@ -608,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>();
@@ -624,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) } });
}
}
//鍒犻櫎宸ュ崟宸ュ簭琛�
@@ -826,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,A.plan_enddate
+ 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
@@ -930,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,A.plan_enddate
+ 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
@@ -1009,7 +1025,7 @@
if (stepcode != "")
{
//鏌ユ壘褰撳墠宸ュ簭浠诲姟
- sql = @"select * from TStep where stepcode=@stepcode and wo_code=@ordercode";
+ 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);
@@ -1024,7 +1040,7 @@
}
//鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟,涓斾笉鑹暟閲忓ぇ浜�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
+ 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
@@ -1041,7 +1057,7 @@
}
else
{
- mes.code = "300";
+ mes.code = "301";
mes.count = 0;
mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
mes.data = null;
@@ -1092,7 +1108,7 @@
}
}
//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.isbott,A.isend
+ 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
@@ -1111,7 +1127,8 @@
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();//宸ュ簭搴忓彿
@@ -1537,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[] { };
@@ -1578,16 +1595,20 @@
}
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 } });
+ //鑾峰彇涓昏〃鏈�澶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(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 } });
+ 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")
@@ -1595,12 +1616,35 @@
//鍐欏叆缂洪櫡璁板綍琛�
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 } });
+ 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
{
@@ -1625,9 +1669,9 @@
//鍐欏叆缂洪櫡璁板綍琛�
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 } });
}
}
@@ -1747,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[] { };
@@ -1771,42 +1815,105 @@
dynamicParams.Add("@wx_code", wxcode);
var data = DapperHelper.selectdata(sql, dynamicParams);
//鑾峰彇鍙戞枡璁板綍鐨勯粯璁ら�変腑鐨勫鍗忎緵搴斿晢涓庢敹鏂欐椂鐨勫鍗忎緵搴斿晢鍋氬姣斿垽鏂�
- sql = @"select A.wx_code,B.name from TK_Wrk_OutRecord A
+ 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' ";
+ 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[0]["WX_CODE"].ToString() != wxcode)
+ 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 = "鎿嶄綔澶辫触,褰撳墠鏀舵枡澶栧崗渚涙柟搴斾负锛�" + da.Rows[0]["NAME"].ToString() + "!";
+ 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 } });
+ 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) //宸叉敹鏂欐�绘暟+褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺>鎬诲彂鏂欐暟閲�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺,涓嶈兘澶т簬寰呮敹鏁伴噺:" + (sum_fqty- sum_sqty) + "!";
+ mes.data = null;
+ return mes;
+ }
+
+
+ //鑾峰彇涓昏〃鏈�澶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,@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 } });
+ 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,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 } });
+ 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
{
@@ -1828,9 +1935,9 @@
//鍐欏叆缂洪櫡璁板綍琛�
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 } });
}
}
@@ -1890,22 +1997,21 @@
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
- where id=@m_id and m_id=@id and style='B'";
+ 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
{
- id = int.Parse(json.Data.Rows[i]["M_ID"].ToString()),
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
- where wo_code=@wo_code and step_code=@stepcode and id=@id and style='B'";
+ 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,
@@ -1920,7 +2026,7 @@
});
//鍐欏叆鎶ュ伐缂洪櫡澶勭悊璁板綍琛�
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,@ngqty,@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,
@@ -1944,25 +2050,24 @@
sumbad_qty = sumbad_qty + decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString());
}
//澶栧崗宸ュ簭
- if (json.Data.Rows[i]["STYLE"].ToString() == "W")
+ 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
- where id=@m_id and m_id=@id and style='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
{
- id = int.Parse(json.Data.Rows[i]["M_ID"].ToString()),
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
- where wo_code=@wo_code and step_code=@stepcode and id=@id and style='S'";
+ 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,
@@ -1977,7 +2082,7 @@
});
//鍐欏叆鎶ュ伐缂洪櫡澶勭悊璁板綍琛�
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,@ngqty,@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,
@@ -2002,7 +2107,7 @@
}
//鍥炲啓宸ュ崟宸ュ簭琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
- sql = @"update TK_Wrk_Step set good_qty=good_qty+@sumrepair_qty,ng_qty=ng_qty-@sumrepair_qty,bad_qty=bad_qty+sumbad_qty where wo_code=@wo_code and step_code=@stepcode";
+ 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,
@@ -2019,14 +2124,14 @@
{
mes.code = "200";
mes.count = 0;
- mes.Message = "鏀舵垚鍔�!";
+ mes.Message = "鎿嶄綔鎴愬姛!";
mes.data = null;
}
else
{
mes.code = "300";
mes.count = 0;
- mes.Message = "鏀舵枡澶辫触!";
+ mes.Message = "鎿嶄綔澶辫触!";
mes.data = null;
}
}
@@ -2167,23 +2272,37 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾彁浜や繚瀛榏
- public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkusercode, 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,partcode,step_code,checkstaned_code,check_user,check_type,check_result,check_descr,lm_user,lm_date)
- values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkusercode,@checktypecode,@checkresult,@checkdescr,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkusercode = checkusercode, 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 ISNULL(IDENT_CURRENT('TStepCheckRecord')+1,1) as id";
--
Gitblit v1.9.3