1
duhe
2024-07-08 69f3ee1b7f46a7f680002d10e6b39cf8d664a4f4
WebAPI/Controllers/Éú²ú¹ÜÀí/ÖÊÁ¿»ã±¨µ¥/Sc_QualityReportBillController.cs
@@ -631,7 +631,7 @@
        #region æäº¤ä¿å­˜ï¼Œå­˜ä¸»å­è¡¨åŠæ˜Žç»†è¡¨
        [Route("Sc_QualityReportBill/set_SaveBill")]
        [HttpGet]
        public object set_SaveBill(long HInterID,string HBillNo, string HChecker,string HBadReasonHQty)
        public object set_SaveBill(long HInterID,string HBillNo, string HChecker)
        {
            try
            {
@@ -658,8 +658,18 @@
                    return objJsonResult;
                }
                //=========================================================
                //保存
                oCN.RunProc("exec h_p_save_Sc_QualityReportBill " + HInterID+",'"+ HBadReasonHQty +"'");
                //保存  æ‰¹é‡ä¿å­˜å…ˆçœ‹å­è¡¨æ˜¯å¦æœ‰æ•°æ®,有数据就进 å­˜å…¥ä¸»è¡¨  æ˜Žç»†è¡¨    æ²¡æœ‰å°±å­˜å‚¨ä¸»å­æ˜Žç»†è¡¨
                string sql = "select * from Sc_QualityReportBillSub where HInterID = '" + HInterID + "'";
                ds = oCN.RunProcReturn(sql, "Sc_QualityReportBillSub");
                if (ds.Tables[0].Rows.Count>0)
                {
                    oCN.RunProc("exec h_p_save_Sc_QualityReportBillSum " + HInterID + "");
                }
                else
                {
                    oCN.RunProc("exec h_p_save_Sc_QualityReportBill " + HInterID + "");
                }
                //判断是否允许保存,不允许则回滚
                ds = oCN.RunProcReturn("exec h_p_JIT_ICMOBillQualityStatus_SaveCtrl", "h_p_JIT_ICMOBillQualityStatus_SaveCtrl");
                if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
@@ -739,6 +749,101 @@
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ä¸è‰¯é‡‡é›†æ‰¹é‡æ±‡æŠ¥ æ–°å¢ž
        [Route("Sc_QualityReportBill/SaveSc_QualityReportBillSub")]
        [HttpPost]
        public object SaveSc_QualityReportBillSub([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();                             //子表1数据
            string refSav = sArray[2].ToString();                           //操作方式
            string msg4 = sArray[3].ToString();                             //用户
            DBUtility.ClsPub.CurUserName = msg4;
            ListModels oListModels = new ListModels();
            try
            {
                DAL.ClsSc_QualityReportBill oBill = new DAL.ClsSc_QualityReportBill();
                //表体数据
                //按 },{来拆分数组 //去掉【和】
                msg3 = msg3.Substring(1, msg3.Length - 2);
                msg3 = msg3.Replace("\\", "");
                msg3 = msg3.Replace("\n", "");  //\n
                List<Model.ClsSc_QualityReportBillSub> ls = new List<Model.ClsSc_QualityReportBillSub>();
                ls = oListModels.getObjectByJson_Sc_QualityReportBillSub(msg3);
                int i = 0;
                foreach (Model.ClsSc_QualityReportBillSub oSub in ls)
                {
                    i++;
                    oSub.HMakeDate = DateTime.Now;
                    oSub.HEntryID = i;
                    string subSql = "Insert into Sc_QualityReportBillSub " +
                 " (HInterID,HEntryID,HBillNo_bak,HRemark" +
                 ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                 ",HMaterID,HUnitID,HQty,HResult,HEmpID,HSourceID,HBadReasonID,HBadReasonNumber,HGroupID" +
                 ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcExchInterID,HProcExchEntryID,HProcExchBillNo" +
                 ",HBarCode,HReportType" +
                 ",HAddr,HMaker,HMakeDate" +
                 ") values(" +
                 "" + oSub.HInterID.ToString() + "" +
                 "," + oSub.HEntryID.ToString() + "" +
                 ",'" + oSub.HBillNo_bak + "'" +
                 ",'" + oSub.HRemark + "'" +
                 "," + oSub.HSourceInterID.ToString() + "" +
                 "," + oSub.HSourceEntryID.ToString() + "" +
                 ",'" + oSub.HSourceBillNo + "'" +
                 ",'" + oSub.HSourceBillType + "'" +
                 "," + oSub.HRelationQty.ToString() + "" +
                 "," + oSub.HRelationMoney.ToString() +
                 "," + oSub.HMaterID.ToString() + "" +
                 "," + oSub.HUnitID.ToString() + "" +
                 ",'" + oSub.HQty.ToString() +
                 "','" + oSub.HResult + "'" +
                 "," + oSub.HEmpID.ToString() + "" +
                 "," + oSub.HSourceID.ToString() + "" +
                 "," + oSub.HBadReasonID.ToString() + "" +
                 ",'" + oSub.HBadReasonNumber.ToString() + "'" +
                 ",'" + oSub.HGroupID.ToString() + "'" +
                 "," + oSub.HICMOInterID.ToString() + "" +
                 "," + oSub.HICMOEntryID.ToString() + "" +
                 ",'" + oSub.HICMOBillNo + "'" +
                 "," + oSub.HProcExchInterID + "" +
                 "," + oSub.HProcExchEntryID + "" +
                 ",'" + oSub.HProcExchBillNo + "'" +
                 ",'" + oSub.HBadReasonNumber.ToString() + "'" +
                 ",'" + 1 +
                 "','" + oSub.HAddr + "'" +
                 ",'" + msg4 + "'" +
                 ",'" + oSub.HMakeDate.ToShortDateString() + "'" +
                 ") ";
                    oCN.RunProc(subSql);
                }
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
@@ -1667,6 +1772,59 @@
        }
        #endregion
        #region ç”Ÿäº§è´¨é‡æœˆæ±‡æŠ¥å•列表 æŸ¥è¯¢
        public class ReportWorkDemandPlanBill1
        {
            public string HYear;
            public string HWorkCenter;
            public string HName;
        }
        [Route("Sc_QualityReportBill/getSc_QualityReportBillMonth")]
        [HttpGet]
        public object getSc_QualityReportBillMonth(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ReportWorkDemandPlanBill1 Report = JsonConvert.DeserializeObject<ReportWorkDemandPlanBill1>(sWhere);
                ds = oCN.RunProcReturn($"exec h_p_Sc_StationOutBillMonth  '{Report.HYear}','{Report.HWorkCenter}','{Report.HName}'", "h_p_Sc_StationOutBillMonth");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}