From c43a4dfbc7a80d6be6e9823cdd0e182898fc2562 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期四, 05 九月 2024 14:06:58 +0800
Subject: [PATCH] 1.生产报工根据工单、工序获取设备/外协供应商信息
---
VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs | 2261 +++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 1,407 insertions(+), 854 deletions(-)
diff --git a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
index df0d84a..35dce96 100644
--- a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
@@ -24,10 +24,11 @@
public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+ public static string sqlServerConnectString = AppSetting.GetAppSetting("DBServer");
#region[ERP璁㈠崟鏌ヨ]
- public static ToMessage ErpOrderSearch(string erporderstus, string wkshopcode, string erpordercode, string saleordercode, string partcode, string partname, string partspec, int startNum,string datatype, string paydatestartdate, string paydateenddate, string creatuser, int endNum, string prop, string order)
+ public static ToMessage ErpOrderSearch(string erporderstus, string wkshopcode, string erpordercode, string saleordercode, string partcode, string partname, string partspec, int startNum, string datatype, string paydatestartdate, string paydateenddate, string creatuser, int endNum, string prop, string order)
{
var dynamicParams = new DynamicParameters();
string search = "";
@@ -129,7 +130,7 @@
#endregion
#region[ERP璁㈠崟涓嬭揪]
- public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string saleOrderDeliveryDate,string paystartdate,string payenddate, string clerkuser, User us)
+ public static ToMessage MarkSaveErpOrder(string erporderid, string sbid, string erpordercode, string saleordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string saleOrderDeliveryDate, string paystartdate, string payenddate, string clerkuser, User us)
{
var sql = "";
List<object> list = new List<object>();
@@ -192,7 +193,7 @@
plan_enddate = Convert.ToDateTime(payenddate),
data_sources = "ERP",
isstep = "N", //鏄惁鍏宠仈宸ュ簭
- clerkuser= clerkuser //閿�鍞鍗曚笟鍔″憳
+ clerkuser = clerkuser //閿�鍞鍗曚笟鍔″憳
}
});
sumqty = sumqty + (decimal.Parse(markqty) - sumqty);
@@ -225,7 +226,7 @@
plan_enddate = Convert.ToDateTime(payenddate),
data_sources = "ERP",
isstep = "N",//鏄惁鍏宠仈宸ュ簭
- clerkuser= clerkuser
+ clerkuser = clerkuser
}
});
}
@@ -306,7 +307,7 @@
{
string erpordercode = group.erpordercode;
int count = 1;
- foreach (var model in obj.Where(s => s.erpordercode==erpordercode).ToList())
+ foreach (var model in obj.Where(s => s.erpordercode == erpordercode).ToList())
{
//鑾峰彇褰撳墠鏈�澶у伐鍗曞彿
sql = @"select isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0) as worknumb
@@ -342,7 +343,7 @@
plan_enddate = Convert.ToDateTime(model.payenddate),
data_sources = "ERP",
isstep = "N", //鏄惁鍏宠仈宸ュ簭
- clerkuser= model.clerkuser //閿�鍞鍗曚笟鍔″憳
+ clerkuser = model.clerkuser //閿�鍞鍗曚笟鍔″憳
}
});
@@ -534,7 +535,7 @@
#region[MES宸ュ崟鏌ヨ]
- public static ToMessage MesOrderSearch(string mesorderstus, string wkshopcode, string mesordercode, string sourceorder, string saleordercode, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string datatype,string paydatestartdate,string paydateenddate, int endNum, string prop, string order)
+ public static ToMessage MesOrderSearch(string mesorderstus, string wkshopcode, string mesordercode, string sourceorder, string saleordercode, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string datatype, string paydatestartdate, string paydateenddate, int endNum, string prop, string order)
{
var dynamicParams = new DynamicParameters();
string search = "";
@@ -624,8 +625,9 @@
}
// --------------鏌ヨ鎸囧畾鏁版嵁--------------
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.torg_name as wkshp_name,
- A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources,A.isstep,A.clerkuser
+ var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.route_code,R.name as route_name,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
+ A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,
+ A.data_sources,A.isstep,A.clerkuser,A.bom_id,M.version
from TK_Wrk_Man A
left join TKimp_Ewo W on A.m_po=W.wo and A.materiel_code=W.materiel_code and A.sbid=W.sbid
left join TMateriel_Info B on A.materiel_code=B.partcode
@@ -633,6 +635,8 @@
left join TSecStck D on A.stck_code=D.code
left join TUser U on A.lm_user=U.usercode
left join TOrganization L on C.parent_id=L.id
+ left join TFlw_Rout R on A.route_code=R.code
+ left join TBom_Main M on A.bom_id=M.id
where A.is_delete<>'1' " + search;
var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
mes.code = "200";
@@ -775,10 +779,9 @@
if (data_sources == "ERP") //鏁版嵁鏉ユ簮ERP
{
//鏌ヨ璁㈠崟浠诲姟鎬绘暟
- sql = @"select qty from TKimp_Ewo where id=@sourceid and wo=@sourcewo";
+ sql = @"select qty,relse_qty from TKimp_Ewo where id=@sourceid and wo=@sourcewo";
dynamicParams.Add("@sourceid", sourceid);
dynamicParams.Add("@sourcewo", sourcewo);
- dynamicParams.Add("@wocode", wocode);
var data0 = DapperHelper.selectdata(sql, dynamicParams);
//鏌ヨ褰撳墠宸ュ崟鍙慨鏀规暟閲�=璁㈠崟鎬绘暟-宸蹭笅杈惧伐鍗曟�绘暟
sql = @"select isnull(sum(plan_qty),0) as plan_qty from TK_Wrk_Man
@@ -808,19 +811,77 @@
}
}
//鑾峰彇宸ュ簭淇℃伅
- sql = @"select S.wo_code,S.seq,S.step_code,T.stepname,S.stepprice,(isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
+ sql = @"select S.id,S.wo_code,S.seq,S.step_code,T.stepname,T.flwtype,S.stepprice as unprice,(isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty,(isnull(S.plan_qty,0)-(isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0))) as delive_qty,S.isbott,S.isend
from TK_Wrk_Step S
left join TStep T on S.step_code=T.stepcode
where S.wo_code=@wocode order by S.seq ";
dynamicParams.Add("@wocode", wocode);
- var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ var parents = DapperHelper.select<WorkRouteStepEqp>(sql, dynamicParams);
+ //鑾峰彇宸ュ簭瀵瑰簲璁惧淇℃伅
+ for (int i = 0; i < parents.Count; i++)
+ {
+ if (parents[i].flwtype == "Z")
+ {
+ //閫氳繃宸ヨ壓璺嚎宸ュ簭琛↖D鏌ユ壘瀵瑰簲璁惧淇℃伅
+ sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as unprice,'Y' as enable,
+ (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
+ S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty
+ from TK_Wrk_StepEqp S
+ inner join TEqpInfo E on S.eqp_code=E.code
+ where S.m_id=@m_id";
+ dynamicParams.Add("@m_id", parents[i].id);
+ var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams);
+ parents[i].children = children.ToList();
+ }
+ else
+ {
+ //閫氳繃宸ヨ壓璺嚎宸ュ簭琛↖D鏌ユ壘瀵瑰簲澶栧崗渚涘簲鍟嗕俊鎭�
+ sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as unprice,'Y' as enable,
+ (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
+ S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty
+ from TK_Wrk_StepEqp S
+ inner join TCustomer E on S.eqp_code=E.code
+ where S.m_id=@m_id";
+ dynamicParams.Add("@m_id", parents[i].id);
+ var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams);
+ parents[i].children = children.ToList();
+ }
+
+ }
+
+
dir.Add("canupdate_qty", canupdate_qty);
- dir.Add("stepdata", data1);
+ dir.Add("stepdata", parents);
mes.code = "200";
- mes.count = data1.Rows.Count;
+ mes.count = parents.Count;
mes.message = "鏌ヨ鎴愬姛";
mes.data = dir;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏂板缂栬緫鏃�,鏍规嵁浜у搧鑾峰彇Bom鐗╂枡娓呭崟]
+ public static ToMessage MesOrderAddUpdateBomVison(string partnumber)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @" select id,version from TBom_Main where materiel_code=@partnumber and status='Y' order by version desc ";
+ dynamicParams.Add("@partnumber", partnumber);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
}
catch (Exception e)
{
@@ -836,166 +897,283 @@
#region[MES宸ュ崟鏂板銆佺紪杈戞彁浜
public static ToMessage AddUpdateMesOrder(string operType, WorkList json, User us)
{
- string sql = "";
+ string sql = "", route_code = "";
var dynamicParams = new DynamicParameters();
List<object> list = new List<object>();
- try
+ using (var conn = new SqlConnection(sqlServerConnectString))
{
- if (operType == "Add")
+ conn.Open();
+ using (var transaction = conn.BeginTransaction())
{
- //鍐欏叆宸ュ崟琛�
- sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,lm_user,lm_date,materiel_code,sourceid,m_po,saleOrderDeliveryDate,plan_startdate,plan_enddate,piroque,isaps,data_sources,isstep)
- values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@lm_user,@lm_date,@materiel_code,@sourceid,@m_po,@saleOrderDeliveryDate,@plan_startdate,@plan_enddate,@orderlev,@isaps,@data_sources,@isstep)";
- list.Add(new
+ try
{
- str = sql,
- parm = new
+ dynamic dynObj = JObject.Parse(us.mesSetting);
+ bool route = dynObj.route;
+ if (route) //宸ヨ壓璺嚎鐗�
{
- wo_code = json.wocode,
- wotype = json.wotype,
- status = json.wostatus,
- wkshp_code = json.wkshopcode,
- plan_qty = json.woqty,
- lm_user = us.usercode,
- lm_date = DateTime.Now.ToString(),
- materiel_code = json.partcode,
- sourceid = json.sourceid == "" ? null : json.sourceid, //鏃犳簮鍗曟椂璧嬪�糔ULL
- m_po = json.sourcewo,
- saleOrderDeliveryDate = json.deliverydate,
- plan_startdate = json.paystartdate,
- plan_enddate = json.payenddate,
- orderlev = "3",//浼樺厛绾э細鐗圭骇锛�1锛� 绱ф�ワ紙2锛� 姝e父锛�3锛�
- isaps = "N", //鏄惁鎺掍骇,榛樿N Y=鏄� N=鍚�
- data_sources = json.data_sources,
- isstep = json.isstep //鏄惁鍏宠仈宸ュ簭
+ route_code = json.routecode;
}
- });
- //鍐欏叆宸ュ簭浠诲姟琛�
- for (int i = 0; i < json.WorkListSub.Count; i++)
- {
- sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
- values(@wo_code,@seq,@step_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date)";
- list.Add(new
+ else //宸ュ簭鐗�
{
- str = sql,
- parm = new
- {
- wo_code = json.wocode,
- seq = json.WorkListSub[i].stepseq,
- step_code = json.WorkListSub[i].stepcode,
- stepprice = json.WorkListSub[i].stepprice,
- plan_qty = json.woqty,
- status = json.wostatus,
- isbott = json.WorkListSub[i].isbott,
- isend = json.WorkListSub[i].isend,
- lm_user = us.usercode,
- lm_date = DateTime.Now.ToString()
- }
- });
- }
- bool aa = DapperHelper.DoTransaction(list);
- if (aa)
- {
- //鍐欏叆鎿嶄綔璁板綍琛�
- LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗗伐鍗�:" + json.wocode, us.usertype);
- mes.code = "200";
- mes.count = 0;
- mes.message = "MES宸ュ崟鏂板缓鎴愬姛!";
- mes.data = null;
- }
- else
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "MES宸ュ崟鏂板缓澶辫触!";
- mes.data = null;
- }
- }
- if (operType == "Update")
- {
- //淇敼宸ュ崟琛�
- sql = @"update TK_Wrk_Man set wotype=@wotype,wkshp_code=@wkshp_code,plan_qty=@plan_qty,lm_user=@lm_user,lm_date=@lm_date,
- materiel_code=@materiel_code,sourceid=@sourceid,m_po=@m_po,saleOrderDeliveryDate=@saleOrderDeliveryDate,plan_startdate=@plan_startdate,plan_enddate=@plan_enddate,isstep=@isstep
- where wo_code=@wo_code";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- wo_code = json.wocode,
- wotype = json.wotype,
- wkshp_code = json.wkshopcode,
- plan_qty = json.woqty,
- materiel_code = json.partcode,
- sourceid = json.sourceid == "" ? null : json.sourceid, //鏃犳簮鍗曟椂璧嬪�糔ULL
- m_po = json.sourcewo,
- saleOrderDeliveryDate = json.deliverydate,
- plan_startdate = json.paystartdate,
- plan_enddate = json.payenddate,
- lm_user = us.usercode,
- lm_date = DateTime.Now.ToString(),
- isstep = json.isstep //鏄惁鍏宠仈宸ュ簭
+ route_code = null;
}
- });
- //鍒犻櫎宸ュ崟宸ュ簭琛�
- sql = @"delete TK_Wrk_Step where wo_code=@wo_code";
- list.Add(new
- {
- str = sql,
- parm = new
+ if (operType == "Add")
{
- wo_code = json.wocode
- }
- });
- //鍐欏叆宸ュ崟宸ュ簭琛�
- for (int i = 0; i < json.WorkListSub.Count; i++)
- {
- sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
- values(@wo_code,@seq,@step_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date)";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- wo_code = json.wocode,
- seq = json.WorkListSub[i].stepseq,
- step_code = json.WorkListSub[i].stepcode,
- stepprice = json.WorkListSub[i].stepprice,
- plan_qty = json.woqty,
- status = json.wostatus,
- isbott = json.WorkListSub[i].isbott,
- isend = json.WorkListSub[i].isend,
- lm_user = us.usercode,
- lm_date = DateTime.Now.ToString()
- }
- });
- }
+ // 鍋囪浣犲凡缁忔湁浜嗘彃鍏ヤ富琛ㄥ拰瀛愯〃鐨凷QL璇彞
+ //鍐欏叆宸ュ崟琛�
+ string workSql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,lm_user,lm_date,materiel_code,route_code,sourceid,m_po,saleOrderDeliveryDate,plan_startdate,plan_enddate,piroque,isaps,data_sources,isstep,bom_id)
+ values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@lm_user,@lm_date,@materiel_code,@route_code,@sourceid,@m_po,@saleOrderDeliveryDate,@plan_startdate,@plan_enddate,@orderlev,@isaps,@data_sources,@isstep,@bom_id)";
+ //鍐欏叆宸ュ崟宸ュ簭琛�
+ string masterInsertSql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,route_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
+ values(@wo_code,@seq,@step_code,@route_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date); SELECT CAST(SCOPE_IDENTITY() AS INT)";
+ //鍐欏叆宸ュ崟宸ュ簭璁惧琛�
+ string detailInsertSql = @"insert into TK_Wrk_StepEqp(m_id,eqp_code,eqpprice)
+ values(@m_id,@eqp_code,@eqpprice)";
+ //鍐欏叆宸ュ崟鐢ㄦ枡琛�
+ string workall = @"insert into TK_Wrk_Allo(wo_code,seq,materiel_code,qty,status,bom_id,stck_code,stopfeed,base_quantity,total_quantity,m_quantity,loss_quantity)
+ select @wocode,A.seq,A.materiel_code,(convert(decimal(18, 0), @woqty)*A.Base_Quantity*(1+A.LOSS_QUANTITY/100))/C.quantity,
+ 'NEW',A.m_id,'','N',A.base_quantity,A.total_quantity,C.quantity,A.loss_quantity
+ from TBom_Deta A
+ left join TBom_Main C on A.m_Id=C.id
+ left join TMateriel_Info B on A.materiel_code = B.partcode
+ where A.m_id=@bom_id";
- bool aa = DapperHelper.DoTransaction(list);
- if (aa)
- {
- //鍐欏叆鎿嶄綔璁板綍琛�
- LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗗伐鍗�:" + json.wocode, us.usertype);
- mes.code = "200";
- mes.count = 0;
- mes.message = "淇敼鎿嶄綔鎴愬姛!";
- mes.data = null;
+ // 鎻掑叆宸ュ崟琛�
+ var workParam = new DynamicParameters();
+ workParam.Add("@wo_code", json.wocode);
+ workParam.Add("@wotype", json.wotype);
+ workParam.Add("@status", json.wostatus);
+ workParam.Add("@wkshp_code", json.wkshopcode);
+ workParam.Add("@plan_qty", json.woqty);
+ workParam.Add("@lm_user", us.usercode);
+ workParam.Add("@lm_date", DateTime.Now.ToString());
+ workParam.Add("@materiel_code", json.partcode);
+ workParam.Add("@route_code", route_code);
+ workParam.Add("@sourceid", json.sourceid == "" ? null : json.sourceid);
+ workParam.Add("@m_po", json.sourcewo);
+ workParam.Add("@saleOrderDeliveryDate", json.deliverydate);
+ workParam.Add("@plan_startdate", json.paystartdate);
+ workParam.Add("@plan_enddate", json.payenddate);
+ workParam.Add("@orderlev", "3");//浼樺厛绾э細鐗圭骇锛�1锛� 绱ф�ワ紙2锛� 姝e父锛�3锛�
+ workParam.Add("@isaps", "N");//鏄惁鎺掍骇,榛樿N Y=鏄� N=鍚�
+ workParam.Add("@data_sources", json.data_sources);
+ workParam.Add("@isstep", json.isstep);//鏄惁鍏宠仈宸ュ簭
+ workParam.Add("@bom_id", string.IsNullOrEmpty(json.bomid) ? null : json.bomid);// 鐗╂枡璇峰崟Bomid
+ conn.Execute(workSql, workParam, transaction);
+
+ //鍐欏叆宸ュ崟宸ュ簭琛�
+ for (int i = 0; i < json.WorkListSub.Count; i++)
+ {
+ // 鎻掑叆涓昏〃骞惰幏鍙栨柊鎻掑叆鐨処D
+ var masterParam = new DynamicParameters();
+ masterParam.Add("@wo_code", json.wocode);
+ masterParam.Add("@seq", json.WorkListSub[i].stepseq);
+ masterParam.Add("@step_code", json.WorkListSub[i].stepcode);
+ masterParam.Add("@route_code", route_code);
+ masterParam.Add("@stepprice", json.WorkListSub[i].unprice);
+ masterParam.Add("@plan_qty", json.woqty);
+ masterParam.Add("@status", json.wostatus);
+ masterParam.Add("@isbott", json.WorkListSub[i].isbott);
+ masterParam.Add("@isend", json.WorkListSub[i].isend);
+ masterParam.Add("@lm_user", us.usercode);
+ masterParam.Add("@lm_date", DateTime.Now.ToString());
+
+ int masterId = Convert.ToInt32(conn.ExecuteScalar(masterInsertSql, masterParam, transaction));
+
+ // 鍐欏叆宸ュ簭浠诲姟琛�
+ foreach (var detail in json.WorkListSub[i].WorkEqpListSub)
+ {
+ var detailParam = new DynamicParameters();
+ detailParam.Add("@m_id", masterId);
+ detailParam.Add("@eqp_code", detail.eqpcode);
+ detailParam.Add("@eqpprice", detail.unprice);
+ conn.Execute(detailInsertSql, detailParam, transaction);
+ }
+ }
+ //鍐欏叆宸ュ崟鐢ㄦ枡琛�(瀛愪欢)
+ if (json.bomid != "" && json != null)
+ {
+ var workallParam = new DynamicParameters();
+ workallParam.Add("@wocode", json.wocode);
+ workallParam.Add("@woqty", json.woqty);
+ workallParam.Add("@bom_id", json.bomid);
+ conn.Execute(workall, workallParam, transaction);
+ }
+
+ // 鎵�鏈夋彃鍏ユ垚鍔燂紝鎻愪氦浜嬪姟
+ transaction.Commit();
+ mes.code = "200";
+ mes.count = 0;
+ mes.message = "MES宸ュ崟鏂板缓鎴愬姛!";
+ mes.data = null;
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗗伐鍗�:" + json.wocode, us.usertype);
+ }
+ if (operType == "Update")
+ {
+ //閫氳繃宸ュ崟鏌ユ壘宸ュ簭浠诲姟
+ sql = @"select * from TK_Wrk_Step where wo_code=@wo_code";
+ dynamicParams.Add("@wo_code", json.wocode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+
+ // 鍋囪浣犲凡缁忔湁浜嗘彃鍏ヤ富琛ㄥ拰瀛愯〃鐨凷QL璇彞
+ //淇敼宸ュ崟琛�
+ string workSql = @"update TK_Wrk_Man set wotype=@wotype,wkshp_code=@wkshp_code,plan_qty=@plan_qty,lm_user=@lm_user,lm_date=@lm_date,
+ materiel_code=@materiel_code,route_code=@route_code,sourceid=@sourceid,m_po=@m_po,saleOrderDeliveryDate=@saleOrderDeliveryDate,plan_startdate=@plan_startdate,plan_enddate=@plan_enddate,isstep=@isstep,bom_id=@bom_id
+ where wo_code=@wo_code";
+ //鍒犻櫎宸ュ崟宸ュ簭璁惧琛�
+ string deleteWrkStepEqp = @"delete TK_Wrk_StepEqp where m_id=@m_id";
+ //鍒犻櫎宸ュ崟宸ュ簭琛�
+ string deleteWrkStep = @"delete TK_Wrk_Step where wo_code=@wo_code";
+ //鍒犻櫎宸ュ崟鐢ㄦ枡琛�
+ string deleteWrkALL = @"delete TK_Wrk_Allo where wo_code=@wo_code";
+ //鍐欏叆宸ュ崟宸ュ簭琛�
+ string masterInsertSql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,route_code,stepprice,plan_qty,status,isbott,isend,lm_user,lm_date)
+ values(@wo_code,@seq,@step_code,@route_code,@stepprice,@plan_qty,@status,@isbott,@isend,@lm_user,@lm_date); SELECT CAST(SCOPE_IDENTITY() AS INT)";
+ //鍐欏叆宸ュ崟宸ュ簭璁惧琛�
+ string detailInsertSql = @"insert into TK_Wrk_StepEqp(m_id,eqp_code,eqpprice)
+ values(@m_id,@eqp_code,@eqpprice)";
+ //鍐欏叆宸ュ崟鐢ㄦ枡琛�
+ string InsertWorkALL = @"insert into TK_Wrk_Allo(wo_code,seq,materiel_code,qty,status,bom_id,stck_code,stopfeed,base_quantity,total_quantity,m_quantity,loss_quantity)
+ select @wocode,A.seq,A.materiel_code,(convert(decimal(18, 0), @woqty)*A.Base_Quantity*(1+A.LOSS_QUANTITY/100))/C.quantity,
+ 'NEW',A.m_id,'','N',A.base_quantity,A.total_quantity,C.quantity,A.loss_quantity
+ from TBom_Deta A
+ left join TBom_Main C on A.m_Id=C.id
+ left join TMateriel_Info B on A.materiel_code = B.partcode
+ where A.m_id=@bom_id";
+ //淇敼鐢熶骇璁㈠崟琛ㄧ姸鎬併�佸凡涓嬭揪鏁伴噺
+ string EwoStatusSql = @"update TKimp_Ewo set status=@status,relse_qty=@relse_qty where id=@sourceid and wo=@sourcewo";
+
+
+ // 淇敼宸ュ崟琛�
+ var workParam = new DynamicParameters();
+ workParam.Add("@wo_code", json.wocode);
+ workParam.Add("@wotype", json.wotype);
+ workParam.Add("@wkshp_code", json.wkshopcode);
+ workParam.Add("@plan_qty", json.woqty);
+ workParam.Add("@lm_user", us.usercode);
+ workParam.Add("@lm_date", DateTime.Now.ToString());
+ workParam.Add("@materiel_code", json.partcode);
+ workParam.Add("@route_code", route_code);
+ workParam.Add("@sourceid", json.sourceid == "" ? null : json.sourceid);
+ workParam.Add("@m_po", json.sourcewo);
+ workParam.Add("@saleOrderDeliveryDate", json.deliverydate);
+ workParam.Add("@plan_startdate", json.paystartdate);
+ workParam.Add("@plan_enddate", json.payenddate);
+ workParam.Add("@isstep", json.isstep);//鏄惁鍏宠仈宸ュ簭
+ workParam.Add("@bom_id", string.IsNullOrEmpty(json.bomid) ? null : json.bomid);//鐗╂枡娓呭崟BOMid
+ conn.Execute(workSql, workParam, transaction);
+
+ //鍒犻櫎宸ュ崟宸ュ簭璁惧琛�
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ var wrkStepEqpParam = new DynamicParameters();
+ wrkStepEqpParam.Add("@m_id", data.Rows[i]["ID"].ToString());
+ conn.Execute(deleteWrkStepEqp, wrkStepEqpParam, transaction);
+ }
+
+
+ //鍒犻櫎宸ュ崟宸ュ簭琛�
+ var workStepParam = new DynamicParameters();
+ workStepParam.Add("@wo_code", json.wocode);
+ conn.Execute(deleteWrkStep, workStepParam, transaction);
+
+ //鍒犻櫎宸ュ崟鐢ㄦ枡琛�
+ var deleteWrkALLParam = new DynamicParameters();
+ deleteWrkALLParam.Add("@wo_code", json.wocode);
+ conn.Execute(deleteWrkALL, deleteWrkALLParam, transaction);
+
+ //鍐欏叆宸ュ崟宸ュ簭琛�
+ for (int i = 0; i < json.WorkListSub.Count; i++)
+ {
+ // 鎻掑叆涓昏〃骞惰幏鍙栨柊鎻掑叆鐨処D
+ var masterParam = new DynamicParameters();
+ masterParam.Add("@wo_code", json.wocode);
+ masterParam.Add("@seq", json.WorkListSub[i].stepseq);
+ masterParam.Add("@step_code", json.WorkListSub[i].stepcode);
+ masterParam.Add("@route_code", route_code);
+ masterParam.Add("@stepprice", json.WorkListSub[i].unprice);
+ masterParam.Add("@plan_qty", json.woqty);
+ masterParam.Add("@status", json.wostatus);
+ masterParam.Add("@isbott", json.WorkListSub[i].isbott);
+ masterParam.Add("@isend", json.WorkListSub[i].isend);
+ masterParam.Add("@lm_user", us.usercode);
+ masterParam.Add("@lm_date", DateTime.Now.ToString());
+
+ int masterId = Convert.ToInt32(conn.ExecuteScalar(masterInsertSql, masterParam, transaction));
+
+ // 鍐欏叆宸ュ簭浠诲姟琛�
+ foreach (var detail in json.WorkListSub[i].WorkEqpListSub)
+ {
+ var detailParam = new DynamicParameters();
+ detailParam.Add("@m_id", masterId);
+ detailParam.Add("@eqp_code", detail.eqpcode);
+ detailParam.Add("@eqpprice", detail.unprice);
+ conn.Execute(detailInsertSql, detailParam, transaction);
+ }
+ }
+ //鍐欏叆宸ュ崟鐢ㄦ枡琛�
+ if (json.bomid != "" && json.bomid != null)
+ {
+ var InsertWorkALLParam = new DynamicParameters();
+ InsertWorkALLParam.Add("@wocode", json.wocode);
+ InsertWorkALLParam.Add("@woqty", json.woqty);
+ InsertWorkALLParam.Add("@bom_id", json.bomid);
+ conn.Execute(InsertWorkALL, InsertWorkALLParam, transaction);
+ }
+ //鍒ゆ柇婧愬ご鍗曟嵁鏄惁鏉ユ簮ERP
+ if (json.data_sources == "ERP")
+ {
+ //鍒ゆ柇宸ュ崟淇敼鏁伴噺宸�兼槸鍚︿负0
+ if (json.difference != "0")
+ {
+ string staus = "";
+ //鏌ヨ璁㈠崟鎬绘暟,宸蹭笅杈炬暟閲�
+ sql = @"select qty,relse_qty from TKimp_Ewo where id=@sourceid and wo=@sourcewo";
+ dynamicParams.Add("@sourceid", json.sourceid);
+ dynamicParams.Add("@sourcewo", json.sourcewo);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ //褰撳墠宸ュ崟鍙慨鏀规暟閲�=璁㈠崟鏁伴噺-闈炲綋鍓嶅伐鍗曟�讳笅杈惧伐鍗曟暟閲�
+ decimal qty = decimal.Parse(data0.Rows[0]["qty"].ToString());//璁㈠崟鎬绘暟
+ decimal relse_qty = decimal.Parse(data0.Rows[0]["relse_qty"].ToString());//璁㈠崟宸蹭笅杈炬�绘暟
+ relse_qty = relse_qty + decimal.Parse(json.difference);//鏂扮殑涓嬭揪鏁伴噺=鍘熷涓嬭揪鏁伴噺+宸��(姝h礋)
+ if (qty == relse_qty)
+ {
+ staus = "CREATED"; //鍏ㄩ儴涓嬭揪
+ }
+ else
+ {
+ staus = "CREATING";//閮ㄥ垎涓嬭揪
+ }
+ //鏇存柊璁㈠崟琛ㄧ姸鎬併�佸凡涓嬭揪鏁伴噺
+ var EwoStatusParam = new DynamicParameters();
+ EwoStatusParam.Add("@status", staus);
+ EwoStatusParam.Add("@relse_qty", relse_qty);
+ EwoStatusParam.Add("@sourceid", json.sourceid);
+ EwoStatusParam.Add("@sourcewo", json.sourcewo);
+ conn.Execute(EwoStatusSql, EwoStatusParam, transaction);
+ }
+ }
+ // 鎵�鏈夋彃鍏ユ垚鍔燂紝鎻愪氦浜嬪姟
+ transaction.Commit();
+ mes.code = "200";
+ mes.count = 0;
+ mes.message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗗伐鍗�:" + json.wocode, us.usertype);
+ }
}
- else
+ catch (Exception e)
{
+ // 鎹曡幏寮傚父锛屽洖婊氫簨鍔�
+ transaction.Rollback();
mes.code = "300";
mes.count = 0;
- mes.message = "淇敼鎿嶄綔澶辫触!";
+ mes.message = e.Message;
mes.data = null;
}
}
- }
- catch (Exception e)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = e.Message;
- mes.data = null;
}
return mes;
}
@@ -1036,13 +1214,22 @@
list.Add(new { str = sql, parm = new { m_po = m_po, souceid = souceid, orderqty = decimal.Parse(orderqty) } });
}
}
+ //鍒犻櫎宸ュ崟宸ュ簭璁惧琛�
+ sql = @"select * from TK_Wrk_Step where wo_code=@wo_code";
+ dynamicParams.Add("@wo_code", wocode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < data1.Rows.Count; i++)
+ {
+ sql = @"delete TK_Wrk_StepEqp where m_id=@m_id";
+ list.Add(new { str = sql, parm = new { m_id = data1.Rows[i]["ID"].ToString() } });
+ }
//鍒犻櫎宸ュ崟宸ュ簭琛�
sql = @"delete TK_Wrk_Step where wo_code=@wocode";
list.Add(new { str = sql, parm = new { wocode = wocode } });
//鍒犻櫎鍔犲伐鍗曠敤鏂欒〃(瀛愪欢)
- //sql = @"delete TK_Wrk_Allo where wo_code=@wocode";
- //list.Add(new { str = sql, parm = new { wocode = wocode } });
+ sql = @"delete TK_Wrk_Allo where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
//鍒犻櫎宸ュ崟琛�
sql = @"delete TK_Wrk_Man where wo_code=@wocode";
@@ -1085,26 +1272,197 @@
#endregion
#region[MES宸ュ崟鏌ユ壘鍘嗗彶寮曠敤鏈�鏂板伐搴忎俊鎭痌
- public static ToMessage MesOrderNewStepContent(string wkshopcode, string partcode, User us)
+ public static ToMessage MesOrderNewStepContent(string wkshopcode, string routecode, string partcode, User us)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ List<WorkRouteStepEqp> parents = new List<WorkRouteStepEqp>();
+ try
+ {
+ dynamic dynObj = JObject.Parse(us.mesSetting);
+ bool route = dynObj.route;
+ if (route) //宸ヨ壓璺嚎鐗�
+ {
+ //MES宸ュ崟鏌ユ壘鍘嗗彶寮曠敤鏈�鏂板伐搴忎俊鎭�
+ sql = @"select S.id,S.wo_code,S.seq,S.step_code,T.stepname,T.flwtype,S.stepprice as unprice,'0' as produceq_qty,
+ '0' as good_qty,'0' as ng_qty,'0' as laborbad_qty,'0' as materielbad_qty,'0' as delive_qty,isbott,isend
+ from TK_Wrk_Step S
+ inner join (
+ select top 1 S.id,A.wo_code,A.route_code from TK_Wrk_Man A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.route_code=S.route_code
+ where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode and A.route_code=@routecode
+ order by A.lm_date desc
+ ) as W on S.wo_code=W.wo_code and S.route_code=W.route_code
+ left join TStep T on S.step_code=T.stepcode
+ order by S.seq";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@routecode", routecode);
+ parents = DapperHelper.select<WorkRouteStepEqp>(sql, dynamicParams);
+ //鑾峰彇宸ュ簭瀵瑰簲璁惧淇℃伅
+ for (int i = 0; i < parents.Count; i++)
+ {
+ if (parents[i].flwtype == "Z")
+ {
+ //閫氳繃宸ヨ壓璺嚎宸ュ簭琛↖D鏌ユ壘瀵瑰簲璁惧淇℃伅
+ sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as unprice,'Y' as enable,
+ (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
+ S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty
+ from TK_Wrk_StepEqp S
+ inner join TEqpInfo E on S.eqp_code=E.code
+ where S.m_id=@m_id";
+ dynamicParams.Add("@m_id", parents[i].id);
+ var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams);
+ parents[i].children = children.ToList();
+ }
+ else
+ {
+ //閫氳繃宸ヨ壓璺嚎宸ュ簭琛↖D鏌ユ壘瀵瑰簲澶栧崗渚涘簲鍟嗕俊鎭�
+ sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as unprice,'Y' as enable,
+ (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
+ S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty
+ from TK_Wrk_StepEqp S
+ inner join TCustomer E on S.eqp_code=E.code
+ where S.m_id=@m_id";
+ dynamicParams.Add("@m_id", parents[i].id);
+ var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams);
+ parents[i].children = children.ToList();
+ }
+ }
+ }
+ else
+ {
+ //MES宸ュ崟鏌ユ壘鍘嗗彶寮曠敤鏈�鏂板伐搴忎俊鎭�
+ sql = @"select S.id,S.wo_code,S.seq,S.step_code,T.stepname,T.flwtype,S.stepprice as unprice,'0' as produceq_qty,
+ '0' as good_qty,'0' as ng_qty,'0' as laborbad_qty,'0' as materielbad_qty,'0' as delive_qty,isbott,isend
+ from TK_Wrk_Step S
+ inner join (
+ select top 1 A.wo_code from TK_Wrk_Man A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code
+ where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode
+ order by A.lm_date desc
+ ) as W on S.wo_code=W.wo_code
+ left join TStep T on S.step_code=T.stepcode
+ order by S.seq";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@partcode", partcode);
+ parents = DapperHelper.select<WorkRouteStepEqp>(sql, dynamicParams);
+ //鑾峰彇宸ュ簭瀵瑰簲璁惧淇℃伅
+ for (int i = 0; i < parents.Count; i++)
+ {
+ if (parents[i].flwtype == "Z")
+ {
+ //閫氳繃宸ヨ壓璺嚎宸ュ簭琛↖D鏌ユ壘瀵瑰簲璁惧淇℃伅
+ sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as unprice,'Y' as enable,
+ (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
+ S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty
+ from TK_Wrk_StepEqp S
+ inner join TEqpInfo E on S.eqp_code=E.code
+ where S.m_id=@m_id";
+ dynamicParams.Add("@m_id", parents[i].id);
+ var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams);
+ parents[i].children = children.ToList();
+ }
+ else
+ {
+ //閫氳繃宸ヨ壓璺嚎宸ュ簭琛↖D鏌ユ壘瀵瑰簲澶栧崗渚涘簲鍟嗕俊鎭�
+ sql = @"select S.eqp_code,E.name as eqp_name,S.eqpprice as unprice,'Y' as enable,
+ (isnull(S.good_qty,0)+isnull(S.ng_qty,0)+isnull(S.laborbad_qty,0)+isnull(S.materielbad_qty,0)) as produceq_qty,
+ S.good_qty,S.ng_qty,S.laborbad_qty,S.materielbad_qty
+ from TK_Wrk_StepEqp S
+ inner join TCustomer E on S.eqp_code=E.code
+ where S.m_id=@m_id";
+ dynamicParams.Add("@m_id", parents[i].id);
+ var children = DapperHelper.select<WorkRouteStepEqpSub>(sql, dynamicParams);
+ parents[i].children = children.ToList();
+ }
+ }
+ }
+ mes.code = "200";
+ mes.count = parents.Count;
+ mes.data = parents;
+ mes.message = "鏌ヨ鎴愬姛!";
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏌ョ湅宸ュ崟SOP]
+ public static ToMessage MesOrderSopSearch(string wocode, string materielcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇SOP鏂囦欢淇℃伅
+ sql = @"select filename,filepath,version from TWrkOrderSop
+ where wo=@wocode and materielcode=@materielcode
+ order by version";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@materielcode", materielcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.message = "褰撳墠宸ュ崟浜у搧鏆傛棤SOP鏂囦欢!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏌ョ湅宸ヨ壓SOP]
+ public static ToMessage MesOrderProcessSopSearch(string materielcode, string routecode, string stepcode, User us)
{
var sql = "";
List<object> list = new List<object>();
var dynamicParams = new DynamicParameters();
try
{
- //MES宸ュ崟鏌ユ壘鍘嗗彶寮曠敤鏈�鏂板伐搴忎俊鎭�
- sql = @"select S.wo_code,S.seq,S.step_code,S.stepprice,isbott,isend
- from TK_Wrk_Step S
- inner join (
- select top 1 A.wo_code from TK_Wrk_Man A
- inner join TK_Wrk_Step S on A.wo_code=S.wo_code
- where A.materiel_code=@partcode and A.wkshp_code=@wkshopcode
- order by A.lm_date desc
- ) as W on S.wo_code=W.wo_code
- left join TStep T on S.step_code=T.stepcode
- order by S.seq";
- dynamicParams.Add("@wkshopcode", wkshopcode);
- dynamicParams.Add("@partcode", partcode);
+ dynamic dynObj = JObject.Parse(us.mesSetting);
+ bool route = dynObj.route;
+ if (route) //宸ヨ壓璺嚎鐗�
+ {
+ //鑾峰彇SOP鏂囦欢淇℃伅
+ sql = @"select filename,filepath,version from TProcessSop
+ where materielcode=@materielcode and routecode=@routecode and stepcode=@stepcode
+ order by version";
+ dynamicParams.Add("@materielcode", materielcode);
+ dynamicParams.Add("@routecode", routecode);
+ dynamicParams.Add("@stepcode", stepcode);
+ }
+ else
+ {
+ //鑾峰彇SOP鏂囦欢淇℃伅
+ sql = @"select filename,filepath,version from TProcessSop
+ where materielcode=@materielcode and stepcode=@stepcode
+ order by version";
+ dynamicParams.Add("@materielcode", materielcode);
+ dynamicParams.Add("@stepcode", stepcode);
+ }
+
var data = DapperHelper.selectdata(sql, dynamicParams);
mes.code = "200";
mes.count = data.Rows.Count;
@@ -1735,21 +2093,82 @@
#endregion
#region [鐢熶骇寮�鎶ュ伐锛氭姤宸�/澶栧崗(鍙戞枡/鏀舵枡)鏃舵潯浠跺垽鏂強鏁版嵁杩斿洖鎺ュ彛]
- public static ToMessage MesOrderStepStart(string OperType, string SelectType, string wocode, string stepcode)
+ public static ToMessage MesOrderStepStart(string OperType, string SelectType, string wocode, string stepcode, User us)
{
var dynamicParams = new DynamicParameters();
try
{
+ dynamic dynObj = JObject.Parse(us.mesSetting);
+ bool isOrder = dynObj.isOrder;
switch (OperType)
{
case "ZZ":
- mes = ScanStartReport.ZZEncodingSeach(wocode, stepcode);
+ if (isOrder) //鎸夊簭鐢熶骇
+ {
+ mes = ScanStartReport.ZZEncodingSeach(wocode, stepcode);
+ }
+ else //涓嶆寜搴忕敓浜�
+ {
+ mes = ScanStartReport.NoZZEncodingSeach(wocode, stepcode);
+ }
break;
case "WX":
- mes = ScanStartReport.WXEncodingSeach(SelectType, wocode, stepcode);
+ if (isOrder) //鎸夊簭鏀跺彂鏂�
+ {
+ mes = ScanStartReport.WXEncodingSeach(SelectType, wocode, stepcode);
+ }
+ else //涓嶆寜搴忔敹鍙戞枡
+ {
+ mes = ScanStartReport.NoWXEncodingSeach(SelectType, wocode, stepcode);
+ }
break;
default:
break;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [鐢熶骇寮�鎶ュ伐锛氭姤宸�/澶栧崗(鍙戞枡/鏀舵枡)鏃惰幏鍙栬澶�/澶栧崗渚涘簲鍟嗘暟鎹繑鍥炴帴鍙
+ public static ToMessage MesOrderStepDeviceCusstomer(string operType, string wocode, string stepcode, User us)
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (operType == "ZZ")
+ {
+ sql = @"select E.eqp_code as code,D.name,E.eqpprice from TK_Wrk_Step S
+ inner join TK_Wrk_StepEqp E on S.id=E.m_id
+ left join TEqpInfo D on E.eqp_code=D.code
+ where S.wo_code=@wocode and S.step_code=@stepcode and D.enable='Y'";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ if (operType == "WX")
+ {
+ sql = @"select E.eqp_code as code,C.name,E.eqpprice from TK_Wrk_Step S
+ inner join TK_Wrk_StepEqp E on S.id=E.m_id
+ inner join TCustomer C on E.eqp_code=C.code
+ where S.wo_code=@wocode and S.step_code=@stepcode ";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
}
}
catch (Exception e)
@@ -1938,8 +2357,6 @@
}
}
}
-
-
//鍥炲啓宸ュ崟宸ュ簭琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
sql = @"update TK_Wrk_Step set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode and step_code=@stepcode";
list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, reportqty = reportqty, ngqty = ngqty } });
@@ -2061,7 +2478,7 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐,鏀舵枡鎻愪氦]
- public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inbarcode, string inuser, string taskqty, string sqty, List<ReportDefectList> defectobjs, string remarks, User us)
+ public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode,string stepprice, string wxcode, string inbarcode, string inuser, string taskqty, string sqty, List<ReportDefectList> defectobjs, string remarks, User us)
{
var sql = "";
string[] arra1 = new string[] { };
@@ -2149,9 +2566,9 @@
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,inbarcode)
- values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)";
- 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 = us.usercode, lm_date = date, inbarcode = inbarcode } });
+ sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,step_price,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@step_price,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode,step_price=stepprice, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = us.usercode, lm_date = date, inbarcode = inbarcode } });
//鍐欏叆澶栧崗璁板綍瀛愯〃
sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
@@ -2176,9 +2593,9 @@
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,inbarcode)
- values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)";
- 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 = us.usercode, lm_date = date, inbarcode = inbarcode } });
+ sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,step_price,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@step_price,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, step_price=stepprice, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = us.usercode, lm_date = date, inbarcode = inbarcode } });
//鍐欏叆澶栧崗璁板綍瀛愯〃
sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
@@ -2686,42 +3103,537 @@
var dynamicParams = new DynamicParameters();
try
{
- //鎺у埗閫昏緫锛氶閬撳伐搴忚皟鏁�-> 鏈亾宸ュ簭褰撳墠璋冩暣鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ユ�绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)>浠诲姟鏁伴噺 ==涓嶈兘澶т簬浠诲姟鏁伴噺
- //鎺у埗閫昏緫锛氶閬撳伐搴忚皟鏁�-> (鏈亾宸ュ簭褰撳墠璋冩暣鍚堟牸鏁�+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ュ悎鏍兼�绘暟)<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾) ==涓嶈兘灏忎簬涓嬮亾鎶ュ伐鎬绘暟
- //鎺у埗閫昏緫锛氭湯閬撳伐搴忚皟鏁�-> 鏈亾宸ュ簭褰撳墠璋冩暣鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ユ�绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)>涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟 ==涓嶈兘澶т簬涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟
- //鎺у埗閫昏緫锛氫腑闂村伐搴忚皟鏁�-> 鏈亾宸ュ簭褰撳墠璋冩暣鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ユ�绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)>涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟 ==涓嶈兘澶т簬涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟
- //鎺у埗閫昏緫锛氫腑闂村伐搴忚皟鏁�-> (鏈亾宸ュ簭褰撳墠璋冩暣鍚堟牸鏁�+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ュ悎鏍兼�绘暟)<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾) ==涓嶈兘灏忎簬涓嬮亾鎶ュ伐鎬绘暟
+ dynamic dynObj = JObject.Parse(us.mesSetting);
+ bool isOrder = dynObj.isOrder;
+ //鑾峰彇姝ゆ鎶ュ伐璋冩暣鎻愪氦鐨勬暟鎹�(鍚堟牸鏁伴噺銆佷笉鑹暟閲忋�佸伐搴熸暟閲忋�佹枡搴熸暟閲�)
+ decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //鎶ュ伐鏁伴噺(鍚堟牸)
+ decimal this_ngqty = json[0].children.Sum(item => decimal.Parse(item.ng_qty));//涓嶈壇鏁伴噺姹囨��
+ decimal this_laborbadqty = json[0].children.Sum(item => decimal.Parse(item.laborbad_qty));//宸ュ簾鏁伴噺姹囨��
+ decimal this_materielbadqty = json[0].children.Sum(item => decimal.Parse(item.materielbad_qty));//鏂欏簾鏁伴噺姹囨��
+ decimal this_ng_dvalue = json[0].children.Sum(item => decimal.Parse(item.ng_dvalue));//涓嶈壇鏁伴噺宸�兼眹鎬�
+ decimal this_laborbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.laborbad_dvalue));//宸ュ簾鏁伴噺宸�兼眹鎬�
+ decimal this_materielbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.materielbad_dvalue));//鏂欏簾鏁伴噺宸�兼眹鎬�
string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
- list.Clear();
- //鑾峰彇褰撳墠宸ュ簭涓婇亾宸ュ簭鍙婂睘鎬�
- sql = @"select T.stepcode,T.stepname,T.flwtype from TK_Wrk_Step A
+ if (isOrder) //鎸夊簭
+ {
+ //鎺у埗閫昏緫锛氶閬撳伐搴忚皟鏁�-> 鏈亾宸ュ簭褰撳墠璋冩暣鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ユ�绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)>浠诲姟鏁伴噺 ==涓嶈兘澶т簬浠诲姟鏁伴噺
+ //鎺у埗閫昏緫锛氶閬撳伐搴忚皟鏁�-> (鏈亾宸ュ簭褰撳墠璋冩暣鍚堟牸鏁�+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ュ悎鏍兼�绘暟)<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾) ==涓嶈兘灏忎簬涓嬮亾鎶ュ伐鎬绘暟
+ //鎺у埗閫昏緫锛氭湯閬撳伐搴忚皟鏁�-> 鏈亾宸ュ簭褰撳墠璋冩暣鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ユ�绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)>涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟 ==涓嶈兘澶т簬涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟
+ //鎺у埗閫昏緫锛氫腑闂村伐搴忚皟鏁�-> 鏈亾宸ュ簭褰撳墠璋冩暣鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ユ�绘暟(鍚堟牸+涓嶈壇+鎶ュ簾)>涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟 ==涓嶈兘澶т簬涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟
+ //鎺у埗閫昏緫锛氫腑闂村伐搴忚皟鏁�-> (鏈亾宸ュ簭褰撳墠璋冩暣鍚堟牸鏁�+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ュ悎鏍兼�绘暟)<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾) ==涓嶈兘灏忎簬涓嬮亾鎶ュ伐鎬绘暟
+
+
+ list.Clear();
+ //鑾峰彇褰撳墠宸ュ簭涓婇亾宸ュ簭鍙婂睘鎬�
+ sql = @"select T.stepcode,T.stepname,T.flwtype 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", json[0].wo_code);
- dynamicParams.Add("@seq", json[0].step_seq);
- var pre = DapperHelper.selectdata(sql, dynamicParams);
- //鑾峰彇褰撳墠宸ュ簭涓嬮亾宸ュ簭鍙婂睘鎬�
- sql = @"select T.stepcode,T.stepname,T.flwtype from TK_Wrk_Step A
+ dynamicParams.Add("@ordercode", json[0].wo_code);
+ dynamicParams.Add("@seq", json[0].step_seq);
+ var pre = DapperHelper.selectdata(sql, dynamicParams);
+ //鑾峰彇褰撳墠宸ュ簭涓嬮亾宸ュ簭鍙婂睘鎬�
+ sql = @"select T.stepcode,T.stepname,T.flwtype 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", json[0].wo_code);
- dynamicParams.Add("@seq", json[0].step_seq);
- var next = DapperHelper.selectdata(sql, dynamicParams);
- //鍒ゆ柇褰撳墠宸ュ簭鏄嚜鍒跺伐搴忚繕鏄鍗忓伐搴�
- if (json[0].flw_type.ToString() == "Z")//鑷埗宸ュ簭
- {
- //鑾峰彇姝ゆ鎶ュ伐璋冩暣鎻愪氦鐨勬暟鎹�(鍚堟牸鏁伴噺銆佷笉鑹暟閲忋�佸伐搴熸暟閲忋�佹枡搴熸暟閲�)
- decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //鎶ュ伐鏁伴噺(鍚堟牸)
- decimal this_ngqty = json[0].children.Sum(item => decimal.Parse(item.ng_qty));//涓嶈壇鏁伴噺姹囨��
- decimal this_laborbadqty = json[0].children.Sum(item => decimal.Parse(item.laborbad_qty));//宸ュ簾鏁伴噺姹囨��
- decimal this_materielbadqty = json[0].children.Sum(item => decimal.Parse(item.materielbad_qty));//鏂欏簾鏁伴噺姹囨��
- decimal this_ng_dvalue = json[0].children.Sum(item => decimal.Parse(item.ng_dvalue));//涓嶈壇鏁伴噺宸�兼眹鎬�
- decimal this_laborbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.laborbad_dvalue));//宸ュ簾鏁伴噺宸�兼眹鎬�
- decimal this_materielbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.materielbad_dvalue));//鏂欏簾鏁伴噺宸�兼眹鎬�
- //棣栭亾宸ュ簭鐨勬姤宸�
- if (json[0].first_choke == "Y")
+ dynamicParams.Add("@ordercode", json[0].wo_code);
+ dynamicParams.Add("@seq", json[0].step_seq);
+ var next = DapperHelper.selectdata(sql, dynamicParams);
+ //鍒ゆ柇褰撳墠宸ュ簭鏄嚜鍒跺伐搴忚繕鏄鍗忓伐搴�
+ if (json[0].flw_type.ToString() == "Z")//鑷埗宸ュ簭
{
- //鏌ヨ褰撳墠棣栭亾鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ //棣栭亾宸ュ簭鐨勬姤宸�
+ if (json[0].first_choke == "Y")
+ {
+ //鏌ヨ褰撳墠棣栭亾鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
+ decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�讳笉鑹暟
+ decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�诲伐搴熸暟
+ decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘枡搴熸暟
+ //鍒ゆ柇锛氬綋鍓嶅伐搴忔姤宸ヨ褰曪細鏈鎶ュ伐鏁伴噺+鏈涓嶈壇鏁伴噺+鏈宸ュ簾鏁伴噺+鏈鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟>宸ュ崟浠诲姟鏁伴噺
+ decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
+ if (updatereportsumqty > decimal.Parse(json[0].task_qty.ToString()))
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠棣栭亾宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡伐鍗曚换鍔℃暟閲忥細銆�" + json[0].task_qty.ToString() + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭鍙婂睘鎬�
+ if (next.Rows.Count > 0)
+ {
+ if (next.Rows[0]["flwtype"].ToString() == "Z")
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氭姤宸ユ�绘暟鏁伴噺+涓嶈壇鎬绘暟鏁伴噺+宸ュ簾鎬绘暟閲�+鏂欏簾鎬绘暟閲�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�+涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�+涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�+涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
+ decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
+ decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
+ decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
+ if ((notthis_reportqty + this_reportqty) < last_updatereportsumqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠棣栭亾宸ュ簭淇敼鎶ュ伐鎬诲悎鏍兼暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撹嚜鍒跺伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
+ sql = @"select isnull(sum(fqty),0) as good_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
+ if ((notthis_reportqty + this_reportqty) < last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠棣栭亾宸ュ簭淇敼鎶ュ伐鎬诲悎鏍兼暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撳鍗忓伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+
+ }
+ //鏈亾宸ュ簭鐨勬姤宸�
+ else if (json[0].last_choke == "Y")
+ {
+ //鏌ヨ褰撳墠鏈亾鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
+ decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
+ decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ュ伐搴熸�绘暟
+ decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ枡搴熸�绘暟
+ //鑾峰彇褰撳墠鏈亾宸ュ簭鎶ュ伐鎬绘暟閲忥細鏈淇敼鎶ュ伐鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鎶ュ伐鏂欏簾鏁伴噺+褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆℃枡搴熸�绘暟
+ decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
+
+ //鍒ゆ柇鏄惁瀛樺湪涓婇亾宸ュ簭鍙婂睘鎬�
+ if (pre.Rows.Count > 0)
+ {
+ if (pre.Rows[0]["flwtype"].ToString() == "Z")
+ {
+ //鏌ヨ褰撳墠鏈亾宸ュ簭涓婇亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq-1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓婇亾宸ュ簭鎶ュ伐鎬绘暟閲�
+ decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓婇亾宸ュ簭涓嶈壇鎬绘暟閲�
+ decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓婇亾宸ュ簭宸ュ簾鎬绘暟閲�
+ decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓婇亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
+ //鍒ゆ柇锛氬綋鍓嶆湯閬撳伐搴忔姤宸ヨ褰曪細褰撳墠鏈亾宸ュ簭鎶ュ伐鎬绘暟閲�>涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟
+ if (updatereportsumqty > last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠鏈亾宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔姤宸ユ�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓婇亾宸ュ簭锛氭�绘敹鏂欐暟閲�
+ sql = @"select isnull(sum(sqty),0) as good_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氭敹鏂欐�绘暟鏁伴噺
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
+ //鍒ゆ柇锛氬綋鍓嶆湯閬撳伐搴忔姤宸ヨ褰曪細褰撳墠鏈亾宸ュ簭鎶ュ伐鎬绘暟閲�>涓婇亾宸ュ簭鏀舵枡鍚堟牸鎬绘暟
+ if (updatereportsumqty > last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠鏈亾宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔敹鏂欐�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ }
+ else //涓棿宸ュ簭鐨勬姤宸�
+ {
+ //鏌ヨ褰撳墠涓棿鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
+ decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
+ decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ュ伐璐规�绘暟
+ decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ枡搴熸�绘暟
+ //鑾峰彇褰撳墠涓棿宸ュ簭鎶ュ伐鎬绘暟閲忥細鏈淇敼鎶ュ伐鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鏂欏簾鎬绘暟+褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟
+ decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
+
+ //鍒ゆ柇鏄惁瀛樺湪涓婇亾宸ュ簭鍙婂睘鎬�
+ if (pre.Rows.Count > 0)
+ {
+ if (pre.Rows[0]["flwtype"].ToString() == "Z")
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓婇亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq-1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓婇亾宸ュ簭鎶ュ伐鎬诲悎鏍兼暟閲�
+ decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓婇亾宸ュ簭涓嶈壇鎬绘暟閲�
+ decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓婇亾宸ュ簭宸ュ簾鎬绘暟閲�
+ decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());//涓婇亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
+ //鍒ゆ柇锛氬綋鍓嶅伐搴忔姤宸ヨ褰曪細褰撳墠宸ュ簭鎶ュ伐鎬绘暟>涓婇亾宸ュ簭鎶ュ伐鎬诲悎鏍兼暟
+ if (updatereportsumqty > last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔姤宸ユ�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓婇亾宸ュ簭锛氭�绘敹鏂欐暟閲�
+ sql = @"select isnull(sum(sqty),0) as good_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氭敹鏂欐�绘暟鏁伴噺
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓婇亾宸ュ簭鏀舵枡鎬诲悎鏍兼暟閲�
+ //鍒ゆ柇锛氬綋鍓嶆湯閬撳伐搴忔姤宸ヨ褰曪細褰撳墠宸ュ簭鎶ュ伐鎬绘暟閲�>涓婇亾宸ュ簭鏀舵枡鎬诲悎鏍兼暟閲�
+ if (updatereportsumqty > last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔敹鏂欐�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭灞炴��
+ if (next.Rows.Count > 0)
+ {
+ if (next.Rows[0]["flwtype"].ToString() == "Z")
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt1.Rows.Count > 0)
+ {
+ decimal last_reportqty = decimal.Parse(dt1.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
+ decimal last_ngqty = decimal.Parse(dt1.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
+ decimal last_laborbad_qty = decimal.Parse(dt1.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
+ decimal last_materielbad_qty = decimal.Parse(dt1.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
+ if ((notthis_reportqty + this_reportqty) < last_updatereportsumqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬诲悎鏍兼暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撳伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
+ sql = @"select isnull(sum(fqty),0) as good_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬诲悎鏍兼暟閲�
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
+ if ((notthis_reportqty + this_reportqty) < last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉ぇ浜庝笅閬撳伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (json[0].flw_type.ToString() == "W")//澶栧崗宸ュ簭
+ {
+ //鏌ヨ褰撳墠棣栭亾宸ュ簭闈炴娆′緵搴斿晢鏀舵枡锛氭�绘敹鏂欐暟閲�
+ sql = @"select isnull(sum(sqty),0) as sqty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code<>@wx_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ dynamicParams.Add("@wx_code", json[0].wxcode);
+ var dt_c = DapperHelper.selectdata(sql, dynamicParams);
+
+ //鑾峰彇褰撳墠宸ュ簭銆佷緵搴斿晢瀵瑰簲鐨勫彂鏂欐暟閲�
+ sql = @"select isnull(sum(fqty),0) as fqty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and id<>@id and step_code=@step_code and wx_code=@wx_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ dynamicParams.Add("@wx_code", json[0].wxcode);
+ var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ //棣栭亾宸ュ簭鐨勬敹鏂�
+ if (json[0].first_choke == "Y")
+ {
+ //鏌ヨ褰撳墠棣栭亾宸ュ簭闈炴娆℃敹鏂欙細鎬绘敹鏂欐暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ dynamicParams.Add("@wx_code", json[0].wxcode);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟
+ decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�讳笉鑹暟
+ decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�诲伐搴熸暟
+ decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘枡搴熸暟
+ //鍒ゆ柇锛氬綋鍓嶅伐搴忔姤宸ヨ褰曪細鏈鏀舵枡鏁伴噺+鏈涓嶈壇鏁伴噺+鏈宸ュ簾鏁伴噺+鏈鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟>鍙戞枡鏁伴噺
+ decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
+ if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠澶栧崗宸ュ簭瀵瑰簲渚涘簲鍟嗘敹鏂欐�绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡彂鏂欐暟閲忥細銆�" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭鍙婂睘鎬�
+ if (next.Rows.Count > 0)
+ {
+ if (next.Rows[0]["flwtype"].ToString() == "Z")
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氭姤宸ユ�绘暟鏁伴噺+涓嶈壇鎬绘暟鏁伴噺+宸ュ簾鎬绘暟閲�+鏂欏簾鎬绘暟閲�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�+涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�+涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�+涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
+ decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
+ decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
+ decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鏀舵枡璋冩暣鏁�+闈炲綋鍓嶄緵搴斿晢鍚屽伐搴忔敹鏂欐�绘暟锛�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
+ if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠澶栧崗宸ュ簭鏀舵枡鏁伴噺锛氥��" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "銆戜笉鑳藉皬浜庝笅閬撹嚜鍒跺伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
+ sql = @"select isnull(sum(fqty),0) as good_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鎶ュ伐璋冩暣鏀舵枡鏁帮級<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
+ if ((notthis_reportqty + this_reportqty) < last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠澶栧崗宸ュ簭鏀舵枡鎬绘暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撳鍗忓伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+
+ }
+ //鏈亾宸ュ簭鐨勬姤宸�
+ else if (json[0].last_choke == "Y")
+ {
+ //鏌ヨ褰撳墠鏈亾鎶ュ伐宸ュ簭闈炴娆℃敹鏂欙細鎬绘敹鏂欐暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃敹鏂欐�绘暟
+ decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
+ decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ュ伐搴熸�绘暟
+ decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ枡搴熸�绘暟
+ //鑾峰彇褰撳墠鏈亾宸ュ簭鏀舵枡鎬绘暟閲忥細鏈淇敼鏀舵枡鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鎶ュ伐鏂欏簾鏁伴噺+褰撳墠鏈亾宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆℃枡搴熸�绘暟
+ decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
+ //鍒ゆ柇褰撳墠宸ュ簭渚涘簲鍟嗘敹鏂欐�绘暟>褰撳墠宸ュ簭渚涘簲鍟嗗搴斿彂鏂欐暟閲�
+ if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠宸ュ簭渚涘簲鍟嗘敹鏂欐�绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡伐搴忎緵搴斿晢鍙戞枡鎬绘暟閲忥細銆�" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+
+ }
+ else //涓棿宸ュ簭鐨勬姤宸�
+ {
+
+ //鏌ヨ褰撳墠棣栭亾宸ュ簭渚涘簲鍟嗛潪姝ゆ鏀舵枡锛氭�绘敹鏂欐暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@id", json[0].id);
+ dynamicParams.Add("@step_code", json[0].step_code);
+ dynamicParams.Add("@wx_code", json[0].wxcode);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟
+ decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�讳笉鑹暟
+ decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�诲伐搴熸暟
+ decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘枡搴熸暟
+ //鍒ゆ柇锛氬綋鍓嶅伐搴忔姤宸ヨ褰曪細鏈鏀舵枡鏁伴噺+鏈涓嶈壇鏁伴噺+鏈宸ュ簾鏁伴噺+鏈鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟>鍙戞枡鏁伴噺
+ decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
+ if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠澶栧崗宸ュ簭瀵瑰簲渚涘簲鍟嗘敹鏂欐�绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡彂鏂欐暟閲忥細銆�" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭鍙婂睘鎬�
+ if (next.Rows.Count > 0)
+ {
+ if (next.Rows[0]["flwtype"].ToString() == "Z")
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
+ sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
+ from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氭姤宸ユ�绘暟鏁伴噺+涓嶈壇鎬绘暟鏁伴噺+宸ュ簾鎬绘暟閲�+鏂欏簾鎬绘暟閲�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�+涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�+涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�+涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
+ decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
+ decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
+ decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
+ decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鏀舵枡璋冩暣鏁�+闈炲綋鍓嶄緵搴斿晢鍚屽伐搴忔敹鏂欐�绘暟锛�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
+ if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠澶栧崗宸ュ簭鏀舵枡鏁伴噺锛氥��" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "銆戜笉鑳藉皬浜庝笅閬撹嚜鍒跺伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else
+ {
+ //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
+ sql = @"select isnull(sum(fqty),0) as good_qty
+ from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1";
+ dynamicParams.Add("@wo_code", json[0].wo_code);
+ dynamicParams.Add("@step_seq", json[0].step_seq);
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
+ decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
+ //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鎶ュ伐璋冩暣鏀舵枡鏁�+闈炲綋鍓嶄緵搴斿晢鍚屽伐搴忔敹鏂欐�绘暟锛�<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
+ if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_reportqty)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.message = "褰撳墠澶栧崗宸ュ簭鏀舵枡鎬绘暟閲忥細銆�" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "銆戜笉鑳藉皬浜庝笅閬撳鍗忓伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else //涓嶆寜搴�
+ {
+ //鎺у埗閫昏緫锛氬綋鍓嶅伐搴忔姤宸ヨ皟鏁�-> (鏈亾宸ュ簭褰撳墠璋冩暣鍚堟牸鏁�+鏈亾宸ュ簭闈炲綋鍓嶆姤宸ュ悎鏍兼�绘暟)<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟(鍚堟牸+涓嶈壇+鎶ュ簾) ==涓嶈兘灏忎簬涓嬮亾鎶ュ伐鎬绘暟
+ list.Clear();
+ //鍒ゆ柇褰撳墠宸ュ簭鏄嚜鍒跺伐搴忚繕鏄鍗忓伐搴�
+ if (json[0].flw_type.ToString() == "Z")
+ {
+
+ //鏌ヨ褰撳墠鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
dynamicParams.Add("@wo_code", json[0].wo_code);
@@ -2738,472 +3650,23 @@
{
mes.code = "300";
mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡伐鍗曚换鍔℃暟閲忥細銆�" + json[0].task_qty.ToString() + "銆�!";
+ mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡伐鍗曚换鍔℃暟閲忥細銆�" + json[0].task_qty.ToString() + "銆�!";
mes.data = null;
return mes;
}
- //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭鍙婂睘鎬�
- if (next.Rows.Count > 0)
- {
- if (next.Rows[0]["flwtype"].ToString() == "Z")
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氭姤宸ユ�绘暟鏁伴噺+涓嶈壇鎬绘暟鏁伴噺+宸ュ簾鎬绘暟閲�+鏂欏簾鎬绘暟閲�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�+涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�+涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�+涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
- decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
- decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
- decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
- if ((notthis_reportqty + this_reportqty) < last_updatereportsumqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭淇敼鎶ュ伐鎬诲悎鏍兼暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撹嚜鍒跺伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- else
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
- sql = @"select isnull(sum(fqty),0) as good_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
- if ((notthis_reportqty + this_reportqty) < last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭淇敼鎶ュ伐鎬诲悎鏍兼暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撳鍗忓伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- }
-
}
- //鏈亾宸ュ簭鐨勬姤宸�
- else if (json[0].last_choke == "Y")
+ if (json[0].flw_type.ToString() == "W")
{
- //鏌ヨ褰撳墠鏈亾鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@id", json[0].id);
- dynamicParams.Add("@step_code", json[0].step_code);
- var dt = DapperHelper.selectdata(sql, dynamicParams);
- decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
- decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
- decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ュ伐搴熸�绘暟
- decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ枡搴熸�绘暟
- //鑾峰彇褰撳墠鏈亾宸ュ簭鎶ュ伐鎬绘暟閲忥細鏈淇敼鎶ュ伐鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鎶ュ伐鏂欏簾鏁伴噺+褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆℃枡搴熸�绘暟
- decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
-
- //鍒ゆ柇鏄惁瀛樺湪涓婇亾宸ュ簭鍙婂睘鎬�
- if (pre.Rows.Count > 0)
- {
- if (pre.Rows[0]["flwtype"].ToString() == "Z")
- {
- //鏌ヨ褰撳墠鏈亾宸ュ簭涓婇亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq-1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓婇亾宸ュ簭鎶ュ伐鎬绘暟閲�
- decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓婇亾宸ュ簭涓嶈壇鎬绘暟閲�
- decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓婇亾宸ュ簭宸ュ簾鎬绘暟閲�
- decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓婇亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
- //鍒ゆ柇锛氬綋鍓嶆湯閬撳伐搴忔姤宸ヨ褰曪細褰撳墠鏈亾宸ュ簭鎶ュ伐鎬绘暟閲�>涓婇亾宸ュ簭鎶ュ伐鍚堟牸鎬绘暟
- if (updatereportsumqty > last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠鏈亾宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔姤宸ユ�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- else
- {
- //鏌ヨ褰撳墠宸ュ簭涓婇亾宸ュ簭锛氭�绘敹鏂欐暟閲�
- sql = @"select isnull(sum(sqty),0) as good_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氭敹鏂欐�绘暟鏁伴噺
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
- //鍒ゆ柇锛氬綋鍓嶆湯閬撳伐搴忔姤宸ヨ褰曪細褰撳墠鏈亾宸ュ簭鎶ュ伐鎬绘暟閲�>涓婇亾宸ュ簭鏀舵枡鍚堟牸鎬绘暟
- if (updatereportsumqty > last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠鏈亾宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔敹鏂欐�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- }
- }
- else //涓棿宸ュ簭鐨勬姤宸�
- {
- //鏌ヨ褰撳墠涓棿鎶ュ伐宸ュ簭闈炴娆℃姤宸ワ細鎬绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and id<>@id and step_code=@step_code";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@id", json[0].id);
- dynamicParams.Add("@step_code", json[0].step_code);
- var dt = DapperHelper.selectdata(sql, dynamicParams);
- decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
- decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
- decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ュ伐璐规�绘暟
- decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ枡搴熸�绘暟
- //鑾峰彇褰撳墠涓棿宸ュ簭鎶ュ伐鎬绘暟閲忥細鏈淇敼鎶ュ伐鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鏂欏簾鎬绘暟+褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟
- decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
-
- //鍒ゆ柇鏄惁瀛樺湪涓婇亾宸ュ簭鍙婂睘鎬�
- if (pre.Rows.Count > 0)
- {
- if (pre.Rows[0]["flwtype"].ToString() == "Z")
- {
- //鏌ヨ褰撳墠宸ュ簭涓婇亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq-1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓婇亾宸ュ簭鎶ュ伐鎬诲悎鏍兼暟閲�
- decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓婇亾宸ュ簭涓嶈壇鎬绘暟閲�
- decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓婇亾宸ュ簭宸ュ簾鎬绘暟閲�
- decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString());//涓婇亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
- //鍒ゆ柇锛氬綋鍓嶅伐搴忔姤宸ヨ褰曪細褰撳墠宸ュ簭鎶ュ伐鎬绘暟>涓婇亾宸ュ簭鎶ュ伐鎬诲悎鏍兼暟
- if (updatereportsumqty > last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔姤宸ユ�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- else
- {
- //鏌ヨ褰撳墠宸ュ簭涓婇亾宸ュ簭锛氭�绘敹鏂欐暟閲�
- sql = @"select isnull(sum(sqty),0) as good_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and step_seq=@step_seq-1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氭敹鏂欐�绘暟鏁伴噺
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓婇亾宸ュ簭鏀舵枡鎬诲悎鏍兼暟閲�
- //鍒ゆ柇锛氬綋鍓嶆湯閬撳伐搴忔姤宸ヨ褰曪細褰撳墠宸ュ簭鎶ュ伐鎬绘暟閲�>涓婇亾宸ュ簭鏀舵枡鎬诲悎鏍兼暟閲�
- if (updatereportsumqty > last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庝笂閬撳伐搴忔敹鏂欐�诲悎鏍兼暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- }
- //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭灞炴��
- if (next.Rows.Count > 0)
- {
- if (next.Rows[0]["flwtype"].ToString() == "Z")
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt1 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt1.Rows.Count > 0)
- {
- decimal last_reportqty = decimal.Parse(dt1.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
- decimal last_ngqty = decimal.Parse(dt1.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
- decimal last_laborbad_qty = decimal.Parse(dt1.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
- decimal last_materielbad_qty = decimal.Parse(dt1.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
- if ((notthis_reportqty + this_reportqty) < last_updatereportsumqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬诲悎鏍兼暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撳伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- else
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
- sql = @"select isnull(sum(fqty),0) as good_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬诲悎鏍兼暟閲�
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鎶ュ伐鎬诲悎鏍兼暟+鏈鎶ュ伐璋冩暣鍚堟牸鏁帮級<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
- if ((notthis_reportqty + this_reportqty) < last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠宸ュ簭淇敼鎶ュ伐鎬绘暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉ぇ浜庝笅閬撳伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- }
- }
-
- ///////////////////////////////淇敼鎶ュ伐//////////////////////////////
-
- //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曞瓙琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
- sql = @"update TK_Wrk_RecordSub set report_qty=report_qty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
- updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
- where m_id=@m_id and id=@id and style='B'";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- m_id = int.Parse(json[0].id),
- id = int.Parse(json[0].sbid),
- repair_qty = decimal.Parse(json[0].report_dvalue),
- ng_qty = this_ng_dvalue,
- laborbad_qty = this_laborbad_dvalue,
- materielbad_qty = this_materielbad_dvalue,
- //bad_money = decimal.Parse(json[i].badmoney_dvalue),
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
- //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曚富琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
- sql = @"update TK_Wrk_Record set start_qty=start_qty+@good_qty, good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
- updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
- where wo_code=@wo_code and step_code=@step_code and id=@id and style='B'";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- good_qty = decimal.Parse(json[0].report_dvalue),
- ng_qty = this_ng_dvalue,
- laborbad_qty = this_laborbad_dvalue,
- materielbad_qty = this_materielbad_dvalue,
- wo_code = json[0].wo_code,
- step_code = json[0].step_code,
- id = int.Parse(json[0].id),
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
- //鍥炲啓宸ュ崟宸ュ簭琛�
- sql = @"update TK_Wrk_Step set good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
- where wo_code=@wo_code and step_code=@step_code";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- good_qty = decimal.Parse(json[0].report_dvalue),
- ng_qty = this_ng_dvalue,
- laborbad_qty = this_laborbad_dvalue,
- materielbad_qty = this_materielbad_dvalue,
- wo_code = json[0].wo_code,
- step_code = json[0].step_code
- }
- });
-
- for (int i = 0; i < json[0].children.Count; i++)
- {
- //鍥炲啓涓嶈壇
- sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
- updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
- where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='B'";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- ng_qty = decimal.Parse(json[0].children[i].ng_dvalue),
- laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
- materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
- wo_code = json[0].wo_code,
- step_code = json[0].step_code,
- ng_id = int.Parse(json[0].children[i].ng_id),
- record_id = json[0].id,
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
- //鍥炲啓涓嶈壇澶勭悊
- sql = @"update CSR_WorkRecord_DefectHandle set laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
- where wo_code=@wo_code and step_code=@step_code and defect_id=@defect_id and style='B'";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
- materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
- wo_code = json[0].wo_code,
- step_code = json[0].step_code,
- defect_id = int.Parse(json[0].children[i].ng_id),
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
- }
- }
- if (json[0].flw_type.ToString() == "W")//澶栧崗宸ュ簭
- {
- //鏌ヨ褰撳墠棣栭亾宸ュ簭闈炴娆′緵搴斿晢鏀舵枡锛氭�绘敹鏂欐暟閲�
- sql = @"select isnull(sum(sqty),0) as sqty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code<>@wx_code";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@id", json[0].id);
- dynamicParams.Add("@step_code", json[0].step_code);
- dynamicParams.Add("@wx_code", json[0].wxcode);
- var dt_c = DapperHelper.selectdata(sql, dynamicParams);
- //鑾峰彇姝ゆ鎶ュ伐璋冩暣鎻愪氦鐨勬暟鎹�(鏀舵枡鏁伴噺銆佷笉鑹暟閲忋�佸伐搴熸暟閲忋�佹枡搴熸暟閲�)
- decimal this_reportqty = decimal.Parse(json[0].report_qty.ToString()); //鏀舵枡鏁伴噺
- decimal this_ngqty = json[0].children.Sum(item => decimal.Parse(item.ng_qty));//涓嶈壇鏁伴噺姹囨��
- decimal this_laborbadqty = json[0].children.Sum(item => decimal.Parse(item.laborbad_qty));//宸ュ簾鏁伴噺姹囨��
- decimal this_materielbadqty = json[0].children.Sum(item => decimal.Parse(item.materielbad_qty));//鏂欏簾鏁伴噺姹囨��
- decimal this_ng_dvalue = json[0].children.Sum(item => decimal.Parse(item.ng_dvalue));//涓嶈壇鏁伴噺宸�兼眹鎬�
- decimal this_laborbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.laborbad_dvalue));//宸ュ簾鏁伴噺宸�兼眹鎬�
- decimal this_materielbad_dvalue = json[0].children.Sum(item => decimal.Parse(item.materielbad_dvalue));//鏂欏簾鏁伴噺宸�兼眹鎬�
- //鑾峰彇褰撳墠宸ュ簭銆佷緵搴斿晢瀵瑰簲鐨勫彂鏂欐暟閲�
- sql = @"select isnull(sum(fqty),0) as fqty
+ //鑾峰彇褰撳墠宸ュ簭銆佷緵搴斿晢瀵瑰簲鐨勬�诲彂鏂欐暟閲�
+ sql = @"select isnull(sum(fqty),0) as fqty
from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and id<>@id and step_code=@step_code and wx_code=@wx_code";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@id", json[0].id);
- dynamicParams.Add("@step_code", json[0].step_code);
- dynamicParams.Add("@wx_code", json[0].wxcode);
- var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
- //棣栭亾宸ュ簭鐨勬敹鏂�
- if (json[0].first_choke == "Y")
- {
- //鏌ヨ褰撳墠棣栭亾宸ュ簭闈炴娆℃敹鏂欙細鎬绘敹鏂欐暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
- sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
dynamicParams.Add("@wo_code", json[0].wo_code);
dynamicParams.Add("@id", json[0].id);
dynamicParams.Add("@step_code", json[0].step_code);
dynamicParams.Add("@wx_code", json[0].wxcode);
- var dt = DapperHelper.selectdata(sql, dynamicParams);
- decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟
- decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�讳笉鑹暟
- decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�诲伐搴熸暟
- decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘枡搴熸暟
- //鍒ゆ柇锛氬綋鍓嶅伐搴忔姤宸ヨ褰曪細鏈鏀舵枡鏁伴噺+鏈涓嶈壇鏁伴噺+鏈宸ュ簾鏁伴噺+鏈鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟>鍙戞枡鏁伴噺
- decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
- if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭瀵瑰簲渚涘簲鍟嗘敹鏂欐�绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡彂鏂欐暟閲忥細銆�" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "銆�!";
- mes.data = null;
- return mes;
- }
- //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭鍙婂睘鎬�
- if (next.Rows.Count > 0)
- {
- if (next.Rows[0]["flwtype"].ToString() == "Z")
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氭姤宸ユ�绘暟鏁伴噺+涓嶈壇鎬绘暟鏁伴噺+宸ュ簾鎬绘暟閲�+鏂欏簾鎬绘暟閲�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�+涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�+涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�+涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
- decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
- decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
- decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鏀舵枡璋冩暣鏁�+闈炲綋鍓嶄緵搴斿晢鍚屽伐搴忔敹鏂欐�绘暟锛�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
- if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭鏀舵枡鏁伴噺锛氥��" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "銆戜笉鑳藉皬浜庝笅閬撹嚜鍒跺伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- else
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
- sql = @"select isnull(sum(fqty),0) as good_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鎶ュ伐璋冩暣鏀舵枡鏁帮級<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
- if ((notthis_reportqty + this_reportqty) < last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭鏀舵枡鎬绘暟閲忥細銆�" + (notthis_reportqty + this_reportqty) + "銆戜笉鑳藉皬浜庝笅閬撳鍗忓伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- }
+ var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
- }
- //鏈亾宸ュ簭鐨勬姤宸�
- else if (json[0].last_choke == "Y")
- {
- //鏌ヨ褰撳墠鏈亾鎶ュ伐宸ュ簭闈炴娆℃敹鏂欙細鎬绘敹鏂欐暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
+ //鏌ヨ褰撳墠宸ュ簭闈炴娆℃敹鏂欙細鎬绘敹鏂欐暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
dynamicParams.Add("@wo_code", json[0].wo_code);
@@ -3214,7 +3677,7 @@
decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ�绘暟
decimal notthis_laborbad_qty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ュ伐搴熸�绘暟
decimal notthis_materielbad_qty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠鏈亾宸ュ簭闈炴湰娆℃姤宸ユ枡搴熸�绘暟
- //鑾峰彇褰撳墠鏈亾宸ュ簭鏀舵枡鎬绘暟閲忥細鏈淇敼鏀舵枡鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鎶ュ伐鏂欏簾鏁伴噺+褰撳墠鏈亾宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠鏈亾宸ュ簭闈炴湰娆℃枡搴熸�绘暟
+ //鑾峰彇褰撳墠鏈亾宸ュ簭鏀舵枡鎬绘暟閲忥細鏈淇敼鏀舵枡鏁伴噺+鏈淇敼涓嶈壇鏁伴噺+鏈淇敼宸ュ簾鏁伴噺+鏈淇敼鎶ュ伐鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟
decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbad_qty + notthis_materielbad_qty;
//鍒ゆ柇褰撳墠宸ュ簭渚涘簲鍟嗘敹鏂欐�绘暟>褰撳墠宸ュ簭渚涘簲鍟嗗搴斿彂鏂欐暟閲�
if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
@@ -3225,192 +3688,220 @@
mes.data = null;
return mes;
}
-
- }
- else //涓棿宸ュ簭鐨勬姤宸�
- {
-
- //鏌ヨ褰撳墠棣栭亾宸ュ簭渚涘簲鍟嗛潪姝ゆ鏀舵枡锛氭�绘敹鏂欐暟閲忋�佹�讳笉鑹暟閲忋�佹�诲伐搴熸暟閲忋�佹�绘枡搴熸暟閲�
- sql = @"select isnull(sum(sqty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='S' and id<>@id and step_code=@step_code and wx_code=@wx_code";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@id", json[0].id);
- dynamicParams.Add("@step_code", json[0].step_code);
- dynamicParams.Add("@wx_code", json[0].wxcode);
- var dt = DapperHelper.selectdata(sql, dynamicParams);
- decimal notthis_reportqty = decimal.Parse(dt.Rows[0]["good_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟
- decimal notthis_ngqty = decimal.Parse(dt.Rows[0]["ng_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�讳笉鑹暟
- decimal notthis_laborbadqty = decimal.Parse(dt.Rows[0]["laborbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�诲伐搴熸暟
- decimal notthis_materielbadqty = decimal.Parse(dt.Rows[0]["materielbad_qty"].ToString()); //褰撳墠宸ュ簭闈炴湰娆℃姤宸ユ�绘枡搴熸暟
- //鍒ゆ柇锛氬綋鍓嶅伐搴忔姤宸ヨ褰曪細鏈鏀舵枡鏁伴噺+鏈涓嶈壇鏁伴噺+鏈宸ュ簾鏁伴噺+鏈鏂欏簾鏁伴噺+褰撳墠宸ュ簭闈炴湰娆℃敹鏂欐�绘暟+褰撳墠宸ュ簭闈炴湰娆′笉鑹�绘暟+褰撳墠宸ュ簭闈炴湰娆″伐搴熸�绘暟+褰撳墠宸ュ簭闈炴湰娆℃枡搴熸�绘暟>鍙戞枡鏁伴噺
- decimal updatereportsumqty = this_reportqty + this_ngqty + this_laborbadqty + this_materielbadqty + notthis_reportqty + notthis_ngqty + notthis_laborbadqty + notthis_materielbadqty;
- if (updatereportsumqty > decimal.Parse(dt_0.Rows[0]["fqty"].ToString()))
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭瀵瑰簲渚涘簲鍟嗘敹鏂欐�绘暟閲忥細銆�" + updatereportsumqty + "銆戜笉鑳藉ぇ浜庡彂鏂欐暟閲忥細銆�" + decimal.Parse(dt_0.Rows[0]["fqty"].ToString()) + "銆�!";
- mes.data = null;
- return mes;
- }
- //鍒ゆ柇鏄惁瀛樺湪涓嬮亾宸ュ簭鍙婂睘鎬�
- if (next.Rows.Count > 0)
- {
- if (next.Rows[0]["flwtype"].ToString() == "Z")
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�绘姤宸ユ暟閲忋�佹�讳笉鑹暟閲忋�佹�绘姤搴熸暟閲�
- sql = @"select isnull(sum(good_qty),0) as good_qty,isnull(sum(ng_qty),0) as ng_qty,isnull(sum(laborbad_qty),0) as laborbad_qty,isnull(sum(materielbad_qty),0) as materielbad_qty
- from TK_Wrk_Record where wo_code=@wo_code and style='B' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氭姤宸ユ�绘暟鏁伴噺+涓嶈壇鎬绘暟鏁伴噺+宸ュ簾鎬绘暟閲�+鏂欏簾鎬绘暟閲�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�+涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�+涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�+涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鎶ュ伐鎬绘暟閲�
- decimal last_ngqty = decimal.Parse(dt0.Rows[0]["ng_qty"].ToString()); //涓嬮亾宸ュ簭涓嶈壇鎬绘暟閲�
- decimal last_laborbad_qty = decimal.Parse(dt0.Rows[0]["laborbad_qty"].ToString()); //涓嬮亾宸ュ簭宸ュ簾鎬绘暟閲�
- decimal last_materielbad_qty = decimal.Parse(dt0.Rows[0]["materielbad_qty"].ToString()); //涓嬮亾宸ュ簭鏂欏簾鎬绘暟閲�
- decimal last_updatereportsumqty = last_reportqty + last_ngqty + last_laborbad_qty + last_materielbad_qty;
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鏀舵枡璋冩暣鏁�+闈炲綋鍓嶄緵搴斿晢鍚屽伐搴忔敹鏂欐�绘暟锛�<涓嬮亾宸ュ簭鎶ュ伐鎬绘暟
- if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_updatereportsumqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭鏀舵枡鏁伴噺锛氥��" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "銆戜笉鑳藉皬浜庝笅閬撹嚜鍒跺伐搴忔姤宸ユ�绘暟閲忥細銆�" + last_updatereportsumqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- else
- {
- //鏌ヨ褰撳墠宸ュ簭涓嬮亾宸ュ簭锛氭�诲彂鏂欐暟閲�
- sql = @"select isnull(sum(fqty),0) as good_qty
- from TK_Wrk_OutRecord where wo_code=@wo_code and style='F' and step_seq=@step_seq+1";
- dynamicParams.Add("@wo_code", json[0].wo_code);
- dynamicParams.Add("@step_seq", json[0].step_seq);
- var dt0 = DapperHelper.selectdata(sql, dynamicParams);
- if (dt0.Rows.Count > 0)
- {
- //鍒ゆ柇褰撳墠宸ュ簭锛氬彂鏂欐�绘暟鏁伴噺
- decimal last_reportqty = decimal.Parse(dt0.Rows[0]["good_qty"].ToString()); //涓嬮亾宸ュ簭鍙戞枡鎬绘暟閲�
- //鍒ゆ柇锛堝綋鍓嶉潪鏈鏀舵枡鏁�+鏈鎶ュ伐璋冩暣鏀舵枡鏁�+闈炲綋鍓嶄緵搴斿晢鍚屽伐搴忔敹鏂欐�绘暟锛�<涓嬮亾宸ュ簭鍙戞枡鎬绘暟
- if ((notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) < last_reportqty)
- {
- mes.code = "300";
- mes.count = 0;
- mes.message = "褰撳墠棣栭亾宸ュ簭鏀舵枡鎬绘暟閲忥細銆�" + (notthis_reportqty + this_reportqty + decimal.Parse(dt_c.Rows[0]["sqty"].ToString())) + "銆戜笉鑳藉皬浜庝笅閬撳鍗忓伐搴忓彂鏂欐�绘暟閲忥細銆�" + last_reportqty + "銆�!";
- mes.data = null;
- return mes;
- }
- }
- }
- }
- }
-
- ///////////////////////////////淇敼鎶ュ伐//////////////////////////////
-
- //鍥炲啓瀵瑰簲鐨勫鍗忚褰曞瓙琛ㄦ敹鏂欐暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
- sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
- updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
- where m_id=@m_id and id=@id and style='S' and wx_code=@wx_code";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- m_id = int.Parse(json[0].id),
- id = int.Parse(json[0].sbid),
- repair_qty = decimal.Parse(json[0].report_dvalue),
- ng_qty = this_ng_dvalue,
- laborbad_qty = this_laborbad_dvalue,
- materielbad_qty = this_materielbad_dvalue,
- wx_code = json[0].wxcode,
- //bad_money = decimal.Parse(json[i].badmoney_dvalue),
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
- //鍥炲啓瀵瑰簲鐨勬敹鏂欒褰曚富琛ㄦ敹鏂欐暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
- sql = @"update TK_Wrk_OutRecord set sqty=sqty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
- updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
- where wo_code=@wo_code and step_code=@step_code and id=@id and style='S' and wx_code=@wx_code";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- good_qty = decimal.Parse(json[0].report_dvalue),
- ng_qty = this_ng_dvalue,
- laborbad_qty = this_laborbad_dvalue,
- materielbad_qty = this_materielbad_dvalue,
- wx_code = json[0].wxcode,
- wo_code = json[0].wo_code,
- step_code = json[0].step_code,
- id = int.Parse(json[0].id),
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
- //鍥炲啓宸ュ崟宸ュ簭琛�
- sql = @"update TK_Wrk_Step set good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
- where wo_code=@wo_code and step_code=@step_code";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- good_qty = decimal.Parse(json[0].report_dvalue),
- ng_qty = this_ng_dvalue,
- laborbad_qty = this_laborbad_dvalue,
- materielbad_qty = this_materielbad_dvalue,
- wo_code = json[0].wo_code,
- step_code = json[0].step_code
- }
- });
-
- for (int i = 0; i < json[0].children.Count; i++)
- {
- //鍥炲啓涓嶈壇
- sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
- updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
- where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='S'";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- ng_qty = decimal.Parse(json[0].children[i].ng_dvalue),
- laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
- materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
- wo_code = json[0].wo_code,
- step_code = json[0].step_code,
- ng_id = int.Parse(json[0].children[i].ng_id),
- record_id = json[0].id,
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
- //鍥炲啓涓嶈壇澶勭悊
- sql = @"update CSR_WorkRecord_DefectHandle set laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
- where wo_code=@wo_code and step_code=@step_code and defect_id=@defect_id and style='S'";
- list.Add(new
- {
- str = sql,
- parm = new
- {
- laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
- materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
- wo_code = json[0].wo_code,
- step_code = json[0].step_code,
- defect_id = int.Parse(json[0].children[i].ng_id),
- updatereportuser = us.usercode,
- updatereportdate = date
- }
- });
}
}
+ switch (json[0].flw_type.ToString())
+ {
+ case "Z":
+ ///////////////////////////////淇敼鎶ュ伐//////////////////////////////
+
+ //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曞瓙琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_RecordSub set report_qty=report_qty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
+ updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+ where m_id=@m_id and id=@id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(json[0].id),
+ id = int.Parse(json[0].sbid),
+ repair_qty = decimal.Parse(json[0].report_dvalue),
+ ng_qty = this_ng_dvalue,
+ laborbad_qty = this_laborbad_dvalue,
+ materielbad_qty = this_materielbad_dvalue,
+ //bad_money = decimal.Parse(json[i].badmoney_dvalue),
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曚富琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_Record set step_price=@step_price,start_qty=start_qty+@good_qty, good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
+ updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+ where wo_code=@wo_code and step_code=@step_code and id=@id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ step_price = decimal.Parse(json[0].unprice),
+ good_qty = decimal.Parse(json[0].report_dvalue),
+ ng_qty = this_ng_dvalue,
+ laborbad_qty = this_laborbad_dvalue,
+ materielbad_qty = this_materielbad_dvalue,
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code,
+ id = int.Parse(json[0].id),
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ //鍥炲啓宸ュ崟宸ュ簭琛�
+ sql = @"update TK_Wrk_Step set good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
+ where wo_code=@wo_code and step_code=@step_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ good_qty = decimal.Parse(json[0].report_dvalue),
+ ng_qty = this_ng_dvalue,
+ laborbad_qty = this_laborbad_dvalue,
+ materielbad_qty = this_materielbad_dvalue,
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code
+ }
+ });
+
+ for (int i = 0; i < json[0].children.Count; i++)
+ {
+ //鍥炲啓涓嶈壇
+ sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
+ updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+ where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ ng_qty = decimal.Parse(json[0].children[i].ng_dvalue),
+ laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
+ materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code,
+ ng_id = int.Parse(json[0].children[i].ng_id),
+ record_id = json[0].id,
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ //鍥炲啓涓嶈壇澶勭悊
+ sql = @"update CSR_WorkRecord_DefectHandle set laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
+ where wo_code=@wo_code and step_code=@step_code and defect_id=@defect_id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
+ materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code,
+ defect_id = int.Parse(json[0].children[i].ng_id),
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ }
+ break;
+ case "W":
+ ///////////////////////////////淇敼鎶ュ伐//////////////////////////////
+
+ //鍥炲啓瀵瑰簲鐨勫鍗忚褰曞瓙琛ㄦ敹鏂欐暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
+ updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+ where m_id=@m_id and id=@id and style='S' and wx_code=@wx_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(json[0].id),
+ id = int.Parse(json[0].sbid),
+ repair_qty = decimal.Parse(json[0].report_dvalue),
+ ng_qty = this_ng_dvalue,
+ laborbad_qty = this_laborbad_dvalue,
+ materielbad_qty = this_materielbad_dvalue,
+ wx_code = json[0].wxcode,
+ //bad_money = decimal.Parse(json[i].badmoney_dvalue),
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ //鍥炲啓瀵瑰簲鐨勬敹鏂欒褰曚富琛ㄦ敹鏂欐暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_OutRecord set step_price=@step_price,sqty=sqty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
+ updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+ where wo_code=@wo_code and step_code=@step_code and id=@id and style='S' and wx_code=@wx_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ step_price = decimal.Parse(json[0].unprice),
+ good_qty = decimal.Parse(json[0].report_dvalue),
+ ng_qty = this_ng_dvalue,
+ laborbad_qty = this_laborbad_dvalue,
+ materielbad_qty = this_materielbad_dvalue,
+ wx_code = json[0].wxcode,
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code,
+ id = int.Parse(json[0].id),
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ //鍥炲啓宸ュ崟宸ュ簭琛�
+ sql = @"update TK_Wrk_Step set good_qty=good_qty+@good_qty,ng_qty=ng_qty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
+ where wo_code=@wo_code and step_code=@step_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ good_qty = decimal.Parse(json[0].report_dvalue),
+ ng_qty = this_ng_dvalue,
+ laborbad_qty = this_laborbad_dvalue,
+ materielbad_qty = this_materielbad_dvalue,
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code
+ }
+ });
+
+ for (int i = 0; i < json[0].children.Count; i++)
+ {
+ //鍥炲啓涓嶈壇
+ sql = @"update CSR_WorkRecord_Defect set defect_qty=defect_qty+@ng_qty,defect_pendqty=defect_pendqty+@ng_qty,laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty,
+ updatereportuser=@updatereportuser,updatereportdate=@updatereportdate
+ where wo_code=@wo_code and step_code=@step_code and id=@ng_id and record_id=@record_id and style='S'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ ng_qty = decimal.Parse(json[0].children[i].ng_dvalue),
+ laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
+ materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code,
+ ng_id = int.Parse(json[0].children[i].ng_id),
+ record_id = json[0].id,
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ //鍥炲啓涓嶈壇澶勭悊
+ sql = @"update CSR_WorkRecord_DefectHandle set laborbad_qty=laborbad_qty+@laborbad_qty,materielbad_qty=materielbad_qty+@materielbad_qty
+ where wo_code=@wo_code and step_code=@step_code and defect_id=@defect_id and style='S'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ laborbad_qty = decimal.Parse(json[0].children[i].laborbad_dvalue),
+ materielbad_qty = decimal.Parse(json[0].children[i].materielbad_dvalue),
+ wo_code = json[0].wo_code,
+ step_code = json[0].step_code,
+ defect_id = int.Parse(json[0].children[i].ng_id),
+ updatereportuser = us.usercode,
+ updatereportdate = date
+ }
+ });
+ }
+ break;
+ default:
+ break;
+ }
bool aa = DapperHelper.DoTransaction(list);
if (aa)
{
@@ -3615,5 +4106,67 @@
return mes;
}
#endregion
+
+ #region[鐢熶骇鎵ц,鎶ュ伐寮冨鏁版嵁鎻愪氦]
+ public static ToMessage MesOrderStepReportNotVerifySeave(User us, string id, string steptype)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (steptype == "Z")//鑷埗宸ュ簭
+ {
+ //鍥炲啓鎶ュ伐璁板綍涓昏〃瀹℃牳鐘舵�併�佸鏍镐汉銆佸鏍告椂闂�
+ sql = @"update TK_Wrk_Record set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where id=@id";
+ list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } });
+ //鍥炲啓鎶ュ伐璁板綍瀛愯〃瀹℃牳鐘舵�併�佸鏍镐汉銆佸鏍告椂闂�
+ sql = @"update TK_Wrk_RecordSub set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where m_id=@id";
+ list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } });
+ }
+ if (steptype == "W")//澶栧崗宸ュ簭
+ {
+ //鍥炲啓澶栧崗璁板綍涓昏〃瀹℃牳鐘舵�併�佸鏍镐汉銆佸鏍告椂闂�
+ sql = @"update TK_Wrk_OutRecord set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where id=@id";
+ list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } });
+ //鍥炲啓澶栧崗璁板綍瀛愯〃瀹℃牳鐘舵�併�佸鏍镐汉銆佸鏍告椂闂�
+ sql = @"update TK_Wrk_OutRecordSub set verify='N',verifyuser=@verifyuser,verifydate=@verifydate where m_id=@id";
+ list.Add(new { str = sql, parm = new { verifyuser = "", verifydate = "", id = id } });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ if (steptype == "Z")
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鎶ュ伐寮冨", "鑷埗鎶ュ伐璁板綍id:" + string.Join(",", id), us.usertype);
+ }
+ if (steptype == "W")
+ {
+ LogHelper.DbOperateLog(us.usercode, "鎶ュ伐寮冨", "澶栧崗鏀舵枡璁板綍id:" + string.Join(",", id), us.usertype);
+ }
+ 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
}
}
--
Gitblit v1.9.3