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;
@@ -38,6 +37,7 @@
        {
            try
            {
                List<object> a = new List<object>();
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOReportBillQuery", 1, false, user))
                {
@@ -50,21 +50,27 @@
                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变量会持有当前列的引用
                {
                    Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接         // 将列名和数据类型信息拼接成一个JSON格式的字符串
                    a.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = a;
                return objJsonResult;
                //}
                //else
@@ -84,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
@@ -120,7 +181,7 @@
                                            HUnitID, 计量单位代码 HUnitCode, 计量单位 HUnitName,HSourceID,生产资源代码 HSourceCode,生产资源 HSourceName,
                                            HWorkerid,操作员代码 HWorkerCode,操作员 HWorkerName,生产数量 HQty,表体备注 HRemark,
                                            HICMOInterID,HICMOEntryID,HICMOBillNo,HICMOInterID as HSourceInterID,HICMOEntryID as HSourceEntryID,
                                            HICMOBillNo as HSourceBillNo,3710 as HSourceBillType
                                            HICMOBillNo as HSourceBillNo,3710 as HSourceBillType,不良数量 HBadQty
                                            FROM h_v_IF_ICMOReportBillList_Edit"), "h_v_IF_ICMOReportBillList_Edit");
                    objJsonResult.code = "0";
@@ -137,7 +198,7 @@
                                            HWorkerid,操作员代码 HWorkerCode,操作员 HWorkerName,生产数量 HQty,表体备注 
                                            HRemark,HICMOInterID,HICMOEntryID,HICMOBillNo,
                                            HICMOInterID as HSourceInterID,HICMOEntryID as HSourceEntryID,
                                            HICMOBillNo as HSourceBillNo,3710 as HSourceBillType
                                            HICMOBillNo as HSourceBillNo,3710 as HSourceBillType,不良数量 HBadQty
                                            FROM h_v_IF_ICMOReportBillList_Edit where 1 = 1 ");
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_IF_ICMOReportBillList_Edit");
@@ -332,7 +393,6 @@
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
@@ -441,11 +501,8 @@
            }
        }
        #endregion
        #region 生产汇报单删除功能
        /// <summary>
        /// 模具处理领用单删除功能
        /// </summary>
        /// <returns></returns>
        #region 生产汇报单删除功能
        [Route("Sc_ICMOReportBill/DeltetICMOReportBill")]
        [HttpGet]
        public object DeltetMouldLifeChangeBill(string HInterID, string user)
@@ -793,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)
@@ -812,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;
@@ -825,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)
@@ -839,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;
@@ -1270,5 +1374,43 @@
        }
        #endregion
        #region 生产汇报单 根据主内码与子内码获取生产汇报单数据
        [Route("Sc_ICMOReportBill/loadSc_ICMOReportBill_Push")]
        [HttpGet]
        public object loadSc_ICMOReportBill_Push(long HInterID, long HSubID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_IF_ICMOReportBillList_Edit where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_ICMOReportBillList_Edit");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "未查询到源单信息!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    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;
            }
        }
        #endregion
    }
}