Admin
6 天以前 bd6818fc9d40f343547bafca0743658f3c0379dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 *所有关于Dt_general_info类的业务代码应在此处编写
*可使用repository.调用常用方法,获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Dt_general_infoService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using WIDESEA.Core.BaseProvider;
using WIDESEA.Core.Extensions.AutofacManager;
using WIDESEA.Entity.DomainModels;
using System.Linq;
using WIDESEA.Core.Utilities;
using System.Linq.Expressions;
using WIDESEA.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using WIDESEA.Services.IRepositories;
using System;
using WIDESEA.Services.Repositories;
 
namespace WIDESEA.Services.Services
{
    public partial class Dt_general_infoService
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly IDt_general_infoRepository _repository;//访问数据库
 
        [ActivatorUtilitiesConstructor]
        public Dt_general_infoService(
            IDt_general_infoRepository dbRepository,
            IHttpContextAccessor httpContextAccessor
            )
        : base(dbRepository)
        {
            _httpContextAccessor = httpContextAccessor;
            _repository = dbRepository;
            //多租户会用到这init代码,其他情况可以不用
            //base.Init(dbRepository);
        }
 
 
        /// <summary>
        /// 修改测量间隔时间
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public static WebResponseContent ModifyGapTime(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
 
            try
            {
                string gapTime = saveModel.MainData["gapTime"].ToString();
 
                Dt_general_info general_Info = Dt_general_infoRepository.Instance.FindFirst(x => true);
                general_Info.general_measure_gap = int.Parse(gapTime);
 
                Dt_general_infoRepository.Instance.Update(general_Info, true);
 
                content.OK();
            }
            catch(Exception ex)
            {
                content.Error(ex.Message);
            }
 
 
            return content;
        }
 
 
 
        /// <summary>
        /// 切换空托入库和组盘入库的模式
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public static WebResponseContent ChangeInboundModel(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
 
            try
            {
                string model = saveModel.MainData["model"].ToString();
 
                Dt_general_info general_Info = Dt_general_infoRepository.Instance.FindFirst(x => true);
                general_Info.general_box_empty_flag = model;
 
                Dt_general_infoRepository.Instance.Update(general_Info, true);
 
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
 
        /// <summary>
        /// 获取当前的入库模式,空托入库和实托入库
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public static WebResponseContent GetInboundModel()
        {
            WebResponseContent content = new WebResponseContent();
 
            try
            {
                Dt_general_info general_Info = Dt_general_infoRepository.Instance.FindFirst(x => true);
 
                string value = general_Info.general_box_empty_flag == "empty" ? "空托入库模式" : "轴承入库模式";
 
                content.OK(data: value);
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}