Explorar o código

处理报工一些bug

hh hai 2 semanas
pai
achega
979208b69a

+ 9 - 9
entry/src/main/ets/model/ElectricScrewdriverPresetModel.ets

@@ -26,17 +26,17 @@ class ElectricScrewdriverPresetModel {
       console.info('hhtest', `getRdbStore err ${JSON.stringify(err)}`);
     }
     // 2.初始化SQL语句
-    const sql = `CREATE TABLE IF NOT EXISTS` + this.tableName + `(
+    const sql = `CREATE TABLE IF NOT EXISTS ElectricScrewdriverPreset(
                   ID INTEGER PRIMARY KEY AUTOINCREMENT,
                   SET_NAME VARCHAR NOT NULL,
-                  ROTATION_DIRECTION REAL NULL,
-                  HOLD_TIME REAL NULL,
-                  TARGET_TORQUE REAL NULL,
-                  MAX_TORQUE_DEVIATION REAL NULL,
-                  MIN_TORQUE_DEVIATION REAL NULL,
-                  DETECTION_STATUS number NULL,
-                  FLOAT_HEIGHT_TURN REAL NULL,
-                  THREAD_STRIP_TURN REAL NULL,
+                  ROTATION_DIRECTION INTEGER NULL,
+                  HOLD_TIME INTEGER NULL,
+                  TARGET_TORQUE INTEGER NULL,
+                  MAX_TORQUE_DEVIATION INTEGER NULL,
+                  MIN_TORQUE_DEVIATION INTEGER NULL,
+                  DETECTION_STATUS INTEGER NULL,
+                  FLOAT_HEIGHT_TURN INTEGER NULL,
+                  THREAD_STRIP_TURN INTEGER NULL
                  )`
     // 3.获取rdb
     relationalStore.getRdbStore(context, config, (err, rdbStore) => {

+ 29 - 6
entry/src/main/ets/pages/ProcessIndex.ets

@@ -29,7 +29,6 @@ import { MqttClientOptions, MqttConnectOptions } from '@ohos/mqtt';
 import MqttManager from '../common/util/mqtt';
 import { UnqualifiedReportDialog } from '../view/UnqualifiedReportDialog';
 import { SelfInspectView } from '../view/process/SelfInspectView';
-import { SpecialInspectionDialog } from '../view/SpecialInspectionDialog';
 import { MultiMediaCollect } from '../view/process/MultiMediaCollect';
 import { BarcodeAssociationDialog } from '../view/BarcodeAssociationDialog';
 import WorkOrderSeq from '../viewmodel/WorkOrderSeq';
@@ -41,6 +40,7 @@ import { AuxiliaryOperationView } from '../view/AuxiliaryOperationView';
 import { BusinessError } from '@ohos.base';
 import window from '@ohos.window';
 import { EquipmentInspectionDialog } from '../view/EquipmentInspectionDialog';
+import preferencesUtil from '../common/util/PerferencesUtil';
 
 // 声明接受参数的类型
 interface Params {
@@ -65,6 +65,8 @@ struct ProcessIndex {
   @State isAuxiliaryViewOpen:boolean = false
   // 选中工序id
   @State selectOperationId: string = ''
+  // 选中工序名称
+  selectOperationName: string = ''
   //选择的按钮索引(默认加载全部)
   @State selectedButtonIndex: number = 0
   // 流转卡号信息集合
@@ -142,7 +144,7 @@ struct ProcessIndex {
       console.log('hhtest', '选择工单被清空-----------------')
     }
   }
-
+  // 扫码开工
   async scanCodeToStartWork() {
     this.process = await ProcessRequest.post('/api/v1/process/info/scan', {
       operationId: this.selectOperationId,
@@ -172,6 +174,14 @@ struct ProcessIndex {
       })
     }
     this.scanState = 1
+    // 保存此流转卡号到数据库中
+    let seqNos: string[] = []
+    seqNos = await preferencesUtil.get(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNos)
+    if (seqNos.includes(this.seqNo)) {
+      return
+    }
+    seqNos.push(this.seqNo)
+    preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNos)
   }
 
   handleAllClick():void {
@@ -314,7 +324,6 @@ struct ProcessIndex {
         .justifyContent(FlexAlign.Start)
         .onClick(() => {
           // router.back()
-          const context = getContext(this)
           window.getLastWindow(getContext()).then((data) => {
             //获取窗口对象
             let windowClass = data;
@@ -485,6 +494,7 @@ struct ProcessIndex {
                           return
                         }
                         this.selectOperationId = item.operationId!
+                        this.selectOperationName = item.operationName!
                         if (!item.exists) {
                           promptAction.showToast({
                             message: `${item.operationName}需要在${item.stationName}工位上生产`,
@@ -632,6 +642,14 @@ struct ProcessIndex {
                           sortNum: 0
                         })
                         this.seqNo = this.scanCode
+                        // 保存此流转卡号到数据库中
+                        let seqNos: string[] = []
+                        seqNos = await preferencesUtil.get(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode, seqNos)
+                        if (seqNos.includes(this.seqNo)) {
+                          return
+                        }
+                        seqNos.push(this.seqNo)
+                        preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode, seqNos)
                       })
                   }
                   .width('65%')
@@ -1017,6 +1035,8 @@ struct ProcessIndex {
   ReportWorkNumController: CustomDialogController = new CustomDialogController({
     builder: ReportWorkNumDialog({
       userName: this.reportList[this.currentReportNumIndex].userName,
+      currentOperationId: this.selectOperationId,
+      currentWorkOrderCode: this.selectWorkOder.workOrderCode!,
       onConfirm:(num:number)=>{
         const index = this.currentReportNumIndex;
         if (this.reportList[index]) {
@@ -1104,7 +1124,10 @@ struct ProcessIndex {
         this.currentUnqualifiedIndex = index
         this.UnqualifiedReportController.open()
       },
-      reportList:this.reportList
+      reportList:this.reportList,
+      selectWorkOder: this.selectWorkOder,
+      selectOperationName: this.selectOperationName,
+      selectOperationId: this.selectOperationId
     }),
     autoCancel: true,
     customStyle: true,
@@ -1141,10 +1164,10 @@ struct ProcessIndex {
       scanState:this.scanState,
       process:this.process,
       scanSeqValue: this.scanCode,
-      currentStationId:this.currentStationId,
       selectWorkOder:this.selectWorkOder,
       currentOperationId:this.selectOperationId,
-      opComponents:this.opComponents
+      opComponents:this.opComponents,
+      seqNo:this.seqNo,
     }),
     autoCancel: true, // 点击遮罩关闭
     customStyle: true,

+ 3 - 4
entry/src/main/ets/view/JoinPersonNameDialog.ets

@@ -40,10 +40,9 @@ export struct JoinPersonNameDialog{
   }
 
   loadPersonNameList = async ()=>{
-    let res = await ProcessRequest.post('/api/v1/sys/user/page', {
+    this.nameList = await ProcessRequest.post('/api/v1/sys/user/list', {
       userName:this.queryName
-    } as RequestParamModel) as PageInfo;
-    this.nameList = res.records as UserInfo[] || []
+    } as RequestParamModel)
     for(let i = 0; i < this.nameList.length; i++) {
       let pinyinStr = pinyin(this.nameList[i].userName, { toneType: "none" });
       let index = pinyinStr.substring(0, 1).toUpperCase();
@@ -122,7 +121,7 @@ export struct JoinPersonNameDialog{
           ForEach(this.nameList, (item:UserInfo,index) => {
             ListItem() {
               Column(){
-                if (index==0||this.nameList[index-1].nameInitial != item.nameInitial){
+                if (index===0||this.nameList[index-1].nameInitial != item.nameInitial){
                   Row(){
                     Text(item.nameInitial)
                       .fontColor($r('app.color.FFFFFF'))

+ 1 - 1
entry/src/main/ets/view/ModifyMaterialNumDialog.ets

@@ -100,7 +100,7 @@ export struct ModifyMaterialNumDialog {
           .fontSize($r('app.float.fontSize_16'))
           .fontWeight(FontWeight.Lighter)
       }
-      .height($r('app.float.virtualSize_56'))
+      .height($r('app.float.virtualSize_80'))
       .width('70.4%')
       .justifyContent(FlexAlign.Start)
       .alignItems(HorizontalAlign.Start)

+ 15 - 12
entry/src/main/ets/view/ProcessReportingDialog.ets

@@ -11,25 +11,23 @@ export struct ProcessReportingDialog{
   private scrollerList: Scroller = new Scroller()
   //查询报工
   @Link reportList: ReportInfo[]
-  //当前工单号
-  @State currentWorkOrderCode:string = ''
-  //当前工序号
-  @State currentOperationId:string = ''
+  //选中的工序id
+  @Link selectOperationId:string
   //当前工位
-  @State currentStationId:string = ''
+  @Consume('currentStationId') currentStationId: string
   //选择的按钮索引(默认加载全部)
   @State addReportingClick: number = 1
   //从首页传来的工单
-  @Prop selectWorkOder: WorkOrderInfo = {}
+  @Link selectWorkOder: WorkOrderInfo
   //工序名字
-  @Prop selectProcessName:string = '正面三防'
+  selectOperationName: string = ''
   //当前工序已报工数量
   @State reportedNum:number = 0
   //计划报工数量
   @State planReportNum:number = 0
   //扫描的流水号/序列/铭牌号
   @State scanSeqValue: string = ''
-  @State userName:string = '王德发'
+  @Consume('currentUserName') userName: string
   @State currentReporterIndex: number = 0; // 记录当前点击的报工人索引
   @Consume ('bindTaskSeq') bindTaskSeq: BindTaskSeqVO[]
 
@@ -53,6 +51,9 @@ export struct ProcessReportingDialog{
 
   //加载第一个报工人(无法删除)
   loadFirstReport=async ()=>{
+    if (this.reportList.length > 0) {
+      return
+    }
     const firstReporter:ReportInfo= {}
     firstReporter.userName = this.userName
     this.reportList.push(firstReporter)
@@ -61,8 +62,8 @@ export struct ProcessReportingDialog{
   onQueryTask = async (currentStateList: Array<number>): Promise<number> => {
     let res = await ProcessRequest.post('/api/v1/plan/task/list', {
       stationId: this.currentStationId,
-      workOrderCode: this.currentWorkOrderCode,
-      operationId: this.currentOperationId,
+      workOrderCode: this.selectWorkOder.workOrderCode!,
+      operationId: this.selectOperationId,
       stateList: currentStateList
     } as RequestParamModel) as TaskSeqVO[];
     return res.length;
@@ -78,6 +79,8 @@ export struct ProcessReportingDialog{
 
   aboutToAppear(): void {
     this.loadFirstReport()
+    this.handleAllClick()
+    this.handleReportedClick()
   }
 
 
@@ -122,7 +125,7 @@ export struct ProcessReportingDialog{
                 .fontSize($r('app.float.fontSize_16'))
                 .fontColor($r('app.color.FFFFFF'))
                 .fontWeight(FontWeight.Lighter)
-              Text(this.selectProcessName)
+              Text(this.selectOperationName)
                 .fontSize($r('app.float.fontSize_16'))
                 .fontColor($r('app.color.FFFFFF'))
             }
@@ -188,7 +191,7 @@ export struct ProcessReportingDialog{
                 ListItem() {
                   Row(){
                     Column(){
-                      Text(`报工人${index}`)
+                      Text(`报工人${index+1}`)
                         .fontColor($r('app.color.FFFFFF'))
                         .fontSize($r('app.float.fontSize_16'))
                         .fontWeight(FontWeight.Regular)

+ 16 - 2
entry/src/main/ets/view/ReportWorkNumDialog.ets

@@ -3,6 +3,8 @@ import ProcessRequest from '../common/util/request/ProcessRequest';
 import { BindTaskSeqVO } from '../viewmodel/BindTaskSeqVO';
 import TaskSeqVO from '../viewmodel/process/TaskSeqInfo';
 import RequestParamModel from '../viewmodel/RequestParamModel';
+import preferencesUtil from '../common/util/PerferencesUtil';
+import CommonConstants from '../common/constants/CommonConstants';
 
 @CustomDialog
 export struct ReportWorkNumDialog{
@@ -19,7 +21,7 @@ export struct ReportWorkNumDialog{
   //当前工序号
   @State currentOperationId:string = ''
   //当前工位
-  @State currentStationId:string = ''
+  @Consume('currentStationId') currentStationId:string
   //总数量
   @State totalNum:number= 0
   //查询报工
@@ -29,12 +31,24 @@ export struct ReportWorkNumDialog{
   @State selectedIndexes:number[] =[]
 
   onQueryTask=async ()=>{
-    this.queryTaskSeq = await ProcessRequest.post('/api/v1/plan/task/list', {
+    let result: TaskSeqVO[] = await ProcessRequest.post('/api/v1/plan/task/list', {
       stationId:this.currentStationId,
       workOrderCode:this.currentWorkOrderCode,
       operationId:this.currentOperationId,
       stateList:[-1,0,1]
     } as RequestParamModel) as TaskSeqVO[];
+    let seqNos: string[] = []
+    seqNos = await preferencesUtil.get(CommonConstants.PREFERENCE_INSTANCE_NAME, this.currentWorkOrderCode, seqNos)
+    if (!seqNos || seqNos.length <= 0) {
+      this.queryTaskSeq = []
+      this.totalNum = 0
+      return
+    }
+    for (const element of result) {
+      if (seqNos.includes(element.seqNo!)) {
+        this.queryTaskSeq.push(element)
+      }
+    }
     this.totalNum = this.queryTaskSeq.length
   }
 

+ 53 - 6
entry/src/main/ets/view/SwitchingProductDialog.ets

@@ -1,11 +1,13 @@
 //切换产品
 import CommonConstants from '../common/constants/CommonConstants'
+import preferencesUtil from '../common/util/PerferencesUtil'
 import ProcessRequest from '../common/util/request/ProcessRequest'
 import OperationComponent from '../viewmodel/process/OperationComponent'
 import ProcessInfo from '../viewmodel/process/ProcessInfo'
 import TaskSeqVO from '../viewmodel/process/TaskSeqInfo'
 import RequestParamModel from '../viewmodel/RequestParamModel'
 import WorkOrderInfo from '../viewmodel/WorkOrderInfo'
+import promptAction from '@ohos.promptAction'
 
 @CustomDialog
 export struct SwitchingProductDialog{
@@ -13,11 +15,11 @@ export struct SwitchingProductDialog{
   //查询报工
   @State queryTaskSeq: TaskSeqVO[] = []
   //选中的工单
-  @State selectWorkOder: WorkOrderInfo = {}
+  @Link selectWorkOder: WorkOrderInfo
   //当前工序号
-  @Prop currentOperationId:string = ''
+  @Link currentOperationId: string
   //当前工位
-  @Prop currentStationId:string = ''
+  @Consume('currentStationId') currentStationId: string
   //当前工序已报工数量
   @State reportedNum:number = 0
   //计划报工数量
@@ -32,10 +34,12 @@ export struct SwitchingProductDialog{
   @Link process: ProcessInfo
   // 扫码开工状态(0:未开工 1:已开工)
   @Link scanState: number
+  // 当前流转卡号
+  @Link seqNo: string
 
   controller: CustomDialogController
   onQueryTask = async (currentStateList: Array<number>): Promise<number> => {
-    let res = await ProcessRequest.post('/api/v1/plan/seq/list', {
+    let res = await ProcessRequest.post('/api/v1/plan/task/list', {
       stationId:this.currentStationId,
       workOrderCode:this.selectWorkOder.workOrderCode,
       operationId:this.currentOperationId,
@@ -229,7 +233,23 @@ export struct SwitchingProductDialog{
              .fontColor($r('app.color.FFFFFF'))
              .enableKeyboardOnFocus(false)
              .onSubmit(() => {
-
+               // 流转卡号是否有效
+               let seqNoFlag = false
+               for (const element of this.queryTaskSeq) {
+                 if (element.seqNo === this.scanSeqValue) {
+                   seqNoFlag = true
+                   break;
+                 }
+               }
+               if (!seqNoFlag) {
+                 promptAction.showToast({
+                   message: `${this.scanSeqValue}不是有效的流水号`,
+                   duration: 1500,
+                   bottom: 100
+                 })
+                 this.scanSeqValue = ''
+                 return
+               }
              })
              .onChange((value: string) => {
                this.scanSeqValue = value;
@@ -276,8 +296,35 @@ export struct SwitchingProductDialog{
           }
           .justifyContent(FlexAlign.Center)
           .width('50%')
-          .onClick(() => {
+          .onClick(async () => {
+            // 流转卡号是否有效
+            let seqNoFlag = false
+            for (const element of this.queryTaskSeq) {
+              if (element.seqNo === this.scanSeqValue) {
+                seqNoFlag = true
+                break;
+              }
+            }
+            if (!seqNoFlag) {
+              promptAction.showToast({
+                message: `${this.scanSeqValue}不是有效的流水号`,
+                duration: 1500,
+                bottom: 100
+              })
+              this.scanSeqValue = ''
+              return
+            }
             this.scanState = 0
+            this.seqNo = this.scanSeqValue
+            // 保存此流转卡号到数据库中
+            let seqNos: string[] = []
+            seqNos = await preferencesUtil.get(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNos)
+            if (seqNos.includes(this.seqNo)) {
+              return
+            }
+            seqNos.push(this.seqNo)
+            preferencesUtil.put(CommonConstants.PREFERENCE_INSTANCE_NAME, this.selectWorkOder.workOrderCode!, seqNos)
+
             this.process = {}
             this.onSwitchProduct();
             this.controller.close();

+ 1 - 4
entry/src/main/syscap.json

@@ -7,10 +7,7 @@
   },
   "development": {
     "addedSysCaps": [
-      "SystemCapability.Window.SessionManager",
-      "SystemCapability.Communication.NFC.Core",
-      "SystemCapability.Communication.NFC.CardEmulation",
-      "SystemCapability.Communication.NFC.Tag"
+      "SystemCapability.Window.SessionManager"
     ]
   }
 }