From 0739748004c887135a19bdd45b25b248d6f86ffb Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期二, 30 五月 2023 10:22:16 +0800
Subject: [PATCH] 反关闭

---
 WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs |  951 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 941 insertions(+), 10 deletions(-)

diff --git a/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs b/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs
index ec4e55b..00aa89a 100644
--- a/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs
+++ b/WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -10,14 +11,658 @@
 
 namespace WebAPI.Controllers
 {
-    //鐢熶骇璐ㄩ噺姹囨姤Controller
-    public class Sc_QualityReportBillController : ApiController
+    //鐢熶骇姹囨姤Controller
+    public class Sc_ICMOReportBillController : ApiController
     {
-        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
+        //鑾峰彇绯荤粺鍙傛暟
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
 
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
+        public DAL.ClsSc_ICMOReportBill BillNew = new DAL.ClsSc_ICMOReportBill();   //瀵瑰簲鍗曟嵁绫�
+        public DAL.ClsSc_ICMOReportBill BillOld = new DAL.ClsSc_ICMOReportBill();   //瀵瑰簲鍗曟嵁绫�
+
+        #region  鐢熶骇姹囨姤鍗�
+
+        #region  鐢熶骇姹囨姤鍗曞垪琛�
+        /// <summary>
+        /// 杩斿洖鐢熶骇姹囨姤鍗曞垪琛�
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Sc_ICMOReportBill/list")]
+        [HttpGet]
+        public object list(string sWhere, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBillQuery", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_IF_ICMOReportBillList_Edit order by hmainid desc ", "h_v_IF_ICMOReportBillList_Edit");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_IF_ICMOReportBillList_Edit where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by hmainid desc ";
+                    ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit");
+                }
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇姹囨姤鍗曠紪杈戞椂鑾峰彇琛ㄥご鏁版嵁
+        [Route("Sc_ICMOReportBill/Sc_GetICMOReportBillListCheckDetai")]
+        [HttpGet]
+        public ApiResult<DataSet> Sc_GetICMOReportBillListCheckDetai(string HID)
+        {
+            if (string.IsNullOrEmpty(HID))
+                return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" };
+            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_IF_ICMOReportBillList_Edit  where hmainid= " + HID + " ", "h_v_IF_ICMOReportBillList_Edit");
+            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
+                return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄧ敓浜ф眹鎶ュ崟鍙�" };
+
+            return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
+        }
+        #endregion
+
+        #region 鐢熶骇姹囨姤鍗曠紪杈戞椂鑾峰彇琛ㄤ綋鏁版嵁
+        [Route("Sc_ICMOReportBill/Sc_ICMOReportBillListProjectDetai")]
+        [HttpGet]
+        public object Sc_ICMOReportBillListProjectDetai(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,鐗╂枡浠g爜 HMaterCode,鐗╂枡鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,
+                                            HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅 HUnitName,HSourceID,鐢熶骇璧勬簮浠g爜 HSourceCode,鐢熶骇璧勬簮 HSourceName,
+                                            HWorkerid,鎿嶄綔鍛樹唬鐮� HWorkerCode,鎿嶄綔鍛� HWorkerName,鐢熶骇鏁伴噺 HQty,琛ㄤ綋澶囨敞 HRemark
+                                            FROM h_v_IF_ICMOReportBillList_Edit"), "h_v_IF_ICMOReportBillList_Edit");
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                    objJsonResult.data = ds.Tables[0];
+                }
+                else
+                {
+
+                    //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark  from Sc_MouldRepairCheckBillSub where 1 = 1 ";
+                    string sql1 = string.Format(@"SELECT HMaterID,鐗╂枡浠g爜 HMaterCode,鐗╂枡鍚嶇О HMaterName,瑙勬牸鍨嬪彿 HMaterSpec,
+                                            HUnitID, 璁¢噺鍗曚綅浠g爜 HUnitCode, 璁¢噺鍗曚綅 HUnitName,HSourceID,鐢熶骇璧勬簮浠g爜 HSourceCode,鐢熶骇璧勬簮 HSourceName,
+                                            HWorkerid,鎿嶄綔鍛樹唬鐮� HWorkerCode,鎿嶄綔鍛� HWorkerName,鐢熶骇鏁伴噺 HQty,琛ㄤ綋澶囨敞 HRemark
+                                            FROM h_v_IF_ICMOReportBillList_Edit where 1 = 1 ");
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit");
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                    objJsonResult.data = ds.Tables[0];
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+            }
+            return objJsonResult;
+        }
+        #endregion
+
+        #region 鐢熶骇姹囨姤鍗曚繚瀛�/缂栬緫
+        /// <summary>
+        /// 淇濆瓨妯″叿棰嗙敤鍗�
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("Sc_ICMOReportBill/SaveGetICMOReportBillList")]
+        [HttpPost]
+        public object SaveGetICMOReportBillList([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 refSav = sArray[2].ToString();
+            string user = sArray[3].ToString();
+
+            string UserName = "";
+            string s = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愮紪杈�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DLL.ClsSc_ICMOReportBill oBill = new DLL.ClsSc_ICMOReportBill();
+                List<Models.ClsSc_ICMOReportBillMain> lsmain = new List<Models.ClsSc_ICMOReportBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_ICMOReportBillMain(msg2);
+
+                foreach (Models.ClsSc_ICMOReportBillMain oItem in lsmain)
+                {
+                    if (refSav == "Add")
+                    {
+                        //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                        if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    if (refSav == "Update")
+                    {
+                        if (BillOld.ShowBill(oItem.HInterID, ref s) == false)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //鍒ゆ柇鏄惁鍙紪杈�
+                        if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (BillOld.omodel.HBillStatus > 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    //oItem.HMaker = "";
+                    UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HBillType = "3711";
+                    oItem.HBillSubType = "3711";
+                    oItem.HBillStatus = 1;   //鍗曟嵁鐘舵�侊紙1鏈锛�2瀹℃牳閫氳繃锛�3鍏抽棴锛�4浣滃簾锛�5瀹℃牳閫�鍥�,6瀹℃牳涓�,7宸查槄锛�8宸插洖澶嶏紝9缁撴锛�10楠岃瘉,11涓嬭揪锛�12寮�宸�,13鐢宠瀹℃壒,15鐢宠妫�楠岋紝16 鍒ゅ畾鍚堟牸锛�17鍒ゅ畾涓嶅悎鏍硷級 
+                    //oItem.HBillNo = "";    //鍗曟嵁鍙�
+                    //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --鏃ユ湡
+                    //oItem.HInnerBillNo = "";  //  --鍐呴儴鍗曟嵁鍙�
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    //oItem.HEquipID = 0;    //璁惧ID(Gy_EquipMent)
+                    //oItem.HPeriod = 0;
+                    //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));  //  --缁翠慨鏃ユ湡
+                    //oItem.HCheckResult = "";     //楠屾敹缁撹--(姝e父锛屽紓甯�)
+                    //oItem.HEmpID = 0;           //楠屾敹浜�(Gy_Employee)
+                    //oItem.HManagerID = 0;      //璐熻矗浜�(Gy_Employee)
+                    //oItem.HDeptID = 0;        //楠屾敹閮ㄩ棬(Gy_Department)
+                    //oItem.HExplanation = "";  //鎽樿(鏁呴殰鎻忚堪)  
+                    //oItem.HRemark = "";       //澶囨敞
+
+                    //oItem.HMainSourceInterID = oItem.HInterID;
+
+                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Models.ClsSc_ICMOReportBillSub> ls = new List<Models.ClsSc_ICMOReportBillSub>();
+                ls = oListModels.getObjectByJson_Gy_ICMOReportBillSub(msg3);
+                int i = 0;
+                foreach (Models.ClsSc_ICMOReportBillSub oItemSub in ls)
+                {
+
+                    i++;
+                    oItemSub.HEntryID = i;
+
+                    //oItemSub.HRepairCheckID = 0;   //楠屾敹椤圭洰ID
+                    //oItemSub.HRepairCheckContent = ""; //楠屾敹鍐呭
+                    //oItemSub.HManagerID = 0;   //璐熻矗浜篒D
+                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+                    //oItemSub.HRemark = "";         //澶囨敞
+                    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                    //oItemSub.HSourceBillNo = "";  //婧愬崟鍗曞彿
+                    //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
+                    //oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                    //oItemSub.HRelationMoney = 0;   //鍏宠仈閲戦 
+                    //oItemSub.HRepairID = 0;       //缁翠慨椤圭洰
+                    //oItemSub.HRepairExplanation ="";   //缁翠慨瑕佹眰
+                    //oItemSub.HMoney = 0;        //缁翠慨璐圭敤
+                    oBill.DetailColl.Add(oItemSub);
+
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.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;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇姹囨姤鍗曚繚瀛榓pi
+        [Route("Sc_ICMOReportBill/Sc_ICMOReportBillSaveApi")]
+        [HttpPost]
+        public object Sc_ICMOReportBillSaveApi([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var model = sMainSub["model"].ToString();
+                var entry = sMainSub["model"]["HENTRY"].ToString();
+
+                model = "[" + model.ToString() + "]";
+                List<ClsSc_ICMOReportBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOReportBillMain>>(model);
+                List<ClsSc_ICMOReportBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_ICMOReportBillSub>>(entry);
+                string sql = string.Empty;
+                oCN.BeginTran();
+                sql = $"delete Sc_ICMOReportBillMain where HinterID = {mainList[0].HInterID}";
+                oCN.RunProc(sql);
+                sql = $"delete Sc_ICMOReportBillSub where HinterID = {mainList[0].HInterID}";
+                oCN.RunProc(sql);
+                //涓昏〃
+                sql = "Insert Into Sc_ICMOReportBillMain   " +
+               "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate" +
+               ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" +
+               ",HGroupID,HDeptID,HDeptNumber" +
+               ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" +
+               ",HChecker,HCheckDate,HUpDater,HUpDateDate,HDeleteMan,HDeleteDate,HPrintQty,HCheckType" +
+               ",HERPInterID,HERPBillType,HPRDORGID" +
+               ") " +
+               " values('" + mainList[0].HBillType + "','" + mainList[0].HBillSubType + "'," + mainList[0].HInterID.ToString() + ",'" + mainList[0].HBillNo + "','" + mainList[0].HDate + "','" + mainList[0].HMaker + "',getdate()" +
+               "," + mainList[0].HYear.ToString() + "," + mainList[0].HPeriod.ToString() + ",'" + mainList[0].HRemark + "','" + mainList[0].HEmpID.ToString() + "','" + mainList[0].HEmpNumber +
+               "','" + mainList[0].HGroupID.ToString() + "'," + mainList[0].HDeptID.ToString() + ",'" + mainList[0].HDeptNumber +
+               "','" + mainList[0].HMainSourceBillNo.ToString() + "'," + mainList[0].HMainSourceInterID.ToString() + ",'" + mainList[0].HMainSourceEntryID + "','" + mainList[0].HMainSourceBillType + "','" + mainList[0].HChecker + "','" + mainList[0].HCheckDate + "','" + mainList[0].HUpDater +
+               "','" + mainList[0].HUpDateDate + "','" + mainList[0].HDeleteMan + "','" + mainList[0].HDeleteDate + "'," + mainList[0].HPrintQty +
+               ",'" + mainList[0].HCheckType + "'," + mainList[0].HERPInterID + ",'" + mainList[0].HERPBillType + "'," + mainList[0].HPRDORGID +
+               ") ";
+                oCN.RunProc(sql);
+                //淇濆瓨涓昏〃
+                foreach (var oSub in subList)
+                {
+                    sql = "Insert into Sc_ICMOReportBillSub " +
+                      " (HInterID,HEntryID,HMaterID,HMaterNumber" +
+                      ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" +
+                      ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," +
+                      "HCloseMan,HCloseType,HRemark," +
+                      "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
+                      ",HICMOInterID,HICMOBillNo,HBarCode" +
+                      ",HOWNERTYPEID,HISENTRUST,HSTOCKINORGID,HOWNERID,HCHECKPRODUCT,HQAIP,HCOSTRATE,HISBACKFLUSH" +
+                      ",HREQSRC,HREQBILLNO,HREQBILLID,HREQENTRYSEQ,HREQENTRYID,HMOMAINENTRYID,HSTOCKINQUASELQTY" +
+                      ",HPRODUCTTYPE,HPROJECTNO,HICMOENTRYSEQ,HSEQ,HPRODUCEDATE,HEXPIRYDATE,HBASEUNITID,HDEPTID" +
+                      ",HGroupID,HDESCRIPTION" +
+                      ",HSourceNumber,HQPQty,HICMOEntryID" +
+                      ",HWhID,HSPID,HBatChNo,HAuxPropID,HMTONo,HPlanMode,HERPInterID,HERPEntryID" +
+                      ") values("
+                      + oSub.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + ",'" + oSub.HMaterNumber + "'" +
+                      "," + oSub.HQty.ToString() + "," + oSub.HUnitID.ToString() + ",'" + oSub.HUnitNumber + "'," + oSub.HTimes.ToString() + "," + oSub.HSourceID.ToString() +
+                      "," + oSub.HQtyMust.ToString() + "," + oSub.HWorkerID.ToString() + ",'" + oSub.HWorkerNumber + "'," + oSub.HBadCount.ToString() + "," + oSub.HWasterQty.ToString() +
+                      ",'" + oSub.HCloseMan + "'," + 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.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
+                      "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "','" + oSub.HBarCode + "','" + oSub.HOWNERTYPEID + "'," +
+                      oSub.HISENTRUST + "," + oSub.HSTOCKINORGID + "," + oSub.HOWNERID + "," + oSub.HCHECKPRODUCT + ",'" + oSub.HQAIP + "'," +
+                      oSub.HCOSTRATE + "," + oSub.HISBACKFLUSH + ",'" + oSub.HREQSRC + "','" + oSub.HREQBILLNO + "'," + oSub.HREQBILLID + "," +
+                      oSub.HREQENTRYSEQ + "," + oSub.HREQENTRYID + "," + oSub.HMOMAINENTRYID + "," + oSub.HSTOCKINQUASELQTY + "," + oSub.HPRODUCTTYPE + ",'" + oSub.HPROJECTNO + "'," + oSub.HICMOENTRYSEQ + "," + oSub.HSEQ + ",'" + oSub.HPRODUCEDATE + "','" + oSub.HEXPIRYDATE + "'," + oSub.HBASEUNITID + "," + oSub.HDEPTID + "," + oSub.HGroupID + ",'" + oSub.HDESCRIPTION + "','" + oSub.HSourceNumber + "'," + oSub.HQPQty + "," + oSub.HICMOEntryID + "," + oSub.HWhID + "," + oSub.HSPID + ",'" + oSub.HBatChNo + "'," + oSub.HAuxPropID + ",'" + oSub.HMTONo + "'," + oSub.HPlanMode + "," + oSub.HERPInterID + "," + oSub.HERPEntryID + ") ";
+                    oCN.RunProc(sql);
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢熶骇姹囨姤鍗曞垹闄ゅ姛鑳�
+        /// <summary>
+        /// 妯″叿澶勭悊棰嗙敤鍗曞垹闄ゅ姛鑳�
+        /// </summary>
+        /// <returns></returns>
+        [Route("Sc_ICMOReportBill/DeltetICMOReportBill")]
+        [HttpGet]
+        public object DeltetMouldLifeChangeBill(string HInterID, string user)
+        {
+            //缂栬緫鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log_second("Sc_ICMOReportBill_Drop", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            string s = "";
+            Int64 lngBillKey = 0;
+            lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+            if (lngBillKey == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁ID涓虹┖锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            DLL.ClsSc_ICMOReportBill oBill = new DLL.ClsSc_ICMOReportBill();
+            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+            {
+                if (oBill.omodel.HBillStatus > 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵��,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (oBill.omodel.HChecker != "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (!DBUtility.Xt_BaseBillFun.Fun_AllowDeleteBill(BillOld, ref s))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = s + "锛屼笉鍏佽鍒犻櫎";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                if (IsDete)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁鏈壘鍒�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region [鐢熶骇姹囨姤鍗曞鏍搞�佸弽瀹℃牳]
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Sc_ICMOReportBill/AuditProcessReportList")]
+        [HttpGet]
+        public object AuditProcessReportList(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "Sc_ICMOReportBill_Check";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+                DLL.ClsSc_ICMOReportBill oBill = new DLL.ClsSc_ICMOReportBill();
+                //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (oBill.omodel.HChecker.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (oBill.omodel.HChecker.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (IsAudit == 0) //瀹℃牳鎻愪氦
+                {
+                    //瀹℃牳鎻愪氦
+                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅鏍告彁浜�
+                {
+                    //鍙嶅鏍告彁浜bandonCheck
+                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #endregion
 
 
         /// <summary>
@@ -25,21 +670,21 @@
         ///鍙傛暟锛歴tring sql銆�
         ///杩斿洖鍊硷細object銆�
         /// </summary>
-        [Route("Sc_QualityReportBill/list")]
+        [Route("Sc_AssemblyBill/list1")]
         [HttpGet]
-        public object list(string sWhere)
+        public object list1(string sWhere)
         {
             try
             {
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_Sc_QualityReportBillList " + sWhere, "h_v_Sc_QualityReportBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_Sc_AssemblyBillList " + sWhere, "h_v_Sc_AssemblyBillList");
                 }
                 else
                 {
-                    string sql1 = "select * from h_v_Sc_QualityReportBillList where 1 = 1 ";
+                    string sql1 = "select * from h_v_Sc_AssemblyBillList where 1 = 1 ";
                     string sql = sql1 + sWhere;
-                    ds = oCN.RunProcReturn(sql, "h_v_Sc_QualityReportBillList");
+                    ds = oCN.RunProcReturn(sql, "h_v_Sc_AssemblyBillList");
                 }
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
@@ -68,8 +713,294 @@
             }
         }
 
+        #region [鍚屾鍗曟嵁]
+        [Route("Sc_ICMOReportBill/Sc_ICMOReportBillViewApi")]
+        [HttpGet]
+        public json Sc_ICMOReportBillViewApi(string BillNo, string BillType)
+        {
+            string sql = string.Empty;
+            string sReturn = "";
+            if (oSystemParameter.ShowBill(ref sReturn) == true)
+            {
+                //绯荤粺鍙傛暟鏄惁涓虹鏈変簯妯″紡,N涓哄叕鏈変簯妯″紡锛孻涓虹鏈変簯妯″紡
+                if (oSystemParameter.omodel.WMS_CloudMode == "Y")
+                {
+                    #region [绉佹湁浜戞ā寮忥紝鐩存帴璋冪敤鏁版嵁搴撳瓨鍌ㄨ繃绋嬫洿鏂癩
+                    try
+                    {
+                        oCN.BeginTran();
+                        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                        DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPSourceBillToLocal '" + BillNo + "','" + BillType + "'", "h_p_WMS_ERPSourceBillToLocal");
+                        if (DS == null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鍚屾澶辫触";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "ERP涓笉瀛樺湪璇ュ崟鎹彿";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                objJsonResult.code = "1";
+                                objJsonResult.count = 1;
+                                objJsonResult.Message = "鍗曟嵁鍚屾鎴愬姛";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
 
+                    }
+                    catch (Exception e)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "Exception锛�" + e.ToString();
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    #endregion
+                }
+                else
+                {
+                    #region [鍏湁浜戞ā寮忥紝璋冪敤WEBAPI鐨勬柟寮忚繘琛屾洿鏂癩
+                    var json = new
+                    {
+                        CreateOrgId = 0,
+                        Number = BillNo,
+                        Id = ""
+                    };
+                    #region [閲戣澏閮ㄥ垎]
+                    //鐧诲綍閲戣澏
+                    var loginRet = InvokeHelper.Login();
+                    var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+                    //鍒ゆ柇鏄惁鐧诲綍鎴愬姛
+                    if (isSuccess < 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = loginRet;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鏌ョ湅 鑾峰彇鏁版嵁                    
+                    var _result = InvokeHelper.View("PRD_MORPT", JsonConvert.SerializeObject(json));
+                    var _saveObj = JObject.Parse(_result);
+                    //鍒ゆ柇鏁版嵁鏄惁鑾峰彇鎴愬姛
+                    if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "閲戣澏鐢熶骇姹囨姤鍗曞悓姝ュけ璐sonRoot锛�" + _result;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
 
-        //
+                    #endregion
+                    //鑾峰彇涓昏〃鏁版嵁
+                    DataSet Ds;
+                    Int64 InterID = 0;
+                    Ds = oCN.RunProcReturn("select * from Sc_ICMOReportBillMain where HBillNo = '" + BillNo + "'", "Sc_ICMOReportBillMain");
+                    if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0)
+                    {
+                        InterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
+                    }
+
+                    #region [涓昏〃鏁版嵁璧嬪�糫
+                    var jsonData = new
+                    {
+                        HInterID = _saveObj["Result"]["Result"]["Id"],
+                        HYear = DateTime.Now.Year,
+                        HPeriod = DateTime.Now.Month,
+                        HBillType = 3711,
+                        HBillSubType = 3711,
+                        HDate = _saveObj["Result"]["Result"]["Date"],
+                        HBillNo = _saveObj["Result"]["Result"]["BillNo"],
+                        HEmpID = 0,
+                        HEmpNumber = "",
+                        HGroupID = 0,
+                        HDeptID = 0,
+                        HDeptNumber = "",
+                        HRemark = "CLD瀵煎叆",
+                        HChecker    = _saveObj["Result"]["Result"]["ApproverId"]["Name"],
+                        HCheckDate  = _saveObj["Result"]["Result"]["ApproveDate"],
+                        HMaker      = _saveObj["Result"]["Result"]["CreatorId"]["Name"],
+                        HMakeDate   = _saveObj["Result"]["Result"]["CreateDate"],
+                        HUpDater    = _saveObj["Result"]["Result"]["ModifierId"]["Name"],
+                        HUpDateDate = _saveObj["Result"]["Result"]["ModifyDate"],
+                        HDeleteMan  = _saveObj["Result"]["Result"]["CANCELER_Id"],
+                        HDeleteDate = _saveObj["Result"]["Result"]["CancelDate"],
+                        HMainSourceBillType    = "",
+                        HMainSourceInterID     = 0,
+                        HMainSourceEntryID     = 0,
+                        HMainSourceBillNo      = "",
+                        HPrintQty              = 0,
+                        HCheckType             = "",
+                        HERPInterID            = _saveObj["Result"]["Result"]["Id"],
+                        HERPBillType           = _saveObj["Result"]["Result"]["BillType_Id"],
+                        HPRDORGID = _saveObj["Result"]["Result"]["PrdOrgId_Id"],
+                    };
+                    #endregion
+                    // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁
+                    sql = $"delete from Sc_ICMOReportBillMain where HInterID = " + InterID;
+                    oCN.RunProc(sql);
+
+                    //鎻掑叆涓昏〃
+                    sql = $@"
+                insert into Sc_ICMOReportBillMain
+                (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HEmpID,HEmpNumber
+	            ,HGroupID,HDeptID,HDeptNumber,HRemark,HChecker,HCheckDate,HMaker,HMakeDate
+	            ,HUpDater,HUpDateDate,HDeleteMan,HDeleteDate
+	            ,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HPrintQty,HCheckType
+	            ,HERPInterID,HERPBillType,HPRDORGID
+                 )
+                values
+                ({jsonData.HInterID},{jsonData.HYear},{jsonData.HPeriod},{jsonData.HBillType},{jsonData.HBillSubType},
+                '{jsonData.HDate}','{jsonData.HBillNo}',{jsonData.HEmpID},'{jsonData.HEmpNumber}',{jsonData.HGroupID},{jsonData.HDeptID},'{jsonData.HDeptNumber}','{jsonData.HRemark}','{jsonData.HChecker}','{jsonData.HCheckDate}','{jsonData.HMaker}','{jsonData.HMakeDate}','{jsonData.HUpDater}','{jsonData.HUpDateDate}','{jsonData.HDeleteMan}','{jsonData.HDeleteDate}','{jsonData.HMainSourceBillType}',{jsonData.HMainSourceInterID},{jsonData.HMainSourceEntryID},'{jsonData.HMainSourceBillNo}',{jsonData.HPrintQty},'{jsonData.HCheckType}',{jsonData.HERPInterID},'{jsonData.HERPBillType}',{jsonData.HPRDORGID})";
+
+                    oCN.RunProc(sql);
+
+                    #region [鐢宠瀛愯〃鍙橀噺]
+                    var dataArr = _saveObj["Result"]["Result"]["PRD_MORPTENTRY"];
+
+                    DataSet Cs;
+                    double RelationQty = 0;
+                    #endregion
+                    int i = 0;
+
+                    // 鑾峰彇瀛愯〃鏁版嵁
+                    Cs = oCN.RunProcReturn("select * from Sc_ICMOReportBillSub where HInterID = " + InterID, "Sc_ICMOReportBillSub");
+                    // 鍒犻櫎瀛愯〃瀵瑰簲鏁版嵁
+                    sql = $"delete from Sc_ICMOReportBillSub where HInterID = " + InterID;
+                    oCN.RunProc(sql);
+
+                    foreach (var oSub in dataArr)
+                    {
+                        #region [瀛愯〃鏁版嵁璧嬪�糫
+
+                        if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HInterID"].ToString()) != 0)
+                        {
+                            RelationQty = ClsPub.isDoule(Cs.Tables[0].Rows[i]["HRelationQty"].ToString());
+
+                            i++;
+                        }
+
+                        var subData = new
+                        {
+                            HInterID = _saveObj["Result"]["Result"]["Id"],
+                            HEntryID = oSub["Id"],
+                            HMaterID = oSub["MaterialId_Id"],
+                            HMaterNumber       = "",
+                            HUnitID            = oSub["UnitID_Id"],
+                            HUnitNumber        = "",
+                            HQtyMust           = oSub["FinishQty"],
+                            HQty               = oSub["FinishQty"],
+                            HWorkerID          = 0,
+                            HWorkerNumber      = "",
+                            HSourceID          = 0,
+                            HSourceNumber      = "",
+                            HTimes             = oSub["StdManHour"],
+                            HBadQty            = oSub["FailQty"],
+                            HBadCount          = 0,
+                            HQPQty             = oSub["QuaQty"],
+                            HWasterQty         = 0,
+                            HRemark            = "CLOUD瀵煎叆",
+                            HSourceInterID     = oSub["SrcInterId"],
+                            HSourceEntryID     = oSub["SrcEntryId"],
+                            HSourceBillNo      = oSub["SrcBillNo"],
+                            HSourceBillType    = oSub["SrcBillType"],
+                            HICMOInterID       = oSub["MoId"],
+                            HICMOEntryID       = oSub["MoEntryId"],
+                            HICMOBillNo        = oSub["MoBillNo"],
+                            HSeOrderInterID    = 0,
+                            HSeOrderEntryID    = 0,
+                            HSeOrderBillNo     = "",
+                            HRelationQty       = oSub["BaseStockInQuaSelQty"],
+                            HRelationMoney     = 0,
+                            HSplitNO           = "",
+                            HBarCode           = "",
+                            HWhID              = oSub["StockId_Id"],
+                            HSPID              = oSub["StockLocId_Id"],
+                            HBatChNo           = oSub["Lot_Text"],
+                            HAuxPropID         = oSub["AuxPropId_Id"],
+                            HMTONo             = oSub["MtoNo"],
+                            HPlanMode          = 0,
+                            HERPInterID        = _saveObj["Result"]["Result"]["Id"],
+                            HERPEntryID = oSub["Id"],
+                            HOWNERTYPEID       = oSub["OwnerTypeId"],
+                            HISENTRUST         = oSub["IsEntrust"] = false ? 0 : 1,
+                            HSTOCKINORGID      = oSub["StockInOrgId_Id"],
+                            HOWNERID           = oSub["OwnerId_Id"],
+                            HCHECKPRODUCT      = oSub["CheckProduct"] = false ? 0 : 1,
+                            HQAIP              = oSub["QAIP"],
+                            HCOSTRATE          = oSub["CostRate"],
+                            HISBACKFLUSH       = oSub["ISBACKFLUSH"],
+                            HREQSRC            = oSub["ReqSrc"],
+                            HREQBILLNO         = oSub["ReqBillNo"],
+                            HREQBILLID         = oSub["ReqBillId"],
+                            HREQENTRYSEQ       = oSub["ReqEntrySeq"],
+                            HREQENTRYID        = oSub["ReqEntryId"],
+                            HMOMAINENTRYID     = oSub["MoMainEntryId"],
+                            HSTOCKINQUASELQTY  = oSub["BaseStockInQuaSelQty"],
+                            HPRODUCTTYPE       = oSub["ProductType"],
+                            HPROJECTNO         = oSub["ProjectNo"],
+                            HICMOENTRYSEQ      = oSub["MoEntrySeq"],
+                            HSEQ               = oSub["Seq"],
+                            HPRODUCEDATE       = oSub["ProduceDate"],
+                            HEXPIRYDATE        = oSub["ExpiryDate"],
+                            HBASEUNITID        = oSub["BaseUnitId_Id"],
+                            HDEPTID            = oSub["WorkshopId_Id"],
+                            HGroupID           = oSub["ShiftGroupId_Id"],
+                            HDESCRIPTION = ""                           
+                        };
+                        #endregion                       
+
+                        //鎻掑叆瀛愯〃
+                        sql = $@"
+                 insert into Sc_ICMOReportBillSub
+                 (HInterID,HEntryID,HMaterID,HMaterNumber,HUnitID,HUnitNumber
+	            ,HQtyMust,HQty,HWorkerID,HWorkerNumber,HSourceID,HSourceNumber,HTimes,HBadQty,HBadCount,HQPQty
+	            ,HWasterQty,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HICMOInterID,HICMOEntryID,HICMOBillNo
+	            ,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HRelationQty,HRelationMoney,HSplitNO,HBarCode
+	            ,HWhID,HSPID,HBatChNo,HAuxPropID,HMTONo,HPlanMode,HERPInterID,HERPEntryID
+	            ,HOWNERTYPEID,HISENTRUST,HSTOCKINORGID,HOWNERID,HCHECKPRODUCT,HQAIP,HCOSTRATE,HISBACKFLUSH,HREQSRC
+	            ,HREQBILLNO,HREQBILLID,HREQENTRYSEQ,HREQENTRYID,HMOMAINENTRYID,HSTOCKINQUASELQTY,HPRODUCTTYPE,HPROJECTNO
+	            ,HICMOENTRYSEQ,HSEQ,HPRODUCEDATE,HEXPIRYDATE,HBASEUNITID,HDEPTID,HGroupID,HDESCRIPTION
+                 )
+                 values
+                 ({subData.HInterID},{subData.HEntryID},{subData.HMaterID},'{subData.HMaterNumber}',{subData.HUnitID},'{subData.HUnitNumber}',{subData.HQtyMust},{subData.HQty},{subData.HWorkerID},'{subData.HWorkerNumber}',{subData.HSourceID},'{subData.HSourceNumber}',{subData.HTimes},{subData.HBadQty},{subData.HBadCount},{subData.HQPQty},{subData.HWasterQty},'{subData.HRemark}',{subData.HSourceInterID},{subData.HSourceEntryID},'{subData.HSourceBillNo}','{subData.HSourceBillType}',{subData.HICMOInterID},{subData.HICMOEntryID},'{subData.HICMOBillNo}',{subData.HSeOrderInterID},{subData.HSeOrderEntryID},'{subData.HSeOrderBillNo}',{subData.HRelationQty},{subData.HRelationMoney},'{subData.HSplitNO}','{subData.HBarCode}',{subData.HWhID},{subData.HSPID},'{subData.HBatChNo}',{subData.HAuxPropID},'{subData.HMTONo}','{subData.HPlanMode}',{subData.HERPInterID},{subData.HERPEntryID},'{subData.HOWNERTYPEID}','{subData.HISENTRUST}',{subData.HSTOCKINORGID},{subData.HOWNERID},'{subData.HCHECKPRODUCT}','{subData.HQAIP}',{subData.HCOSTRATE},'{subData.HISBACKFLUSH}','{subData.HREQSRC}','{subData.HREQBILLNO}',{subData.HREQBILLID},{subData.HREQENTRYSEQ},{subData.HREQENTRYID},{subData.HMOMAINENTRYID},{subData.HSTOCKINQUASELQTY},'{subData.HPRODUCTTYPE}','{subData.HPROJECTNO}',{subData.HICMOENTRYSEQ},{subData.HSEQ},'{subData.HPRODUCEDATE}','{subData.HEXPIRYDATE}',{subData.HBASEUNITID},{subData.HDEPTID},{subData.HGroupID},'{subData.HDESCRIPTION}'
+                  )";
+
+                        oCN.RunProc(sql);
+                    }
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍗曟嵁鍚屾鎴愬姛锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                    #endregion
+                }
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁璇诲彇澶辫触锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1