feat: 添加MES设备动态凭证支持
实现MES设备配置管理功能,支持根据不同设备动态获取凭证:
1. 新增MES设备配置实体和服务接口
2. 在拆盘/组盘确认接口中添加设备名称参数
3. 实现MES接口的动态Token调用
4. 完善入库出站时的设备凭证处理
5. 添加设备配置SQL脚本和测试数据
| | |
| | | { |
| | | "tool_name": "Bash", |
| | | "tool_input_preview": "{\"command\":\"node -e \\\"\\nconst f=require('fs'),p=require('path'),h=require('os').homedir();\\nconst d=process.env.CLAUDE_CONFIG_DIR||p.join(h,'.claude');\\nconst cf=p.join(d,'.omc-config.json');\\nconst e...", |
| | | "error": "Exit code 1\n<anonymous_script>:1\r\n\r\n\r\nSyntaxError: Unexpected end of JSON input\r\n at JSON.parse (<anonymous>)\r\n at [eval]:5:38\r\n at runScriptInThisContext (node:internal/vm:219:10)\r\n at node:internal/process/execution:451:12\r\n at [eval]-wrapper:6:24\r\n at runScriptInContext (node:internal/process/execution:449:60)\r\n at evalFunction (node:internal/process/execution:283:30)\r\n at evalTypeScript (node:internal/process/execution:295:3)\r\n at node:internal/main/eval_string:71:...", |
| | | "timestamp": "2026-04-18T06:15:45.665Z", |
| | | "tool_name": "Read", |
| | | "tool_input_preview": "{\"file_path\":\"D:\\\\Git\\\\ShanMeiXinNengYuan\\\\Code\\\\WMS\\\\WIDESEA_WMSServer\\\\WIDESEA_TaskInfoService\\\\WCS\\\\TaskService.cs\"}", |
| | | "error": "File does not exist. Note: your current working directory is D:\\Git\\ShanMeiXinNengYuan\\Code.", |
| | | "timestamp": "2026-04-18T07:45:29.125Z", |
| | | "retry_count": 1 |
| | | } |
| | |
| | | { |
| | | "updatedAt": "2026-04-16T13:59:54.835Z", |
| | | "updatedAt": "2026-04-18T07:46:50.058Z", |
| | | "missions": [ |
| | | { |
| | | "id": "session:9007b9ea-1eb6-4d24-8fe7-2c3a949eac88:none", |
| | |
| | | "sourceKey": "session-stop:a93149b10e8b430e7" |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | "id": "session:f36717d7-c4c4-4816-8723-6f7d562203f6:none", |
| | | "source": "session", |
| | | "name": "none", |
| | | "objective": "Session mission", |
| | | "createdAt": "2026-04-18T06:36:59.451Z", |
| | | "updatedAt": "2026-04-18T07:46:50.058Z", |
| | | "status": "done", |
| | | "workerCount": 8, |
| | | "taskCounts": { |
| | | "total": 8, |
| | | "pending": 0, |
| | | "blocked": 0, |
| | | "inProgress": 0, |
| | | "completed": 8, |
| | | "failed": 0 |
| | | }, |
| | | "agents": [ |
| | | { |
| | | "name": "Explore:a1ab626", |
| | | "role": "Explore", |
| | | "ownership": "a1ab62633715919c8", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T06:39:31.702Z" |
| | | }, |
| | | { |
| | | "name": "general-purpose:ae116cb", |
| | | "role": "general-purpose", |
| | | "ownership": "ae116cb86a435866d", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T06:50:41.503Z" |
| | | }, |
| | | { |
| | | "name": "general-purpose:a4e061e", |
| | | "role": "general-purpose", |
| | | "ownership": "a4e061e4a6d17c682", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T06:52:02.047Z" |
| | | }, |
| | | { |
| | | "name": "general-purpose:afdf6ef", |
| | | "role": "general-purpose", |
| | | "ownership": "afdf6efad435c036a", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T06:50:50.428Z" |
| | | }, |
| | | { |
| | | "name": "general-purpose:ab1f8d2", |
| | | "role": "general-purpose", |
| | | "ownership": "ab1f8d2625bd8a667", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T06:54:35.702Z" |
| | | }, |
| | | { |
| | | "name": "general-purpose:a99f2fa", |
| | | "role": "general-purpose", |
| | | "ownership": "a99f2fa258ad9b5a1", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T06:50:30.602Z" |
| | | }, |
| | | { |
| | | "name": "general-purpose:aa71986", |
| | | "role": "general-purpose", |
| | | "ownership": "aa71986c72a8dd1f4", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T07:46:50.058Z" |
| | | }, |
| | | { |
| | | "name": "general-purpose:aadbd70", |
| | | "role": "general-purpose", |
| | | "ownership": "aadbd702e8fdf756c", |
| | | "status": "done", |
| | | "currentStep": null, |
| | | "latestUpdate": "completed", |
| | | "completedSummary": null, |
| | | "updatedAt": "2026-04-18T07:46:15.279Z" |
| | | } |
| | | ], |
| | | "timeline": [ |
| | | { |
| | | "id": "session-stop:ab1f8d2625bd8a667:2026-04-18T06:54:35.702Z", |
| | | "at": "2026-04-18T06:54:35.702Z", |
| | | "kind": "completion", |
| | | "agent": "general-purpose:ab1f8d2", |
| | | "detail": "completed", |
| | | "sourceKey": "session-stop:ab1f8d2625bd8a667" |
| | | }, |
| | | { |
| | | "id": "session-start:aa71986c72a8dd1f4:2026-04-18T07:45:17.089Z", |
| | | "at": "2026-04-18T07:45:17.089Z", |
| | | "kind": "update", |
| | | "agent": "general-purpose:aa71986", |
| | | "detail": "started general-purpose:aa71986", |
| | | "sourceKey": "session-start:aa71986c72a8dd1f4" |
| | | }, |
| | | { |
| | | "id": "session-start:aadbd702e8fdf756c:2026-04-18T07:45:17.153Z", |
| | | "at": "2026-04-18T07:45:17.153Z", |
| | | "kind": "update", |
| | | "agent": "general-purpose:aadbd70", |
| | | "detail": "started general-purpose:aadbd70", |
| | | "sourceKey": "session-start:aadbd702e8fdf756c" |
| | | }, |
| | | { |
| | | "id": "session-stop:aadbd702e8fdf756c:2026-04-18T07:46:15.279Z", |
| | | "at": "2026-04-18T07:46:15.279Z", |
| | | "kind": "completion", |
| | | "agent": "general-purpose:aadbd70", |
| | | "detail": "completed", |
| | | "sourceKey": "session-stop:aadbd702e8fdf756c" |
| | | }, |
| | | { |
| | | "id": "session-stop:aa71986c72a8dd1f4:2026-04-18T07:46:50.058Z", |
| | | "at": "2026-04-18T07:46:50.058Z", |
| | | "kind": "completion", |
| | | "agent": "general-purpose:aa71986", |
| | | "detail": "completed", |
| | | "sourceKey": "session-stop:aa71986c72a8dd1f4" |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | } |
| | |
| | | "status": "completed", |
| | | "completed_at": "2026-04-16T13:59:54.835Z", |
| | | "duration_ms": 111569 |
| | | }, |
| | | { |
| | | "agent_id": "a1ab62633715919c8", |
| | | "agent_type": "Explore", |
| | | "started_at": "2026-04-18T06:36:59.451Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T06:39:31.702Z", |
| | | "duration_ms": 152251 |
| | | }, |
| | | { |
| | | "agent_id": "ae116cb86a435866d", |
| | | "agent_type": "general-purpose", |
| | | "started_at": "2026-04-18T06:49:33.031Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T06:50:41.503Z", |
| | | "duration_ms": 68472 |
| | | }, |
| | | { |
| | | "agent_id": "a4e061e4a6d17c682", |
| | | "agent_type": "general-purpose", |
| | | "started_at": "2026-04-18T06:49:33.090Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T06:52:02.047Z", |
| | | "duration_ms": 148957 |
| | | }, |
| | | { |
| | | "agent_id": "afdf6efad435c036a", |
| | | "agent_type": "general-purpose", |
| | | "started_at": "2026-04-18T06:49:33.151Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T06:50:50.428Z", |
| | | "duration_ms": 77277 |
| | | }, |
| | | { |
| | | "agent_id": "ab1f8d2625bd8a667", |
| | | "agent_type": "general-purpose", |
| | | "started_at": "2026-04-18T06:49:33.209Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T06:54:35.702Z", |
| | | "duration_ms": 302493 |
| | | }, |
| | | { |
| | | "agent_id": "a99f2fa258ad9b5a1", |
| | | "agent_type": "general-purpose", |
| | | "started_at": "2026-04-18T06:49:33.266Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T06:50:30.602Z", |
| | | "duration_ms": 57336 |
| | | }, |
| | | { |
| | | "agent_id": "aa71986c72a8dd1f4", |
| | | "agent_type": "general-purpose", |
| | | "started_at": "2026-04-18T07:45:17.089Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T07:46:50.058Z", |
| | | "duration_ms": 92969 |
| | | }, |
| | | { |
| | | "agent_id": "aadbd702e8fdf756c", |
| | | "agent_type": "general-purpose", |
| | | "started_at": "2026-04-18T07:45:17.153Z", |
| | | "parent_mode": "none", |
| | | "status": "completed", |
| | | "completed_at": "2026-04-18T07:46:15.279Z", |
| | | "duration_ms": 58126 |
| | | } |
| | | ], |
| | | "total_spawned": 77, |
| | | "total_completed": 74, |
| | | "total_spawned": 82, |
| | | "total_completed": 82, |
| | | "total_failed": 0, |
| | | "last_updated": "2026-04-16T13:59:54.939Z" |
| | | "last_updated": "2026-04-18T07:46:50.164Z" |
| | | } |
| | |
| | | /// 彿çä»»å¡å
¨é¨å宿¶è°ç¨ï¼ä¸æ¬¡æ§ä¸ä¼ æ´ä¸ªæççè§£ç»æ°æ®å° MESã |
| | | /// </remarks> |
| | | /// <param name="palletCode">æºæçå·</param> |
| | | /// <param name="deviceName">设å¤åç§°ï¼ç¨äºä¼ éå° WMS</param> |
| | | /// <returns>HTTP ååºç»æ</returns> |
| | | public HttpResponseResult<WebResponseContent> PostSplitPalletConfirmAsync(string palletCode) |
| | | public HttpResponseResult<WebResponseContent> PostSplitPalletConfirmAsync(string palletCode, string deviceName) |
| | | { |
| | | var request = new { PalletCode = palletCode }; |
| | | var request = new { PalletCode = palletCode, DeviceName = deviceName }; |
| | | return _httpClientHelper.Post<WebResponseContent>(nameof(ConfigKey.SplitPalletConfirm), request.ToJson()); |
| | | } |
| | | |
| | |
| | | /// å½ç»çä»»å¡å
¨é¨æ¾å®æ¶è°ç¨ï¼ä¸æ¬¡æ§ä¸ä¼ æ´ä¸ªæççç»å®æ°æ®å° MESã |
| | | /// </remarks> |
| | | /// <param name="palletCode">ç®æ æçå·</param> |
| | | /// <param name="deviceName">设å¤åç§°ï¼ç¨äºä¼ éå° WMS</param> |
| | | /// <returns>HTTP ååºç»æ</returns> |
| | | public HttpResponseResult<WebResponseContent> PostGroupPalletConfirmAsync(string palletCode) |
| | | public HttpResponseResult<WebResponseContent> PostGroupPalletConfirmAsync(string palletCode, string deviceName) |
| | | { |
| | | var request = new { PalletCode = palletCode }; |
| | | var request = new { PalletCode = palletCode, DeviceName = deviceName }; |
| | | return _httpClientHelper.Post<WebResponseContent>(nameof(ConfigKey.GroupPalletConfirm), request.ToJson()); |
| | | } |
| | | } |
| | |
| | | { |
| | | // è°ç¨æ¹éæç确认æ¥å£ï¼æ¢çåå®é¶æ®µï¼ |
| | | var sourcePallet = state.CurrentTask.RobotSourceAddressPalletCode; |
| | | var confirmResult = _taskProcessor.PostSplitPalletConfirmAsync(sourcePallet); |
| | | var confirmResult = _taskProcessor.PostSplitPalletConfirmAsync(sourcePallet, state.RobotCrane?.DeviceName); |
| | | if (!confirmResult.IsSuccess) |
| | | { |
| | | QuartzLogger.Error($"æ¹éæç确认失败: {confirmResult.ErrorMessage}", state.RobotCrane?.DeviceName ?? "Unknown"); |
| | |
| | | { |
| | | // è°ç¨æ¹éæç确认æ¥å£ |
| | | var sourcePallet = state.CurrentTask.RobotSourceAddressPalletCode; |
| | | var confirmResult = _taskProcessor.PostSplitPalletConfirmAsync(sourcePallet); |
| | | var confirmResult = _taskProcessor.PostSplitPalletConfirmAsync(sourcePallet, state.RobotCrane?.DeviceName); |
| | | if (!confirmResult.IsSuccess) |
| | | { |
| | | QuartzLogger.Error($"æ¹éæç确认失败: {confirmResult.ErrorMessage}", state.RobotCrane?.DeviceName ?? "Unknown"); |
| | |
| | | { |
| | | // è°ç¨æ¹éç»ç确认æ¥å£ï¼æ¢çæ¾å®é¶æ®µï¼ |
| | | var targetPallet = state.CurrentTask.RobotTargetAddressPalletCode; |
| | | var confirmResult = _taskProcessor.PostGroupPalletConfirmAsync(targetPallet); |
| | | var confirmResult = _taskProcessor.PostGroupPalletConfirmAsync(targetPallet, state.RobotCrane?.DeviceName); |
| | | if (!confirmResult.IsSuccess) |
| | | { |
| | | QuartzLogger.Error($"æ¹éç»ç确认失败: {confirmResult.ErrorMessage}", state.RobotCrane?.DeviceName ?? "Unknown"); |
| | |
| | | { |
| | | // è°ç¨æ¹éç»ç确认æ¥å£ |
| | | //var targetPallet = state.CurrentTask.RobotTargetAddressPalletCode; |
| | | //var confirmResult = _taskProcessor.PostGroupPalletConfirmAsync(targetPallet); |
| | | //if (!confirmResult.IsSuccess) |
| | | //{ |
| | | // QuartzLogger.Error($"æ¹éç»ç确认失败: {confirmResult.ErrorMessage}", state.RobotCrane?.DeviceName ?? "Unknown"); |
| | | //} |
| | | //_taskProcessor.PostGroupPalletConfirmAsync(targetPallet, state.RobotCrane?.DeviceName); |
| | | |
| | | // å¤çå
¥åºä»»å¡åä¼ |
| | | // useSourceAddress: false 表示使ç¨ç®æ å°åï¼ç»çåºæ¯ï¼ |
| | |
| | | }; |
| | | } |
| | | |
| | | private HttpRequestConfig BuildConfig(string token) |
| | | { |
| | | return new HttpRequestConfig |
| | | { |
| | | Headers = new Dictionary<string, string> |
| | | { |
| | | { "Authorization", token } |
| | | }, |
| | | TimeoutMs = 30000, |
| | | MaxRetryCount = 0, |
| | | EnableLogging = true |
| | | }; |
| | | } |
| | | |
| | | private HttpResponseResult<MesResponse> Post<T>(string url, T request) |
| | | { |
| | | string json = JsonConvert.SerializeObject(request); |
| | | return _httpClient.Post<MesResponse>(url, json, "application/json", BuildConfig()); |
| | | } |
| | | |
| | | private HttpResponseResult<MesResponse> Post<T>(string url, T request, HttpRequestConfig config) |
| | | { |
| | | string json = JsonConvert.SerializeObject(request); |
| | | return _httpClient.Post<MesResponse>(url, json, "application/json", config); |
| | | } |
| | | |
| | | public HttpResponseResult<MesResponse> BindContainer(BindContainerRequest request) |
| | |
| | | public HttpResponseResult<MesResponse> UnBindContainer(UnBindContainerRequest request) |
| | | { |
| | | return Post(_baseUrl + UnBindContainerPath, request); |
| | | } |
| | | |
| | | public HttpResponseResult<MesResponse> BindContainer(BindContainerRequest request, string token) |
| | | { |
| | | return Post(_baseUrl + BindContainerPath, request, BuildConfig(token)); |
| | | } |
| | | |
| | | public HttpResponseResult<MesResponse> UnBindContainer(UnBindContainerRequest request, string token) |
| | | { |
| | | return Post(_baseUrl + UnBindContainerPath, request, BuildConfig(token)); |
| | | } |
| | | |
| | | public HttpResponseResult<MesResponse> ContainerNgReport(ContainerNgReportRequest request) |
| | |
| | | { |
| | | return Post(_baseUrl + OutboundInContainerPath, request); |
| | | } |
| | | |
| | | public HttpResponseResult<MesResponse> InboundInContainer(InboundInContainerRequest request, string token) |
| | | { |
| | | return Post(_baseUrl + InboundInContainerPath, request, BuildConfig(token)); |
| | | } |
| | | |
| | | public HttpResponseResult<MesResponse> OutboundInContainer(OutboundInContainerRequest request, string token) |
| | | { |
| | | return Post(_baseUrl + OutboundInContainerPath, request, BuildConfig(token)); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// ç®æ æçå· |
| | | /// </summary> |
| | | public string PalletCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 设å¤åç§°ï¼ç¨äºå¨æMESåè¯æ¥è¯¢ï¼ |
| | | /// </summary> |
| | | public string DeviceName { get; set; } |
| | | } |
| | | } |
| | |
| | | /// æºæçå· |
| | | /// </summary> |
| | | public string PalletCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 设å¤åç§°ï¼ç¨äºå¨æMESåè¯æ¥è¯¢ï¼ |
| | | /// </summary> |
| | | public string DeviceName { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_IBasicService |
| | | { |
| | | /// <summary> |
| | | /// MES设å¤é
ç½®ä¿¡æ¯æå¡æ¥å£ |
| | | /// </summary> |
| | | public interface IMESDeviceConfigService : IDependency |
| | | { |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤åç§°è·åMES设å¤é
ç½®ï¼ç²¾ç¡®å¹é
ï¼ |
| | | /// </summary> |
| | | /// <param name="deviceName">设å¤åç§°</param> |
| | | /// <returns>MES设å¤é
ç½®ï¼å¦ææªæ¾å°åè¿ånull</returns> |
| | | Dt_MESDeviceConfig? GetByDeviceName(string deviceName); |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤åç§°åä»åºç¼ç è·åMES设å¤é
ç½® |
| | | /// å¹é
æ¡ä»¶ï¼DeviceName精确å¹é
ä¸ï¼WarehouseCode为空æçäºæå®çä»åºç¼ç ï¼ |
| | | /// </summary> |
| | | /// <param name="deviceName">设å¤åç§°</param> |
| | | /// <param name="warehouseCode">ä»åºç¼ç </param> |
| | | /// <returns>MES设å¤é
ç½®ï¼å¦ææªæ¾å°åè¿ånull</returns> |
| | | Dt_MESDeviceConfig? GetByDeviceNameAndWarehouse(string deviceName, string warehouseCode); |
| | | } |
| | | } |
| | |
| | | HttpResponseResult<MesResponse> UnBindContainer(UnBindContainerRequest request); |
| | | |
| | | /// <summary> |
| | | /// æççµè¯ç»å®ï¼æ¯æå¨æTokenï¼ |
| | | /// </summary> |
| | | HttpResponseResult<MesResponse> BindContainer(BindContainerRequest request, string token); |
| | | |
| | | /// <summary> |
| | | /// æççµè¯è§£ç»ï¼æ¯æå¨æTokenï¼ |
| | | /// </summary> |
| | | HttpResponseResult<MesResponse> UnBindContainer(UnBindContainerRequest request, string token); |
| | | |
| | | /// <summary> |
| | | /// æçNGçµè¯ä¸æ¥ |
| | | /// </summary> |
| | | HttpResponseResult<MesResponse> ContainerNgReport(ContainerNgReportRequest request); |
| | |
| | | HttpResponseResult<MesResponse> InboundInContainer(InboundInContainerRequest request); |
| | | |
| | | /// <summary> |
| | | /// æçè¿ç«ï¼æ¯æå¨æTokenï¼ |
| | | /// </summary> |
| | | HttpResponseResult<MesResponse> InboundInContainer(InboundInContainerRequest request, string token); |
| | | |
| | | /// <summary> |
| | | /// æçåºç« |
| | | /// </summary> |
| | | HttpResponseResult<MesResponse> OutboundInContainer(OutboundInContainerRequest request); |
| | | |
| | | /// <summary> |
| | | /// æçåºç«ï¼æ¯æå¨æTokenï¼ |
| | | /// </summary> |
| | | HttpResponseResult<MesResponse> OutboundInContainer(OutboundInContainerRequest request, string token); |
| | | } |
| | | } |
| | |
| | | /// æ¹éæç确认 - 䏿¬¡æ§è°ç¨MESè§£ç»æ´ä¸ªæç |
| | | /// </summary> |
| | | /// <param name="palletCode">æºæçå·</param> |
| | | /// <param name="deviceName">设å¤åç§°ï¼ç¨äºå¨æMESåè¯æ¥è¯¢ï¼</param> |
| | | /// <returns>æä½ç»æ</returns> |
| | | Task<WebResponseContent> SplitPalletConfirmAsync(string palletCode); |
| | | Task<WebResponseContent> SplitPalletConfirmAsync(string palletCode, string deviceName); |
| | | |
| | | /// <summary> |
| | | /// æ¹éç»ç确认 - 䏿¬¡æ§è°ç¨MESç»å®æ´ä¸ªæç |
| | | /// </summary> |
| | | /// <param name="palletCode">ç®æ æçå·</param> |
| | | /// <param name="deviceName">设å¤åç§°ï¼ç¨äºå¨æMESåè¯æ¥è¯¢ï¼</param> |
| | | /// <returns>æä½ç»æ</returns> |
| | | Task<WebResponseContent> GroupPalletConfirmAsync(string palletCode); |
| | | Task<WebResponseContent> GroupPalletConfirmAsync(string palletCode, string deviceName); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using SqlSugar; |
| | | using System; |
| | | using WIDESEA_Core.DB.Models; |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | /// <summary> |
| | | /// MES设å¤é
ç½®å®ä½ |
| | | /// </summary> |
| | | [SugarTable(nameof(Dt_MESDeviceConfig))] |
| | | public class Dt_MESDeviceConfig : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// 主é®IDï¼èªå¢ |
| | | /// </summary> |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®ID")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 设å¤åç§°ï¼å¦"注液ç»çæºæ¢°æ" |
| | | /// </summary> |
| | | [SugarColumn(Length = 50, IsNullable = false, ColumnDescription = "设å¤åç§°")] |
| | | public string DeviceName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// MES设å¤ç¼ç ï¼å¦"A02-YZHJJS-001" |
| | | /// </summary> |
| | | [SugarColumn(Length = 50, IsNullable = false, ColumnDescription = "MES设å¤ç¼ç ")] |
| | | public string EquipmentCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// MESèµæºç¼ç ï¼å¦"ZY25091001" |
| | | /// </summary> |
| | | [SugarColumn(Length = 50, IsNullable = false, ColumnDescription = "MESèµæºç¼ç ")] |
| | | public string ResourceCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// MES API JWT令ç |
| | | /// </summary> |
| | | [SugarColumn(Length = 500, IsNullable = false, ColumnDescription = "MES API JWT令ç")] |
| | | public string Token { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»åºç¼ç ï¼ç¨äºéè¦åºåä»åºçæºæ¢°æï¼å¯ä¸ºç©ºï¼ |
| | | /// </summary> |
| | | [SugarColumn(Length = 50, IsNullable = true, ColumnDescription = "ä»åºç¼ç ")] |
| | | public string WarehouseCode { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- Dt_MESDeviceConfig SQL Script |
| | | -- 对åºå®ä½ Dt_MESDeviceConfigï¼ç»§æ¿èª BaseEntityï¼å
å« Creater, CreateDate, Modifier, ModifyDateï¼ |
| | | DROP TABLE IF EXISTS Dt_MESDeviceConfig; |
| | | |
| | | CREATE TABLE Dt_MESDeviceConfig ( |
| | | Id INT IDENTITY(1,1) PRIMARY KEY, |
| | | DeviceName NVARCHAR(50) NOT NULL, |
| | | EquipmentCode NVARCHAR(50) NOT NULL, |
| | | ResourceCode NVARCHAR(50) NOT NULL, |
| | | Token NVARCHAR(500) NOT NULL, |
| | | WarehouseCode NVARCHAR(50) NULL, |
| | | Creater NVARCHAR(50) NOT NULL, |
| | | CreateDate DATETIME NOT NULL, |
| | | Modifier NVARCHAR(50) NULL, |
| | | ModifyDate DATETIME NULL |
| | | ); |
| | | |
| | | -- INSERT device configuration data |
| | | INSERT INTO Dt_MESDeviceConfig (DeviceName, EquipmentCode, ResourceCode, Token, WarehouseCode, Creater, CreateDate) |
| | | VALUES |
| | | (N'注液ç»çæºæ¢°æ', N'A02-YZHJJS-001', N'ZY25091001', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwODkyNjQ4MzYzODUzODI0MCIsIm5hbWUiOiLkuIDms6jlkI7mnLrmorDmiYsiLCJGYWN0b3J5SWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIlNpdGVJZCI6IjQyODc0NTYxNzc4MjUzODI0IiwiQ29kZSI6IkEwMi1ZWkhKSlMtMDAxIiwibmJmIjoxNzc2NDExODk0LCJleHAiOjIyMTc5MTU4OTQsImlzcyI6Imh0dHBzOi8vd3d3Lmh5bXNvbi5jb20iLCJhdWQiOiJodHRwczovL3d3dy5oeW1zb24uY29tIn0.HCBK-mq7zrbn6s335Ddn1ZwUffCXdFAmflgHFtOyOXg', NULL, N'Admin', GETDATE()), |
| | | (N'髿¸©1æ¢çæºæ¢°æ', N'A02-GW1HJJS-001', N'ZY25091002', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwODkyNjUxOTA3NDExNTU4NCIsIm5hbWUiOiLpq5jmuKkx5ZCO5py65qKw5omLIiwiRmFjdG9yeUlkIjoiNDI4NzQ1NjE3NzgyNTM4MjQiLCJTaXRlSWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIkNvZGUiOiJBMDItR1cxSEpKUy0wMDEiLCJuYmYiOjE3NzY0MTE5MDgsImV4cCI6MjIxNzkxNTkwOCwiaXNzIjoiaHR0cHM6Ly93d3cuaHltc29uLmNvbSIsImF1ZCI6Imh0dHBzOi8vd3d3Lmh5bXNvbi5jb20ifQ.A8frl5Txy6F3hCM2AuMbrPk_0x-rYmwjvL4a1RbxdeY', NULL, N'Admin', GETDATE()), |
| | | (N'åææ¢çæºæ¢°æ', N'A02-HCHJJS-001', N'ZY25091003', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwODkyNjU0ODk2NTg3MTYxNiIsIm5hbWUiOiLljJbmiJDlkI7mnLrmorDmiYvvvIjpq5jmuKky77yJIiwiRmFjdG9yeUlkIjoiNDI4NzQ1NjE3NzgyNTM4MjQiLCJTaXRlSWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIkNvZGUiOiJBMDItSENISkpTLTAwMSIsIm5iZiI6MTc3NjQxMTkxNiwiZXhwIjoyMjE3OTE1OTE2LCJpc3MiOiJodHRwczovL3d3dy5oeW1zb24uLmNvbSIsImF1ZCI6Imh0dHBzOi8vd3d3Lmh5bXNvbi5jb20ifQ.SHxbsdYoV2m4oUkaJauOBu4A-TfuX__J8-W-mqghg_A', NULL, N'Admin', GETDATE()), |
| | | (N'å¸¸æ¸©æºæ¢°æ', N'A02-CW1JJS-001', N'ZY25091004', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwODkyNjU4MDA2ODczMjkyOCIsIm5hbWUiOiLluLjmuKkx5py65qKw5omLIiwiRmFjdG9yeUlkIjoiNDI4NzQ1NjE3NzgyNTM4MjQiLCJTaXRlSWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIkNvZGUiOiJBMDItQ1cxSkpTLTAwMSIsIm5iZiI6MTc3NjQxMTkyNCwiZXhwIjoyMjE3OTE1OTI0LCJpc3MiOiJodHRwczovL3d3dy5oeW1zb24uY29tIiwiYXVkIjoiaHR0cHM6Ly93d3cuaHltc29uLmNvbSJ9.CnBUKdmdSGURyW-YzW_JZvtP93o17zG2r5ZxHx867PQ', NULL, N'Admin', GETDATE()), |
| | | (N'æåç»çæºæ¢°æ', N'A02-EHJJS-001', N'ZY25091005', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwODkyNjYwOTU1OTkzMjkyOCIsIm5hbWUiOiLkuozmrKHmsKbmo4DlkI7mnLrmorDmiYsiLCJGYWN0b3J5SWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIlNpdGVJZCI6IjQyODc0NTYxNzc4MjUzODI0IiwiQ29kZSI6IkEwMi1FSEpKUy0wMDEiLCJuYmYiOjE3NzY0MTE5MzIsImV4cCI6MjIxNzkxNTkzMiwiaXNzIjoiaHR0cHM6Ly93d3cuaHltc29uLmNvbSIsImF1ZCI6Imh0dHRwczovL3d3dy5oeW1zb24uY29tIn0.Imc2-8pDFrXgPrE_ro9Riasb8eGJ3Vi6gDyUDnUTpfY', NULL, N'Admin', GETDATE()), |
| | | (N'髿¸©éç½®1', N'A02-GWJZ-001', N'ZY25030001', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwNzU0NjM1MTU4NDY5NDI3MiIsIm5hbWUiOiLpq5jmuKnpnZnnva4xIiwiRmFjdG9yeUlkIjoiNDI4NzQ1NjE3NzgyNTM4MjQiLCJTaXRlSWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIkNvZGUiOiJBMDItR1dKWi0wMDEiLCJuYmYiOjE3NzUwOTkzMDEsImV4cCI6MjIxNjYwMzMwMSwiaXNzIjoiaHR0cHM6Ly93d3cuaHltc29uLmNvbSIsImF1ZCI6Imh0dHBzOi8vd3d3Lmh5bXNvbi5jb20ifQ.EI3Q6kHieKk5q4a6Nmf9fozi0haan0WuqkA9QNA-bHk', NULL, N'Admin', GETDATE()), |
| | | (N'髿¸©éç½®2', N'A02-GWJZ-002', N'ZY25060001', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwNzU0NjUxNTA0NTEwNTY2NCIsIm5hbWUiOiLpq5jmuKnpnZnnva4yIiwiRmFjdG9yeUlkIjoiNDI4NzQ1NjE3NzgyNTM4MjQiLCJTaXRlSWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIkNvZGUiOiJBMDItR1dKWi0wMDIiLCJuYmYiOjE3NzUwOTkzNDAsImV4cCI6MjIxNjYwMzM0MCwiaXNzIjoiaHR0cHM6Ly93d3cuaHltc29uLmNvbSIsImF1ZCI6Imh0dHBzOi8vd3d3Lmh5bXNvbi5jb20ifQ.imaa_1Xd9bHZKF3cy6c82Lb1ODXJC2MVytks4_eIyR4', NULL, N'Admin', GETDATE()), |
| | | (N'常温éç½®1', N'A02-CWJZ-001', N'ZY25070001', N'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwNzU0NjU1ODU5OTgxMTA3MiIsIm5hbWUiOiLluLjmuKnpnZnnva4xIiwiRmFjdG9yeUlkIjoiNDI4NzQ1NjE3NzgyNTM4MjQiLCJTaXRlSWQiOiI0Mjg3NDU2MTc3ODI1MzgyNCIsIkNvZGUiOiJBMDItQ1dKWi0wMDEiLCJuYmYiOjE3NzUwOTkzNDgsImV4cCI6MjIxNjYwMzM0OCwiaXNzIjoiaHR0cHM6Ly93d3cuaHltc29uLmNvbSIsImF1ZCI6Imh0dHRzOi8vd3d3Lmh5bXNvbi5jb20ifQ.-WmBS4g4T0ZpJZ2qHszZMfe2pseMWCh6zyVeYgzsho4', NULL, N'Admin', GETDATE()); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_StockService |
| | | { |
| | | /// <summary> |
| | | /// MES设å¤é
ç½®æå¡å®ç°ç±» |
| | | /// </summary> |
| | | public class MESDeviceConfigService : ServiceBase<Dt_MESDeviceConfig, IRepository<Dt_MESDeviceConfig>>, IMESDeviceConfigService |
| | | { |
| | | /// <summary> |
| | | /// è·åMES设å¤é
ç½®ä»å¨æ¥å£ |
| | | /// </summary> |
| | | public IRepository<Dt_MESDeviceConfig> Repository => BaseDal; |
| | | |
| | | /// <summary> |
| | | /// æé 彿° |
| | | /// </summary> |
| | | /// <param name="baseDal">åºç¡æ°æ®è®¿é®å¯¹è±¡</param> |
| | | public MESDeviceConfigService(IRepository<Dt_MESDeviceConfig> baseDal) : base(baseDal) |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤åç§°è·åMES设å¤é
ç½®ï¼ç²¾ç¡®å¹é
ï¼ |
| | | /// </summary> |
| | | /// <param name="deviceName">设å¤åç§°</param> |
| | | /// <returns>MES设å¤é
ç½®ï¼å¦ææªæ¾å°åè¿ånull</returns> |
| | | public Dt_MESDeviceConfig? GetByDeviceName(string deviceName) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(deviceName)) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | return BaseDal.QueryFirst(x => x.DeviceName == deviceName); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤åç§°åä»åºç¼ç è·åMES设å¤é
ç½® |
| | | /// å¹é
æ¡ä»¶ï¼DeviceName精确å¹é
ä¸ï¼WarehouseCode为空æçäºæå®çä»åºç¼ç ï¼ |
| | | /// </summary> |
| | | /// <param name="deviceName">设å¤åç§°</param> |
| | | /// <param name="warehouseCode">ä»åºç¼ç </param> |
| | | /// <returns>MES设å¤é
ç½®ï¼å¦ææªæ¾å°åè¿ånull</returns> |
| | | public Dt_MESDeviceConfig? GetByDeviceNameAndWarehouse(string deviceName, string warehouseCode) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(deviceName)) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | return BaseDal.QueryFirst(x => |
| | | x.DeviceName == deviceName && |
| | | (string.IsNullOrEmpty(x.WarehouseCode) || x.WarehouseCode == warehouseCode)); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// æ¹éæç确认 - 䏿¬¡æ§è°ç¨MESè§£ç»æ´ä¸ªæç |
| | | /// </summary> |
| | | /// <param name="palletCode">æºæçå·</param> |
| | | /// <param name="deviceName">设å¤åç§°ï¼ç¨äºå¨æMESåè¯æ¥è¯¢ï¼</param> |
| | | /// <returns>æä½ç»æ</returns> |
| | | public async Task<WebResponseContent> SplitPalletConfirmAsync(string palletCode) |
| | | public async Task<WebResponseContent> SplitPalletConfirmAsync(string palletCode, string deviceName) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | if (sfcList == null || !sfcList.Any()) |
| | | return content.Error("临æ¶è¡¨ä¸çµè¯å表为空"); |
| | | |
| | | // 2. è°ç¨MESè§£ç» |
| | | // 2. è·åMES设å¤é
ç½®ï¼å¨æåè¯ï¼ |
| | | string equipmentCode = StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = StockConstants.MES_RESOURCE_CODE; |
| | | string token = null; |
| | | |
| | | if (!string.IsNullOrWhiteSpace(deviceName)) |
| | | { |
| | | var mesConfig = ResolveMesConfig(deviceName, palletCode); |
| | | if (mesConfig != null) |
| | | { |
| | | equipmentCode = mesConfig.EquipmentCode; |
| | | resourceCode = mesConfig.ResourceCode; |
| | | token = mesConfig.Token; |
| | | } |
| | | } |
| | | |
| | | // 3. è°ç¨MESè§£ç» |
| | | var unbindRequest = new UnBindContainerRequest |
| | | { |
| | | EquipmentCode = StockConstants.MES_EQUIPMENT_CODE, |
| | | ResourceCode = StockConstants.MES_RESOURCE_CODE, |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | ContainCode = palletCode, |
| | | SfcList = sfcList |
| | | }; |
| | | var unbindResult = _mesService.UnBindContainer(unbindRequest); |
| | | var unbindResult = string.IsNullOrWhiteSpace(token) |
| | | ? _mesService.UnBindContainer(unbindRequest) |
| | | : _mesService.UnBindContainer(unbindRequest, token); |
| | | if (unbindResult == null || unbindResult.Data == null || !unbindResult.Data.IsSuccess) |
| | | { |
| | | return content.Error($"MESè§£ç»å¤±è´¥: {unbindResult?.Data?.Msg ?? unbindResult?.ErrorMessage ?? "æªç¥é误"}"); |
| | | } |
| | | |
| | | // 3. å é¤ä¸´æ¶è¡¨è®°å½ |
| | | // 4. å é¤ä¸´æ¶è¡¨è®°å½ |
| | | await SqlSugarClient.Deleteable<Dt_SplitTemp>().Where(t => t.PalletCode == palletCode).ExecuteCommandAsync(); |
| | | |
| | | return content.OK("æ¹éæç确认æå"); |
| | |
| | | /// æ¹éç»ç确认 - 䏿¬¡æ§è°ç¨MESç»å®æ´ä¸ªæç |
| | | /// </summary> |
| | | /// <param name="palletCode">ç®æ æçå·</param> |
| | | /// <param name="deviceName">设å¤åç§°ï¼ç¨äºå¨æMESåè¯æ¥è¯¢ï¼</param> |
| | | /// <returns>æä½ç»æ</returns> |
| | | public async Task<WebResponseContent> GroupPalletConfirmAsync(string palletCode) |
| | | public async Task<WebResponseContent> GroupPalletConfirmAsync(string palletCode, string deviceName) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | |
| | | if (details == null || !details.Any()) |
| | | return content.Error("æç䏿 çµè¯æ°æ®"); |
| | | |
| | | // 2. è°ç¨MESç»å® |
| | | // 2. è·åMES设å¤é
ç½®ï¼å¨æåè¯ï¼ |
| | | string equipmentCode = StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = StockConstants.MES_RESOURCE_CODE; |
| | | string token = null; |
| | | |
| | | if (!string.IsNullOrWhiteSpace(deviceName)) |
| | | { |
| | | var mesConfig = ResolveMesConfig(deviceName, palletCode); |
| | | if (mesConfig != null) |
| | | { |
| | | equipmentCode = mesConfig.EquipmentCode; |
| | | resourceCode = mesConfig.ResourceCode; |
| | | token = mesConfig.Token; |
| | | } |
| | | } |
| | | |
| | | // 3. è°ç¨MESç»å® |
| | | var bindRequest = new BindContainerRequest |
| | | { |
| | | ContainerCode = palletCode, |
| | | EquipmentCode = StockConstants.MES_EQUIPMENT_CODE, |
| | | ResourceCode = StockConstants.MES_RESOURCE_CODE, |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | OperationType = StockConstants.MES_BIND_OPERATION_TYPE, |
| | | ContainerSfcList = details.Select(d => new ContainerSfcItem |
| | |
| | | Location = d.InboundOrderRowNo.ToString() |
| | | }).ToList() |
| | | }; |
| | | var bindResult = _mesService.BindContainer(bindRequest); |
| | | var bindResult = string.IsNullOrWhiteSpace(token) |
| | | ? _mesService.BindContainer(bindRequest) |
| | | : _mesService.BindContainer(bindRequest, token); |
| | | if (bindResult == null || bindResult.Data == null || !bindResult.Data.IsSuccess) |
| | | { |
| | | return content.Error($"MESç»å®å¤±è´¥: {bindResult?.Data?.Msg ?? bindResult?.ErrorMessage ?? "æªç¥é误"}"); |
| | |
| | | return content.Error($"æ¹éç»ç确认失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤åç§°åæçå·è§£æMES设å¤é
ç½® |
| | | /// </summary> |
| | | /// <param name="deviceName">设å¤åç§°</param> |
| | | /// <param name="palletCode">æçå·ï¼ç¨äºæ¥è¯¢ä»åºç¼ç ï¼</param> |
| | | /// <returns>MES设å¤é
ç½®ï¼ä¸å卿¶è¿ånull</returns> |
| | | private Dt_MESDeviceConfig ResolveMesConfig(string deviceName, string palletCode) |
| | | { |
| | | // æ¢çæºæ¢°æéè¦åºåä»åº |
| | | if (deviceName.Contains("æ¢ç")) |
| | | { |
| | | // æ¥è¯¢æç对åºçä»åºç¼ç |
| | | var stockInfo = StockInfoService.Repository.QueryFirst(s => s.PalletCode == palletCode); |
| | | if (stockInfo != null && stockInfo.WarehouseId > 0) |
| | | { |
| | | var warehouse = _warehouseService.Repository.QureyDataById(stockInfo.WarehouseId); |
| | | if (warehouse != null && !string.IsNullOrWhiteSpace(warehouse.WarehouseCode)) |
| | | { |
| | | // å
æè®¾å¤å+ä»åºç¼ç æ¥è¯¢ |
| | | var config = SqlSugarClient.Queryable<Dt_MESDeviceConfig>() |
| | | .Where(c => c.DeviceName == deviceName && c.WarehouseCode == warehouse.WarehouseCode) |
| | | .First(); |
| | | if (config != null) |
| | | return config; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æè®¾å¤åç§°æ¥è¯¢ï¼éç¨äºç»çæºæ¢°æææ¢çæºæ¢°ææªæ¾å°ä»åºå¹é
çæ
åµï¼ |
| | | return SqlSugarClient.Queryable<Dt_MESDeviceConfig>() |
| | | .Where(c => c.DeviceName == deviceName) |
| | | .First(); |
| | | } |
| | | } |
| | | } |
| | |
| | | private readonly IStockInfo_HtyService _stockInfo_HtyService; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IRecordService _recordService; |
| | | private readonly IMESDeviceConfigService _mesDeviceConfigService; |
| | | |
| | | public IRepository<Dt_Task> Repository => BaseDal; |
| | | |
| | |
| | | ITask_HtyService task_HtyService, |
| | | IStockInfo_HtyService stockInfo_HtyService, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | | IRecordService recordService) : base(BaseDal) |
| | | IRecordService recordService, |
| | | IMESDeviceConfigService mesDeviceConfigService) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _stockInfoService = stockInfoService; |
| | |
| | | _stockInfo_HtyService = stockInfo_HtyService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _recordService = recordService; |
| | | _mesDeviceConfigService = mesDeviceConfigService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | |
| | | var updateStockResult = await _stockInfoService.UpdateStockAsync(stockInfo); |
| | | if (!updateLocationResult || !updateStockResult) |
| | | return WebResponseContent.Instance.Error("ä»»å¡å®æå¤±è´¥"); |
| | | // æ ¹æ®åºåRemarkéæ©é置设å¤ï¼æ¥MES卿åè¯ |
| | | string deviceName = stockInfo.Remark == "GW_1" ? "髿¸©éç½®1" |
| | | : stockInfo.Remark == "GW_2" ? "髿¸©éç½®2" |
| | | : "常温éç½®1"; |
| | | var mesConfig = _mesDeviceConfigService.GetByDeviceName(deviceName); |
| | | string equipmentCode = mesConfig?.EquipmentCode ?? StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = mesConfig?.ResourceCode ?? StockConstants.MES_RESOURCE_CODE; |
| | | string token = mesConfig?.Token; |
| | | |
| | | // è°ç¨MESæçè¿ç« |
| | | //var inboundRequest = new InboundInContainerRequest |
| | | //{ |
| | | // EquipmentCode = "STK-GROUP-001", |
| | | // ResourceCode = "STK-GROUP-001", |
| | | // LocalTime = DateTime.Now, |
| | | // ContainerCode = taskDto.PalletCode |
| | | //}; |
| | | //var inboundResult = _mesService.InboundInContainer(inboundRequest); |
| | | //if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess) |
| | | //{ |
| | | // return content.Error($"ä»»å¡å®æå¤±è´¥ï¼MESè¿ç«å¤±è´¥: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "æªç¥é误"}"); |
| | | //} |
| | | var inboundRequest = new InboundInContainerRequest |
| | | { |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = taskDto.PalletCode |
| | | }; |
| | | var inboundResult = string.IsNullOrWhiteSpace(token) |
| | | ? _mesService.InboundInContainer(inboundRequest) |
| | | : _mesService.InboundInContainer(inboundRequest, token); |
| | | if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess) |
| | | { |
| | | return content.Error($"ä»»å¡å®æå¤±è´¥ï¼MESè¿ç«å¤±è´¥: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "æªç¥é误"}"); |
| | | } |
| | | return await CompleteTaskAsync(task, "å
¥åºå®æ"); |
| | | }); |
| | | } |
| | |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | |
| | | inboundTaskDto = _mapper.Map<WMSTaskDTO>(inboundTask); |
| | | } |
| | | |
| | | // è°ç¨MESæçåºç« |
| | | string deviceName = stockInfo.Remark == "GW_1" ? "髿¸©éç½®1" |
| | | : stockInfo.Remark == "GW_2" ? "髿¸©éç½®2" |
| | | : "常温éç½®1"; |
| | | var mesConfig = _mesDeviceConfigService.GetByDeviceName(deviceName); |
| | | string equipmentCode = mesConfig?.EquipmentCode ?? StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = mesConfig?.ResourceCode ?? StockConstants.MES_RESOURCE_CODE; |
| | | string token = mesConfig?.Token; |
| | | |
| | | var outboundRequest = new OutboundInContainerRequest |
| | | { |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = taskDto.PalletCode |
| | | }; |
| | | var outboundResult = string.IsNullOrWhiteSpace(token) |
| | | ? _mesService.OutboundInContainer(outboundRequest) |
| | | : _mesService.OutboundInContainer(outboundRequest, token); |
| | | if (outboundResult == null || outboundResult.Data == null || !outboundResult.Data.IsSuccess) |
| | | { |
| | | return content.Error($"åºåºå®æå¤±è´¥ï¼MESåºç«å¤±è´¥: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "æªç¥é误"}"); |
| | | } |
| | | |
| | | var completeResult = await CompleteTaskAsync(task, "åºåºå®æ"); |
| | | if (!completeResult.Status) |
| | | return completeResult; |
| | |
| | | [HttpPost("SplitPalletConfirm"), AllowAnonymous] |
| | | public async Task<WebResponseContent> SplitPalletConfirm([FromBody] SplitPalletConfirmRequestDto dto) |
| | | { |
| | | return await Service.SplitPalletConfirmAsync(dto.PalletCode); |
| | | return await Service.SplitPalletConfirmAsync(dto.PalletCode, dto.DeviceName); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | [HttpPost("GroupPalletConfirm"), AllowAnonymous] |
| | | public async Task<WebResponseContent> GroupPalletConfirm([FromBody] GroupPalletConfirmRequestDto dto) |
| | | { |
| | | return await Service.GroupPalletConfirmAsync(dto.PalletCode); |
| | | return await Service.GroupPalletConfirmAsync(dto.PalletCode, dto.DeviceName); |
| | | } |
| | | } |
| | | } |