From d6502baa8e5610c04127fbee92ff6111e40956f8 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期二, 13 六月 2023 09:50:02 +0800
Subject: [PATCH] 生产入库、采购入库接口提交
---
VueWebApi/DLL/DAL/ProductionManagementDAL.cs | 1031 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 947 insertions(+), 84 deletions(-)
diff --git a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
index f2336c9..567d12b 100644
--- a/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductionManagementDAL.cs
@@ -608,7 +608,7 @@
{
mes.code = "300";
mes.count = 0;
- mes.Message = "褰撳墠宸ヨ壓璺嚎瀵瑰簲宸ュ簭銆�"+dtck.Rows[i]["step_code"].ToString()+"銆戯紝鏈叧鑱旇澶囷紝璇峰叧鑱旀墍鏈夊伐搴忓搴旇澶�!";
+ mes.Message = "褰撳墠宸ヨ壓璺嚎瀵瑰簲宸ュ簭銆�" + dtck.Rows[i]["step_code"].ToString() + "銆戯紝鏈叧鑱旇澶囷紝璇峰叧鑱旀墍鏈夊伐搴忓搴旇澶�!";
mes.data = null;
return mes;
}
@@ -628,8 +628,8 @@
where C.step_code=@step_code";
dynamicParams.Add("@step_code", dtck1.Rows[i]["step_code"].ToString());
var dtck2 = DapperHelper.selectdata(sql, dynamicParams);
- int query = dtck2.AsEnumerable().Where<DataRow>(a => a["enable"].ToString() =="N").Count();
- if (dtck1.Rows.Count == query)
+ int query = dtck2.AsEnumerable().Where<DataRow>(a => a["enable"].ToString() == "N").Count();
+ if (dtck2.Rows.Count == query)
{
mes.code = "300";
mes.count = 0;
@@ -1365,7 +1365,7 @@
}
//鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟(鑷埗宸ュ簭)
sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend,
- S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
left join TMateriel_Info M on B.materiel_code=M.partcode
@@ -1469,7 +1469,7 @@
}
//鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟(鑷埗宸ュ簭)
sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend,
- S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
left join TMateriel_Info M on B.materiel_code=M.partcode
@@ -1563,7 +1563,7 @@
}
//鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟,涓斾笉鑹暟閲忓ぇ浜�0
sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,A.seq,A.isend,
- S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,B.lm_date
from TK_Wrk_Step A
left join TK_Wrk_Man B on A.wo_code=B.wo_code
left join TMateriel_Info M on B.materiel_code=M.partcode
@@ -2078,7 +2078,7 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐,鎶ュ伐鎻愪氦]
- public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string reckway, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string remarks, string username)
+ public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string remarks, string username)
{
var sql = "";
//string[] arra = new string[] { };
@@ -2123,9 +2123,9 @@
sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id";
var dt = DapperHelper.selecttable(sql);
//鍐欏叆寮�鎶ュ伐璁板綍琛�
- sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date)
- values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date } });
+ sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date, inbarcode = inbarcode } });
//鍐欏叆瀛愯〃
for (int i = 0; i < arra.Count; i++)
@@ -2194,9 +2194,9 @@
sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id";
var dt = DapperHelper.selecttable(sql);
//鍐欏叆寮�鎶ュ伐璁板綍琛�
- sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date)
- values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date } });
+ sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date, inbarcode = inbarcode } });
//鍐欏叆瀛愯〃
for (int i = 0; i < arra.Count; i++)
@@ -2246,6 +2246,10 @@
//sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
//list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } });
+ //鍐欏叆ERP鍏ュ簱鍗�
+
+ //鍒ゆ柇鏄惁鏈亾宸ュ簭瀹屽伐鎶ュ伐(鑷姩鍏抽棴宸ュ崟鍙婂伐搴忎换鍔�)
+ //list = AutosCloseOrder.AutosColseOrderReport(list,mesordercode, partcode, stepseq,stepcode,reportqty,ngqty);
bool aa = DapperHelper.DoTransaction(list);
if (aa)
{
@@ -2351,7 +2355,7 @@
#endregion
#region[鐢熶骇寮�鎶ュ伐, 鏀舵枡鎻愪氦]
- public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string remarks, string username)
+ public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inbarcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string remarks, string username)
{
var sql = "";
string[] arra1 = new string[] { };
@@ -2432,9 +2436,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)
- values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } });
+ sql = @"insert into TK_Wrk_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 = username, 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)
@@ -2481,9 +2485,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)
- values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date } });
+ sql = @"insert into TK_Wrk_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 = username, 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)
@@ -2509,6 +2513,12 @@
//鍥炲啓宸ュ崟琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
//sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
//list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } });
+
+ ////鍐欏叆ERP鍏ュ簱鍗�
+
+ //鍒ゆ柇鏄惁鏈亾宸ュ簭瀹屽伐鎶ュ伐(鑷姩鍏抽棴宸ュ崟鍙婂伐搴忎换鍔�)
+ //list = AutosCloseOrder.AutosColseOrderReport(list, mesordercode, partcode, stepseq, stepcode, sqty, ngqty);
+
bool aa = DapperHelper.DoTransaction(list);
if (aa)
{
@@ -2706,13 +2716,16 @@
}
#endregion
- #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾壂鐮佽幏鍙栦换鍔′俊鎭痌
- public static ToMessage MesOrderStepCheckSearch(string orderstepqrcode)
+
+
+ #region[宸ュ簭妫�楠屾壂鐮佽幏鍙栦换鍔′俊鎭痌
+ public static ToMessage MesOrderStepCheckSearch(string orderstepqrcode, string checktype)
{
var sql = "";
string ordercode = "";
string stepcode = "";
var dynamicParams = new DynamicParameters();
+ Dictionary<string, object> list = new Dictionary<string, object>();
try
{
if (orderstepqrcode != "" && orderstepqrcode != null)
@@ -2732,7 +2745,7 @@
stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
}
//閫氳繃鎵弿浜岀淮鐮佷俊鎭煡鎵句换鍔′俊鎭�
- sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,S.stepcode,S.stepname
+ sql = @"select A.wo_code,A.good_qty,M.partcode,M.partname,M.partspec,M.stocktype_code,S.stepcode,S.stepname
from TK_Wrk_Step A
inner join TK_Wrk_Man P on A.wo_code=P.wo_code
left join TMateriel_Info M on P.materiel_code=M.partcode
@@ -2743,11 +2756,44 @@
var data = DapperHelper.selectdata(sql, dynamicParams);
if (data.Rows.Count > 0)
{
- mes.code = "200";
- mes.count = 0;
- mes.Message = "鏌ヨ鎴愬姛!";
- mes.data = data;
- return mes;
+ if (decimal.Parse(data.Rows[0]["good_qty"].ToString()) > 0)
+ {
+ //鑾峰彇缁戝畾鐨勮川妫�鏂规銆佹娊鏍锋柟寮忋�佹牱鏈暟
+ sql = @"select code as checkstandcode,name as checkstandname,sampmethod,sampscare
+ from TStepCheckStandard
+ where (PATINDEX('%,' + RTRIM(@partcode) + ',%',',' + suitpart + ',')>0 or PATINDEX('%,' + RTRIM(@stocktype_code) + ',%',',' + suitpart + ',')>0)
+ and checktype=@checktype and stepcode=@stepcode ";
+ dynamicParams.Add("@partcode", data.Rows[0]["partcode"].ToString());//鐗╂枡缂栫爜
+ dynamicParams.Add("@stepcode", stepcode);//宸ュ簭缂栫爜
+ dynamicParams.Add("@stocktype_code", data.Rows[0]["stocktype_code"].ToString());//瀛樿揣绫诲瀷缂栫爜
+ dynamicParams.Add("@checktype", checktype);//妫�楠岀被鍨�
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)
+ {
+ list.Add("labcont", data);
+ list.Add("chekstand", data1);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠浜у搧銆�" + data.Rows[0]["partname"].ToString() + "銆�,瀵瑰簲宸ュ簭銆�" + data.Rows[0]["stepname"].ToString() + "銆戯紝鏈寚瀹氳川妫�鏂规!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟鏃犳姤宸ヤ骇鍑�!";
+ mes.data = null;
+ return mes;
+ }
}
else
{
@@ -2778,47 +2824,36 @@
}
#endregion
- #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠岃幏鍙栨楠屾爣鍑嗕笅鎷夋鏁版嵁]
- public static ToMessage MesOrderStepCheckSelect()
- {
- string sql = "";
- var dynamicParams = new DynamicParameters();
- try
- {
- //鑾峰彇宸ュ簭妫�楠屾爣鍑�
- sql = @"select code,name from TStepCheckStandard where is_delete<>'1'";
- var data = DapperHelper.selecttable(sql);
- mes.code = "200";
- mes.Message = "鏌ヨ鎴愬姛!";
- mes.data = data;
- }
- catch (Exception e)
- {
- mes.code = "300";
- mes.count = 0;
- mes.Message = e.Message;
- mes.data = null;
- }
- return mes;
- }
- #endregion
-
- #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾牴鎹楠屾爣鍑嗚幏鍙栨楠岄」鐩垪琛╙
+ #region[宸ュ簭妫�楠屾牴鎹�夋嫨鐨勬楠屾柟妗堟煡鎵炬楠岄」鐩甝
public static ToMessage MesOrderStepCheckItemList(string checkstandcode)
{
string sql = "";
var dynamicParams = new DynamicParameters();
try
{
- //鏍规嵁妫�楠屾爣鍑嗙紪鐮佽幏鍙栧伐搴忔楠岄」鐩�
- sql = @"select B.code,B.name,A.stepcheckitem_desc,A.stepcheckitem_seq from TStepCheckStandardSub A
+ //璐ㄦ鏂规缂栫爜鑾峰彇妫�楠岄」
+ sql = @"select A.stepcheckitem_seq, B.code,B.name,A.required,A.numberjudge,A.unit,A.decimalnum,
+ A.standvalue,A.uppervalue,A.lowervalue,A.stepcheckitem_desc
+ from TStepCheckStandardSub A
left join TStepCheckItem B on A.stepcheckitem_code=B.code
- where B.is_delete<>'1' and A.stepstaned_code=@checkstandcode";
- dynamicParams.Add("@checkstandcode", checkstandcode);
+ where A.stepstaned_code=@checkstandcode
+ order by A.stepcheckitem_seq";
+ dynamicParams.Add("@checkstandcode", checkstandcode);//璐ㄦ鏂规缂栫爜
var data = DapperHelper.selectdata(sql, dynamicParams);
- mes.code = "200";
- mes.Message = "鏌ヨ鎴愬姛!";
- mes.data = data;
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璐ㄦ鏂规鏃犳楠岄」!";
+ mes.data = null;
+ }
}
catch (Exception e)
{
@@ -2831,21 +2866,24 @@
}
#endregion
- #region[鐢熶骇寮�鎶ュ伐,宸ュ簭妫�楠屾彁浜や繚瀛榏
- public static ToMessage SaveMesOrderStepCheckItem(string mesordercode, string partcode, string stepcode, string checkstanedcode, string checkusercode, string checktypecode, string checkresult, string checkdescr, string checkqty, string username, List<StepCheck> json)
+ #region[宸ュ簭妫�楠�,鎻愪氦]
+ public static ToMessage SaveMesOrderStepCheckItem(string wocode, string partcode, string stepcode, string checkstandcode, string check_type, string sampmethod, string qualitystatus, string labqty, string sampleqty, string goodqty, string ngqty, string checkitemcont, string username)
{
var sql = "";
- string[] arra = new string[] { };
- string[] arra1 = new string[] { };
- List<object> list = new List<object>();
string checktypename = "";
+ List<object> list = new List<object>();
var dynamicParams = new DynamicParameters();
try
{
- string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
-
+ string datetime = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ //鑾峰彇妫�楠岄」鐩俊鎭�
+ JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(checkitemcont);
list.Clear();
- switch (checktypecode)
+
+ //鍐欏叆妫�楠岃褰曚富琛�
+ sql = @"insert into TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_typename,sampmethod,check_result,check_qty,good_qty,ng_qty,lm_user,lm_date)
+ values(@wo_code,@partcode,@step_code,@checkstaned_code,@check_user,@check_type,@check_typename,@sampmethod,@check_result,@check_qty,@good_qty,@ng_qty,@lm_user,@lm_date)";
+ switch (check_type)
{
case "FirstCheck":
checktypename = "棣栨";
@@ -2859,20 +2897,48 @@
default:
break;
}
- //鍐欏叆宸ュ簭妫�楠岃褰曚富琛�
- sql = @"insert into TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_typename,check_result,check_descr,check_qty,lm_user,lm_date)
- values(@mesordercode,@partcode,@stepcode,@checkstanedcode,@checkusercode,@checktypecode,@checktypename,@checkresult,@checkdescr,@check_qty,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { mesordercode = mesordercode, partcode = partcode, stepcode = stepcode, checkstanedcode = checkstanedcode, checkusercode = checkusercode, checktypecode = checktypecode, checktypename = checktypename, checkresult = checkresult, checkdescr = checkdescr, check_qty = checkqty, lm_user = username, lm_date = date } });
- //鍐欏叆宸ュ簭妫�楠岃褰曞瓙琛�
- //鑾峰彇涓昏〃鏈�澶D
- sql = @"select ISNULL(IDENT_CURRENT('TStepCheckRecord')+1,1) as id";
- var dt = DapperHelper.selecttable(sql);
- for (int i = 0; i < json.Count; i++)
+ list.Add(new
{
- sql = @"insert into TStepCheckRecordSub(m_id,checkitem_seq,checkitem_code,checkitem_name,checkitem_descr,check_result,lm_user,lm_date)
- values(@m_id,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_result,@lm_user,@lm_date)";
- list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), checkiem_seq = int.Parse(json[i].seq), checkitem_code = json[i].code, checkitem_name = json[i].name, checkitem_descr = json[i].descr, check_result = json[i].checkresult, lm_user = username, lm_date = date } });
-
+ str = sql,
+ parm = new
+ {
+ wo_code = wocode,
+ partcode = partcode,
+ step_code = stepcode,
+ checkstaned_code = checkstandcode,
+ check_user = username,
+ check_type = check_type,
+ check_typename = checktypename,
+ sampmethod = sampmethod,
+ check_result = qualitystatus,
+ check_qty = decimal.Parse(sampleqty),
+ good_qty = decimal.Parse(goodqty),
+ ng_qty = decimal.Parse(ngqty),
+ lm_user = username,
+ lm_date = datetime
+ }
+ });
+ //鍐欏叆妫�楠岃褰曞瓙琛�
+ for (int j = 0; j < arra.Count; j++)
+ {
+ sql = @"insert into TStepCheckRecordSub(m_id,checknum,checkitem_seq,checkitem_code,checkitem_name,checkitem_descr,check_value,check_result,lm_user,lm_date)
+ values(CONVERT(INT,IDENT_CURRENT('TStepCheckRecord')),@checknum,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_value,@check_result,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ checknum = arra[j]["checknum"].ToString(),
+ checkiem_seq = arra[j]["checkiem_seq"].ToString(),
+ checkitem_code = arra[j]["checkitem_code"].ToString(),
+ checkitem_name = arra[j]["checkitem_name"].ToString(),
+ checkitem_descr = arra[j]["checkitem_descr"].ToString(),
+ check_value = arra[j]["check_value"].ToString(),
+ check_result = arra[j]["check_result"].ToString(),
+ lm_user = username,
+ lm_date = datetime
+ }
+ });
}
bool aa = DapperHelper.DoTransaction(list);
@@ -2880,14 +2946,14 @@
{
mes.code = "200";
mes.count = 0;
- mes.Message = "妫�楠屾垚鍔�!";
+ mes.Message = "鎿嶄綔鎴愬姛!";
mes.data = null;
}
else
{
mes.code = "300";
mes.count = 0;
- mes.Message = "妫�楠屽け璐�!";
+ mes.Message = "鎿嶄綔澶辫触!";
mes.data = null;
}
}
@@ -2901,6 +2967,8 @@
return mes;
}
#endregion
+
+
#region[MES宸ュ崟鎵归噺鍏抽棴鏌ヨ]
@@ -4010,6 +4078,254 @@
}
#endregion
+ #region[NEW鎺掍骇璁惧淇℃伅]
+ public static List<AdvancedSchedulingDevice> NewOnclickAdvancedSchedulingDevice(List<ApsOrderSerch> json, ref ToMessage mes)
+ {
+ string sql = "", sql0 = "";
+ var dynamicParams = new DynamicParameters();
+ List<AdvancedSchedulingDevice> list = new List<AdvancedSchedulingDevice>();
+ DataTable dt, dt1;
+ //List<ApsOrderSerch> json = new List<ApsOrderSerch>();
+ try
+ {
+ for (int w = 0; w < json.Count; w++)
+ {
+
+
+ DateTime beginDate = Convert.ToDateTime(json[w].startdate);
+ DateTime endDate = DateTime.Parse(json[w].enddate);
+ if (beginDate > endDate)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "瑕佹眰浜や粯鏃堕棿涓嶈兘灏忎簬褰撳墠绯荤粺鏃堕棿锛�";
+ mes.data = null;
+ return list;
+ }
+ bool IsCap = false; //鏄惁璁剧疆浜ц兘
+ //閫氳繃宸ュ崟鏌ユ壘瀵瑰簲杞﹂棿宸ヨ壓璺嚎涓嬪叧閿伐搴忔墍鍏宠仈鐨勮澶囨槸鍚﹀彲鐢�
+ sql = @"select distinct C.eqp_code ,D.Enable from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode and D.wksp_code=@wkshpcode";
+ dynamicParams.Add("@wocode", json[w].wocode);
+ dynamicParams.Add("@partcode", json[w].partcode);
+ dynamicParams.Add("@wkshpcode", json[w].wkshpcode);
+ var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt_0.Rows.Count > 0)
+ {
+ int cout = dt_0.Rows.Count;
+ int num = 0;
+ for (int m = 0; m < dt_0.Rows.Count; m++)
+ {
+ if (dt_0.Rows[m]["Enable"].ToString() == "N")
+ {
+ num = num + 1;
+ }
+ }
+ if (num == cout)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧涓嶅彲鐢紒";
+ mes.data = null;
+ return list;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ヨ壓璺嚎鏈叧鑱旇澶囷紒";
+ mes.data = null;
+ return list;
+ }
+
+ //閫氳繃宸ュ崟鏌ユ壘宸ヨ壓璺嚎瀵瑰簲鍏抽敭宸ュ簭鎵�鍏宠仈鐨勮澶囨墍灞炶溅闂�
+ sql0 = @"select distinct D.wksp_code from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode ";
+ dynamicParams.Add("@wocode", json[w].wocode);
+ dynamicParams.Add("@partcode", json[w].partcode);
+ var dt0 = DapperHelper.selectdata(sql0, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ string sy = "0";
+ for (int i = 0; i < dt0.Rows.Count; i++)
+ {
+ if (dt0.Rows[i]["WKSP_CODE"].ToString() == json[w].wkshpcode) //宸ュ崟鍒涘缓杞﹂棿鏄惁绛変簬鎺掍骇璁惧 杞﹂棿
+ {
+ sy = "1";
+ break;
+ }
+ else
+ {
+ sy = "0";
+ }
+ }
+ if (sy == "0")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掍骇璁惧杞﹂棿涓庡伐鍗曞垱寤虹殑杞﹂棿涓嶅悓锛�";
+ mes.data = null;
+ return list;
+ }
+ else
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(json[w].wocode, json[w].wkshpcode, json[w].partcode);
+ for (DateTime date = beginDate; date <= endDate; date = date.AddDays(1))
+ {
+ AdvancedSchedulingDevice tbj = new AdvancedSchedulingDevice();
+ tbj.wo_code = json[w].wocode;
+ tbj.YearDate = date.ToString("yyyy-MM-dd");
+ tbj.children = new List<AdvancedSchedulingDeviceCont>();
+ for (int j = 0; j < listData.Count; j++)
+ {
+ if (listData[j].AdvaDevicCropMob.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "绋煎姩鐜囦笉鑳戒负0鎴栦负绌猴紒";
+ mes.data = null;
+ return list;
+ }
+ if (listData[j].AdvaDevicRhythm.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "鏈缃妭鎷嶏紒";
+ mes.data = null;
+ return list;
+ }
+ string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start,G.name
+ from TWkm_capac_plan E
+ left join TWkm_capac_plan_sub F on E.id=F.m_id
+ left join TBas_wkshift_info G on F.wkshift_code=G.code
+ where E.wkshop=@wkshop and E.eqp_typecode=@eqp_typecode and E.ClassType=@classtype
+ and CONVERT(varchar(100), F.wkdate, 23)=@wkdate and E.enable='Y'";
+ dynamicParams.Add("@wkshop", json[w].wkshpcode);
+ dynamicParams.Add("@eqp_typecode", listData[j].Style.ToString());
+ dynamicParams.Add("@classtype", listData[j].ClassType.ToString());
+ dynamicParams.Add("@wkdate", date.ToString("yyyy-MM-dd"));
+ dt1 = DapperHelper.selectdata(sql1, dynamicParams);
+
+ AdvancedSchedulingDeviceCont tbjson = new AdvancedSchedulingDeviceCont();
+ tbjson.AdvaDevicNumber = listData[j].eqp_id.ToString();
+ tbjson.AdvaDevicName = listData[j].name.ToString();
+ tbjson.AdvaDevicCropMob = listData[j].AdvaDevicCropMob.ToString(); //绋煎姩鐜�
+ tbjson.AdvaDevicRhythm = listData[j].AdvaDevicRhythm.ToString(); //鐢熶骇鑺傛媿
+ if (dt1.Rows.Count > 0)
+ {
+ tbjson.OneStartDate = dt1.Rows[0]["wktme1_start"].ToString();
+ tbjson.TwoStartDate = dt1.Rows[0]["wktme2_start"].ToString();
+ tbjson.ThreeStartDate = dt1.Rows[0]["wktme3_start"].ToString();
+ tbjson.FourStartDate = dt1.Rows[0]["wktme4_start"].ToString();
+ tbjson.FiveStartDate = dt1.Rows[0]["wktme5_start"].ToString();
+ tbj.children.Add(tbjson);
+ IsCap = true;
+ }
+ else
+ {
+
+ tbjson.OneStartDate = "";
+ tbjson.TwoStartDate = "";
+ tbjson.ThreeStartDate = "";
+ tbjson.FourStartDate = "";
+ tbjson.FiveStartDate = "";
+ tbj.children.Add(tbjson);
+ }
+ }
+
+ list.Add(tbj);
+ }
+ if (list.Select(p => p.children).ToList().Count > 0)
+ {
+ int one = list.Where(t => t.children.Select(s => s.OneStartDate).Any(x => x != "")).ToList().Count;
+ int two = list.Where(t => t.children.Select(s => s.TwoStartDate).Any(x => x != "")).ToList().Count;
+ int three = list.Where(t => t.children.Select(s => s.ThreeStartDate).Any(x => x != "")).ToList().Count;
+ int four = list.Where(t => t.children.Select(s => s.FourStartDate).Any(x => x != "")).ToList().Count;
+ int five = list.Where(t => t.children.Select(s => s.FiveStartDate).Any(x => x != "")).ToList().Count;
+ if (one <= 0 && two <= 0 && three <= 0 && four <= 0 && five <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ崟鍔犲伐浜у搧瀵瑰簲宸ヨ壓璺嚎璁惧鏈缃骇鑳芥垨鏈缃敓浜ц妭鎷嶏紒";
+ mes.data = null;
+ }
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧娌℃湁鍏宠仈杞﹂棿锛�";
+ mes.data = null;
+ }
+ }
+ return list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return list;
+ }
+ #endregion
+
+ #region[New璁惧宸叉帓绋嬩俊鎭痌
+ public static List<DataTable> NewAlreadyScheduling(List<ApsOrderSerch> json)
+ {
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<DataTable> list = new List<DataTable>();
+ try
+ {
+ for (int i = 0; i < json.Count; i++)
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(json[i].wocode, json[i].wkshpcode, json[i].partcode);
+ string[] empIds = listData.Select(a => a.eqp_id).ToArray();
+ string str = string.Join(",", empIds);
+ string[] s1 = Array.ConvertAll<string, string>(str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[]
+ //string s1 = string.Format("'{0}'", str.Replace(",", "','"));
+
+ string sql = @"select B.wo_code, B.eqp_code,B.time_start,B.time_end, 'S' status , B.alloc_qty,D.partcode as part_code,D.partname as part_name,T.name as uom_name
+ from TK_Wrk_EqpAps B
+ left join TK_Wrk_Man C on B.wo_code=C.wo_code
+ left join TMateriel_Info D on C.materiel_code=D.partcode
+ left join TUom T on D.uom_code=T.code
+ where B.eqp_code in @eqpcode
+ and convert(varchar(100),B.Time_Start,21)>=@startdate and convert(varchar(100),B.Time_End,21)<=@enddate order by time_end";
+ dt = DapperHelper.selectlist(sql, new { eqpcode = s1.ToArray(), startdate = json[i].startdate + " 00:00:00", enddate = json[i].enddate + " 23:59:59" });
+ //dynamicParams.Add("@s1", new { shopcode = s1.ToArray() });
+ //dynamicParams.Add("@startdate", startdate + " 00:00:00");
+ //dynamicParams.Add("@enddate", enddate + " 23:59:59");
+ //var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt == null || dt.Rows.Count == 0)
+ {
+ return null;
+ }
+ list.Add(dt);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+ return list;
+ }
+ #endregion
+
#region[鎺掔▼鏁版嵁鎻愪氦]
public static ToMessage SubmitAlreadyScheduling(string username, string wocode, string botprocecode, List<AlreadyScheduling> objs)
{
@@ -4170,5 +4486,552 @@
}
#endregion
+
+
+ #region[鐢熶骇鍏ュ簱鏉$爜琛ユ墦]
+ public static ToMessage ProductInHouseLabCode(string ordercode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇鏈亾宸ュ簭鎶ュ伐鏉$爜鏁版嵁
+ sql = @"select * from(
+ select A.inbarcode,A.wo_code,P.partcode,P.partname,P.partspec,
+ A.good_qty,U.username,A.lm_date
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TMateriel_Info P on A.materiel_code=P.partcode
+ inner join TUser U on A.lm_user=U.usercode
+ where A.style='B' and S.isend='Y' and A.good_qty>0
+ union all
+ select A.inbarcode,A.wo_code,P.partcode,P.partname,P.partspec,
+ A.sqty as sqty,U.username,A.lm_date
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TMateriel_Info P on A.materiel_code=P.partcode
+ inner join TUser U on A.lm_user=U.usercode
+ where A.style='S' and S.isend='Y' and A.sqty>0
+ ) as AA where AA.wo_code=@ordercode";
+ dynamicParams.Add("@ordercode", ordercode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱閫氳繃杞﹂棿鏌ユ壘鐢熶骇璁㈠崟]
+ public static ToMessage ProductInHouseWkshopOrder(string ordertype, string wkshopcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (ordertype == "Y") //鏈夋簮鍗�
+ {
+ sql = @"select distinct AA.ordercode from (
+ select A.m_po as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_Record S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='B' and B.isend='Y' and A.m_po<>'' and S.good_qty>0 and S.good_qty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ union all
+ select A.m_po as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_OutRecord S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='S' and B.isend='Y' and A.m_po<>'' and S.sqty>0 and S.sqty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ ) as AA";
+ }
+ if (ordertype == "N")
+ {
+ sql = @"select distinct AA.ordercode from (
+ select A.wo_code as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_Record S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='B' and B.isend='Y' and A.m_po='' and S.good_qty>0 and S.good_qty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ union all
+ select A.wo_code as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_OutRecord S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='S' and B.isend='Y' and A.m_po='' and S.sqty>0 and S.sqty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ ) as AA";
+ }
+
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱淇℃伅鏌ヨ]
+ public static ToMessage ProductInHouseOrderSearch(string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec, string startorderdate, string endorderdate)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and AA.wkshp_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ if (erpordercode != "" && erpordercode != null)
+ {
+ search += "and AA.m_po like '%'+@erpordercode+'%' ";
+ dynamicParams.Add("@erpordercode", erpordercode);
+ }
+ if (mesordercode != "" && mesordercode != null)
+ {
+ search += "and AA.wo_code like '%'+@mesordercode+'%' ";
+ dynamicParams.Add("@mesordercode", mesordercode);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and AA.partcode like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and AA.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and AA.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
+ if (startorderdate != "" && startorderdate != null)
+ {
+ search += "and AA.lm_date between @startorderdate and @endorderdate ";
+ dynamicParams.Add("@opencheckdate", startorderdate + " 00:00:00");
+ dynamicParams.Add("@endorderdate", endorderdate + " 23:59:59");
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select * from(
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='B' and S.isend='Y' and A.good_qty>0
+ union all
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='S' and S.isend='Y' and A.sqty>0
+ ) as AA where AA.good_qty>AA.inhouseqty " + search;
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱鑾峰彇鍗曟嵁鍙穄
+ public static ToMessage ProductInHouseOrderCodeSearch(string rightcode)
+ {
+ try
+ {
+ mes = SeachEncodeJob.EncodingSeach(rightcode);
+ return mes;
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱鎻愪氦]
+ public static ToMessage ProductInHouseOrderSeave(string username, JObject obj)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ var dynamicParams1 = new DynamicParameters();
+ try
+ {
+ string sub = obj["sub"].ToString();//鏄庣粏
+ string subsum = obj["subsum"].ToString();//姹囨��
+ //鑾峰彇鎶ュ伐鏄庣粏
+ JArray sub_arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(sub);
+ //鑾峰彇姹囨��
+ JArray subsum_arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(subsum);
+
+ //鍥炲啓鎶ュ伐璁板綍涓昏〃銆佸伐鍗曞伐搴忚〃宸插叆搴撴暟閲忋�佸啓鍏ES搴撳瓨琛�
+ for (int i = 0; i < sub_arra.Count; i++)
+ {
+ if (sub_arra[i]["style"].ToString() == "B")
+ {
+ //鍥炲啓鎶ュ伐璁板綍涓昏〃鐨勫叆搴撴暟閲�
+ sql = @"update TK_Wrk_Record set inhouseqty=inhouseqty+@stinhouseqty where inbarcode=@inbarcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ inbarcode = sub_arra[i]["inbarcode"].ToString()
+ }
+ });
+ }
+ if (sub_arra[i]["style"].ToString() == "S")
+ {
+ //鍥炲啓澶栧崗鏀舵枡璁板綍涓昏〃鐨勫叆搴撴暟閲�
+ sql = @"update TK_Wrk_OutRecord set inhouseqty=inhouseqty+@stinhouseqty where inbarcode=@inbarcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ inbarcode = sub_arra[i]["inbarcode"].ToString()
+ }
+ });
+ }
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄦ湯閬撳伐搴忓凡鍏ュ簱鏁伴噺
+ sql = @"update TK_Wrk_Step set inhouseqty=inhouseqty+@stinhouseqty where wo_code=@wo_code and step_code=@step_code and isend='Y'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ wo_code = sub_arra[i]["wo_code"].ToString(),
+ step_code = sub_arra[i]["step_code"].ToString()
+ }
+ });
+ //鍐欏叆MES搴撳瓨琛�
+ sql = @"insert into TK_WMS_Stock(hbillno,labcode,materiel_code,storehouse_code,qty,lm_user,lm_date)
+ values(@hbillno,@labcode,@materiel_code,@storehouse_code,@qty,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ hbillno = obj["head"]["hbillno"].ToString(),
+ labcode = sub_arra[i]["inbarcode"].ToString(),
+ materiel_code = sub_arra[i]["partcode"].ToString(),
+ storehouse_code = sub_arra[i]["stockcode"].ToString(),
+ qty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ }
+ //鍐橫ES鍏ュ簱璁板綍涓昏〃
+ sql = @"insert into TK_WMS_Inwh_Main(docu_typecode,hbillno,hsoucenillnoid,hsoucenillno,saleorderid,saleordercode,status,wkshpcode,lm_user,lm_date)
+ values(@docu_typecode,@hbillno,@hsoucenillnoid,@hsoucenillno,@saleorderid,@saleordercode,@status,@wkshpcode,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ docu_typecode = "1202",
+ hbillno = obj["head"]["hbillno"].ToString(),
+ hsoucenillnoid = obj["head"]["sourceVoucherId"].ToString(),
+ hsoucenillno = obj["head"]["sourceVoucherCode"].ToString(),
+ saleorderid = obj["head"]["saleOrderId"].ToString(),
+ saleordercode = obj["head"]["saleOrderCode"].ToString(),
+ status = "NEW",
+ wkshpcode = obj["head"]["wkshpcode"].ToString(),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+
+ //鑾峰彇ERP鍏ュ簱琛╯ql
+ //DataTable dt = DapperHelper.lissql("h_p_MesInErpProductWareHous");
+ //鍐欏叆ERP鍏ュ簱璁板綍涓昏〃
+ //sql = @"" + dt.Rows[0]["cname"].ToString() + "";
+ //list.Add(new
+ //{
+ // str = sql,
+ // parm = new
+ // {
+ // code = obj["head"]["hbillno"].ToString(),
+ // sourceVoucherId = obj["head"]["sourceVoucherId"].ToString(),
+ // sourceVoucherCode = obj["head"]["sourceVoucherCode"].ToString(),
+ // saleOrderId = obj["head"]["saleOrderId"].ToString(),
+ // saleOrderCode = obj["head"]["saleOrderCode"].ToString(),
+ // rdDirectionFlag = obj["head"]["rdDirectionFlag"].ToString(),
+ // makerid = obj["head"]["makerid"].ToString(),
+ // maker = obj["head"]["maker"].ToString(),
+ // accountingyear = obj["head"]["accountingyear"].ToString(),
+ // VoucherYear = obj["head"]["VoucherYear"].ToString(),
+ // VoucherPeriod = obj["head"]["VoucherPeriod"].ToString(),
+ // ManufactureOrderCode = obj["head"]["ManufactureOrderCode"].ToString(),
+ // idbusitype = obj["head"]["idbusitype"].ToString(),
+ // iddepartment = obj["head"]["iddepartment"].ToString(),
+ // idrdstyle = obj["head"]["idrdstyle"].ToString(),
+ // idwarehouse = obj["head"]["idwarehouse"].ToString(),
+ // voucherState = obj["head"]["voucherState"].ToString(),
+ // idvouchertype = obj["head"]["idvouchertype"].ToString(),
+ // voucherdate = obj["head"]["voucherdate"].ToString(),
+ // madedate = obj["head"]["madedate"].ToString(),
+ // createdtime = obj["head"]["createdtime"].ToString(),
+ // DataSource = obj["head"]["DataSource"].ToString(),
+ // idsourcevouchertype= obj["head"]["idsourcevouchertype"].ToString()
+
+ // }
+ //});
+ //鍐欏叆ERP銆丮ES鍏ュ簱璁板綍瀛愯〃
+ for (int j = 0; j < subsum_arra.Count; j++)
+ {
+ //鍐欏叆ERP鍏ュ簱璁板綍瀛愯〃
+ //sql = @"" + dt.Rows[1]["cname"].ToString() + "";
+ //list.Add(new
+ //{
+ // str = sql,
+ // parm = new
+ // {
+ // code = subsum_arra[j]["code"].ToString(),
+ // arrivalQuantity = subsum_arra[j]["arrivalQuantity"].ToString(),
+ // quantity = subsum_arra[j]["quantity"].ToString(),
+ // compositionQuantity = subsum_arra[j]["compositionQuantity"].ToString(),
+ // baseQuantity = subsum_arra[j]["baseQuantity"].ToString(),
+ // sourceVoucherId = subsum_arra[j]["sourceVoucherId"].ToString(),
+ // sourceVoucherCode = subsum_arra[j]["sourceVoucherCode"].ToString(),
+ // sourceVoucherDetailId = subsum_arra[j]["sourceVoucherDetailId"].ToString(),
+ // idsourcevouchertype = subsum_arra[j]["idsourcevouchertype"].ToString(),
+ // saleOrderId = subsum_arra[j]["saleOrderId"].ToString(),
+ // saleOrderCode = subsum_arra[j]["saleOrderCode"].ToString(),
+ // saleOrderDetailId = subsum_arra[j]["saleOrderDetailId"].ToString(),
+ // ManufactureOrderId = subsum_arra[j]["ManufactureOrderId"].ToString(),
+ // ManufactureOrderCode = subsum_arra[j]["ManufactureOrderCode"].ToString(),
+ // ManufactureOrderDetailId = subsum_arra[j]["ManufactureOrderDetailId"].ToString(),
+ // idbusiTypeByMergedFlow = subsum_arra[j]["idbusiTypeByMergedFlow"].ToString(),
+ // idinventory = subsum_arra[j]["idinventory"].ToString(),
+ // idbaseunit = subsum_arra[j]["idbaseunit"].ToString(),
+ // idunit = subsum_arra[j]["idunit"].ToString(),
+ // idwarehouse = subsum_arra[j]["idwarehouse"].ToString(),
+ // SourceVoucherIdByMergedFlow = subsum_arra[j]["SourceVoucherIdByMergedFlow"].ToString(),
+ // SourceVoucherCodeByMergedFlow = subsum_arra[j]["SourceVoucherCodeByMergedFlow"].ToString(),
+ // SourceVoucherDetailIdByMergedFlow = subsum_arra[j]["SourceVoucherDetailIdByMergedFlow"].ToString(),
+ // idsourceVoucherTypeByMergedFlow = subsum_arra[j]["idsourceVoucherTypeByMergedFlow"].ToString(),
+ // createdtime = subsum_arra[j]["createdtime"].ToString(),
+ // DataSource = subsum_arra[j]["DataSource"].ToString()
+ // }
+ //});
+ //鍐欏叆ERP鐜板瓨閲忔煡璇㈣〃
+ //sql = @"" + dt.Rows[2]["cname"].ToString() + "";
+ //list.Add(new
+ //{
+ // str = sql,
+ // parm = new
+ // {
+ // idinventory = subsum_arra[j]["idinventory"].ToString(),
+ // idwarehouse = subsum_arra[j]["idwarehouse"].ToString(),
+ // propertyName = "ProductForReceive",
+ // baseQuantity= subsum_arra[j]["quantity"].ToString(),
+ // IdMarketingOrgan="1",
+ // idbaseunit= subsum_arra[j]["idbaseunit"].ToString(),
+ // updated= DateTime.Now.ToString(),
+ // isCarriedForwardOut ="0",
+ // isCarriedForwardIn = "0"
+ // }
+ //});
+
+
+
+ //鍐欏叆MES鍏ュ簱璁板綍瀛愯〃
+ sql = @"insert into TK_WMS_Inwh_Sub(hbillno,rownumber,materiel_code,storehouse_code,qty)
+ values(@hbillno,@rownumber,@materiel_code,@storehouse_code,@qty)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ hbillno = obj["head"]["hbillno"].ToString(),
+ rownumber = subsum_arra[j]["rownumber"].ToString(),
+ materiel_code = subsum_arra[j]["materiel_code"].ToString(),
+ storehouse_code = subsum_arra[j]["warehouse"].ToString(),
+ qty = decimal.Parse(subsum_arra[j]["quantity"].ToString())
+ }
+ });
+ }
+ //鏇存柊鍗曟嵁娴佹按鍙�
+ List<object> list1 = SeachEncodeJob.StrEncodingUpdate(obj["head"]["rightcode"].ToString(), obj["head"]["incbit"].ToString());
+ list.Add(list1[0]);
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[鐢熶骇鍏ュ簱鎵弿鏉$爜]
+ public static ToMessage MesAppProductInHouseOrderBarCodeSearch(string labcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇鏉$爜鏄惁瀛樺湪
+ sql = @"select distinct AA.inbarcode from (
+ select A.inbarcode
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode
+ union all
+ select A.inbarcode
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode
+ ) as AA";
+ dynamicParams.Add("@labcode", labcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "鏃犳晥鏉$爜!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇鏉$爜鏄惁瀛樺彲鐢�
+ sql = @"select distinct AA.inbarcode,AA.good_qty,AA.inhouseqty from (
+ select A.inbarcode,sum(A.good_qty) as good_qty,sum(isnull(A.inhouseqty,0)) as inhouseqty
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode
+ group by A.inbarcode
+ union all
+ select A.inbarcode,sum(A.sqty) as good_qty,sum(isnull(A.inhouseqty,0)) as inhouseqty
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode
+ group by A.inbarcode
+ ) as AA where AA.good_qty>AA.inhouseqty ";
+ dynamicParams.Add("@labcode", labcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠鏉$爜宸插叆搴�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //鏍规嵁閲囪喘璁㈠崟鍙锋煡璇㈢墿鏂欎俊鎭紝渚涘簲鍟嗕俊鎭�
+ sql = @"select * from(
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,A.lm_date,A.style
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode
+ union all
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,A.lm_date,A.style
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode
+ ) as AA where AA.good_qty>AA.inhouseqty";
+ dynamicParams.Add("@labcode", labcode);
+ 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 = "鏆傛棤鐗╂枡鏁版嵁!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
}
}
\ No newline at end of file
--
Gitblit v1.9.3