qinchulong
2025-03-29 039a4a5433e7f80adc88b491b549e5d9486e4f9a
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
/*
 *所有关于Base_ware_location类的业务代码应在此处编写
*可使用repository.调用常用方法,获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*Base_ware_locationService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using WIDESEA_Services.IRepositories;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using System;
using WIDESEA_Common.Tools;
using WIDESEA_Core.ManageUser;
 
namespace WIDESEA_Services.Services
{
    public partial class base_ware_locationService
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly Ibase_ware_locationRepository _repository;//访问数据库
 
        [ActivatorUtilitiesConstructor]
        public base_ware_locationService(
            Ibase_ware_locationRepository dbRepository,
            IHttpContextAccessor httpContextAccessor
            )
        : base(dbRepository)
        {
            _httpContextAccessor = httpContextAccessor;
            _repository = dbRepository;
            //多租户会用到这init代码,其他情况可以不用
            //base.Init(dbRepository);
        }
        public override WebResponseContent Update(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Guid id =Guid.Parse(saveModel.MainData["id"].ToString());
                string upper_code = saveModel.MainData["upper_code"].ToString();
                string down_code = saveModel.MainData["down_code"].ToString();
                string area = saveModel.MainData["area"].ToString();
                string equipment_type = saveModel.MainData["equipment_type"].ToString();
                string name = saveModel.MainData["name"].ToString();
                int logic_layer = Convert.ToInt32(saveModel.MainData["logic_layer"].ToString());
                int logic_col = Convert.ToInt32(saveModel.MainData["logic_col"].ToString());
                int logic_row = Convert.ToInt32(saveModel.MainData["logic_row"].ToString());
                string location_state = saveModel.MainData["location_state"].ToString();
                int status = Convert.ToInt32(saveModel.MainData["status"].ToString());
                base_ware_location BaseWare = repository.FindFirst(x => x.id == id);
                if (BaseWare == null)
                {
                    content = WebResponseContent.Instance.Error($"未找到该数据,id:{id}");
                }
                else
                {
                    content = repository.DbContextBeginTransaction(() =>
                    {
                        BaseWare.upper_code = upper_code;
                        BaseWare.down_code = down_code;
                        BaseWare.area = area;
                        BaseWare.equipment_type = equipment_type;
                        BaseWare.name = name;
                        BaseWare.logic_layer = logic_layer;
                        BaseWare.logic_col = logic_col;
                        BaseWare.logic_row = logic_row;
                        BaseWare.location_state = location_state;
                        BaseWare.status = status;
                        repository.Update(BaseWare, true);
                        WriteLog.Info("人工更改货位状态").Write("货位编码:" + BaseWare.upper_code+"\t"+"货位状态:"+BaseWare.location_state + "\t" +"修改账号:"+ UserContext.Current.UserName + DateTime.Now, "人工更改货位状态");
                        return WebResponseContent.Instance.OK("货位信息修改成功");
                    });
                }
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error($"货位信息修改失败,错误消息:{ex.Message}");
            }
            return content;
        }
     }
}