chenhaozhe
5 天以前 d516af1f95472c0a5f86ab3b789c7b1e3c1c8656
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -2584,11 +2584,8 @@
            }
        }
        #endregion
        /// <summary>
        /// 新增模具档案-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        #region[器具档案保存与修改保存方法]
        [Route("Gy_Mould_Edit/AddBill")]
        [HttpPost]
        public object AddBill([FromBody] JObject oMain)
@@ -2702,6 +2699,16 @@
                int HMouldHeight = mainList[0].HMouldHeight;          //高
                int HMouldFoldHeight = mainList[0].HMouldFoldHeight;  //折叠高度
                int HUserID = mainList[0].HUserID;  // 使用人(Gy_Employee)
                string HBrand = mainList[0].HBrand;  // 品牌
                string HCalibrationType = mainList[0].HCalibrationType;  // 校准类型 (内/外校)
                string HLocation = mainList[0].HLocation;  // 位置
                DateTime HCalibrationDate = mainList[0].HCalibrationDate;  // 校准日期
                string HCalibrationCycle = mainList[0].HCalibrationCycle;  // 校准周期
                string HProductDesignSize = mainList[0].HProductDesignSize;  // 产品设计尺寸
                string HGaugeDesignSize = mainList[0].HGaugeDesignSize;  // 检具设计尺寸
                int HProductQTY = mainList[0].HProductQTY;  // 产品数量
                //保存前控制=========================================
                string HBillNote = "";
                ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFileMain_BeforeSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MouldFileMain_BeforeSaveCtrl");
@@ -2737,19 +2744,21 @@
                ",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" +
                ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" +
                ",HMouldClass,HNowWHID,HNowSPID,HInitLife,HMouldUseStatus,HCREATEORGID,HUSEORGID " +
                 ",HMouldLength,HMouldWidth,HMouldHeight,HMouldFoldHeight,HTransPackFlag,HSendPackFlag ) " +
                 ",HMouldLength,HMouldWidth,HMouldHeight,HMouldFoldHeight,HTransPackFlag,HSendPackFlag," +
                 "HUserID,HBrand,HCalibrationType,HLocation,HCalibrationDate,HCalibrationCycle,HProductDesignSize,HGaugeDesignSize,HProductQTY ) " +
               " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
                        "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" +
                        ",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" +
                        ",'" + HSubjoin + "','" + HSubjoin2 + "','" + HPICNo + "','" + HWorkMaterModel + "'" +
                        "," + HMaterID + ",'" + HMaterNumber + "'," + HMouleTypeID + "," + HUnitID +
                        ",'" + HOutComDate + "','" + HOutComNo + "'," + HDeptID + "," + HSupID + ",'" + HSupNumber + "'" +
                        "," + 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 + "','" + HMouldUseStatus + "'," + HCREATEORGID + "," + HUSEORGID +
                        "," + HMouldLength + "," + HMouldWidth + "," + HMouldHeight + "," + HMouldFoldHeight + "," + Convert.ToString(HTransPackFlag ? 1 : 0) + "," + Convert.ToString(HSendPackFlag ? 1 : 0) + ") ");
                "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" +
                ",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" +
                ",'" + HSubjoin + "','" + HSubjoin2 + "','" + HPICNo + "','" + HWorkMaterModel + "'" +
                "," + HMaterID + ",'" + HMaterNumber + "'," + HMouleTypeID + "," + HUnitID +
                ",'" + HOutComDate + "','" + HOutComNo + "'," + HDeptID + "," + HSupID + ",'" + HSupNumber + "'" +
                "," + 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 + "','" + 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 + "') ");
                //子表
                oCN.RunProc("Insert into Gy_MouldFileSub " +
@@ -2796,6 +2805,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.HInterID = HInterID.ToString();
                objJsonResult.Message = null;
                objJsonResult.data = null;
                return objJsonResult;
@@ -2811,12 +2821,6 @@
            }
        }
        /// <summary>
        /// 修改单据-保存按钮
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Gy_Mould_Edit/AddBill1")]
        [HttpPost]
        public object AddBill1([FromBody] JObject oMain)
@@ -2908,6 +2912,18 @@
                int HMouldWidth = mainList[0].HMouldWidth;            //宽
                int HMouldHeight = mainList[0].HMouldHeight;          //高
                int HMouldFoldHeight = mainList[0].HMouldFoldHeight;  //折叠高度
                int HUserID = mainList[0].HUserID;  // 使用人(Gy_Employee)
                string HBrand = mainList[0].HBrand;  // 品牌
                string HCalibrationType = mainList[0].HCalibrationType;  // 校准类型 (内/外校)
                string HLocation = mainList[0].HLocation;  // 位置
                DateTime HCalibrationDate = mainList[0].HCalibrationDate;  // 校准日期
                string HCalibrationCycle = mainList[0].HCalibrationCycle;  // 校准周期
                string HProductDesignSize = mainList[0].HProductDesignSize;  // 产品设计尺寸
                string HGaugeDesignSize = mainList[0].HGaugeDesignSize;  // 检具设计尺寸
                int HProductQTY = mainList[0].HProductQTY;  // 产品数量
                //若MAINDI重复则重新获取
                oCN.BeginTran();
@@ -2996,12 +3012,16 @@
                 ",HInitLife='" + HInitLife +
                 "',HNextMainDate='" + HNextMainDate +
                 "',HMouldUseStatus='" + HMouldUseStatus +
                  "' where HInterID=" + HInterID.ToString());
                //修改子项目代码
                //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
                //将上级 为非末级
                // oCN.RunProc("Update Gy_Department set HEndflag=0 where HItemID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                 "',HUserID='" + HUserID +
                 "',HBrand='" + HBrand +
                 "',HCalibrationType='" + HCalibrationType +
                 "',HLocation='" + HLocation +
                 "',HCalibrationDate='" + HCalibrationDate +
                 "',HCalibrationCycle='" + HCalibrationCycle +
                 "',HProductDesignSize='" + HProductDesignSize +
                 "',HGaugeDesignSize='" + HGaugeDesignSize +
                 "',HProductQTY='" + HProductQTY +
                 "' where HInterID=" + HInterID.ToString());
                oCN.RunProc("delete from Gy_MouldFileSub_SubMater where HInterID='" + HInterID + "'");
                oCN.RunProc("delete from Gy_MouldFileSub_MaintainRule where HInterID='" + HInterID + "'");
@@ -3035,7 +3055,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "修改单据成功!";
                //objJsonResult.data = null;
                objJsonResult.HInterID = HInterID.ToString();
                return objJsonResult;
            }
            catch (Exception e)
@@ -3130,11 +3150,9 @@
            return objJsonResult;
        }
        /// <summary>
        /// 磨具档案修改按钮方法-计算下次保养/校正日期-获取档案最近一次的保养记录
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        #endregion
        #region [模具档案修改按钮方法-计算下次保养/校正日期-获取档案最近一次的保养记录]
        [Route("Gy_Mould_Edit/calculateHNextMainDate")]
        [HttpGet]
        public object calculateHNextMainDate(long HInterID)
@@ -3164,6 +3182,8 @@
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// 磨具档案修改按钮方法
@@ -3996,7 +4016,7 @@
        #region [模具档案批量生成]
        [Route("Gy_Mould/SaveBatchGen_MouldFile")]
        [HttpGet]
        public object SaveBatchGen_MouldFile(long HInterID, string StarNum, string EndNum)
        public object SaveBatchGen_MouldFile(long HInterID, string StarNum, string EndNum,string user)
        {
            int StarNum1 = int.Parse(StarNum);
            int EndNum1 = int.Parse(EndNum);
@@ -4049,10 +4069,10 @@
                        ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID" +
                        ") " +
                        " values('3899','3899'," + HItemID + ",'" + Num1 + j + "',getdate()" +
                        "," + dr["HYear"] + "," + dr["HPeriod"] + ",'" + dr["HRemark"] + "','" + dr["HMaker"] + "',getdate(),'" + Num1 + j +
                        "," + dr["HYear"] + "," + dr["HPeriod"] + ",'" + dr["HRemark"] + "','" + user + "',getdate(),'" + Num1 + j +
                        "','" + Num1 + j + "','" + dr["HName"] + "','" + dr["HModel"] + "','" + dr["HModel2"] + "','" + dr["HDiameter"] + "'" +
                        ",'" + dr["HSubjoin"] + "','" + dr["HSubjoin2"] + "','" + dr["HPICNo"] + "','" + dr["HWorkMaterModel"] + "'" +
                        "," + dr["HMaterID"] + ",'" + dr["HMaterNumber"] + "',0," + dr["HUnitID"] +
                        "," + dr["HMaterID"] + ",'" + dr["HMaterNumber"] + "',"+dr["HMouldType"]+"," + dr["HUnitID"] +
                        ",'" + dr["HOutComDate"] + "','" + dr["HOutComNo"] + "'," + dr["HDeptID"] + "," + dr["HSupID"] + ",'" + dr["HSupNumber"] + "'" +
                        "," + dr["HPrintQty"] + ",'" + dr["HMouldStatus"] + "'," + dr["HWHID"] + "," + dr["HRoutingID"] + ",'" + dr["HCaveQty"] +
                        "'," + dr["HBOMID"] + ",'" + dr["HVersion"] + "'," + dr["HSPGroupID"] + "," + dr["HSPID"] + ",'" + dr["HDesignLife"] + "','" + dr["HNowSupID"] + "','" + dr["HNowSupTypeID"] + "'" +
@@ -4896,6 +4916,185 @@
        #endregion
        #endregion
        #region 器具档案 文件上传
        [Route("Gy_MouldFileBIllMain/UploadFile_Gy_MouldFilen")]
        [HttpPost]
        public object UploadFile_Gy_MouldFilen()
        {
            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);
            dynamic dyResult = UploadFile_Gy_MouldFilen(files, path, HBillNo, HRemark, HUserName);
            if (dyResult != null && dyResult.result == 1)
            {
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "上传成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = dyResult.returnval;
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public dynamic UploadFile_Gy_MouldFilen(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName)
        {
            dynamic Result_Ob = new { result = 1, returnval = "上传成功!" };
            string filePath = Path.GetFullPath(files.FileName);//文件上传路径
            string fileExtension = Path.GetExtension(files.FileName);// 文件扩展名
            string filename = files.FileName;//文件名
            string fileSavePath = path;// 上传保存路径
            int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte
            int Maxsize = 40000 * 1024;//定义上传文件的最大空间大小为40M
            try
            {
                if (files == null || files.ContentLength <= 0)
                {
                    Result_Ob = new { result = 0, returnval = "文件不能为空!" };
                    return Result_Ob;
                }
                if (filesize >= Maxsize)
                {
                    Result_Ob = new { result = 0, returnval = "上传文件超过40M,不能上传!" };
                    return Result_Ob;
                }
                string fileurl = Path.Combine(fileSavePath, filename);
                if (Directory.Exists(fileurl) == true)  //如果存在重名文件就提示
                {
                    Result_Ob = new { result = 0, returnval = "存在同名文件!" };
                    return Result_Ob;
                }
                //删除数据表数据
                ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
                if (Directory.Exists(path))
                {
                    File.Delete(fileurl);      //删除指定文件
                    files.SaveAs(fileurl);
                    string StrPath = "/files/Gy_MouldFilen/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
                        //写入数据表
                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
                                    ",HFileClsID,HSourceBillNo" +
                                   ") values('"
                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
                                    "','" + 0 + "','" + HBillNo +
                                   "') ");
                    }
                    else
                    {
                        Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" };
                    }
                }
                else
                {
                    Directory.CreateDirectory(fileSavePath); //添加文件夹
                    files.SaveAs(fileurl);
                    string StrPath = "/files/Gy_MouldFilen/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
                        //写入数据表
                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
                                    ",HFileClsID,HSourceBillNo" +
                                   ") values('"
                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
                                    "','" + 0 + "','" + HBillNo +
                                   "') ");
                    }
                    else
                    {
                        Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" };
                    }
                }
            }
            catch (Exception e)
            {
                Result_Ob = new { result = 0, returnval = e.Message };
            }
            return Result_Ob;
        }
        /// <summary>
        /// 根据单据号查找上传文件列表
        /// </summary>
        /// <param name="sWhere"></param>
        /// <returns></returns>
        [Route("Gy_MouldFileBIllMain/Gy_MouldFilen_Filelist")]
        [HttpGet]
        public object Gy_MouldFilen_Filelist(string HBillNo)
        {
            var url = fileip + "/Files/Gy_MouldFilen/" + HBillNo + "/";
            try
            {
                ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url  from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 根据ID,单据号,文件名 删除文件
        /// </summary>
        /// <param name="sWhere"></param>
        /// <returns></returns>
        [Route("Gy_MouldFileBIllMain/Gy_MouldFilen_DeleteFilelist")]
        [HttpGet]
        public object Gy_MouldFilen_DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName)
        {
            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);      //删除指定文件
                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
        //根据条码找物料信息
        [Route("Gy_Material/findMaterialByNumber")]