Browse Source

代码提交

hh 2 weeks ago
parent
commit
b0b4f8e4e5

+ 3 - 1
entry/oh-package.json5

@@ -5,6 +5,8 @@
   "main": "",
   "author": "",
   "license": "",
-  "dependencies": {}
+  "dependencies": {
+    "@ohos/axios": "2.2.1-rc.0"
+  }
 }
 

+ 49 - 0
entry/src/main/ets/common/constants/CommonConstants.ets

@@ -0,0 +1,49 @@
+import DictValue from '../../viewmodel/DictValue'
+import HashMap from '@ohos.util.HashMap'
+
+export default class CommonConstants {
+  static readonly RDB_NAME: string = 'Presentation.db'
+  static readonly PRE_NAME: string = 'MyPreferences'
+  static AUTH_TOKEN: string = ''
+  // 附件地址前缀
+  static FILE_URL_PREFIX: string = 'http://192.168.1.3:9000'
+
+  // 当前登录用户相关信息
+  static USER_ID?: number = 1
+  static USER_NAME: string = '1'
+  static USER_AVATAR: string = ''
+  static STATION_NANE: string = '1'
+  static STATION_ID: number
+  static STATION_CODE: string = 'GW0002'
+  static STATION_IP: string = ''
+  static stationDictValue: string = ''
+
+  static MATERIAL_BOX_ID: string = ''
+  // 是否是退出登陆
+  static LOGIN_OUT: boolean = false
+  static readonly STORAGE_TYPE: string[] = ['电子元器件', '电路板', '结构件', '辅助材料']
+  //吊篮高度
+  static readonly HANGING_HEIGHT :Array<SelectOption> =[
+    {value:"原位"},
+    {value:"第一层"},
+    {value:"第二层"},
+    {value:"第三层"},
+    {value:"第四层"},
+    {value:"第五层"},
+    {value:"第六层"},
+    {value:"工位料口层"},
+    {value:"库位料口层"}
+  ]
+  static readonly PARK_TYPE: string[] = ['出入库位置', '充电位置', '工作台', '其他']
+  static readonly RGV_STATUS: Record<string, string> = {
+    '0': '空闲',
+    '1': '移动中',
+    '2': '等待路径',
+    '3': '取箱中',
+    '4': '放箱中',
+    '5': '充电中',
+    '6': '关机',
+  };
+
+  static DICT_DATA: HashMap<string, DictValue[]> = new HashMap<string, DictValue[]>()
+}

+ 55 - 0
entry/src/main/ets/common/util/TimeUtil.ets

@@ -0,0 +1,55 @@
+class TimeUtil {
+
+  getCurrentDate(): string {
+    let dateTime = new Date()
+    let month: string = JSON.stringify(dateTime.getMonth() + 1)
+    let time = dateTime.getFullYear() + '-' + (dateTime.getMonth() + 1).toString().padStart(2, '0')
+      + '-' + (dateTime.getDate().toString().padStart(2, '0'))
+    return time
+  }
+
+  getCurrentTime(): string {
+    let dateTime = new Date()
+    let time = dateTime.getFullYear() + '-' + (dateTime.getMonth() + 1).toString().padStart(2, '0')
+      + '-' + (dateTime.getDate().toString().padStart(2, '0')) + ' ' +
+      (dateTime.getHours().toString().length == 1 ? '0' + dateTime.getHours() : dateTime.getHours()) + ':'
+      + (dateTime.getMinutes().toString().length == 1 ? '0' + dateTime.getMinutes() : dateTime.getMinutes()) + ':'
+      + (dateTime.getSeconds().toString().length == 1 ? '0'+ dateTime.getSeconds(): dateTime.getSeconds())
+    return time
+  }
+
+  getHourAndMinute(): string {
+    let dateTime = new Date()
+    let time = (dateTime.getHours().toString().length == 1 ? '0' + dateTime.getHours() : dateTime.getHours()) + ':'
+      + (dateTime.getMinutes().toString().length == 1 ? '0' + dateTime.getMinutes() : dateTime.getMinutes())
+    return time
+  }
+
+  getDateAndWeek(): string {
+    let dateTime = new Date()
+    let weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
+    let time = ((dateTime.getMonth() + 1) < 10 ? ' ' + (dateTime.getMonth() + 1) : (dateTime.getMonth() + 1))
+      + '月' + (dateTime.getDate() < 10 ? dateTime.getDate().toString() + '日' + '  ' : dateTime.getDate().toString() + '日' + ' ')+
+    weekDay[dateTime.getDay()]
+    return time
+  }
+
+  //上午、下午、晚上
+  getTimePeriod(): string {
+    let currentTime = new Date();
+    let currentHour = currentTime.getHours();
+    let period: string;
+    if (currentHour < 12) {
+      period = "上午";
+    } else if (currentHour < 18) {
+      period = "下午";
+    } else {
+      period = "晚上";
+    };
+    return period;
+  }
+}
+
+let timeUtil = new TimeUtil();
+
+export default timeUtil as TimeUtil;

+ 108 - 0
entry/src/main/ets/common/util/request/helps.ets

@@ -0,0 +1,108 @@
+import { InternalAxiosRequestConfig, AxiosResponse, AxiosError } from "@ohos/axios"
+import promptAction from '@ohos.promptAction'
+
+// 是否在控制台打印某项log
+const pConfig = false
+const pHeaders = false
+const pUrl = true
+const pParams = true
+const pBody = true
+const pResponse = true
+const pData = true
+const pError = true
+
+// @CustomDialog
+// struct CustomDialogExample {
+//   controller: CustomDialogController
+//   build() {
+//     Column() {
+//       Text('我是内容')
+//         .fontSize(20)
+//         .margin({ top: 10, bottom: 10 })
+//     }
+//   }
+// }
+
+const printRequest = (config: InternalAxiosRequestConfig) => {
+  if (pConfig) {
+    console.debug("printRequest config", JSON.stringify(config))
+  }
+
+  if (pHeaders) {
+    console.debug("printRequest headers", JSON.stringify(config.headers))
+  }
+
+  if (pUrl) {
+    console.debug("printRequest url", `Method:${config.method} ${config.baseURL}${config.url}`)
+  }
+
+  if (pBody) {
+    console.debug("printRequest 请求参数data", JSON.stringify(config.data))
+  }
+
+  if (pParams) {
+    console.debug("printRequest 请求参数params", JSON.stringify(config.params))
+  }
+
+}
+
+const printResponse = (response: AxiosResponse) => {
+  if (pResponse) {
+    console.debug('printResponse response: ', JSON.stringify(response))
+  }
+  if (pData) {
+    console.debug("printResponse data", JSON.stringify(response.data))
+  }
+}
+
+const printError = (error: AxiosError) => {
+  if (pError) {
+    console.debug("printError error", error.message)
+  }
+  promptAction.showToast({
+    message: error.message ?? "请求出错",
+    duration: 1500,
+    bottom: 100
+  })
+}
+
+
+// 处理返回数据
+const handleRes = (response: AxiosResponse): [boolean, string] => {
+  let isSuccess = true
+  let msg = ""
+
+  if (response.status === 200) { //判断返回状态是否为200
+    if (String(response.data?.code) === "200") { //判断数据的code是否为200,有可能是500的服务器错误
+      isSuccess = true
+      msg = `请求数据成功`
+    }
+    else {
+      isSuccess = false
+      // msg = `${response.data?.code}: ${response.data?.msg ?? "服务器错误"}`
+      msg = `${response.data?.msg ?? "服务器错误"}`
+    }
+  }
+  else {
+    isSuccess = false
+    msg = `状态码非200 status: ${response.status}}`
+  }
+
+  if (!isSuccess) {
+    promptAction.showToast({
+      message: msg,
+      duration: 2000,
+      bottom: 100
+    })
+
+    // const dialogController: CustomDialogController = new CustomDialogController({
+    //   builder: CustomDialogExample({}),
+    // })
+    // dialogController.open()
+  }
+
+  return [isSuccess, msg]
+}
+
+
+export { printRequest, printResponse, printError, handleRes }

+ 47 - 0
entry/src/main/ets/component/TimeAndTitle.ets

@@ -0,0 +1,47 @@
+import TimeUtil from "../common/util/TimeUtil"
+@Component
+export struct TimeAndTitle {
+  build() {
+    Row() {
+      Row(){
+      Text(TimeUtil.getDateAndWeek())
+        .fontSize($r('app.float.fontSize_16'))
+        .fontColor($r('app.color.FFFFFF'))
+        .fontWeight(FontWeight.Lighter)
+      Text(' ' + TimeUtil.getTimePeriod())
+        .fontSize($r('app.float.fontSize_16'))
+        .fontColor($r('app.color.FFFFFF'))
+        .fontWeight(FontWeight.Lighter)
+      Text(' ' + TimeUtil.getHourAndMinute())
+        .fontSize($r('app.float.fontSize_16'))
+        .fontColor($r('app.color.FFFFFF'))
+        .fontWeight(FontWeight.Lighter)
+        }
+      Row() {
+        Image($r('app.media.state_ai'))
+          .width($r('app.float.virtualSize_24'))
+          .height($r('app.float.virtualSize_24'))
+          .fillColor($r('app.color.FFFFFF'))
+        Image($r('app.media.state_ipc'))
+          .width($r('app.float.virtualSize_24'))
+          .height($r('app.float.virtualSize_24'))
+          .fillColor($r('app.color.FFFFFF'))
+        Image($r('app.media.state_voice'))
+          .width($r('app.float.virtualSize_24'))
+          .height($r('app.float.virtualSize_24'))
+          .fillColor($r('app.color.FFFFFF'))
+        Image($r('app.media.state_microphone'))
+          .width($r('app.float.virtualSize_24'))
+          .height($r('app.float.virtualSize_24'))
+          .fillColor($r('app.color.FFFFFF'))
+      }
+      .width('10%')
+      .justifyContent(FlexAlign.SpaceEvenly)
+      .alignItems(VerticalAlign.Bottom)
+      .margin({ right: 1 })
+      .height('100%')
+    }
+    .justifyContent(FlexAlign.SpaceEvenly)
+    .alignItems(VerticalAlign.Bottom)
+  }
+}

+ 110 - 6
entry/src/main/ets/pages/Index.ets

@@ -1,17 +1,121 @@
+import { TimeAndTitle } from '../component/TimeAndTitle';
+import router from '@ohos.router';
+import WorkOrderInfo from '../viewmodel/WorkOrderInfo';
+import CommonConstants from '../common/constants/CommonConstants';
+
 @Entry
 @Component
 struct Index {
   @State message: string = 'Hello World';
+  // 工单列表
+  @State workOrders: WorkOrderInfo[] = []
+  // 选中工单
+  @State selectWorkOder: WorkOrderInfo = {}
+  // 工位通知数量
+  @State noticeNum: number = 100
+  async aboutToAppear() {
+
+  }
 
   build() {
-    Row() {
-      Column() {
-        Text(this.message)
-          .fontSize(50)
-          .fontWeight(FontWeight.Bold)
+    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
+      //时间和导航标
+      Row(){
+        TimeAndTitle()
+      }.width('100%')
+      .height('3.4%')
+      .alignItems(VerticalAlign.Bottom)
+      .justifyContent(FlexAlign.End)
+      Row(){
+        Image($r('app.media.general_return'))
+          .height($r('app.float.virtualSize_56'))
+          .width($r('app.float.virtualSize_56'))
+          .fillColor($r('app.color.FFFFFF'))
+        Text('生产执行')
+          .fontColor($r('app.color.FFFFFF'))
+          .fontSize($r('app.float.fontSize_38'))
+      }
+      .height('4%')
+      .width('94.8%')
+      .justifyContent(FlexAlign.Start)
+      .onClick(()=> {
+        router.back()
+      })
+
+      Row() {
+        // 左侧选择工单、工位、人员;工序查看
+        Column() {
+          Button('请选择工单', { type: ButtonType.Normal })
+            .width('100%')
+            .height('12.4%')
+            .fontWeight(FontWeight.Medium)
+            .fontColor($r('app.color.FFFFFF'))
+            .fontSize($r('app.float.fontSize_24'))
+            .backgroundColor($r('app.color.20FFFFFF'))
+            .borderRadius($r('app.float.fontSize_16'))
+          // 工位、人员信息
+          Row() {
+            Row().width('5.6%')
+            Column() {
+              Text(CommonConstants.STATION_NANE)
+                .fontSize($r('app.float.fontSize_16'))
+                .fontWeight(FontWeight.Regular)
+                .fontColor($r('app.color.FFFFFF'))
+              Text(CommonConstants.USER_NAME)
+                .fontSize($r('app.float.fontSize_12'))
+                .fontWeight(FontWeight.Lighter)
+                .fontColor($r('app.color.FFFFFF'))
+            }
+            .width('48.8%')
+            .height('100%')
+            .justifyContent(FlexAlign.Center)
+            .alignItems(HorizontalAlign.Start)
+
+            Row() {
+              Text(this.noticeNum > 99 ? '99+' : this.noticeNum.toString())
+                .fontSize($r('app.float.fontSize_16'))
+                .fontWeight(FontWeight.Bold)
+                .fontColor($r('app.color.FFFFFF'))
+                .textAlign(TextAlign.Center)
+                .height('42.3%')
+                .width('42%')
+                .backgroundColor($r('app.color.20FFFFFF'))
+                .borderRadius($r('app.float.fontSize_16'))
+            }
+            .width('40%')
+            .height('100%')
+            .justifyContent(FlexAlign.End)
+            Row().width('5.6%')
+          }
+          .width('100%')
+          .height('8.1%')
+          .backgroundColor($r('app.color.20FFFFFF'))
+          .borderRadius($r('app.float.fontSize_16'))
+          // 工序
+          Column() {
+
+          }
+          .width('100%')
+          .height('77.2%')
+          .backgroundColor($r('app.color.20FFFFFF'))
+          .borderRadius($r('app.float.fontSize_16'))
+        }
+        .height('100%')
+        .width('19.8%')
+        .justifyContent(FlexAlign.SpaceBetween)
+        // 右侧生产操作栏
+        Column() {
+
+        }
+        .width('79.1%')
+        .height('100%')
       }
-      .width('100%')
+      .height('80%')
+      .width('94.8%')
+      .justifyContent(FlexAlign.SpaceBetween)
     }
+    .width('100%')
     .height('100%')
+    .backgroundColor($r('app.color.000000'))
   }
 }

+ 8 - 0
entry/src/main/ets/viewmodel/DictInfo.ets

@@ -0,0 +1,8 @@
+import DictValue from './DictValue'
+
+export default class DictInfo {
+  // 字典编码
+  dictCode?: string
+  // 字典值
+  list?: DictValue[]
+}

+ 8 - 0
entry/src/main/ets/viewmodel/DictValue.ets

@@ -0,0 +1,8 @@
+export default class DictValue {
+  // 字典标签
+  dictLabel?: string
+  // 字典排序
+  dictSort?: number
+  // 字典值
+  dictValue?: string
+}

+ 68 - 0
entry/src/main/ets/viewmodel/WorkOrderInfo.ets

@@ -0,0 +1,68 @@
+export default class WorkOrderInfo {
+  // 工单编码
+  workOrderCode?: string
+  // 工单id
+  orderId?: number
+  // 订单编码
+  orderCode?: string
+  // 订单名称
+  orderName?: string
+  // 物料编号
+  materialCode?: string
+  // 物料名称
+  materialName?: string
+  //物料批次号
+  batchCode?:string
+  //物料序列号
+  batchNo?:string
+  //扫码物料数量
+  num?:number
+  //物料单位
+  unitDictLabel?:string
+  // 物料型号
+  materialModel?: string
+  // 工艺版本
+  processRouteVersion?: string
+  // 优先级
+  priority?: string
+  // 产线id
+  productLineId?: string
+  // 产线名称
+  productLineName?: string
+  //工艺路线id
+  processRouteId?: number
+  // 工艺路线编码
+  processRouteCode?: string
+  // 工艺路线名称
+  processRouteName?: string
+  // 计划开始时间
+  planStartWhen?: string
+  // 计划结束时间
+  planStartEnd?: string
+  // 生产车间id
+  workshopId?: string
+  // 生产车间名
+  workshopName?: string
+  // 计划数量
+  planNum?: string
+  // 完成数量
+  completeNum?: string
+  // 报废数量
+  scrapNum?: string
+  // 入库数量
+  inventoryNum?: string
+  // 提前下线数量
+  beforeNum?: string
+  // 工单状态
+  workOrderState?: string
+  // 物料分配状态
+  itemAllotState?: number
+  orderType?: string
+  // 数据包地址
+  packageUrl?: string
+  engineeringCode?: string
+  // 更新时间
+  updated?: string
+  // 齐套进度
+  kitCompleteProgress?: number
+}

+ 3 - 0
entry/src/main/resources/base/media/general_return.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" fill="currentColor" viewBox="0 0 48 48">
+  <path d="m28.989 11.565-.064.06-9.9 9.9a3.5 3.5 0 0 0-.083 4.863l.083.086 9.9 9.9c.257.258.586.402.922.433l.092.006h.092a1.5 1.5 0 0 0 1.075-2.496l-.06-.064-9.192-9.193a1.5 1.5 0 0 1-.06-2.057l.06-.064 9.192-9.192a1.5 1.5 0 0 0-1.02-2.56h-.092c-.34.011-.675.137-.945.378Z"/>
+</svg>

+ 3 - 0
entry/src/main/resources/base/media/state_ai.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
+  <path d="M19.832 3.5a1.308 1.308 0 0 0-1.308 1.308v14.716a1.308 1.308 0 1 0 2.617 0V4.809A1.308 1.308 0 0 0 19.833 3.5Zm-9.406.762c-.48-1.045-1.98-1.007-2.404.063L2.592 17.97a1.309 1.309 0 1 0 2.433.968l1.333-3.349c.023.001.044.013.068.013h6.33l1.56 3.397a1.308 1.308 0 0 0 2.377-1.092L10.426 4.262Zm-3.034 8.721L9.324 8.13l2.23 4.853H7.391Z"/>
+</svg>

+ 3 - 0
entry/src/main/resources/base/media/state_ipc.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
+  <path fill-rule="evenodd" d="M4.5 3h15A1.5 1.5 0 0 1 21 4.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 19.5v-15A1.5 1.5 0 0 1 4.5 3Zm12.75 4.5a.75.75 0 0 0-1.5 0v1.25h-1.5V7.5a.75.75 0 0 0-1.5 0v1.25h-1.5V7.5a.75.75 0 0 0-1.5 0v1.25h-1.5V7.5a.75.75 0 0 0-1.5 0v1.293a.75.75 0 0 0-.5.707v4c0 .414.336.75.75.75h1.75v2.25c0 .414.336.75.75.75h5a.75.75 0 0 0 .75-.75v-2.25H17a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 0-.5-.707V7.5Z" clip-rule="evenodd"/>
+</svg>

+ 5 - 0
entry/src/main/resources/base/media/state_microphone.svg

@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
+  <path d="M15.5 5.5a3.5 3.5 0 1 0-7 0V12a3.5 3.5 0 1 0 7 0V5.5Z"/>
+  <path fill-rule="evenodd" d="M4.5 10.75a.75.75 0 0 1 .75.75 6.75 6.75 0 0 0 13.5 0 .75.75 0 0 1 1.5 0 8.25 8.25 0 1 1-16.5 0 .75.75 0 0 1 .75-.75Z" clip-rule="evenodd"/>
+  <path fill-rule="evenodd" d="M12 18.25a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 .75-.75Z" clip-rule="evenodd"/>
+</svg>

File diff suppressed because it is too large
+ 3 - 0
entry/src/main/resources/base/media/state_user.svg


+ 5 - 0
entry/src/main/resources/base/media/state_voice.svg

@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
+  <path fill-rule="evenodd" d="M5.48 17.17a14.283 14.283 0 0 0 1.613 2.057C8.218 20.41 9.93 21.75 12 21.75a.75.75 0 0 0 .75-.75V3a.75.75 0 0 0-.75-.75c-2.065 0-3.776 1.315-4.902 2.482a14.101 14.101 0 0 0-1.614 2.023H3a1.75 1.75 0 0 0-1.75 1.75v6.914c0 .967.784 1.75 1.75 1.75h2.48Z" clip-rule="evenodd"/>
+  <path d="M16.5 6.94a.75.75 0 0 0-1.06.06l.03.53.03.53c.252.23.533.533.736.812A5.285 5.285 0 0 1 17.25 12a5.287 5.287 0 0 1-.997 3.106 5.21 5.21 0 0 1-.752.835.75.75 0 1 0 .999 1.118 6.69 6.69 0 0 0 .969-1.075A6.785 6.785 0 0 0 18.75 12a6.786 6.786 0 0 0-1.302-4.013 6.702 6.702 0 0 0-.948-1.046Z"/>
+  <path d="M15.44 7a.75.75 0 0 0 .06 1.06l-.03-.53-.03-.53Zm1.678 13.593A9.995 9.995 0 0 0 22 12a9.994 9.994 0 0 0-4.747-8.51"/>
+</svg>