1
duhe
2 天以前 78549fbacdf433bb0026a2c2f41351e9638cb3d4
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -2708,6 +2708,9 @@
                string HProductDesignSize = mainList[0].HProductDesignSize;  // 产品设计尺寸
                string HGaugeDesignSize = mainList[0].HGaugeDesignSize;  // 检具设计尺寸
                int HProductQTY = mainList[0].HProductQTY;  // 产品数量
                int HManagerID = mainList[0].HManagerID;  // 负责人
                double HPackV = mainList[0].HPackV;     //托体积
                double HStandardQtyForMouldInPack = mainList[0].HStandardQtyForMouldInPack; //托标准容器数量
                //保存前控制=========================================
                string HBillNote = "";
@@ -2745,7 +2748,7 @@
                ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" +
                ",HMouldClass,HNowWHID,HNowSPID,HInitLife,HMouldUseStatus,HCREATEORGID,HUSEORGID " +
                 ",HMouldLength,HMouldWidth,HMouldHeight,HMouldFoldHeight,HTransPackFlag,HSendPackFlag," +
                 "HUserID,HBrand,HCalibrationType,HLocation,HCalibrationDate,HCalibrationCycle,HProductDesignSize,HGaugeDesignSize,HProductQTY ) " +
                 "HUserID,HBrand,HCalibrationType,HLocation,HCalibrationDate,HCalibrationCycle,HProductDesignSize,HGaugeDesignSize,HProductQTY,HManagerID,HPackV,HStandardQtyForMouldInPack) " +
               " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
                "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" +
@@ -2758,7 +2761,7 @@
                ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID +
                ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "','" + HMouldUseStatus + "'," + HCREATEORGID + "," + HUSEORGID +
                "," + HMouldLength + "," + HMouldWidth + "," + HMouldHeight + "," + HMouldFoldHeight + "," + Convert.ToString(HTransPackFlag ? 1 : 0) + "," + Convert.ToString(HSendPackFlag ? 1 : 0) + "," +
                "'" + HUserID + "','" + HBrand + "','" + HCalibrationType + "','" + HLocation + "','" + HCalibrationDate + "','" + HCalibrationCycle + "','" + HProductDesignSize + "','" + HGaugeDesignSize + "','" + HProductQTY + "') ");
                "'" + HUserID + "','" + HBrand + "','" + HCalibrationType + "','" + HLocation + "','" + HCalibrationDate + "','" + HCalibrationCycle + "','" + HProductDesignSize + "','" + HGaugeDesignSize + "','" + HProductQTY + "','" + HManagerID + "','" + HPackV + "','" + HStandardQtyForMouldInPack + "') ");
                //子表
                oCN.RunProc("Insert into Gy_MouldFileSub " +
@@ -2891,7 +2894,6 @@
                string HUpDater = mainList[0].HUpDater;
                string HMaterNumber = mainList[0].HMaterNumber;
                string HSupNumber = mainList[0].HSupNumber;
                long HPrintQty = mainList[0].HPrintQty;
                string HMouldOWNER = mainList[0].HMouldOWNER;
                string HSaveLife = mainList[0].HSaveLife;
                int HCaveQty = mainList[0].HCaveQty;
@@ -2918,11 +2920,14 @@
                string HBrand = mainList[0].HBrand;  // 品牌
                string HCalibrationType = mainList[0].HCalibrationType;  // 校准类型 (内/外校)
                string HLocation = mainList[0].HLocation;  // 位置
                DateTime HCalibrationDate = mainList[0].HCalibrationDate;  // 校准日期
                DateTime HCalibrationDate = mainList[0].HCalibrationDate != null ? mainList[0].HCalibrationDate: DateTime.Now; // 校准日期
                string HCalibrationCycle = mainList[0].HCalibrationCycle;  // 校准周期
                string HProductDesignSize = mainList[0].HProductDesignSize;  // 产品设计尺寸
                string HGaugeDesignSize = mainList[0].HGaugeDesignSize;  // 检具设计尺寸
                int HProductQTY = mainList[0].HProductQTY;  // 产品数量
                int HManagerID = mainList[0].HManagerID;  // 负责人
                double HPackV = mainList[0].HPackV;     //托体积
                double HStandardQtyForMouldInPack = mainList[0].HStandardQtyForMouldInPack; //托标准容器数量
                //若MAINDI重复则重新获取
                oCN.BeginTran();
@@ -2948,9 +2953,7 @@
                    return objJsonResult;
                }
                //=========================================================
                                //主表
                oCN.RunProc("UpDate Gy_MouldFileMain set  " +
                string sql= "UpDate Gy_MouldFileMain set  " +
                 " HBillNo='" + HBillNo + "'" +  //固定赋值===============
                 ",HDate='" + HDate + "'" +
                 ",HYear='" + HYear.ToString() + "'" +
@@ -2979,7 +2982,6 @@
                 ",HDeptID=" + HDeptID.ToString() +
                 ",HSupID=" + HSupID.ToString() +
                 ",HSupNumber='" + HSupNumber + "'" +
                 ",HPrintQty=" + HPrintQty.ToString() +
                 ",HMouldStatus='" + HMouldStatus + "'" +
                 ",HSaveLife='" + HSaveLife + "'" +
                 ",HWhID=" + HWHID.ToString() +
@@ -3021,6 +3023,87 @@
                 "',HProductDesignSize='" + HProductDesignSize +
                 "',HGaugeDesignSize='" + HGaugeDesignSize +
                 "',HProductQTY='" + HProductQTY +
                 "',HManagerID='" + HManagerID +
                 "',HPackV='" + HPackV +
                 "',HStandardQtyForMouldInPack='" + HStandardQtyForMouldInPack +
                 "' where HInterID=" + HInterID.ToString();
                LogService.Write(sql);
                //主表
                oCN.RunProc("UpDate Gy_MouldFileMain set  " +
                 " HBillNo='" + HBillNo + "'" +  //固定赋值===============
                 ",HDate='" + HDate + "'" +
                 ",HYear='" + HYear.ToString() + "'" +
                 ",HPeriod='" + HPeriod.ToString() + "'" +
                 ",HRemark='" + HRemark + "'" +
                 ",HUpDater='" + HUpDater + "'" +
                 ",HUpDateDate=getdate()" +
                 //========================================
                 ",HMouldNo='" + HMouldNo + "'" +
                 ",HName='" + HName + "'" +
                 ",HModel='" + HModel + "'" +
                 ",HModel2='" + HModel2 + "'" +
                 ",HDiameter='" + HDiameter + "'" +
                 ",HSubjoin='" + HSubjoin + "'" +
                 ",HSubjoin2='" + HSubjoin2 + "'" +
                 ",HPICNo='" + HPICNo + "'" +
                 ",HWorkMaterModel='" + HWorkMaterModel + "'" +
                 ",HMaterID=" + HMaterID.ToString() +
                 ",HUSEORGID=" + HUSEORGID.ToString() +
                 ",HMaterNumber='" + HMaterNumber + "'" +
                 ",HMouldClass='" + HMouldClass + "'" +
                 ",HMouldType=" + HMouleTypeID.ToString() +
                 ",HUnitID=" + HUnitID.ToString() +
                 ",HOutComDate='" + HOutComDate + "'" +
                 ",HOutComNo='" + HOutComNo + "'" +
                 ",HDeptID=" + HDeptID.ToString() +
                 ",HSupID=" + HSupID.ToString() +
                 ",HSupNumber='" + HSupNumber + "'" +
                 ",HMouldStatus='" + HMouldStatus + "'" +
                 ",HSaveLife='" + HSaveLife + "'" +
                 ",HWhID=" + HWHID.ToString() +
                 ",HRoutingID=" + HRoutingID.ToString() +
                 ",HBomID=" + HBOMID.ToString() +
                 ",HVersion='" + HVersion + "'" +
                 ",HSPGroupID=" + HSPGroupID.ToString() +
                 ",HSPID=" + HSPID.ToString() +
                 ",HDesignLife=" + HDesignLife.ToString() +
                 ",HCaveQty=" + HCaveQty.ToString() +
                 ",HUseLife=" + HUseLife.ToString() +
                 ",HLeaveLife=" + HLeaveLife.ToString() +
                 ",HProdQty=" + HProdQty.ToString() +
                 ",HMouldDotCheckRuleInterID=" + HMouldDotCheckRuleInterID.ToString() +
                 ",HMouldMaintainRuleInterID=" + HMouldMaintainRuleInterID.ToString() +
                 ",HMouldOWNER='" + HMouldOWNER + "'" +
                 ",HNowSupID=" + HNowSupID.ToString() +
                 ",HNowSupTypeID=" + HNowSupTypeID.ToString() +
                 ",HProdWeight=" + HProdWeight.ToString() +
                 ",HBarCode='" + HBarCode.ToString() + "'" +
                 ",HMadeSupID=" + HMadeSupID +
                 ",HNowWHID=" + HNowWHID +
                 ",HNowSPID=" + HNowSPID +
                 ",HTransPackFlag=" + Convert.ToString(HTransPackFlag ? 1 : 0) +
                 ",HSendPackFlag=" + Convert.ToString(HSendPackFlag ? 1 : 0) +
                 ",HMouldLength=" + HMouldLength +
                 ",HMouldWidth=" + HMouldWidth +
                 ",HMouldHeight=" + HMouldHeight +
                 ",HMouldFoldHeight=" + HMouldFoldHeight +
                 ",HInitLife='" + HInitLife +
                 "',HNextMainDate='" + HNextMainDate +
                 "',HMouldUseStatus='" + HMouldUseStatus +
                 "',HUserID='" + HUserID +
                 "',HBrand='" + HBrand +
                 "',HCalibrationType='" + HCalibrationType +
                 "',HLocation='" + HLocation +
                 "',HCalibrationDate='" + HCalibrationDate +
                 "',HCalibrationCycle='" + HCalibrationCycle +
                 "',HProductDesignSize='" + HProductDesignSize +
                 "',HGaugeDesignSize='" + HGaugeDesignSize +
                 "',HProductQTY='" + HProductQTY +
                 "',HManagerID='" + HManagerID +
                 "',HPackV='" + HPackV +
                 "',HStandardQtyForMouldInPack='" + HStandardQtyForMouldInPack +
                 "' where HInterID=" + HInterID.ToString());             
                oCN.RunProc("delete from Gy_MouldFileSub_SubMater where HInterID='" + HInterID + "'");
@@ -3235,7 +3318,7 @@
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from Gy_MouldFileMain where HInterID = " + hmainid + " and ISNULL(HChecker,'') <> ''", "Gy_MouldFileMain");
                ds = oCN.RunProcReturn("select * from Gy_MouldFileMain where HInterID = " + hmainid + " and ISNULL(HChecker,'') <> '' ", "Gy_MouldFileMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
@@ -3244,77 +3327,76 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oBill.DeleteBill(hmainid, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    oCN.BeginTran();
                    //删除前控制=========================================
                    ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_BeforeDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_BeforeDelCtrl");
                    if (ds == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除前判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                    oCN.RunProc("Delete From Gy_MouldFileSub_MaintainRule  where HInterID=" + hmainid);
                    oCN.RunProc("Delete From Gy_MouldFileSub_DotCheckRule  where HInterID=" + hmainid);
                    //删除后控制=========================================
                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_AfterDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_AfterDelCtrl");
                    if (ds2 == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除后判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                    oCN.Commit();
                    //写入日志
                    ClsPub.Add_Log("", "删除项目,代码:" + oBill.omodel.HMouldNo + ",名称:" + oBill.omodel.HName, ClsPub.CurUserName);
                    //更新上级为 末级
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除成功";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                ds = oCN.RunProcReturn("select * from Gy_MouldFileMain where HInterID = " + hmainid + "  and HPrintQty>0", "Gy_MouldFileMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除失败";
                    objJsonResult.Message = "删除失败!单据已被打印!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //ds = oCN.RunProcReturn("delete from Gy_Department where HItemID =  " + HItemID, "Gy_Department");
                oCN.BeginTran();
                //删除前控制=========================================
                ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_BeforeDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_BeforeDelCtrl");
                if (ds == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除前判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                oCN.RunProc("Delete From Gy_MouldFileMain  where HInterID=" + hmainid);
                oCN.RunProc("Delete From Gy_MouldFileSub  where HInterID=" + hmainid);
                oCN.RunProc("Delete From Gy_MouldFileSub2  where HInterID=" + hmainid);
                oCN.RunProc("Delete From Gy_MouldFileSub_SubMater  where HInterID=" + hmainid);
                oCN.RunProc("Delete From Gy_MouldFileSub_MaintainRule  where HInterID=" + hmainid);
                oCN.RunProc("Delete From Gy_MouldFileSub_DotCheckRule  where HInterID=" + hmainid);
                //删除后控制=========================================
                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_AfterDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_AfterDelCtrl");
                if (ds2 == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除后判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                oCN.Commit();
                //写入日志
                ClsPub.Add_Log("", "删除模具档案,代码:" + oBill.omodel.HMouldNo + ",名称:" + oBill.omodel.HName, ClsPub.CurUserName);
                //更新上级为 末级
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
@@ -4027,6 +4109,8 @@
                DataSet ds = new DataSet();
                ds = oCN.RunProcReturn("select * from Gy_MouldFileMain where HInterID=" + HInterID, "Gy_MouldFileMain");
                DataRow dr = ds.Tables[0].Rows[0];
                dr["HPrintQty"] = 0;
                string Num = dr["HBarCode"].ToString();
                string Num1 = Num.Substring(0, (Num.Length) - 5);
                oCN.BeginTran();
@@ -4832,7 +4916,7 @@
                        "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty +
                        "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" +
                        ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID +
                        ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + " ) ");
                        ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "' ) ");
                    }
                    else
                    {
@@ -4922,11 +5006,23 @@
        public object UploadFile_Gy_MouldFilen()
        {
            string path = "";
            string HBillNo = HttpContext.Current.Request.Params["HBillNo"];  //单据号
            string HRemark = HttpContext.Current.Request.Params["HRemark"];  //备注
            string HUserName = HttpContext.Current.Request.Params["HUserName"];  //创建人
            HttpPostedFile files = HttpContext.Current.Request.Files["file"];
            string path = HttpContext.Current.Server.MapPath("~/../Files/Gy_MouldFilen/" + HBillNo);
            string Ret = "";
            if (oSystemParameter.ShowBill(ref Ret))
            {
                if (oSystemParameter.omodel.WMS_CampanyName == "凯贝奈特")
                {
                    path = "D:/网站发布/LAYUI/Files/Gy_MouldFilen/" + HBillNo;
                }
                else
                {
                    path = HttpContext.Current.Server.MapPath("~/../Files/Gy_MouldFilen/" + HBillNo);
                }
            }
            dynamic dyResult = UploadFile_Gy_MouldFilen(files, path, HBillNo, HRemark, HUserName);
            if (dyResult != null && dyResult.result == 1)
            {
@@ -4981,7 +5077,20 @@
                {
                    File.Delete(fileurl);      //删除指定文件
                    files.SaveAs(fileurl);
                    string StrPath = "/files/Gy_MouldFilen/" + HBillNo + "/" + filename;
                    string StrPath = "";
                    string Ret = "";
                    if (oSystemParameter.ShowBill(ref Ret))
                    {
                        if (oSystemParameter.omodel.WMS_CampanyName == "凯贝奈特")
                        {
                            StrPath = "D:/网站发布/LAYUI/Files/Gy_MouldFilen/" + HBillNo + "/" + filename;
                        }
                        else
                        {
                            StrPath = "/files/Gy_MouldFilen/" + HBillNo + "/" + filename;
                        }
                    }
                    if (File.Exists(fileurl))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -5041,7 +5150,19 @@
        [HttpGet]
        public object Gy_MouldFilen_Filelist(string HBillNo)
        {
            var url = fileip + "/Files/Gy_MouldFilen/" + HBillNo + "/";
            string Ret = "";
            var url = "";
            if (oSystemParameter.ShowBill(ref Ret))
            {
                if (oSystemParameter.omodel.WMS_CampanyName == "凯贝奈特")
                {
                    url = "D:/网站发布/LAYUI/Files/Gy_MouldFilen/" + HBillNo + "/";
                }
                else
                {
                    url = fileip + "/Files/Gy_MouldFilen/" + HBillNo + "/";
                }
            }
            try
            {
@@ -5075,9 +5196,7 @@
            try
            {
                oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
                string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/Gy_MouldFilen/" + HSourceBillNo), HFileName);
                File.Delete(fileurl);      //删除指定文件
                oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
@@ -5103,7 +5222,7 @@
        {
            try
            {
                ds = oCN.RunProcReturn($"select *,b.hname HMaterNumber from Gy_BarCodeBill a left join Gy_Material b on a.HMaterID=b.HItemID where HBarCode='{HbarCode}' ", "Gy_Material");
                ds = oCN.RunProcReturn($"select *,b.hnumber HMaterNumber,b.hname HMaterName_m from Gy_BarCodeBill a with(nolock) left join Gy_Material b with(nolock) on a.HMaterID=b.HItemID where HBarCode='{HbarCode}' ", "Gy_Material");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";