Bladeren bron

维护已扫码数量

hh 3 weken geleden
bovenliggende
commit
a41ad8e2f4

+ 39 - 17
entry/src/main/ets/pages/ProcessIndex.ets

@@ -106,6 +106,15 @@ struct ProcessIndex {
   @State seqList: WorkOrderSeq[] = []
   // 设备每日点检
   @State deviceChecks: ProcessDeviceDailyCheck[] = []
+  // 报工人信息
+  @State reporterList: ReportInfo[] = []
+  @State currentReporterIndex:number =0
+  @State currentReportNumIndex:number =0
+  @State currentDefectIndex:number =0
+  // mqtt是否连接
+  @State isConnected: boolean = false
+  // 当前订单扫码流水号数量
+  @State scanSeqNos: number = 0
 
   private scrollerList: Scroller = new Scroller()
 
@@ -120,12 +129,7 @@ struct ProcessIndex {
   @Provide('currentUserId') currentUserId: number = 0
   // 报工人、报工流水号和不良流水号
   @Provide('bindTaskSeq') bindTaskSeq: BindTaskSeq[] = []
-  @State reporterList: ReportInfo[] = []
-  @State currentReporterIndex:number =0
-  @State currentReportNumIndex:number =0
-  @State currentDefectIndex:number =0
-  // mqtt是否连接
-  @State isConnected: boolean = false
+
   startWorkTime: string = ''
   // 工位发生改变则可能需要重新选择工单
   async refreshWorkOrder() {
@@ -176,6 +180,9 @@ struct ProcessIndex {
       workOrderCode: this.selectWorkOder.workOrderCode!,
       stationId: this.currentStationId
     } as RequestParamModel)
+    if (!this.seqNo) {
+      this.seqNo = this.scanCode
+    }
     this.opComponents = []
     if (this.process && this.process.id) {
       this.opComponents = await ProcessRequest.get(`/api/v1/process/opCompent/get/${this.selectOperationId!}/${this.process?.id!}`)
@@ -206,6 +213,7 @@ struct ProcessIndex {
     }
     seqNos.push(this.seqNo)
     preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNos)
+    this.scanSeqNos = seqNos.length
     if (!this.startWorkTime) {
       this.startWorkTime = TimeUtil.getCurrentTime()
     }
@@ -232,16 +240,23 @@ struct ProcessIndex {
       sortNum: 0
     })
   }
+
+  // 刷新当前工单已扫码流水号数量
+  async refreshScanSeqNos() {
+    let seqNoList: string[] = []
+    seqNoList = await preferencesUtil.get(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNoList)
+    this.scanSeqNos = seqNoList.length
+  }
   // 清除选中的相关数据(工单不做处理)
   clearSelectData() {
     this.selectOperationId = ''
     this.seqNo = ''
+    this.scanCode = ''
     this.seqList = []
     this.scanState = 0
     this.process = {}
     this.opComponents = []
     this.taskSeqArray = []
-    preferencesUtil.clear(CommonConstants.PREFERENCE_INSTANCE_NAME)
     this.handleAllClick()
   }
 
@@ -340,6 +355,8 @@ struct ProcessIndex {
     // 判断是否选中工单,未选择则选则工单
     if (!this.selectWorkOder || !this.selectWorkOder.workOrderCode) {
       this.selectOrderController.open()
+    } else {
+      this.refreshScanSeqNos()
     }
     //判断今日是否进行设备点检,否则先进行点检
     this.deviceChecks = await ProcessRequest.post('/api/v1/process/deviceDailyCheck/list', {
@@ -569,13 +586,12 @@ struct ProcessIndex {
                           promptAction.showToast({
                             message: `${item.operationName}需要在${item.stationName}工位上生产`,
                             duration: 1500,
-                            bottom: 100
                           })
                           if (this.scanCode) {
                             // 未开工查询工序组件
                             this.getComponentsForNotStartWork()
                           }
-                        } else if (this.scanState === 0 && this.scanCode) {
+                        } else if (this.scanState === 0 && this.seqNo) {
                           // 未开工查询工序组件
                           this.getComponentsForNotStartWork()
                         } else if (this.scanState === 1) {
@@ -729,6 +745,7 @@ struct ProcessIndex {
                         }
                         seqNos.push(this.seqNo)
                         preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode, seqNos)
+                        this.scanSeqNos = seqNos.length
                       })
                   }
                   .width('65%')
@@ -802,7 +819,7 @@ struct ProcessIndex {
                     selectOperationId: this.selectOperationId,
                     process: this.process,
                   })
-                } else if (this.selectComponentType === '3' && this.scanState == 1) {
+                } else if (this.selectComponentType === '3' && this.scanState === 1) {
                   MultiMediaCollect({
                     seqNo: this.seqNo,
                     selectOperationId: this.selectOperationId,
@@ -908,10 +925,14 @@ struct ProcessIndex {
               })
             Column({ space: 2 }) {
               Row() {
-                Text((this.selectWorkOder && this.selectWorkOder.workOrderCode) ? parseInt(this.selectWorkOder.completeNum!) + '/' + parseInt(this.selectWorkOder.planNum) : '')
+                Text(this.scanSeqNos + '/')
                   .fontColor($r('app.color.FFFFFF'))
                   .fontSize($r('app.float.fontSize_16'))
                   .fontWeight(FontWeight.Lighter)
+                Text((this.selectWorkOder && this.selectWorkOder.workOrderCode) ? parseInt(this.selectWorkOder.planNum).toString() : '')
+                  .fontColor($r('app.color.60FFFFFF'))
+                  .fontSize($r('app.float.fontSize_16'))
+                  .fontWeight(FontWeight.Lighter)
               }
               .width('100%')
               .height('50%')
@@ -1333,13 +1354,14 @@ struct ProcessIndex {
   // 切换产品弹窗控制器
   switchingProductDialogController: CustomDialogController = new CustomDialogController({
     builder: SwitchingProductDialog({
-      scanState:this.scanState,
-      process:this.process,
+      scanState: this.scanState,
+      process: this.process,
       scanSeqValue: this.scanCode,
-      selectWorkOder:this.selectWorkOder,
-      currentOperationId:this.selectOperationId,
-      opComponents:this.opComponents,
-      seqNo:this.seqNo,
+      selectWorkOder: this.selectWorkOder,
+      currentOperationId: this.selectOperationId,
+      opComponents: this.opComponents,
+      seqNo: this.seqNo,
+      scanSeqNos: this.scanSeqNos,
     }),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,

+ 30 - 1
entry/src/main/ets/view/ReportPieceworkDialog.ets

@@ -6,6 +6,8 @@ import RequestParamModel from '../viewmodel/RequestParamModel'
 import WorkOrderInfo from '../viewmodel/WorkOrderInfo'
 import promptAction from '@ohos.promptAction'
 import ProcessInfo from '../viewmodel/process/ProcessInfo'
+import preferencesUtil from '../common/util/PerferencesUtil'
+import CommonConstants from '../common/constants/CommonConstants'
 
 //工序(计件)报工
 @CustomDialog
@@ -365,13 +367,40 @@ export struct ReportPieceworkDialog {
             }
             if (!this.bindTaskSeq || this.bindTaskSeq.length <= 0) {
               promptAction.showToast({
-                message: '请先选择用户和报工的流水号',
+                message: '请先选择用户',
                 duration: 2000
               });
               return;
             }
+            for (const taskSeq of this.bindTaskSeq) {
+              if ((!taskSeq.reportSeqNos || taskSeq.reportSeqNos.length <= 0) && (!taskSeq.defectSeqNos || taskSeq.defectSeqNos.length <= 0)) {
+                promptAction.showToast({
+                  message: `请选择${taskSeq.userName}}报工的流水号或者不良流水号`,
+                  duration: 2000
+                });
+                return;
+              }
+            }
             this.bindTaskSeq[0].processId = this.process.id!
             await ProcessRequest.post('/api/v1/process/info/reportByPiecework', this.bindTaskSeq)
+            let seqNos: string[] = []
+            for (const taskSeq of this.bindTaskSeq) {
+              if (taskSeq.reportSeqNos && taskSeq.reportSeqNos.length > 0) {
+                seqNos.concat(taskSeq.reportSeqNos)
+              }
+              if (taskSeq.defectSeqNos && taskSeq.defectSeqNos.length > 0) {
+                seqNos.concat(taskSeq.defectSeqNos)
+              }
+            }
+            // 删除已报工的seqNo,并保存到数据库中
+            let seqNoList: string[] = []
+            seqNoList = await preferencesUtil.get(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNoList)
+            if (seqNoList.length === seqNos.length) {
+              preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, [])
+            } else {
+              seqNoList = seqNoList.filter(item => !seqNos.includes(item));
+              await preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNoList)
+            }
             this.clearSelectData()
             this.controller.close();
           })

+ 11 - 0
entry/src/main/ets/view/ReportTimeBasedDialog.ets

@@ -9,6 +9,8 @@ import WorkOrderInfo from '../viewmodel/WorkOrderInfo'
 import promptAction from '@ohos.promptAction'
 import ProcessReportTimeBased from '../viewmodel/process/ProcessReportTimeBased'
 import { BindTaskSeq } from '../viewmodel/process/BindTaskSeq'
+import preferencesUtil from '../common/util/PerferencesUtil'
+import CommonConstants from '../common/constants/CommonConstants'
 
 @CustomDialog
 export struct ReportTimeBasedDialog {
@@ -452,6 +454,15 @@ export struct ReportTimeBasedDialog {
               processUserReportList: this.reporterList,
               seqList: seqNos
             } as ProcessReportTimeBased)
+            // 删除已报工的seqNo,并保存到数据库中
+            let seqNoList: string[] = []
+            seqNoList = await preferencesUtil.get(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNoList)
+            if (seqNoList.length === seqNos.length) {
+              preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, [])
+            } else {
+              seqNoList = seqNoList.filter(item => !seqNos.includes(item));
+              await preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNoList)
+            }
             this.clearSelectData()
             this.controller.close();
           })

+ 4 - 0
entry/src/main/ets/view/ReportWorkHourRateDialog.ets

@@ -14,6 +14,10 @@ export struct ReportWorkHourRateDialog {
   rateNum: number = 50
   private rateList: string[] = ['10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%']
 
+  aboutToAppear(): void {
+    this.rateNum = Number.parseFloat(this.rateList[this.selectIndex].slice(0, -1) as string)
+  }
+
   build() {
     Column(){
       Column() {

+ 3 - 0
entry/src/main/ets/view/SwitchingProductDialog.ets

@@ -36,6 +36,8 @@ export struct SwitchingProductDialog{
   @Link scanState: number
   // 当前流转卡号
   @Link seqNo: string
+  // 当前订单扫码流水号数量
+  @Link scanSeqNos: number
 
   controller: CustomDialogController
   onQueryTask = async (currentStateList: Array<number>): Promise<number> => {
@@ -341,6 +343,7 @@ export struct SwitchingProductDialog{
             }
             seqNos.push(this.seqNo)
             preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNos)
+            this.scanSeqNos = seqNos.length
             this.controller.close();
           })
         }