chenhaozhe
1 天以前 14ae0e21c8660dbb3ac20a5b0d9db9b6dde3cfb9
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -90,11 +90,12 @@
                double HPeriod = DateTime.Now.Month;
                string HRemark = list[0].HRemark;//备注
                string HSourceName = list[0].HSourceName;//生产资源名称
                double HPieceQty = list[0].HPieceQty;//进站PCS数
                double HPieceQty = list[0].HPieceQty;//进站PCS数  件数
                double HWasterQty = list[0].HWasterQty;//报废数量
                double HPlanPieceQty = list[0].HPlanPieceQty;//进站PNL数
                double HBadPNL = list[0].HBadPNL;//报废PNL数
                long HICMOInterID = list[0].HICMOInterID;//任务单ID
                long HICMOEntryID = list[0].HICMOEntryID;//任务单ID
                string HICMOBillNo = list[0].HICMOBillNo;//任务单
                int HProcPlanInterID = 0;
                int HProcPlanEntryID = 0;
@@ -411,7 +412,7 @@
                    oCN.RunProc("Insert Into Sc_StationOutBillMain " +
                    "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" +
                    ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" +
                    ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
                    ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
                    ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID,HPayProcID" +
                    ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" +
                    ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
@@ -422,7 +423,7 @@
                    ") " +
                    " values('" + BillType + "','" + (OperationType == "5" ? "SUB" : HBillSubType)  + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",'"+ HDate + "','" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
                    "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
                    "," + HICMOInterID + "," + HICMOEntryID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
                    ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID +
                    "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + "," + HSourceID2 + "," + HSourceID3 + "," + HSourceID4 + "," + HSourceID5 +
                    "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" +
@@ -643,9 +644,18 @@
                    //判断客户为华舟包装 生成条码主档
                    else if (oSystemParameter.omodel.WMS_CampanyName == "华舟")
                    {
                        var objResult = Cj_StationOutBarCode_Save(HInterID);
                        var objResult = Cj_StationOutBarCode_Save(HInterID,1);
                    }
                }
                else if ("Modify".Equals(eventType))
                {
                    //判断客户为华舟包装 生成条码主档
                    if (oSystemParameter.omodel.WMS_CampanyName == "华舟")
                    {
                        var objResult = Cj_StationOutBarCode_Save(HInterID, 2);
                    }
                }
                sw.Stop();//结束计时
                LogService.Write($"11.参数查询结束,新增结束,用时" + sw.Elapsed);
                LogService.Write("END--出站单据保存结束,出站单号:" + HBillNo);
@@ -1355,88 +1365,187 @@
        #region [出站单生成条码主档]    
        [Route("Cj_StationOutBill/Cj_StationOutBarCode_Save")]
        [HttpPost]
        public object Cj_StationOutBarCode_Save(long HInterID)
        public object Cj_StationOutBarCode_Save(long HInterID, int Type)
        {
            try
            {
                ListModels oListModels = new ListModels();
                DAL.ClsGy_BarCodeBill_ChaiMa BillNew = new DAL.ClsGy_BarCodeBill_ChaiMa();
                DAL.ClsGy_BarCodeBill_ChaiMa BillNew = new DAL.ClsGy_BarCodeBill_ChaiMa();
                oCN.BeginTran();
                ds = oCN.RunProcReturn("select  * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
                if (ds != null || ds.Tables[0].Rows.Count > 0)
                // 如果Type为2,先删除老的条码记录
                if (Type == 2)
                {
                    string deleteSql = "DELETE FROM Gy_BarCodeBill WHERE HInterID = '" + HInterID + "'";
                    oCN.RunProc(deleteSql);
                }
                    string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " +
                  "HPrintQty, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HinitQty, HEndQty, HBarcodeQtys, HBarcodeNo, HDeptID, HWhID, HSPID, HRemark, " +
                  "HCusID, HCusType, HEndDate, HWorkLineName, HBarCodeDate, HSTOCKORGID, HOWNERID, HSeOrderBillNo, HGiveAwayFlag, HMaterName, HMaterModel, " +
                  "HPinfan, HAuxPropID, HMTONo, HInnerBillNo, HCoilNO, HFurnaceNO, HFactory, HAuxQty, HheatNO, HEmpID, HCusModel, HCusMaterName, HCheckEmpName, HZZRQ,HSupMaterNumber,HSupBatchNo" +
                  ") values (" +
                  "'" + ds.Tables[0].Rows[0]["HInterID"].ToString() + "', " +
                  "'1', " +
                  "'" + ds.Tables[0].Rows[0]["HBillNO"].ToString() + "', " +
                  "'唯一条码', " +
                  "'', " +
                  "'" + ds.Tables[0].Rows[0]["HMaterID"].ToString() + "', " +
                  "'0', " +
                  "'" + ds.Tables[0].Rows[0]["HQty"].ToString() + "', " +
                  "'', " +
                  "'', " +
                  "'" + ds.Tables[0].Rows[0]["HGroupID"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HMaker"].ToString() + "', getdate(), " +
                  "'0', " +
                  "'" + ds.Tables[0].Rows[0]["HICMOInterID"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HICMOEntryID"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HICMOBillNo"].ToString() + "', " +
                  "'3772', " +
                  "'0', " +
                  "'0', " +
                  "'1', " +
                  "'1', " +
                  "'" + ds.Tables[0].Rows[0]["HDeptID"].ToString() + "', " +
                  "'0', " +
                  "'0', " +
                  "'" + ds.Tables[0].Rows[0]["HRemark"].ToString() + "', " +
                  "'0', " +
                  "'', " +
                  "getdate(), " +
                  "'', " +
                  "getdate(), " +
                  "'" + ds.Tables[0].Rows[0]["HPRDORGID"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HPRDORGID"].ToString() + "', " +
                  "'', " +
                  "'0', " +
                  "'', " +
                  "'', " +
                  "'', " +
                  "'0', " +
                  "'', " +
                  "'', " +
                  "'', " +
                  "'', " +
                  "'', " +
                  "'0', " +
                  "'', " +
                  "'" + ds.Tables[0].Rows[0]["HEmpID"].ToString() + "', " +
                  "'', " +
                  "'', " +
                  "'', " +
                  "'', " +
                  "'', " +
                  "''" +
                  ")";
                    //插入拆分条码
                    oCN.RunProc(sql);
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                // 查询 HQty、HPieceQty 和 重量字段
                DataSet dsPiece = oCN.RunProcReturn("select HPieceQty, HQty, HWeight from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
                if (dsPiece == null || dsPiece.Tables[0].Rows.Count == 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!未查询到条码信息";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                decimal HPieceQty = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HPieceQty"]);
                decimal HQty = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HQty"]);
                decimal totalWeight = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HWeight"]);
                if (HPieceQty <= 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!件数必须大于0";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                if (totalWeight <= 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!重量必须大于0";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                // 固定生成指定件数的条码
                int barcodeCount = (int)HPieceQty;  // HPieceQty 作为条码件数
                // 计算每张条码的基础数量和基础重量
                decimal baseQtyPerPiece = Math.Floor(HQty / HPieceQty);
                decimal remainderQty = HQty % HPieceQty;
                /// 重量均分基础值与余数
                decimal baseWeightPerPiece = totalWeight / HPieceQty;
                decimal remainderWeight = totalWeight % HPieceQty;
                // 查询原始单据信息
                ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow row = ds.Tables[0].Rows[0];
                    // 循环生成条码
                    for (int i = 0; i < barcodeCount; i++)
                    {
                        // ====================== 修复数量计算 ======================
                        decimal currentQty;
                        if (barcodeCount == 1)
                        {
                            // 只有1件时,直接使用总数量,不做取整拆分
                            currentQty = HQty;
                        }
                        else
                        {
                            currentQty = baseQtyPerPiece;
                            // 有余数则前N条各加1(只针对整数余数场景)
                            if (i < remainderQty)
                            {
                                currentQty += 1;
                            }
                        }
                        // ====================== 修复重量计算 ======================
                        decimal currentWeight;
                        if (barcodeCount == 1)
                        {
                            currentWeight = totalWeight;
                        }
                        else
                        {
                            currentWeight = baseWeightPerPiece;
                            if (i < remainderWeight)
                            {
                                currentWeight += baseWeightPerPiece;
                            }
                        }
                        // 生成条码号
                        string barcodeNumber = row["HBillNO"].ToString() + (barcodeCount > 1 ? "-" + (i + 1).ToString() : "");
                        // 修改插入语句,添加HMaterialJQty和HMaterialMQty字段
                        string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HMaterialJQty, HMaterialMQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " +
                          "HPrintQty, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HinitQty, HEndQty, HBarcodeQtys, HBarcodeNo, HDeptID, HWhID, HSPID, HRemark, " +
                          "HCusID, HCusType, HEndDate, HWorkLineName, HBarCodeDate, HSTOCKORGID, HOWNERID, HSeOrderBillNo, HGiveAwayFlag, HMaterName, HMaterModel, " +
                          "HPinfan, HAuxPropID, HMTONo, HInnerBillNo, HCoilNO, HFurnaceNO, HFactory, HAuxQty, HheatNO, HEmpID, HCusModel, HCusMaterName, HCheckEmpName, HZZRQ, HSupMaterNumber, HSupBatchNo" +
                          ") values (" +
                          "'" + row["HInterID"].ToString() + "', " +
                          "'" + (i + 1).ToString() + "', " +  // HEntryID 改为序号
                          "'" + barcodeNumber + "', " +  // 使用带序号的条码号
                          "'唯一条码', " +
                          "'', " +
                          "'" + row["HMaterID"].ToString() + "', " +
                          "'0', " +
                          "'" + currentQty.ToString() + "', " +  // 使用当前条码的数量
                          "'" + currentWeight.ToString() + "', " +  // 净重
                          "'" + currentWeight.ToString() + "', " +  // 毛重(与净重相同)
                          "'', " +
                          "'', " +
                          "'" + row["HGroupID"].ToString() + "', " +
                          "'" + row["HMaker"].ToString() + "', getdate(), " +
                          "'0', " +
                          "'" + row["HICMOInterID"].ToString() + "', " +
                          "'" + row["HICMOEntryID"].ToString() + "', " +
                          "'" + row["HICMOBillNo"].ToString() + "', " +
                          "'3710', " +
                          "'0', " +
                          "'0', " +
                          "'1', " +
                          "'" + (i + 1).ToString() + "', " +  // HBarcodeNo 改为序号
                          "'" + row["HDeptID"].ToString() + "', " +
                          "'0', " +
                          "'0', " +
                          "'" + row["HRemark"].ToString() + "', " +
                          "'0', " +
                          "'', " +
                          "getdate(), " +
                          "'', " +
                          "'" + row["HDate"].ToString() + "', " +
                          "'" + row["HPRDORGID"].ToString() + "', " +
                          "'" + row["HPRDORGID"].ToString() + "', " +
                          "'', " +
                          "'0', " +
                          "'', " +
                          "'', " +
                          "'', " +
                          "'0', " +
                          "'', " +
                          "'', " +
                          "'', " +
                          "'', " +
                          "'', " +
                          "'0', " +
                          "'', " +
                          "'" + row["HEmpID"].ToString() + "', " +
                          "'', " +
                          "'', " +
                          "'', " +
                          "'', " +
                          "'', " +
                          "''" +
                          ")";
                        // 插入拆分条码
                        oCN.RunProc(sql);
                    }
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = barcodeCount;
                    objJsonResult.Message = "保存成功!共生成" + barcodeCount + "张条码";
                    objJsonResult.data = barcodeCount;
                    return objJsonResult;
                }
                else
                {
@@ -1451,7 +1560,7 @@
            catch (Exception e)
            {
                oCN.RollBack();
                oCN.RunProc("update Sc_StationOutBillMain set HInterFaceRemark =" + e.ToString() + ", HInterFaceStatus ='未生成' where HInterID=" + HInterID);
                oCN.RunProc("update Sc_StationOutBillMain set HInterFaceRemark ='" + e.ToString().Replace("'", "''") + "', HInterFaceStatus ='未生成' where HInterID=" + HInterID);
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
@@ -3683,15 +3792,15 @@
        #region 工序汇报单获取对应所以序列
        [Route("Cj_StationOutBill/getAllHSEQ")]
        [HttpGet]
        public object getAllHSEQ(string HInterID)
        public object getAllHSEQ(int HInterID)
        {
            try
            {
                //得到信息(委外标记为0时,流转标记为1时
                ds = oCN.RunProcReturn("select * from Sc_ProcessExchangeBillSEQ  where HInterID= " + HInterID, "Sc_ProcessExchangeBillSEQ");
                DataSet DS = oCN.RunProcReturn("select * from Sc_ProcessExchangeBillSEQ  where HInterID= " + HInterID, "Sc_ProcessExchangeBillSEQ");
                
                //写入信息
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -3702,7 +3811,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "[0000-1-037]Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.data = DS.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
@@ -3960,6 +4069,7 @@
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "";
@@ -3981,6 +4091,8 @@
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
@@ -4026,14 +4138,27 @@
                    return objJsonResult;
                }
                List<object> columnNameList = new List<object>();
                string sql1 = "select * from h_v_MES_StationOutBillList_SN where 1 = 1 ";
                string sql = sql1 + sWhere + "  order by 制单日期 desc";
                ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList_SN");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    LogService.Write(21231321);
                    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)
@@ -4754,6 +4879,259 @@
        #endregion
        #region 工序汇报,审核前修改
        //审核,带编辑功能
        [Route("Cj_StationOutBill/setOtherProperty")]
        [HttpPost]
        public object setOtherProperty([FromBody] JObject oMain)
        {
            try
            {
                var _value = oMain["oMain"].ToString();
                string msg1 = _value.ToString();
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string msg2 = "[" + sArray[0].ToString() + "]";
                string user = sArray[1].ToString();
                ////判断是否有编辑权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //审核权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "审核失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<StationBill> list1 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2);
                long HInterID = list1[0].HInterID;
                double HQty = list1[0].HQty;
                double HBadCount = list1[0].HBadCount;
                double HWasterQty = list1[0].HWasterQty;
                long HSourceID = list1[0].HSourceID;
                string HSourceName = list1[0].HSourceName;
                long HCenterID = list1[0].HCenterID;
                long HGroupID = list1[0].HGroupID;
                long HEmpID = list1[0].HEmpID;
                oCN.BeginTran();
                DataSet ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID=" + HInterID, "Sc_StationOutBillMain");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                {
                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                    //审核前控制================================================================================
                    string sql = "exec h_p_Sc_StationOutBill_BeforeCheckCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_BeforeCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //================================================================================
                    if (HQty > 0)
                    {
                        oCN.RunProc($"update Sc_StationOutBillMain set HBillStatus = 2, HQty={HQty},HBadCount='{HBadCount}',HWasterQty='{HWasterQty}',HSourceID='{HSourceID}',HCenterID='{HCenterID}',HGroupID={HGroupID},HEmpID={HEmpID},HChecker='{user}',HCheckDate=getdate() where HInterID={HInterID} ");
                    }
                    string sReturn = "";
                    //获取系统参数
                    oSystemParameter.ShowBill(ref sReturn);
                    //判断客户为天擎 同步金蝶工序汇报单
                    if (oSystemParameter.omodel.WMS_CampanyName == "天擎")
                    {
                        //同步前控制=========================================
                        ds = oCN.RunProcReturn("Exec  h_p_Sc_StationOutBill_BeforeSyncCtrl  " + HInterID.ToString() + ", '" + HBillNo + "','" + user + "'", " h_p_Sc_StationOutBill_BeforeSyncCtrl ");
                        if (ds == null)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "[0000-2-012]保存前判断失败!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "[0000-1-051]同步失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //=========================================================
                        if (oWebs.set_SaveStationOutBill_CLD(HInterID, HBillNo, user, ref DBUtility.ClsPub.sErrInfo))
                        {
                            oCN.Commit();
                            objJsonResult.code = "1";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "成功";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            oCN.RollBack();
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核修改成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    oCN.Commit();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    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 工序汇报自动生成进站接收单
        //工序汇报开工按钮自动开工
        [Route("Cj_StationOutBill/startTranslating")]
        [HttpGet]
        public object startTranslating(int HProcExchInterID,int HProcExchEntryID,int HOrgID,int HProcNo,string user)
        {
            try
            {
                oCN.BeginTran();
                //判断是否有编辑权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationInBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3790-2-003]开工单无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string HBillType = "3790";
                string HBillNo = "";
                Int64 HInterID = 0;//显示的字段
                HInterID = DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
                HBillNo = DBUtility.ClsPub.CreateBillCode(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                int HBillStatus = 0;
                string HMaker = user;
                int HYear = DateTime.Now.Year;
                double HPeriod = DateTime.Now.Month;
                string HRemark = "出战汇报单自动开工";//备注
                long HICMOInterID = 0;//任务单ID
                string HICMOBillNo = "";//任务单
                long HProcPlanInterID = 0;
                long HProcPlanEntryID = 0;
                string HProcPlanBillNo = "";
                long HMaterID = 1;//产品ID
                long HProcID = 1;//当前工序
                double HICMOQty = 0;//任务单数量
                double HPlanQty = 0;//流转卡数量
                long HSourceID = 0;//生产资源ID
                long HGroupID = 0;//班组ID
                long HDeptID = 0;
                long HEmpID = 0;//接收人ID
                string HBarCode = "";//条形码
                string HAddr = "";
                string HBarCodeMaker = "";
                long HSupID = 0;
                double HQty = 0;//接收数量
                double HPrice = 0;
                double HMoney = 0;
                double HPieceQty = 0;//接收件数
                string HSourceName = "";//生产资源名称
                long HCenterID = 0;//工作中心ID
                string HOrderProcNO = "";//订单跟踪号
                long HPRDOrgID = HOrgID;//组织ID
                double HmaterOutqty = 0;//白坯发布
                string HProcExchBillNo = "";//上料防错单单据号
                int HMainInterID = 0;//白坯发布
                oCN.RunProc("Insert Into Sc_StationInBillMain " +
                    "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
                    ",HYear,HPeriod,HRemark" +
                    ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
                    ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID" +
                    ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" +
                    ",HSupID,HQty,HPrice,HMoney,HPieceQty,HSourceName,HCenterID" +
                    ",HProcNo,HOrderProcNO,HMainInterID,HPRDOrgID" +
                    ",HmaterOutqty" +
                    ") " +
                    " values('" + HBillType + "','" + (HBillType) + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate()" +
                    "," + HYear + "," + HPeriod + ",'" + HRemark + "'" +
                    "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
                    ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID +
                    "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" +
                    "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HPieceQty + ",'" + HSourceName + "'," + HCenterID +
                    ",'" + HProcNo + "','" + HOrderProcNO + "','" + HMainInterID + "'," + HPRDOrgID +
                    "," + HmaterOutqty + ") ");
                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
    }
}