From 81bb8ba5bcc184ceb6ef82f53c41812bc71f5ee0 Mon Sep 17 00:00:00 2001
From: ch <37327@LLOOCCY>
Date: 星期二, 18 五月 2021 10:11:54 +0800
Subject: [PATCH] noting

---
 WebAPI/Models/ClsWW_EntrustWorkOrderBillSub.cs      |   26 +
 WebAPI/ListModels.cs                                |   12 
 WebAPI/Controllers/QC_ManagementController.cs       |  241 +++++++++++++++++
 WebAPI/WebAPI.csproj.user                           |    4 
 WebAPI/Controllers/Sc_ProcessMangementController.cs |  162 +++++++++++
 WebAPI/DLL/ClsWW_EntrustWorkOrderBill.cs            |  343 ++++++++++++++++++++++++
 WebAPI/Models/ClsWW_EntrustWorkOrderBillMain.cs     |   13 
 WebAPI/Controllers/WebAPIController.cs              |   31 ++
 8 files changed, 830 insertions(+), 2 deletions(-)

diff --git a/WebAPI/Controllers/QC_ManagementController.cs b/WebAPI/Controllers/QC_ManagementController.cs
new file mode 100644
index 0000000..9d9d419
--- /dev/null
+++ b/WebAPI/Controllers/QC_ManagementController.cs
@@ -0,0 +1,241 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Http;
+using WebAPI.Models;
+using WebAPI.Service;
+using System.Collections.Generic;
+using System.Data;
+using Newtonsoft.Json.Linq;
+
+namespace WebAPI.Controllers
+{
+    public class QC_ManagementController : ApiController
+    {
+
+        #region 閿欒杩斿洖鏂规硶
+        // GET: QC_Management
+        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
+
+        private json objJsonResult = new json();
+
+        ///<summary>
+        ///灏佽鐘舵�佺爜鍙婅繑鍥炰俊鎭殑鍏敤鏂规硶銆�
+        ///鍙傛暟锛欴ataSet銆�
+        ///杩斿洖鍊硷細json銆�
+        ///</summary>
+        public object GetObjectJson(DataSet ds)
+        {
+            try
+            {
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        ///<summary>
+        ///缁熶竴姝g‘淇℃伅鏂规硶銆�
+        ///鍙傛暟锛歴tring銆�
+        ///杩斿洖鍊硷細object銆�
+        ///</summary>
+        public object CustomCorrect(DataSet ds)
+        {
+            if (ds == null || ds.Tables[0].Rows.Count <= 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+        }
+
+        ///<summary>
+        ///鑷畾涔夐敊璇俊鎭柟娉曘��
+        ///鍙傛暟锛歴tring銆�
+        ///杩斿洖鍊硷細object銆�
+        ///</summary>
+        public object CustomError(string msg)
+        {
+            objJsonResult.code = "0";
+            objJsonResult.count = 0;
+            objJsonResult.Message = msg;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+        #endregion
+        /// <summary>
+        /// 杩斿洖妫�楠屾柟妗堝崟鍒楄〃
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("QC_Management/MES_QC_CheckProjectList_Json")]
+        [HttpGet]
+        public object MES_QC_CheckProjectList_Json(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_Gy_QCCheckProjectList ", "h_v_Gy_QCCheckProjectList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_Gy_QCCheckProjectList where 1 = 1 ";
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_QCCheckProjectList");
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+        /// <summary>
+        /// 杩斿洖鏉ユ枡妫�楠屽崟鍒楄〃
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("QC_Management/MES_QC_POStockInCheckBillList_Json")]
+        [HttpGet]
+        public object MES_QC_POStockInCheckBillList_Json(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_POStockInCheckBillList ", "h_v_QC_POStockInCheckBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_QC_POStockInCheckBillList where 1 = 1 ";
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_QC_POStockInCheckBillList");
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+        /// <summary>
+        ///杩斿洖棣栦欢妫�楠屽崟鍒楄〃
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("QC_Management/MES_QC_FirstPieceCheckBillList_Json")]
+        [HttpGet]
+        public object MES_QC_FirstPieceCheckBillList_Json(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_FirstPieceCheckBillList ", "h_v_QC_FirstPieceCheckBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_QC_FirstPieceCheckBillList where 1 = 1 ";
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_QC_FirstPieceCheckBillList");
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+        /// <summary>
+        /// 杩斿洖宸℃璁板綍鍗曞垪琛�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("QC_Management/MES_QC_PatrolProcCheckBillList_Json")]
+        [HttpGet]
+        public object MES_QC_PatrolProcCheckBillList_Json(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_PatrolProcCheckBillList ", "h_v_QC_PatrolProcCheckBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_QC_PatrolProcCheckBillList where 1 = 1 ";
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_QC_PatrolProcCheckBillList");
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+
+
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/Controllers/Sc_ProcessMangementController.cs b/WebAPI/Controllers/Sc_ProcessMangementController.cs
index 981824b..24831dd 100644
--- a/WebAPI/Controllers/Sc_ProcessMangementController.cs
+++ b/WebAPI/Controllers/Sc_ProcessMangementController.cs
@@ -2177,6 +2177,168 @@
         }
 
 
+        /// <summary>
+        /// 淇濆瓨濮斿宸ュ崟淇℃伅
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("SaveWWWorkOrder")]
+        [HttpPost]
+        public object SaveWWWorkOrder([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+            string UserName = "";
+            ListModels oListModels = new ListModels();
+
+            try
+            {
+                WebAPI.DLL.ClsWW_EntrustWorkOrderBill WorkOrder = new WebAPI.DLL.ClsWW_EntrustWorkOrderBill();
+                List<Models.ClsWW_EntrustWorkOrderBillMain> lsmain = new List<Models.ClsWW_EntrustWorkOrderBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");
+                lsmain = oListModels.getObjectByJson_WorkOrderMain(msg2);
+                foreach (Models.ClsWW_EntrustWorkOrderBillMain oItem in lsmain)
+                {
+                    UserName = oItem.HMaker;
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HDate = DateTime.Now;
+                    oItem.HMainSourceInterID = oItem.HInterID;
+                    oItem.HInterID = 0;
+
+
+
+                    WorkOrder.omodel = oItem;
+
+
+                }
+
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                List<WebAPI.Models.Sc_ProcessPlanViewModel> ls = new List<WebAPI.Models.Sc_ProcessPlanViewModel>();
+                ls = oListModels.getObjectByJson_SendWorkSub(msg3);
+                int i = 0;
+                List<Models.ClsWW_EntrustWorkOrderBillSub> lss = new List<Models.ClsWW_EntrustWorkOrderBillSub>();
+                foreach (WebAPI.Models.Sc_ProcessPlanViewModel oItemSub in ls)
+                {
+
+                    i++;
+                    Models.ClsWW_EntrustWorkOrderBillSub WorkOrdersub = new Models.ClsWW_EntrustWorkOrderBillSub();
+                    WorkOrdersub.HProcID = oItemSub.hprocid.Value;//--宸ュ簭ID
+                    WorkOrdersub.HSourceInterID = oItemSub.hmainid.Value; //--婧愬崟id
+                    WorkOrdersub.HSourceEntryID = oItemSub.hsubid.Value; //--婧愬崟瀛怚D
+                    WorkOrdersub.HSourceBillNo = oItemSub.鍗曟嵁鍙�; //--婧愬崟鍗曞彿
+                    WorkOrdersub.HSourceBillType= oItemSub.HBillType; //--婧愬崟绫诲瀷
+                    WorkOrdersub.HRelationQty = 0;  //--鍏宠仈鏁伴噺
+                    WorkOrdersub.HRelationMoney = 0; //--鍏宠仈閲戦
+                    WorkOrdersub.HOrderBillNo = ""; //--閿�鍞鍗曞彿
+                    WorkOrdersub.HMaterLenModel = ""; //--鏉愯川
+                    WorkOrdersub.HMaterQty = 0; //--鏉愯川鏁伴噺
+                    WorkOrdersub.HMaterID = oItemSub.HMaterID.Value; //--鐗╂枡
+                    WorkOrdersub.HQty = (double)oItemSub.璁″垝鏁伴噺; //--璁㈠崟鏁伴噺
+                    WorkOrdersub.HEntrustType = "3739"; //--濮斿绫诲瀷
+                    WorkOrdersub.HNextProcName = ""; //--涓嬮亾宸ュ簭
+                    WorkOrdersub.HPrice =0; //鍔犲伐璐�
+                    WorkOrdersub.HOutQty = 0;  //--鍏宠仈鍙戝嚭鏁伴噺
+                    WorkOrdersub.HInQty =0; //--鍏宠仈鎺ユ敹鏁伴噺
+                    WorkOrdersub.HBackSupDate = DateTime.Now; //--瀹為檯浜よ揣鏃ユ湡
+                    WorkOrdersub.HInDate = DateTime.Now; //--浜よ揣鏃ユ湡 
+                    WorkOrdersub.HWorkProcFlow = ""; //--宸ヨ壓娴�
+                    WorkOrdersub.HLeftMater = ""; //--浣欐枡鎯呭喌
+
+                    if (oItemSub.璁″垝鏁伴噺 <= 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺" + i.ToString() + "琛屾暟閲忎笉澶т簬0鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    if (Convert.ToInt32(WorkOrdersub.HQty) > Convert.ToInt32(oItemSub.璁″垝鏁伴噺))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺" + i.ToString() + "琛屾淳宸ユ暟閲忎笉鑳藉ぇ浜庤鍒掑崟鏁伴噺锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    WorkOrdersub.HEntryID = i;
+                    WorkOrdersub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    WorkOrdersub.HRemark = "";
+                    WorkOrdersub.HCloseMan = "";
+                    WorkOrdersub.HCloseType = false;
+                    WorkOrdersub.HSourceBillType = oItemSub.HBillType;
+                    lss.Add(WorkOrdersub);//鍏堟妸鏁版嵁瀛樻斁鍒板澶栧伐鍗曞瓙琛ㄩ泦鍚堥噷
+
+
+                }
+                if (lss.Count > 0)
+                {
+                    //鐒跺悗鍐嶅惊鐜繚瀛樺埌濮斿宸ュ崟瀛愯〃鐨勯泦鍚堥噷
+                    foreach (Models.ClsWW_EntrustWorkOrderBillSub Itemsendwork in lss)
+                    {
+                        WorkOrder.DetailColl.Add(Itemsendwork);
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛乴ss闆嗗悎灏忎簬0";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (WorkOrder.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = WorkOrder.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = WorkOrder.ModifyBill(WorkOrder.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+
 
     }
 }
\ No newline at end of file
diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index 84bae22..0ed6fa9 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -1055,6 +1055,37 @@
             }
         }
 
+        /// <summary>
+        /// 鑾峰彇鐧诲綍椤电粍缁囧垪
+        /// </summary>
+        /// <returns></returns>
+        [Route("Web/GetOrganizations")]
+        [HttpGet]
+        public object GetOrganizations()
+        {
+            try
+            {
+                ClsCN oCn = new ClsCN();
+                DataSet oDs = new DataSet();
+                //==========
+                oDs = oCn.RunProcReturn("select HItemID ID,Hname Name,HStopflag Stopflag from Xt_ORGANIZATIONS", "Xt_ORGANIZATIONS");
+                objjson.code = "1";
+                objjson.count = 1;
+                objjson.Message = "鑾峰彇鎴愬姛锛�";
+                objjson.data = oDs.Tables[0];
+                return objjson; ;
+            }
+            catch (Exception e)
+            {
+
+                objjson.code = "0";
+                objjson.count = 0;
+                objjson.Message = "鑾峰彇澶辫触锛佸紓甯�" + e.ToString();
+                objjson.data = null;
+                return objjson; ;
+            }
+        }
+
 
 
         #endregion
diff --git a/WebAPI/DLL/ClsWW_EntrustWorkOrderBill.cs b/WebAPI/DLL/ClsWW_EntrustWorkOrderBill.cs
new file mode 100644
index 0000000..4ac493d
--- /dev/null
+++ b/WebAPI/DLL/ClsWW_EntrustWorkOrderBill.cs
@@ -0,0 +1,343 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+
+namespace WebAPI.DLL
+{
+    public class ClsWW_EntrustWorkOrderBill : DBUtility.ClsXt_BaseBill
+    {
+        public WebAPI.Models.ClsWW_EntrustWorkOrderBillMain omodel = new Models.ClsWW_EntrustWorkOrderBillMain();
+        public List<Models.ClsWW_EntrustWorkOrderBillSub> DetailColl = new List<Models.ClsWW_EntrustWorkOrderBillSub>();
+
+        public ClsWW_EntrustWorkOrderBill()
+        {
+            base.MvarItemKeySub = "WW_EntrustWorkOrderBillSub";
+            base.MvarItemKeySub2 = "";
+            base.MvarItemKeySub3 = "";
+            base.MvarItemKeySub4 = "";
+            base.MvarItemKey = "WW_EntrustWorkOrderBillMain";
+            base.MvarReportTitle = "濮斿宸ュ崟";
+            base.BillType = "3739";
+            base.HBillSubType = "3739";
+
+        }
+
+        #region 鍥哄畾浠g爜
+
+        ~ClsWW_EntrustWorkOrderBill()
+        {
+            DetailColl = null;
+        }
+
+        #endregion   鑷畾涔夋柟娉�
+
+
+        //鍒犻櫎鍗曟嵁
+        public override bool DeleteBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                oCn.BeginTran();
+                //鍒犻櫎鍏宠仈
+                DeleteRelation(ref sReturn, lngBillKey);
+                oCn.RunProc("exec h_p_WW_EntrustWorkOrderToProcExch_Del " + lngBillKey.ToString());
+                //鍒犻櫎鏄庣粏琛�
+                DeleteBillSub(lngBillKey);
+                DeleteBillSub2(lngBillKey);
+                DeleteBillSub3(lngBillKey);
+                DeleteBillSub4(lngBillKey);
+                //鍒犻櫎涓昏〃
+                DeleteBillMain(lngBillKey);
+                sReturn = "鍒犻櫎鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+        //淇敼鍗曟嵁
+        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //
+                oCn.BeginTran();
+                //鏇存柊涓昏〃
+                oCn.RunProc("UpDate WW_EntrustWorkOrderBillMain set  " +
+                " HBillNo='" + omodel.HBillNo + "'" +  //鍥哄畾璧嬪��===============
+                ",HDate='" + omodel.HDate + "'" +
+                ",HYear='" + omodel.HYear.ToString() + "'" +
+                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
+                ",HRemark='" + omodel.HRemark + "'" +
+                ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
+                ",HUpDateDate=getdate()" +
+                    //========================================
+                ",HDeptID=" + omodel.HDeptID.ToString() +
+                ",HSupID=" + omodel.HSupID.ToString() +
+                ",HOrderProcNO='" + omodel.HOrderProcNO + "'" +
+                " where HInterID=" + lngBillKey.ToString());
+                //鍒犻櫎鍏宠仈
+                DeleteRelation(ref sReturn, lngBillKey);
+                oCn.RunProc("exec h_p_WW_EntrustWorkOrderToProcExch_Del " + lngBillKey.ToString());
+
+                //鍒犻櫎瀛愯〃
+                DeleteBillSub(lngBillKey);
+                //鎻掑叆瀛愯〃
+                omodel.HInterID = lngBillKey;
+                foreach (Models.ClsWW_EntrustWorkOrderBillSub oSub in DetailColl)
+                {
+                    oCn.RunProc("Insert into WW_EntrustWorkOrderBillSub " +
+                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                      ",HOrderBillNo,HMaterLenModel,HMaterQty,HMaterID,HQty" +
+                      ",HEntrustType,HNextProcName,HPrice,HOutQty,HInQty" +
+                      ",HBackSupDate,HInDate,HWorkProcFlow,HProcID,HLeftMater" +
+                      ") values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      ",'" + oSub.HOrderBillNo + "','" + oSub.HMaterLenModel + "'," + oSub.HMaterQty.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HQty.ToString() +
+                      ",'" + oSub.HEntrustType + "','" + oSub.HNextProcName + "'," + oSub.HPrice.ToString() + "," + oSub.HOutQty.ToString() + "," + oSub.HInQty.ToString() +
+                      ",'" + oSub.HBackSupDate.ToShortDateString() + "','" + oSub.HInDate.ToShortDateString() + "','" + oSub.HWorkProcFlow + "'," + oSub.HProcID.ToString() +",'" + oSub.HLeftMater + "'" + 
+                      ") ");
+                }
+                //鏍规嵁鍐呯爜 濮斿宸ュ崟琛ㄥご渚涘簲鍟� 鍥炲~瀵瑰簲娴佽浆鍗� 渚涘簲鍟嗭紝鏈夊澶栨爣璁版墠鍥炲~
+                oCn.RunProc("exec h_p_WW_EntrustWorkOrderToProcExch " + omodel.HInterID.ToString());
+                //
+                //
+                DataSet Ds;
+                Ds = oCn.RunProcReturn("exec h_p_WW_EntrustWorkOrderToProcExch_QtyCtrl " + omodel.HInterID.ToString() + "", "h_p_WW_EntrustWorkOrderToProcExch_QtyCtrl");
+                if (Ds == null)
+                {
+                    sReturn = "鍒ゆ柇鏁伴噺澶辫触锛�";
+                    oCn.RollBack();
+                    return false;
+                }
+                if (Ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍒ゆ柇鏁伴噺澶辫触锛�";
+                    oCn.RollBack();
+                    return false;
+                }
+                if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBack"]) == "2")
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBackRemark"]);
+                    oCn.RollBack();
+                    return false;
+                }
+                //
+
+                sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //鏂板鍗曟嵁
+        public override bool AddBill(ref string sReturn)
+        {
+            try
+            {
+                //寰楀埌mainid
+                omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                //omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                //if (IsExistBillNo(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HBillNo, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew, omodel.HInterID))
+                //{
+                //    omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                //}
+                if (IsExistMainID(ref DBUtility.ClsPub.sExeReturnInfo, omodel.HInterID, Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew))
+                {
+                    omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                //
+                oCn.BeginTran();
+                //涓昏〃
+                oCn.RunProc("Insert Into WW_EntrustWorkOrderBillMain   " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HDeptID,HSupID,HOrderProcNO" +
+                ") " +
+                " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
+                ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" +
+                ", " + omodel.HDeptID.ToString() + "," + omodel.HSupID.ToString() + ",'" + omodel.HOrderProcNO + "'" +
+                ") ");
+                //鎻掑叆瀛愯〃
+                foreach (Models.ClsWW_EntrustWorkOrderBillSub oSub in DetailColl)
+                {
+                    oCn.RunProc("Insert into WW_EntrustWorkOrderBillSub " +
+                      " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                      ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                      ",HOrderBillNo,HMaterLenModel,HMaterQty,HMaterID,HQty" +
+                      ",HEntrustType,HNextProcName,HPrice,HOutQty,HInQty" +
+                      ",HBackSupDate,HInDate,HWorkProcFlow,HProcID,HLeftMater" +
+                      ") values("
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+                      ",'" + oSub.HOrderBillNo + "','" + oSub.HMaterLenModel + "'," + oSub.HMaterQty.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HQty.ToString() +
+                      ",'" + oSub.HEntrustType + "','" + oSub.HNextProcName + "'," + oSub.HPrice.ToString() + "," + oSub.HOutQty.ToString() + "," + oSub.HInQty.ToString() +
+                      ",'" + oSub.HBackSupDate.ToShortDateString() + "','" + oSub.HInDate.ToShortDateString() + "','" + oSub.HWorkProcFlow + "'," + oSub.HProcID.ToString() + ",'" + oSub.HLeftMater +  "'"  + 
+                      ") ");
+                }
+
+                ////鏍规嵁鍐呯爜 濮斿宸ュ崟琛ㄥご渚涘簲鍟� 鍥炲~瀵瑰簲娴佽浆鍗� 渚涘簲鍟嗭紝鏈夊澶栨爣璁版墠鍥炲~..骞朵笖鍥炲~ 鍏宠仈鏁伴噺
+                //oCn.RunProc("exec h_p_WW_EntrustWorkOrderToProcExch " + omodel.HInterID.ToString());
+                ////
+                //DataSet Ds;
+                //Ds = oCn.RunProcReturn("exec h_p_WW_EntrustWorkOrderToProcExch_QtyCtrl " + omodel.HInterID.ToString() + "", "h_p_WW_EntrustWorkOrderToProcExch_QtyCtrl");
+                //if (Ds == null)
+                //{
+                //    sReturn = "鍒ゆ柇鏁伴噺澶辫触锛�";
+                //    oCn.RollBack();
+                //    return false;
+                //}
+                //if (Ds.Tables[0].Rows.Count == 0)
+                //{
+                //    sReturn = "鍒ゆ柇鏁伴噺澶辫触锛�";
+                //    oCn.RollBack();
+                //    return false;
+                //}
+                //if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBack"]) == "2")
+                //{
+                //    sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBackRemark"]);
+                //    oCn.RollBack();
+                //    return false;
+                //}
+                //
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //鏄剧ず鍗曟嵁
+        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //鏌ヨ涓昏〃
+                DataSet Ds;
+                Ds = oCn.RunProcReturn("Select * from WW_EntrustWorkOrderBillMain Where HInterID=" + lngBillKey.ToString(), "WW_EntrustWorkOrderBillMain");
+                if (Ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍗曟嵁鏈壘鍒帮紒";
+                    return false;
+                }
+                //鍥哄畾璧嬪��===========================================
+                omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
+                omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
+                omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
+                omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]);
+                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
+                omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
+                omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
+                omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]);
+                omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]);
+                omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]);
+                omodel.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]);
+                omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
+                omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
+                omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
+                omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
+                omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
+                omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
+                omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
+                omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
+                omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
+                omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
+                omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
+                omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
+                omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
+                omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
+                //========================================================
+                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
+                omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
+                omodel.HOrderProcNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HOrderProcNO"]);
+                //
+
+                //寰幆
+                DataSet DsSub;
+                DsSub = oCn.RunProcReturn("Select * from WW_EntrustWorkOrderBillSub Where HInterID=" + lngBillKey.ToString(), "WW_EntrustWorkOrderBillSub");
+                DetailColl.Clear();//娓呯┖
+                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
+                {
+                    Models.ClsWW_EntrustWorkOrderBillSub oSub = new Models.ClsWW_EntrustWorkOrderBillSub();
+                    // 鍥哄畾璧嬪��===============================================
+                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
+                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
+                    oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
+                    oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
+                    oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
+                    oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
+                    oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]);
+                    oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]);
+                    oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
+                    oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
+                    oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
+                    oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
+                    //===================================================
+                    oSub.HOrderBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HOrderBillNo"]);
+                    oSub.HLeftMater = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HLeftMater"]);
+                    oSub.HMaterLenModel = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HMaterLenModel"]);
+                    oSub.HMaterQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HMaterQty"]);
+                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
+                    oSub.HProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcID"]);
+                    oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]);
+                    oSub.HEntrustType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HEntrustType"]);
+                    oSub.HNextProcName = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HNextProcName"]);
+                    oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]);
+                    oSub.HOutQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HOutQty"]);
+                    oSub.HInQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HInQty"]);
+                    oSub.HInDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HInDate"]);
+                    oSub.HBackSupDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HBackSupDate"]);
+                    oSub.HWorkProcFlow = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HWorkProcFlow"]);
+                    DetailColl.Add(oSub);
+                }
+                sReturn = "鏄剧ず鍗曟嵁鎴愬姛锛�";
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+
+
+        //鏇存柊鎵撳嵃娆℃暟
+        public bool Set_PrintQty(long sInterID)
+        {
+            try
+            {
+                oCn.BeginTran();
+                //鏇存柊 鎵撳嵃娆℃暟
+                oCn.RunProc("update WW_EntrustWorkOrderBillMain set HPrintQty=isnull(HPrintQty,0)+1 where HInterID=" + sInterID.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
+
+    }
+
+}
diff --git a/WebAPI/ListModels.cs b/WebAPI/ListModels.cs
index c47b8d8..c2f2a22 100644
--- a/WebAPI/ListModels.cs
+++ b/WebAPI/ListModels.cs
@@ -321,5 +321,17 @@
             return list;
         }
 
+        /// <summary>
+        /// 濮斿宸ュ崟涓昏〃json澶勭悊
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Models.ClsWW_EntrustWorkOrderBillMain> getObjectByJson_WorkOrderMain(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Models.ClsWW_EntrustWorkOrderBillMain> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsWW_EntrustWorkOrderBillMain>>(jsonString);
+            return list;
+        }
+
     }
 }
\ No newline at end of file
diff --git a/WebAPI/Models/ClsWW_EntrustWorkOrderBillMain.cs b/WebAPI/Models/ClsWW_EntrustWorkOrderBillMain.cs
new file mode 100644
index 0000000..ef5f5b6
--- /dev/null
+++ b/WebAPI/Models/ClsWW_EntrustWorkOrderBillMain.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsWW_EntrustWorkOrderBillMain:DBUtility.ClsXt_BaseBillMain
+    {
+        public Int64 HDeptID;//		int	//申请部门(h_v_CLD_Department)
+        public Int64 HSupID;//		int	//外协供应商(h_v_CLD_Supplier)
+        public string HOrderProcNO;//	varchar(100)	//订单跟踪号
+    }
+}
diff --git a/WebAPI/Models/ClsWW_EntrustWorkOrderBillSub.cs b/WebAPI/Models/ClsWW_EntrustWorkOrderBillSub.cs
new file mode 100644
index 0000000..e141383
--- /dev/null
+++ b/WebAPI/Models/ClsWW_EntrustWorkOrderBillSub.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebAPI.Models
+{
+    public class ClsWW_EntrustWorkOrderBillSub:DBUtility.ClsXt_BaseBillSub
+    {
+        public string HOrderBillNo;//	varchar(100)	//订单号
+        public string HMaterLenModel;//	varchar(200)	//板材料件尺寸
+        public double HMaterQty;//	dec(18,8)		//板材张数
+        public Int64 HMaterID;//		int		//加工产品(h_v_CLD_Material)
+        public double HQty;//		dec(18,8)		//生产数量
+        public string HEntrustType;//	varchar(200)	//委外加工类型
+        public string HNextProcName;//	varchar(200) 	//委外下道工序
+        public double HPrice;//		dec(18,8)		//加工单价
+        public double HOutQty;//		dec(18,8)		//转出数量
+        public double HInQty;//		dec(18,8)		//接收数量
+        public DateTime HInDate;//		datetime		//回厂时间
+        public string HRemark;//		varchar(500)	//备注
+        public string HWorkProcFlow;//	varchar(500)	//产品工艺
+        public Int64 HProcID;
+        public DateTime HBackSupDate;
+        public string HLeftMater;           //余料
+    }
+}
diff --git a/WebAPI/WebAPI.csproj.user b/WebAPI/WebAPI.csproj.user
index f0fb4b6..6192eed 100644
--- a/WebAPI/WebAPI.csproj.user
+++ b/WebAPI/WebAPI.csproj.user
@@ -17,8 +17,8 @@
     <IISExpressUseClassicPipelineMode />
     <UseGlobalApplicationHostFile />
     <ProjectView>ShowAllFiles</ProjectView>
-    <Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
-    <Controller_SelectedScaffolderCategoryPath>root/Common/Web API</Controller_SelectedScaffolderCategoryPath>
+    <Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
+    <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
   </PropertyGroup>
   <ProjectExtensions>
     <VisualStudio>

--
Gitblit v1.9.1