From daf2a4075e8ce949cda132de6a03b7ea86597b37 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周日, 18 5月 2025 14:30:56 +0800 Subject: [PATCH] 33 --- PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Models/Service/PipeAccessoryAssembly.ts | 16 + PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs | 459 ++++++++++++++++++++++++++++++ PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/CompleteAssemblyProcessInput.cs | 29 + PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Views/Pages/WorkPlan/Config.ts | 32 +- PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/StartProductionInput.cs | 28 + PipeLineLems/pipelinelems_web/src/config/menu.ts | 28 PipeLineLems/server/src/CMS.Plugin.PipeLineLems/Controller/WorkPlanPublicController.cs | 98 +++++ PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Views/Pages/PipeAccessoryAssembly/PipeAccessoryAssembly.tsx | 100 +++++- PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs | 85 +++++ 9 files changed, 816 insertions(+), 59 deletions(-) diff --git a/PipeLineLems/pipelinelems_web/src/config/menu.ts b/PipeLineLems/pipelinelems_web/src/config/menu.ts index f61ab9b..6366b2d 100644 --- a/PipeLineLems/pipelinelems_web/src/config/menu.ts +++ b/PipeLineLems/pipelinelems_web/src/config/menu.ts @@ -14,17 +14,17 @@ "notPage": false }, { - "name": "宸ュ崟绠$悊(鏂�)", - "path": "/information-base/OrderManagement-main", - "patchName": "OrderManagement-main", - "icon": "order", - "notPage": false - }, - { "name": "MyPluginName", "path": "/information-base/MyPluginName", "patchName": "MyPluginName", "icon": "p", + "notPage": false + }, + { + "name": "宸ュ崟绠$悊(鏂�)", + "path": "/information-base/OrderManagement-main", + "patchName": "OrderManagement-main", + "icon": "order", "notPage": false }, { @@ -64,13 +64,6 @@ "icon": "p", "notPage": false }, - "OrderManagement-main": { - "name": "宸ュ崟绠$悊(鏂�)", - "path": "/information-base/OrderManagement-main", - "patchName": "OrderManagement-main", - "icon": "order", - "notPage": false - }, "MyPluginName": { "name": "MyPluginName", "path": "/information-base/MyPluginName", @@ -78,6 +71,13 @@ "icon": "p", "notPage": false }, + "OrderManagement-main": { + "name": "宸ュ崟绠$悊(鏂�)", + "path": "/information-base/OrderManagement-main", + "patchName": "OrderManagement-main", + "icon": "order", + "notPage": false + }, "Http": { "name": "API璇锋眰", "path": "/information-base/Http", diff --git a/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Models/Service/PipeAccessoryAssembly.ts b/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Models/Service/PipeAccessoryAssembly.ts index c73c49e..92614a8 100644 --- a/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Models/Service/PipeAccessoryAssembly.ts +++ b/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Models/Service/PipeAccessoryAssembly.ts @@ -61,3 +61,19 @@ export const findSingleWorkPlanByFilter = (data: any) => { return request.post('/api/v1/PipeLineLems/WorkPlan/FindSingleByFilter', data) } + +/** + * 鏍规嵁 浠诲姟缂栧彿杩涜寮�宸� + * @returns + */ +export const startProduction = (data: any) => { + return request.post('/api/v1/PipeLineLems/WorkPlanPublic/startProduction', data) +} + +/** + * 鏍规嵁 浠诲姟缂栧彿杩涜瀹屽伐 + * @returns + */ +export const finishProduction = (data: any) => { + return request.post('/api/v1/PipeLineLems/WorkPlanPublic/finishProduction', data) +} \ No newline at end of file diff --git a/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Views/Pages/PipeAccessoryAssembly/PipeAccessoryAssembly.tsx b/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Views/Pages/PipeAccessoryAssembly/PipeAccessoryAssembly.tsx index 2f3a96f..79d0893 100644 --- a/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Views/Pages/PipeAccessoryAssembly/PipeAccessoryAssembly.tsx +++ b/PipeLineLems/pipelinelems_web/src/widgets/PipeAccessoryAssembly/Views/Pages/PipeAccessoryAssembly/PipeAccessoryAssembly.tsx @@ -2,6 +2,7 @@ import type { Ref } from 'vue' import styles from './PipeAccessoryAssembly.module.scss' import pipeImage from '@/images/pipe-assembly-drawing-example.png' +import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox' import { ElInput, ElForm, @@ -16,7 +17,9 @@ getPlaceNoForStockList, getMaterialModelList, instock, - findSingleWorkPlanByFilter + findSingleWorkPlanByFilter, + startProduction, + finishProduction } from '@/widgets/PipeAccessoryAssembly/Models/Service/PipeAccessoryAssembly' import { Message } from '@element-plus/icons-vue/dist/types' @@ -123,13 +126,74 @@ } }; + // 寮�宸ヤ簨浠跺鐞� + const startWork = () => { + console.log('鎵ц寮�宸ユ搷浣�'); + if(queryForm.value.pipeSpecCode==''){ + ElMessage.error('璇疯緭鍏ョ娈电紪鐮�'); + return + } + ConfirmBox( + `纭畾瑕佸皢绠℃缂栫爜${queryForm.value.pipeSpecCode}寮�宸ュ悧` + ).then(async () => { + //鎮ㄧ殑涓氬姟閫昏緫 + const param={ + taskCode:queryForm.value.taskCode, + }; + const ret = await startProduction(param); + console.log('杩斿洖:'+ret); + if(ret.code="200"){ + ElMessage.success('寮�宸ユ垚鍔�'); + }else{ + ElMessage.error('寮�宸ュけ璐�:'+ret.message); + } + }) + } + // 瀹屽伐浜嬩欢澶勭悊 + const finishWork = () => { + console.log('鎵ц寮�宸ユ搷浣�'); + if(queryForm.value.pipeSpecCode==''){ + ElMessage.error('璇疯緭鍏ョ娈电紪鐮�'); + return + } + ConfirmBox( + `纭畾瑕佸皢绠℃缂栫爜${queryForm.value.pipeSpecCode}瀹屽伐鍚梎 + ).then(async () => { + //鎮ㄧ殑涓氬姟閫昏緫 + const param={ + pipeSpecCode:queryForm.value.pipeSpecCode, + processName:queryForm.value.processName, + }; + const ret = await finishProduction(param); + console.log('杩斿洖:'+ret); + if(ret.code="200"){ + ElMessage.success('瀹屽伐鎴愬姛'); + }else{ + ElMessage.error('瀹屽伐澶辫触:'+ret.message); + } + }) + } + const tableData = ref([ + { sequence: 1, flangeA: 'RF-200-1.6MPa', flangeB: 'WN-200-1.6MPa' }, + { sequence: 2, flangeA: 'WN-250-2.5MPa', flangeB: 'SO-250-2.5MPa' }, + { sequence: 3, flangeA: 'PL-300-1.0MPa', flangeB: 'RF-300-1.0MPa' }, + { sequence: 4, flangeA: 'SO-150-2.0MPa', flangeB: 'WN-150-2.0MPa' }, + { sequence: 5, flangeA: 'RF-400-1.6MPa', flangeB: 'PL-400-1.6MPa' }, + { sequence: 6, flangeA: 'WN-200-4.0MPa', flangeB: 'SO-200-4.0MPa' }, + { sequence: 7, flangeA: 'SO-300-1.6MPa', flangeB: 'RF-300-1.6MPa' }, + { sequence: 8, flangeA: 'PL-250-1.0MPa', flangeB: 'WN-250-1.0MPa' }, + { sequence: 9, flangeA: 'RF-150-2.5MPa', flangeB: 'SO-150-2.5MPa' }, + { sequence: 10, flangeA: 'WN-400-2.0MPa', flangeB: 'PL-400-2.0MPa' } + ]); + + return () => { return ( <div class={styles.PipeAccessoryAssemblyContent} style="overflow-y: auto !important; height: 100%;" > - <ElFormItem label="绠℃缂栧彿"> + <ElFormItem label="绠℃缂栫爜 "> <ElInput v-model={queryForm.value.pipeSpecCode} clearable @@ -138,8 +202,8 @@ /> </ElFormItem> <div class={styles.actionButtons}> - <ElButton type="warning">寮�宸�</ElButton> - <ElButton type="warning">瀹屽伐</ElButton> + <ElButton type="warning" onClick={startWork}>寮�宸�</ElButton> + <ElButton type="warning" onClick={finishWork}>瀹屽伐</ElButton> <ElButton type="warning">鏆傚仠</ElButton> <ElButton type="warning">鑷姩</ElButton> <ElButton type="warning">璐ㄦ</ElButton> @@ -148,7 +212,7 @@ <h2 class={styles.blockTitle}>褰撳墠浠诲姟</h2> <ElForm label-position="left" > - <ElFormItem label="鐗╂枡娴佸悜"> + <ElFormItem label="鐗╂枡娴佸悜 "> <ElInput v-model={queryForm.value.processRouteNumber} disabled @@ -156,7 +220,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="浠诲姟缂栧彿"> + <ElFormItem label="浠诲姟缂栧彿 "> <ElInput v-model={queryForm.value.taskCode} disabled @@ -164,7 +228,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="绠℃闀垮害"> + <ElFormItem label="绠℃闀垮害 "> <ElInput v-model={queryForm.value.length} disabled @@ -172,7 +236,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="椤圭洰鍙�"> + <ElFormItem label="椤圭洰 鍙�"> <ElInput v-model={queryForm.value.projectNumber} disabled @@ -180,7 +244,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="鑸瑰彿"> + <ElFormItem label="鑸� 鍙�"> <ElInput v-model={queryForm.value.shipNumber} disabled @@ -188,7 +252,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="鏉愯川"> + <ElFormItem label="鏉� 璐�"> <ElInput v-model={queryForm.value.material} disabled @@ -196,7 +260,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="澶栧緞"> + <ElFormItem label="澶� 寰�"> <ElInput v-model={queryForm.value.outerDiameter} disabled @@ -204,7 +268,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="澹� 鍘�"> + <ElFormItem label="澹� 鍘�"> <ElInput v-model={queryForm.value.thickness} disabled @@ -232,7 +296,7 @@ <h2 class={styles.blockTitle}>褰撳墠宸ヤ綅/璁惧淇℃伅</h2> <ElForm label-position="left" > - <ElFormItem label="宸ヤ綅浠g爜"> + <ElFormItem label="宸ヤ綅浠g爜 "> <ElInput v-model={queryForm.value.workstationCode} disabled @@ -240,7 +304,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="宸ュ簭鍚嶇О"> + <ElFormItem label="宸ュ簭鍚嶇О "> <ElInput v-model={queryForm.value.processName} disabled @@ -248,7 +312,7 @@ class={styles.formInput} /> </ElFormItem> - <ElFormItem label="璁惧浠g爜"> + <ElFormItem label="璁惧浠g爜 "> <ElInput v-model={queryForm.value.equipmentCode} disabled @@ -274,14 +338,14 @@ </ElFormItem> */} </ElForm> - <div class="info-block"> + {/* <div class="info-block"> <h2 class="block-title">宸ヨ壓淇℃伅</h2> - <el-table stripe> + <el-table stripe v-model:dataSource={tableData}> <el-table-column prop="sequence" label="搴�"></el-table-column> <el-table-column prop="flangeA" label="娉曞叞A"></el-table-column> <el-table-column prop="flangeB" label="娉曞叞B"></el-table-column> </el-table> - </div> + </div> */} <h2 class="block-title">鍥剧焊</h2> <img src={pipeImage} diff --git a/PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Views/Pages/WorkPlan/Config.ts b/PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Views/Pages/WorkPlan/Config.ts index e051aae..de41e2e 100644 --- a/PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Views/Pages/WorkPlan/Config.ts +++ b/PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Views/Pages/WorkPlan/Config.ts @@ -10,6 +10,21 @@ width:160, }, { + field: 'pipeSpecCode', + title: '绠℃缂栫爜', + width:160, +}, +{ + field: 'pipeSectionName', + title: '绠℃鍚嶇О', + width:160, +}, +{ + field: 'processName', + title: '宸ュ簭鍚嶇О', + width:160, +}, +{ field: 'workPlanStatusDesc', title: '璁″垝鐘舵��', width:160, @@ -119,11 +134,7 @@ title: '椤圭洰鍙�', width:160, }, -{ - field: 'processName', - title: '宸ュ簭鍚嶇О', - width:160, -}, + { field: 'pipeFittingCode', title: '绠′欢缂栫爜', @@ -134,16 +145,7 @@ title: '椤哄簭鍙�', width:160, }, -{ - field: 'pipeSpecCode', - title: '绠℃缂栫爜', - width:160, -}, -{ - field: 'pipeSectionName', - title: '绠℃鍚嶇О', - width:160, -}, + { field: 'outerDiameter', title: '澶栧緞(mm)', diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/CompleteAssemblyProcessInput.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/CompleteAssemblyProcessInput.cs new file mode 100644 index 0000000..f0f5d8b --- /dev/null +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/CompleteAssemblyProcessInput.cs @@ -0,0 +1,29 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CMS.Plugin.PipeLineLems.Application.Contracts.Dtos.WorkPlan +{ + /// <summary> + /// 瑁呴厤宸ュ簭瀹屽伐 杈撳叆鍙傛暟妯″瀷 + /// </summary> + [Serializable] + public class CompleteAssemblyProcessInput + { + + /// <summary> + /// 绠℃缂栫爜 + /// </summary> + public string PipeSpecCode { get; set; } + + /// <summary> + /// 宸ュ簭鍚嶇О + /// </summary> + public string ProcessName { get; set; } + + + + } +} \ No newline at end of file diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/StartProductionInput.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/StartProductionInput.cs new file mode 100644 index 0000000..eb74166 --- /dev/null +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application.Contracts/Dtos/WorkPlan/StartProductionInput.cs @@ -0,0 +1,28 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CMS.Plugin.PipeLineLems.Application.Contracts.Dtos.WorkPlan +{ + /// <summary> + /// 寮�宸ヨ緭鍏ュ弬鏁版ā鍨� + /// </summary> + [Serializable] + public class StartProductionInput + { + + /// <summary> + /// 浠诲姟缂栫爜 + /// </summary> + public string TaskCode { get; set; } + + ///// <summary> + ///// 宸ュ簭鍚嶇О + ///// </summary> + //public string ProcessName { get; set; } + + + } +} \ No newline at end of file diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs index 06bd5f4..7a43278 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs @@ -61,6 +61,7 @@ var traceProvider = _serviceProvider.GetRequiredService<ITraceProvider>(); var materialProvider = _serviceProvider.GetRequiredService<IMaterialProvider>(); var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>(); + var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>(); //Dictionary<string, object?> keyValuePairs = new Dictionary<string, object?> // { @@ -103,6 +104,9 @@ var firstWorkPlans = await workPlanAppService.GetListByFilterAsync(x => x.PipeSpecCode == input.PipeSpecCode); var firstWorkPlan = await workPlanAppService.GetSingleByFilterAsync(x => x.PipeSpecCode == input.PipeSpecCode); + + var callMaterialOrder = await callMaterialOrderAppService.GetSingleByFilterAsync(x => x.DataIdentifier == firstWorkPlan.DataIdentifier); + var rawPipe_DataIdentifier = await materialProvider.FindByNameAsync("鍘熸枡绠℃爣璇�"); var rawPipe_MaterialMode = await materialProvider.FindByNameAsync("鍘熸枡绠″瀷鍙�"); var rawPipe_Batch = await materialProvider.FindByNameAsync("鍘熸枡绠℃壒娆�"); @@ -141,7 +145,7 @@ Quantity = 1, MaterialId = rawPipe_Batch.MaterialId, MaterialDetailId = rawPipe_Batch.MaterialDetails.First().Id, - Value = "111",//鎵规鏆傛椂鍐欐 + Value = callMaterialOrder.MaterialBatch,//鎵规鏆傛椂鍐欐 }); } @@ -154,7 +158,30 @@ string _value = ""; if (item.Name == "鍒嗘嫞鏂瑰悜") { - _value = "鐭瑁呴厤"; + _value = "鐭鍒嗘嫞"; + } + if (item.Name == "鍒嗘嫞鎵樼洏鍙�") + { + _value = input.ContinerNo; + } + if (item.Name == "鍒嗘嫞浜�") + { + _value = myCurrentUser.UserAccount; + } + //item.Key + TraceParamModel traceParamModel = new TraceParamModel() + { + Key = item.Key, + Value = _value + }; + traceModel.Params.Add(traceParamModel); + }; + foreach (var item in workSection.FormulaParameters) + { + string _value = ""; + if (item.Name == "鍒嗘嫞鏂瑰悜") + { + _value = "鐭鍒嗘嫞"; } if (item.Name == "鍒嗘嫞鎵樼洏鍙�") { @@ -566,6 +593,434 @@ } /// <summary> + ///瑁呴厤/鐒婃帴寮�宸� + /// </summary> + /// <param name="input"></param> + /// <param name="_serviceProvider"></param> + /// <param name="myCurrentUser"></param> + /// <returns></returns> + /// <exception cref="UserFriendlyException"></exception> + public async Task<MesOrderResponse> StartProduction(StartProductionInput input, IServiceProvider _serviceProvider, MyCurrentUser myCurrentUser) + { + if (string.IsNullOrEmpty(input.TaskCode.ToString())) + { + throw new UserFriendlyException("浠诲姟缂栫爜涓嶈兘涓虹┖"); + } + + string processName = ""; + + VariableService _variableService = _serviceProvider.GetRequiredService<VariableService>(); + var callMaterialOrderRepository = _serviceProvider.GetRequiredService<ICallMaterialOrderRepository>(); + var workPlanRepository = _serviceProvider.GetRequiredService<IWorkPlanRepository>(); + var callMaterialOrderRecordRepository = _serviceProvider.GetRequiredService<ICallMaterialOrderRecordRepository>(); + var orderManager = _serviceProvider.GetRequiredService<IOrderManager>(); + var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>(); + + // 鏌ユ壘鏁版嵁 + + var workPlan = await workPlanRepository.GetSingleByFilterAsync(x => x.TaskCode == input.TaskCode); + if (workPlan == null) + { + throw new UserFriendlyException($"鎵句笉鍒颁綔涓氳鍒�"); + } + if (workPlan.ProcessName == "瑁呴厤宸ュ簭") + { + processName = "瑁呴厤"; + } + else if (workPlan.ProcessName == "鐒婃帴宸ュ簭") + { + processName = "鐒婃帴"; + } + + // 楠岃瘉鐘舵�� + if (workPlan.WorkPlanStatus != Domain.Shared.Enums.WorkPlanStatusEnum.鏆傚仠涓� && workPlan.WorkPlanStatus != Domain.Shared.Enums.WorkPlanStatusEnum.鏈敓浜�) + { + //鏆傛椂娉ㄩ噴 + //throw new UserFriendlyException($"浠诲姟缂栫爜 '{input.TaskCode}' 鐨勫綍鐘舵�佷负 '{workPlan.WorkPlanStatus}'锛屼笉鍏佽寮�宸�"); + } + + var callMaterialOrder = await callMaterialOrderAppService.GetSingleByFilterAsync(x => x.DataIdentifier == workPlan.DataIdentifier); + #region 浜嬪姟 + + using var scope = _serviceProvider.CreateScope(); + var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); + using var uow = unitOfWorkManager.Begin(requiresNew: true); + + try + { + #region 鏁版嵁澶勭悊 + + //1銆佹洿鏂颁綔涓氳鍒掕〃涓� 鐢熶骇涓� + //2銆佺粰PLC鍙戝伐鑹哄弬鏁版寚浠�,骞跺啓鍏� plc涓� 浜у搧id + //if (workPlan.ProcessName == "瑁呴厤宸ュ簭") + //{ + // workPlan.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.鐢熶骇涓�; + //} + //else if (workPlan.ProcessName == "鐒婃帴宸ュ簭") + //{ + // workPlan.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.宸插畬鎴�; + //} + if (workPlan.ProcessRouteNumber == "鏃�") + { + workPlan.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.宸插畬鎴�; + } + else + { + workPlan.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.鐢熶骇涓�; + } + + await workPlanRepository.UpdateAsync(workPlan); + + Dictionary<string, object?> keyValuePairs = new Dictionary<string, object?> + { + { $"{processName}_ProductID", workPlan.PipeSpecCode }, + { $"{processName}绠℃缂栫爜", workPlan.PipeSpecCode }, + { $"{processName}绠℃鍚嶇О", workPlan.PipeSectionName }, + { $"{processName}鍘熸枡绠℃壒娆�", callMaterialOrder.MaterialBatch }, + { $"{processName}鍘熸枡绠″瀷鍙�", callMaterialOrder.MaterialMode }, + { $"{processName}鍘熸枡绠℃爣璇�", callMaterialOrder.DataIdentifier }, + { $"{processName}椤圭洰鍙�", workPlan.ProjectNumber }, + { $"{processName}鑸瑰彿", workPlan.ShipNumber }, + + //閲囬泦鏁版嵁妯℃嫙鍐欏叆 + { $"{processName}鍘嬪姏", "10.0 MPa" }, + { $"{processName}閫熷害", "18mm/s"}, + + { $"{processName}浜�", myCurrentUser.UserAccount}, + { $"{processName}闂撮殭","15mm"}, + { $"{processName}浣嶇疆", "10,23,24"}, + }; + _variableService.WriteValueAsync(keyValuePairs); + + + #endregion + + await uow.CompleteAsync(); + + // 杩斿洖缁撴灉 + var response = new MesOrderResponse + { + Code = "200", + Message = "澶勭悊鎴愬姛", + Time = DateTime.UtcNow + }; + return response; + } + catch (Exception) + { + await uow.RollbackAsync(); + throw; + } + finally + { + + } + + + + #endregion + } + + + + /// <summary> + /// 瑁呴厤宸ュ簭瀹屽伐 + /// </summary> + /// <param name="_serviceProvider"></param> + /// <param name="input"></param> + /// <param name="myCurrentUser"></param> + /// <returns></returns> + public async Task<MesOrderResponse> CompleteAssemblyProcess(IServiceProvider _serviceProvider, CompleteAssemblyProcessInput input, MyCurrentUser myCurrentUser) + { + //1銆佽褰曞垎鎷h褰曡〃 + //2銆佹洿鏂颁綔涓氳鍒掕〃鐨勭姸鎬� =宸插垎鎷� + //3銆佸啓鍏� 鍒嗘嫞鍙橀噺 + //4銆佸啓鍏ヨ拷婧姤琛� + //5銆佺墿鏂欑粍鐩� + + if (string.IsNullOrEmpty(input.PipeSpecCode)) + { + throw new UserFriendlyException($"绠℃缂栫爜涓嶈兘涓虹┖"); + } + + + VariableService _variableService = _serviceProvider.GetRequiredService<VariableService>(); + var _workSectionManager = _serviceProvider.GetRequiredService<IWorkSectionManager>(); + var _workStationManager = _serviceProvider.GetRequiredService<IWorkStationManager>(); + var traceProvider = _serviceProvider.GetRequiredService<ITraceProvider>(); + var materialProvider = _serviceProvider.GetRequiredService<IMaterialProvider>(); + var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>(); + var workPlanRepository = _serviceProvider.GetRequiredService<IWorkPlanRepository>(); + var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>(); + + string processName = ""; + //鐗╂枡鍙傛暟鍒楄〃 + var firstWorkPlan = await workPlanAppService.GetSingleByFilterAsync(x => x.PipeSpecCode == input.PipeSpecCode && x.ProcessName == input.ProcessName); + if (firstWorkPlan == null) + { + throw new UserFriendlyException($"鎵句笉鍒颁綔涓氳鍒�"); + } + if (firstWorkPlan.ProcessName == "瑁呴厤宸ュ簭") + { + processName = "瑁呴厤"; + } + else if (firstWorkPlan.ProcessName == "鐒婃帴宸ュ簭") + { + processName = "鐒婃帴"; + } + + await CompleteHandleOutStoreFinish(_serviceProvider, processName, true); + + //鏍规嵁宸ュ簭鍚嶈幏鍙栧伐搴忓璞� + var workSection = await _workSectionManager.GetByNameAsync($"{processName}宸ュ簭"); + var workStation = await _workStationManager.GetByNameAsync($"{processName}宸ヤ綅"); + //鍐欏叆杩芥函鎶ヨ〃 + var finishTime = DateTime.Now; + TraceModel traceModel = new TraceModel() + { + SerialNumber = input.PipeSpecCode, + WorkSectionId = workSection.Id, + WorkSectionName = workSection.Name, + WorkStationName = workStation.Name, + + FinishTime = finishTime, + IsQualified = true, + UnqualifiedReason = "", + ProductModel = "", + ProductName = "", + + }; + traceModel.Params = new List<TraceParamModel>(); + foreach (var item in workSection.ProcessParameters) + { + var value = "ssss"; + traceModel.Params.Add(new TraceParamModel() + { + Key = item.Key, + Value = value.SafeString() + }); + } + + #region 浜嬪姟 + + using var scope = _serviceProvider.CreateScope(); + var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); + using var uow = unitOfWorkManager.Begin(requiresNew: true); + + try + { + #region 鏁版嵁澶勭悊 + + + + firstWorkPlan.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.宸插畬鎴�; + await workPlanRepository.UpdateAsync(firstWorkPlan); + + var callMaterialOrder = await callMaterialOrderAppService.GetSingleByFilterAsync(x => x.DataIdentifier == firstWorkPlan.DataIdentifier); + + var rawPipe_DataIdentifier = await materialProvider.FindByNameAsync("鍘熸枡绠℃爣璇�"); + var rawPipe_MaterialMode = await materialProvider.FindByNameAsync("鍘熸枡绠″瀷鍙�"); + var rawPipe_Batch = await materialProvider.FindByNameAsync("鍘熸枡绠℃壒娆�"); + var rawPipe_ProjectNumber = await materialProvider.FindByNameAsync("椤圭洰鍙�"); + var rawPipe_ShipNumber = await materialProvider.FindByNameAsync("鑸瑰彿"); + List<TraceMaterialModel> _MaterialParams = new List<TraceMaterialModel>(); + foreach (var item in workSection.MaterialParameters) + { + if (item.Name == "鍘熸枡绠″瀷鍙�") + { + _MaterialParams.Add(new TraceMaterialModel() + { + Key = item.Key, + Quantity = 1, + MaterialId = rawPipe_MaterialMode.MaterialId, + MaterialDetailId = rawPipe_MaterialMode.MaterialDetails.First().Id, + Value = firstWorkPlan.MaterialMode + + }); + } + if (item.Name == "鍘熸枡绠℃爣璇�") + { + _MaterialParams.Add(new TraceMaterialModel() + { + Key = item.Key, + Quantity = 1, + MaterialId = rawPipe_DataIdentifier.MaterialId, + MaterialDetailId = rawPipe_DataIdentifier.MaterialDetails.First().Id, + Value = firstWorkPlan.DataIdentifier, + + }); + } + if (item.Name == "鍘熸枡绠℃壒娆�") + { + _MaterialParams.Add(new TraceMaterialModel() + { + Key = item.Key, + Quantity = 1, + MaterialId = rawPipe_Batch.MaterialId, + MaterialDetailId = rawPipe_Batch.MaterialDetails.First().Id, + Value = callMaterialOrder.MaterialBatch,//鎵规鏆傛椂鍐欐 + + }); + } + if (item.Name == "椤圭洰鍙�") + { + _MaterialParams.Add(new TraceMaterialModel() + { + Key = item.Key, + Quantity = 1, + MaterialId = rawPipe_ProjectNumber.MaterialId, + MaterialDetailId = rawPipe_ProjectNumber.MaterialDetails.First().Id, + Value = firstWorkPlan.ProjectNumber, + + }); + } + if (item.Name == "鑸瑰彿") + { + _MaterialParams.Add(new TraceMaterialModel() + { + Key = item.Key, + Quantity = 1, + MaterialId = rawPipe_ShipNumber.MaterialId, + MaterialDetailId = rawPipe_ShipNumber.MaterialDetails.First().Id, + Value = firstWorkPlan.ShipNumber, + + }); + } + }; + + //閰嶇疆杩囩▼鍙傛暟(閲囬泦鍙傛暟銆侀厤鏂瑰弬鏁�) + traceModel.Params = new List<TraceParamModel>(); + foreach (var item in workSection.ProcessParameters) + { + string _value = ""; + + //閲囬泦鍙傛暟 + if (item.Name == $"{processName}鍘嬪姏") + { + var _getValue = await _variableService.ReadValueAsync($"{processName}鍘嬪姏"); + _value = _getValue.Content.Value.SafeString().ToString(); + } + if (item.Name == $"{processName}浣嶇疆") + { + var _getValue = await _variableService.ReadValueAsync($"{processName}浣嶇疆"); + _value = _getValue.Content.Value.SafeString().ToString(); + } + if (item.Name == $"{processName}閫熷害") + { + var _getValue = await _variableService.ReadValueAsync($"{processName}閫熷害"); + _value = _getValue.Content.Value.SafeString().ToString(); + } + + if (item.Name == $"{processName}闂撮殭") + { + _value = "15mm"; + } + if (item.Name == $"{processName}浜�") + { + _value = myCurrentUser.UserAccount; + } + //item.Key + TraceParamModel traceParamModel = new TraceParamModel() + { + Key = item.Key, + Value = _value + }; + traceModel.Params.Add(traceParamModel); + }; + foreach (var item in workSection.FormulaParameters) + { + string _value = ""; + + //閲囬泦鍙傛暟 + if (item.Name == $"{processName}鍘嬪姏") + { + var _getValue = await _variableService.ReadValueAsync($"{processName}鍘嬪姏"); + _value = _getValue.Content.Value.SafeString().ToString(); + } + if (item.Name == $"{processName}浣嶇疆") + { + var _getValue = await _variableService.ReadValueAsync($"{processName}浣嶇疆"); + _value = _getValue.Content.Value.SafeString().ToString(); + } + if (item.Name == $"{processName}閫熷害") + { + var _getValue = await _variableService.ReadValueAsync($"{processName}閫熷害"); + _value = _getValue.Content.Value.SafeString().ToString(); + } + + if (item.Name == $"{processName}闂撮殭") + { + _value = "15mm"; + } + if (item.Name == $"{processName}浜�") + { + _value = myCurrentUser.UserAccount; + } + //item.Key + TraceParamModel traceParamModel = new TraceParamModel() + { + Key = item.Key, + Value = _value + }; + traceModel.Params.Add(traceParamModel); + }; + + traceModel.MaterialParams = _MaterialParams; + + await traceProvider.CreateTraceAsync(traceModel); + + var response = new MesOrderResponse + { + Code = "200", + Data = "", + Message = "澶勭悊鎴愬姛", + Time = DateTime.UtcNow + }; + return response; + + #endregion + + await uow.CompleteAsync(); + } + catch (Exception) + { + await uow.RollbackAsync(); + throw; + } + finally + { + + } + + + + #endregion + + } + + + /// <summary> + /// 鍏叡澶勭悊 鍝嶅簲鍑虹珯瀹屾垚淇″彿 + /// </summary> + /// <param name="_serviceProvider"></param> + /// <param name="input"></param> + /// <param name="myCurrentUser"></param> + /// <returns></returns> + public async Task CompleteHandleOutStoreFinish(IServiceProvider _serviceProvider, string processName, bool isOutResult) + { + + VariableService _variableService = _serviceProvider.GetRequiredService<VariableService>(); + + Dictionary<string, object?> keyValuePairs = new Dictionary<string, object?> + { + { $"{processName}鍑虹珯瀹屾垚",isOutResult}, + { $"{processName}鍑虹珯缁撴灉",isOutResult? "鎴愬姛":""}, + }; + await _variableService.WriteValueAsync(keyValuePairs); + + } + + /// <summary> /// 鐢熸垚闅忔満鐨刉msTaskNo /// </summary> /// <returns>闅忔満鐢熸垚鐨勪换鍔$紪鍙�</returns> diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/Controller/WorkPlanPublicController.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/Controller/WorkPlanPublicController.cs index 0ad0a16..c2ecf7d 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/Controller/WorkPlanPublicController.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/Controller/WorkPlanPublicController.cs @@ -60,12 +60,23 @@ [Route("Pick")] public virtual async Task<MesOrderResponse> Pick([FromBody] PickInput input) { - MyCurrentUser myCurrentUser = new MyCurrentUser() + try { - UserAccount = _currentUser.UserAccount, - UserId = _currentUser.UserId - }; - return await sharedService.CommonPick(_serviceProvider, input, myCurrentUser); + 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 + }; + } } @@ -79,14 +90,81 @@ [Route("CallMaterial")] public virtual async Task<MesOrderResponse> CallMaterial([FromBody] CallMaterialByDataIdentifierInput input) { - MyCurrentUser myCurrentUser = new MyCurrentUser() + try { - UserAccount = _currentUser.UserAccount, - UserId = _currentUser.UserId - }; - return await sharedService.CallMaterial(input, _serviceProvider, myCurrentUser); + 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 + }; + } + } } } diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs index 3d83626..d3853a7 100644 --- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs +++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems/ProjectService/PipeLineLemsProjectService.cs @@ -22,6 +22,8 @@ using System.Collections.Generic; using CMS.Framework.AspNetCore.Users; using NPOI.SS.Formula.Functions; +using CMS.Plugin.PipeLineLems.Application.Implements; +using CmsQueryExtensions.Entitys; namespace CMS.Plugin.PipeLineLems.ProjectService { @@ -90,6 +92,8 @@ { "璇锋眰鐢熸垚鎵撶爜浜у搧鐮佷俊鍙�", "璇锋眰鐢熸垚鎵撶爜浜у搧鐮佷俊鍙�(鎻忚堪)" }, { "璇锋眰鐢熸垚鍒囧壊浜у搧鐮佷俊鍙�", "璇锋眰鐢熸垚鍒囧壊浜у搧鐮佷俊鍙�(鎻忚堪)" }, { "鍒囧壊杩涚珯淇″彿", "鍒囧壊杩涚珯淇″彿(鎻忚堪)" }, + + { "瑁呴厤瀹屽伐淇″彿", "瑁呴厤瀹屽伐淇″彿(鎻忚堪)" }, }; // 鍒涘缓閫氶亾鐩戝惉 @@ -253,6 +257,25 @@ _ = Task.Run(async () => { await HanlderForCutByCreateProductWhenFlaseAsync(); + }); + } + } + + + if (changed.Name == "瑁呴厤瀹屽伐淇″彿") + { + if (changed.New?.Value.SafeString().ToBool() == true) + { + _ = Task.Run(async () => + { + await HanlderFor瑁呴厤瀹屽伐淇″彿Async(); + }); + } + else + { + _ = Task.Run(async () => + { + await HanlderFor瀹屽伐淇″彿WhenFalseAsync("瑁呴厤"); }); } } @@ -778,5 +801,67 @@ }; var ret = _variableService.WriteValueAsync(keyValuePairs_productID); } + + + + /// <summary> + /// 瑁呴厤瀹屽伐淇″彿=true鏃� + /// </summary> + /// <returns></returns> + private async Task HanlderFor瑁呴厤瀹屽伐淇″彿Async() + { + + var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>(); + var workPlanRepository = _serviceProvider.GetRequiredService<IWorkPlanRepository>(); + var callMaterialOrderAppService = _serviceProvider.GetRequiredService<ICallMaterialOrderAppService>(); + + var pipeSpecCode = await _variableService.ReadValueAsync("瑁呴厤绠℃缂栫爜"); + + if (string.IsNullOrEmpty(pipeSpecCode?.Content?.Value.SafeString().ToString())) + { + + } + else + { + + + + var myPipeSpecCode = pipeSpecCode.Content.Value.SafeString().ToString(); + CallMaterialOrder callMaterialOrder = null; + try + { + var sharedService = _serviceProvider.GetRequiredService<SharedService>(); + var userName = await _variableService.ReadValueAsync("瑁呴厤浜�"); + MyCurrentUser myCurrentUser = new MyCurrentUser() + { + UserAccount = userName.Content.Value.SafeString().ToString() + }; + sharedService.CompleteAssemblyProcess(_serviceProvider, new Application.Contracts.Dtos.WorkPlan.CompleteAssemblyProcessInput() { PipeSpecCode = myPipeSpecCode, ProcessName="瑁呴厤宸ュ簭" }, myCurrentUser); + + } + catch (Exception) + { + + } + } + } + + /// <summary> + /// 瀹屽伐淇″彿=false鏃� + /// </summary> + /// <returns></returns> + private async Task HanlderFor瀹屽伐淇″彿WhenFalseAsync(string processName) + { + try + { + var sharedService = _serviceProvider.GetRequiredService<SharedService>(); + await sharedService.CompleteHandleOutStoreFinish(_serviceProvider, processName, false); + } + catch (Exception) + { + + + } + } } } -- Gitblit v1.9.3