222
schangxiang@126.com
2025-05-18 4967c641bf731d3fd230cdcb84420f6837a1b7f2
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using CMS.Extensions.Abp.AspNetCore.Mvc.Filters;
using CMS.Framework.AspNetCore.Users;
using CMS.Plugin.PipeLineLems.Application.Contracts.Dtos.WorkPlan;
using CMS.Plugin.PipeLineLems.Application.Contracts.Services;
using CmsQueryExtensions.Entitys;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
 
namespace CMS.Plugin.PipeLineLems.Controller
{
    /// <summary>
    /// 作业计划服务
    /// </summary>
    [ApiController]
    [TypeFilter(typeof(CMSLanguageFilter))]
    [TypeFilter(typeof(CMSUowActionFilter))]
    [TypeFilter(typeof(CMSAuditActionFilter))]
    [TypeFilter(typeof(CMSExceptionFilter))]
    [Route("api/v{version:apiVersion}/PipeLineLems/[controller]")]
    public class WorkPlanPublicController : ControllerBase
    {
 
        private readonly IMesAppService _mesAppService;
        private readonly ICurrentUser _currentUser;
        private readonly Application.Implements.SharedService sharedService;
        private IServiceProvider _serviceProvider;
 
        /// <summary>
        /// Initializes a new instance of the <see cref="TestEntityNameController"/> class.
        /// </summary>
        /// <param name="testentitynameAppService">The testentityname application service.</param>
        public WorkPlanPublicController(IMesAppService mesAppService, ICurrentUser currentUser, Application.Implements.SharedService _sharedService,
            IServiceProvider serviceProvider)
        {
            _mesAppService = mesAppService;
            _currentUser = currentUser;
            sharedService = _sharedService;
            _serviceProvider = serviceProvider;
        }
 
        /// <summary>
        /// 获取生产计划.
        /// </summary>
        /// <param name="input">标识符.</param>
        /// <returns></returns>
        [HttpPost]
        public virtual async Task<MesOrderResponse> GetWorkPlanAsync([FromBody] List<WorkPlanInput> input)
        {
            return await _mesAppService.CreateAsync(input, "", "");
        }
 
        /// <summary>
        /// 分拣
        /// </summary>
        /// <param name="input">标识符.</param>
        /// <returns></returns>
        [Authorize]
        [HttpPost]
        [Route("Pick")]
        public virtual async Task<MesOrderResponse> Pick([FromBody] PickInput input)
        {
            try
            {
                MyCurrentUser myCurrentUser = new MyCurrentUser()
                {
                    UserAccount = _currentUser.UserAccount,
                    UserId = _currentUser.UserId
                };
                return await sharedService.CommonPick(_serviceProvider, input, myCurrentUser);
            }
            catch (Exception ex)
            {
                return new MesOrderResponse()
                {
                    Code = "400",
                    Message = ex.Message
                };
            }
        }
 
 
        /// <summary>
        /// 叫料
        /// </summary>
        /// <param name="input">标识符.</param>
        /// <returns></returns>
        [Authorize]
        [HttpPost]
        [Route("CallMaterial")]
        public virtual async Task<MesOrderResponse> CallMaterial([FromBody] CallMaterialByDataIdentifierInput input)
        {
            try
            {
                MyCurrentUser myCurrentUser = new MyCurrentUser()
                {
                    UserAccount = _currentUser.UserAccount,
                    UserId = _currentUser.UserId
                };
                return await sharedService.CallMaterial(input, _serviceProvider, myCurrentUser);
            }
            catch (Exception ex)
            {
                return new MesOrderResponse()
                {
                    Code = "400",
                    Message = ex.Message
                };
            }
        }
 
        /// <summary>
        /// 开工
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Authorize]
        [HttpPost]
        [Route("StartProduction")]
        public virtual async Task<MesOrderResponse> StartProduction([FromBody] StartProductionInput input)
        {
            try
            {
                MyCurrentUser myCurrentUser = new MyCurrentUser()
                {
                    UserAccount = _currentUser.UserAccount,
                    UserId = _currentUser.UserId
                };
                return await sharedService.StartProduction(input, _serviceProvider, myCurrentUser);
            }
            catch (Exception ex)
            {
                return new MesOrderResponse()
                {
                    Code = "400",
                    Message = ex.Message
                };
            }
        }
 
        /// <summary>
        /// 完工
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Authorize]
        [HttpPost]
        [Route("FinishProduction")]
        public virtual async Task<MesOrderResponse> FinishProduction([FromBody] CompleteAssemblyProcessInput input)
        {
            try
            {
                MyCurrentUser myCurrentUser = new MyCurrentUser()
                {
                    UserAccount = _currentUser.UserAccount,
                    UserId = _currentUser.UserId
                };
                return await sharedService.CompleteAssemblyProcess(_serviceProvider, input, myCurrentUser);
            }
            catch (Exception ex)
            {
                return new MesOrderResponse()
                {
                    Code = "400",
                    Message = ex.Message
                };
            }
        }
    }
}