cnf
6 天以前 1b3db8f5683373dd8e179b006e7314783dd1f9db
WebApi/Gs.JJGZ/MesAttanConController.cs
@@ -1,14 +1,13 @@
using Gs.Toolbox;
using System.Data;
using System.Data.SqlClient;
using System.Dynamic;
using System.Text;
using Gs.Toolbox;
using Gs.Toolbox.ApiCore.Abstract.Mvc;
using Gs.Toolbox.ApiCore.Common.Mvc;
using Gs.Toolbox.ApiCore.Group;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Dynamic;
using System.Text;
using static Gs.Toolbox.UtilityHelper;
namespace Gs.JJGZ;
@@ -19,6 +18,7 @@
    private readonly IHttpContextAccessor _http;
    private readonly string _userCode, _userGuid, _orgFids;
    public MesAttanConController(IHttpContextAccessor httpContextAccessor)
    {
        _http = httpContextAccessor;
@@ -46,12 +46,15 @@
        m.list3 = new List<dynamic>();
        try
        {
            var parameters = new[] {
                    new SqlParameter("@inLineNo", lineNo),
                    new SqlParameter("@inDate", date),
                    new SqlParameter("@inOrgId", orgId)
                };
            var dsMain = DbHelperSQL.Query("EXEC prc_AttanCon_lst @inLineNo, @inDate, @inOrgId", parameters);
            var parameters = new[]
            {
                new SqlParameter("@inLineNo", lineNo),
                new SqlParameter("@inDate", date),
                new SqlParameter("@inOrgId", orgId)
            };
            var dsMain = DbHelperSQL.Query(
                "EXEC prc_AttanCon_lst @inLineNo, @inDate, @inOrgId",
                parameters);
            if (dsMain != null && dsMain.Tables.Count > 0)
            {
                var _tb = dsMain.Tables[0].TableToDynamicList();
@@ -70,14 +73,16 @@
        catch (Exception ex)
        {
            LogHelper.Debug(ToString(), ex.Message);
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "读取失败!");
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                "读取失败!");
        }
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
            "读取成功!");
    }
    /// <summary>
    /// 修改
    ///     修改
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
@@ -92,12 +97,13 @@
        foreach (var m in model.list)
        {
            var _line = m.GUID + _split
                                    + m.Hour + _split
                                    + m.Reason;
                               + m.Hour + _split
                               + m.Reason;
            if (_sb.Length > 0)
                _sb.Append("~");
            _sb.Append(_line);
        }
        dynamic mObj = new ExpandoObject();
        mObj.outMsg = "";
        mObj.outSum = -1;
@@ -145,10 +151,12 @@
                }
            }
        }
        if (mObj.outSum <= 0)
            return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, mObj.outMsg);
        return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, mObj.outMsg);
        if (mObj.outSum <= 0)
            return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception,
                mObj.outMsg);
        return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success,
            mObj.outMsg);
    }
@@ -168,14 +176,14 @@
        mObj.outMsg = "";
        using (var conn = new SqlConnection(DbHelperSQL.strConn))
        {
            using (var cmd = new SqlCommand("[prc_AttanCon_count]", conn))
            {
                try
                {
                    conn.Open();
                    cmd.CommandType = CommandType.StoredProcedure;
                    var parameters = new[] {
                    var parameters = new[]
                    {
                        new SqlParameter("@inLineNo", lineNo),
                        new SqlParameter("@inDate", date),
                        new SqlParameter("@inOrgId", orgId),
@@ -200,10 +208,12 @@
                }
            }
        }
        if (mObj.outSum <= 0)
            return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, mObj.outMsg);
        return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, mObj.outMsg);
        if (mObj.outSum <= 0)
            return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception,
                mObj.outMsg);
        return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success,
            mObj.outMsg);
    }
    /// <summary>
@@ -224,8 +234,9 @@
        try
        {
            // 假设提交就是更新某个字段
            string sql = $"UPDATE MES_JJGZ_KQHZ SET check_status='{_inFieldValue}',check_date = getdate(), check_user='{_userGuid}' WHERE Line_No='{lineNo}' and attenDate = '{attenDate}'";
            int rows = DbHelperSQL.ExecuteSql(sql);
            var sql =
                $"UPDATE MES_JJGZ_KQHZ SET check_status='{_inFieldValue}',check_date = getdate(), check_user='{_userGuid}' WHERE Line_No='{lineNo}' and attenDate = '{attenDate}'";
            var rows = DbHelperSQL.ExecuteSql(sql);
            m.outSum = rows;
            m.outMsg = rows > 0 ? "操作成功!" : "未更新任何数据";
        }
@@ -234,8 +245,10 @@
            LogHelper.Debug(ToString(), "EditModelSubmit error:" + ex.Message);
            m.outMsg = ex.Message;
            m.outSum = -1;
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, ex.Message);
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                ex.Message);
        }
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!");
    }
@@ -248,12 +261,14 @@
    public ReturnDto<ExpandoObject> GetTimeType([FromBody] dynamic model)
    {
        dynamic m = new ExpandoObject();
        string mainTable = "MES_JJGZ_TIMETYPE";
        var mainTable = "MES_JJGZ_TIMETYPE";
        try
        {
            string sqlMain = $"SELECT HourlyType 计时类型,HourlySalary 计时单价 FROM MES_JJGZ_JSSALARY WHERE CHECK_STATUS = 1";
            var sqlMain =
                "SELECT HourlyType 计时类型,HourlySalary 计时单价 FROM MES_JJGZ_JSSALARY WHERE CHECK_STATUS = 1";
            var dsMain = DbHelperSQL.Query(sqlMain);
            if (dsMain != null && dsMain.Tables.Count > 0 && dsMain.Tables[0].Rows.Count > 0)
            if (dsMain != null && dsMain.Tables.Count > 0 &&
                dsMain.Tables[0].Rows.Count > 0)
            {
                var _tb = dsMain.Tables[0].TableToDynamicList();
                m.list = _tb;
@@ -263,8 +278,10 @@
        {
            LogHelper.Debug(ToString(), ex.Message);
        }
        if (m != null)
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "读取成功!");
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
                "读取成功!");
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "读取失败!");
    }
@@ -279,9 +296,11 @@
        dynamic m = new ExpandoObject();
        try
        {
            string sqlMain = $"select line_no 产线,name 产线名称 from MES_WORKSHOP_LINE WHERE line_no IN (SELECT Line_No FROM Mes_DepartmentToLine )";
            var sqlMain =
                "select line_no 产线,name 产线名称 from MES_WORKSHOP_LINE WHERE line_no IN (SELECT Line_No FROM Mes_DepartmentToLine )";
            var dsMain = DbHelperSQL.Query(sqlMain);
            if (dsMain != null && dsMain.Tables.Count > 0 && dsMain.Tables[0].Rows.Count > 0)
            if (dsMain != null && dsMain.Tables.Count > 0 &&
                dsMain.Tables[0].Rows.Count > 0)
            {
                var _tb = dsMain.Tables[0].TableToDynamicList();
                m.list = _tb;
@@ -291,10 +310,10 @@
        {
            LogHelper.Debug(ToString(), ex.Message);
        }
        if (m != null)
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "读取成功!");
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
                "读取成功!");
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, "读取失败!");
    }
}