duhe
2025-03-26 7eb2427db47b9cd9413a3ef51afd34658ed71c3d
WebAPI/Controllers/SCGL/Sc_ICMOReportBillController.cs
@@ -1,11 +1,10 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using SyntacticSugar.constant;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web.Http;
using WebAPI.Models;
@@ -51,13 +50,13 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_IF_ICMOReportBillList_Edit order by hmainid desc ", "h_v_IF_ICMOReportBillList_Edit");
                    ds = oCN.RunProcReturn("select * from h_v_IF_ICMOReportBillList order by hmainid desc ", "h_v_IF_ICMOReportBillList_Edit");
                }
                else
                {
                    string sql1 = "select * from h_v_IF_ICMOReportBillList_Edit where 1 = 1 ";
                    string sql1 = "select * from h_v_IF_ICMOReportBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc ";
                    ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit");
                    ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList");
                }
                foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用
                {
@@ -91,6 +90,61 @@
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 生产汇报单 分页列表
        [Route("Sc_ICMOReportBill/Sc_ICMOReportBillListPage")]
        [HttpGet]
        public json Sc_ICMOReportBillListPage(string sWhere, string user, int page, int size)
        {
            DataSet ds;
            json res = new json();
            try
            {
                List<object> columnNameList = new List<object>();
                //判断权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBillQuery", 3, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                sWhere = sWhere.Replace("'", "''");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_ICMOReportBillMainList " + page + "," + size + ",''", "h_p_Sc_ICMOReportBillMainList");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_ICMOReportBillMainList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_ICMOReportBillMainList");
                }
                //添加列名
                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列对象的列名
                }
                res.code = CodeConstant.SUCCEED;
                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                res.Message = "Sucess!";
                res.list = columnNameList;
                res.data = ds.Tables[0];
                return res;
            }
            catch (Exception e)
            {
                res.code = CodeConstant.FAIL;
                res.count = CountConstant.FAIL;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return res;
            }
        }
        #endregion
@@ -339,7 +393,6 @@
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
@@ -448,11 +501,8 @@
            }
        }
        #endregion
        #region 生产汇报单删除功能
        /// <summary>
        /// 模具处理领用单删除功能
        /// </summary>
        /// <returns></returns>
        #region 生产汇报单删除功能
        [Route("Sc_ICMOReportBill/DeltetICMOReportBill")]
        [HttpGet]
        public object DeltetMouldLifeChangeBill(string HInterID, string user)
@@ -800,12 +850,13 @@
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Sc_ICMOReportBillMain";
                oCN.BeginTran();//开始事务
                DataSet ds;
                DataSet ds1;
                //Type 1 关闭  2  反关闭
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
@@ -819,8 +870,32 @@
                            return objJsonResult;
                        }
                    }
                    //关闭前控制===============================================Begin===================================================================
                    sql = "exec h_p_Sc_ICMOReportBill_BeforeCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
                    ds1 = oCN.RunProcReturn(sql, "h_p_Sc_ICMOReportBill_BeforeUnCheckCtrl");
                    if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:关闭前前判断失败,无返回信息,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //关闭前控制===============================================End===================================================================
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_ICMOReportBill_AfterCloseCtrl",  user , ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
@@ -832,7 +907,6 @@
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
@@ -846,8 +920,31 @@
                            return objJsonResult;
                        }
                    }
                    //反关闭前控制===============================================Begin===================================================================
                    sql = "exec h_p_Sc_ICMOReportBill_BeforeUnCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
                    ds1 = oCN.RunProcReturn(sql, "h_p_Sc_ICMOReportBill_BeforeUnCheckCtrl");
                    if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:反关闭前前判断失败,无返回信息,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //反关闭前控制===============================================End===================================================================
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_ICMOReportBill_AfterUnCloseCtrl", user, ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;