123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654 |
- import EquipmentRequest from '../common/util/request/EquipmentRequest'
- import JGRequest from '../common/util/request/Request'
- import StorageRequest from '../common/util/request/StorageRequest'
- import RequestParamModel from '../viewmodel/RequestParamModel'
- import promptAction from '@ohos.promptAction'
- export class routerClass {
- xRoute?: number
- YRoute?: number
- }
- export class routerHttp {
- XCoordinateIn?: number
- YCoordinateIn?: number
- }
- export class Adjustment {
- destx?: string
- code?: string
- msg?: string
- cmdId?: string
- state?: string
- }
- export class carPositionClass {
- code?: string
- message?: string
- data?: dataClass
- }
- export class dataClass {
- x?: number
- y?: number
- }
- enum ChooseStatus {
- Normal = 0,
- isChoosing = 1,
- Chosen = 2, //已经选择了
- }
- @Extend(Text)
- function commonSquare() {
- .width(px2vp(55))
- .height(px2vp(55))
- .fontColor($r('app.color.blue_100'))
- .textAlign(TextAlign.Center)
- .border({ width: px2vp(1), color: '#7DC8EA' })
- }
- @Extend(Button)
- function choiceBtnSty() {
- .width(px2vp(292))
- .borderRadius(px2vp(76))
- .height(px2vp(80))
- }
- @Entry
- @Component
- export struct WarehouseMap {
- //车的位置请求返回数据
- @State CarPosition: Array<carPositionClass> = []
- @State rgvNo: string = 'rgv1'
- @State route: routerClass[] = [
- { xRoute: 10, YRoute: 9 },
- { xRoute: 10, YRoute: 9 },
- { xRoute: 10, YRoute: 10 },
- { xRoute: 9, YRoute: 10 },
- { xRoute: 8, YRoute: 10 },
- ]
- //选择层数颜色
- @State selectColor: number = -1
- @State selectSvg: number = 0
- //车坐标
- @State carYCoordinate: number = 10
- @State carXCoordinate: number = 10
- @State carYCoordinate1: number = 8
- @State carXCoordinate1: number = 9
- //调入xy坐标
- @State YCoordinateIn: number = 0
- @State XCoordinateIn: number = 0
- //调出xy坐标
- @State YCoordinate: number = 0
- @State XCoordinate: number = 0
- //调入格子
- @State SelectEnter: number = ChooseStatus.Normal
- //调出格子
- @State SelectOut: ChooseStatus = ChooseStatus.Normal //点击 选调出料格
- @State boxNumber: number = 0 //调箱数量
- @State numberEnable: number = 0 //调入料格的剩余的个数
- @State JobHopping: number = 0
- scroller: Scroller = new Scroller()
- //选择的第几层
- @State selectStorey: number = -1
- //选调出格子有多少层
- @State storeyNumber: number = -1
- @State private storey: number[] = [6, 5, 4, 3, 2, 1]
- @State private YAxis: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
- @State private XAxis: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
- // @State private XAxis: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]
- @State private XYxis: number[][] = [
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 6, 0, 6, 6],
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 6, 0, 6, 6],
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [-1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 6, 6, 6, 0, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [-1, -1, -1, -1, -1, -1, -1, 0, 6, 0, 6, 5, 6, 0, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [-1, -1, -1, -1, -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [-1, -1, -1, -1, -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [-1, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [-1, -1, -1, -1, -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [-1, -1, -1, -1, -1, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [0, 0, 0, -1, -1, 6, 6, 6, 2, 6, 6, 6, 6, 3, 6, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1],
- [0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
- ]
- @State yNum: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
- //提示弹窗
- promptsController: CustomDialogController = new CustomDialogController({
- builder: prompt({
- JobHopping: this.JobHopping
- }),
- alignment: DialogAlignment.Center,
- gridCount: 4,
- customStyle: true,
- })
- //硬件调仓操作
- AdjustmentHttp = async (): Promise<Adjustment[]> => {
- let res: Adjustment[] = await EquipmentRequest.post("/api/v1/wcs/box/movMultiple",
- //todo 坐标加1,二维数组索引从零开始
- {
- //目标位置
- dest: (this.XCoordinateIn + 1) + '-' + (this.YCoordinateIn + 1),
- //移动位置
- src: (this.XCoordinate + 1) + '-' + (this.YCoordinate + 1),
- //todo 数量暂时写死1
- num: "1"
- } as RequestParamModel)
- //
- console.log('textTag', 'post请求结果' + JSON.stringify(res)
- );
- return res
- }
- Adjustment = async (): Promise<Adjustment[]> => {
- let res: Adjustment[] = await EquipmentRequest.get("/api/v1/wcs/rgvs/",
- {
- // destx:this.XCoordinateIn,
- // destY:this.YCoordinateIn,
- // rgvNo:'rgvNo1'
- })
- return res
- }
- //请求车的位置
- CarPositionHttp = async (): Promise<carPositionClass> => {
- let res: carPositionClass = await EquipmentRequest.get("/api/v1/wcs/rgv/" + this.rgvNo, {}) as carPositionClass
- if (res !== undefined && res.data !== undefined) {
- this.carYCoordinate = res.data.y!
- this.carXCoordinate = res.data.x!
- }
- return res
- }
- // 获取仓库坐标信息,x和y轴的信息
- getStorageXYData = async () => {
- let result: number[][] = await StorageRequest.post("/api/v1/wms/position/lineInfo/")
- console.log("getStorageXYData", JSON.stringify(result))
- let doubleArray: number[][] = []
- // let arrOne: number[] = []
- result.forEach((level1) => {
- let arrTwo: number[] = []
- level1.forEach((value) => {
- if (arrTwo.length < 18) {
- arrTwo.push(value)
- }
- })
- doubleArray.push(arrTwo)
- })
- // doubleArray.push(arrTwo)
- console.log("getStorageXYData", JSON.stringify(doubleArray))
- this.XYxis = doubleArray
- }
- aboutToAppear(): void {
- this.getStorageXYData()
- this.CarPositionHttp().then((res: carPositionClass) => {
- console.log('textTag', '-------car现在的位置执行情况结果 cccccc11' + JSON.stringify(res))
- })
- }
- // 停止调仓后重置数据
- resetData = () => {
- this.JobHopping = 0
- this.SelectOut = ChooseStatus.Normal
- this.SelectEnter = ChooseStatus.Normal
- this.storeyNumber = -1
- this.boxNumber = 0
- this.selectStorey = -1
- this.stop()
- }
- build() {
- Row() {
- Column() {
- Button(this.JobHopping === 0 ? '启动调仓' : '停止调仓', { type: ButtonType.Normal, stateEffect: true })
- .borderRadius(8)
- .borderRadius(px2vp(76))
- .backgroundColor(this.JobHopping === 0 ? $r('app.color.blue_100') : $r('app.color.red_100'))
- .width(px2vp(292))
- .height(px2vp(80))
- .onClick(() => {
- if (this.JobHopping === 0) {
- this.getStorageXYData()
- this.promptsController.open()
- } else if (this.JobHopping === 1) {
- this.resetData()
- }
- })
- Blank()
- if (this.SelectOut == ChooseStatus.Chosen) {
- Text('层数')
- .fontSize($r('app.float.fontSize_24'))
- .fontWeight(FontWeight.Medium)
- .textAlign(TextAlign.Center)
- .width(px2vp(292))
- .height(px2vp(80))
- List({ space: px2vp(20) }) {
- ForEach(this.storey, (item: number, index: number) => {
- ListItem() {
- Text(item.toString())
- .width(px2vp(291))
- .height(px2vp(80))
- .fontColor($r('app.color.black_100'))
- .textAlign(TextAlign.Center)
- .border({ width: px2vp(1) })
- .backgroundColor((index === (this.selectStorey - 1)) ? $r('app.color.red_100') : index >= (6 - this.storeyNumber) ? $r('app.color.green_100') : $r('app.color.white_f1f3f5'))
- .borderRadius(px2vp(16))
- .onClick(() => {
- if (index >= (6 - this.storeyNumber)) {
- this.selectStorey = index + 1
- this.boxNumber = this.storeyNumber - (6 - this.selectStorey)
- }
- })
- }
- })
- }
- .scrollBar(BarState.Off)
- .width(px2vp(292))
- .height(px2vp(600))
- }
- }.width(px2vp(292))
- .height(px2vp(800))
- .margin({ right: px2vp(24) })
- Column() {
- Row() {
- Column() {
- Text('y')
- .width(px2vp(25))
- .height(px2vp(25))
- .fontColor($r('app.color.order_producing_state_background'))
- .textAlign(TextAlign.Center)
- }
- .width(px2vp(25))
- .height(px2vp(55))
- .justifyContent(FlexAlign.End)
- Column() {
- Text('x')
- .width(px2vp(25))
- .height(px2vp(25))
- .fontColor($r('app.color.order_producing_state_background'))
- .textAlign(TextAlign.Center)
- }
- .width(px2vp(25))
- .height(px2vp(55))
- .justifyContent(FlexAlign.Start)
- }
- .width(px2vp(50))
- .height(px2vp(55))
- List({ space: px2vp(1) }) {
- ForEach(this.YAxis, (item: number, index: number) => {
- ListItem() {
- Text(item.toString())
- .width(px2vp(55))
- .height(px2vp(55))
- .fontColor($r('app.color.black_10'))
- .textAlign(TextAlign.Center)
- }
- })
- }
- .scrollBar(BarState.Off)
- .width(px2vp(60))
- .height(px2vp(745))
- }
- .width(px2vp(60))
- .height(px2vp(800))
- Scroll(this.scroller) {
- Column() {
- List({ space: px2vp(1) }) {
- ForEach(this.XAxis, (item: number, index: number) => {
- ListItem() {
- Text(item.toString())
- .width(px2vp(55))
- .height(px2vp(55))
- .fontColor($r('app.color.black_10'))
- .textAlign(TextAlign.Center)
- }
- })
- }
- .listDirection(Axis.Horizontal)
- .scrollBar(BarState.Off)
- .width(px2vp(1020))
- .height(px2vp(55))
- List({ space: px2vp(1) }) {
- ForEach(this.XYxis, (y: number[], index1: number) => {
- ListItem() {
- List({ space: px2vp(1) }) {
- ForEach(y, (x: number, index2: number) => {
- ListItem() {
- if (x >= 0 && x != 999) {
- Stack() {
- // 根据不同的状态展示不同的颜色
- // 任何状态下都展示数字
- Text(x.toString())
- .commonSquare().backgroundColor($r('app.color.white_f1f3f5'))
- // 调出正在选择中
- if (this.SelectOut == ChooseStatus.isChoosing) {
- if (Number(x) > 0) {
- Text(x.toString())
- .commonSquare().backgroundColor($r('app.color.green_100'))
- .onClick(() => {
- this.YCoordinate = index1
- this.XCoordinate = index2
- this.SelectOut = ChooseStatus.Chosen
- this.storeyNumber = x
- })
- }
- else {
- Text(x.toString())
- .commonSquare().backgroundColor($r('app.color.white_f1f3f5'))
- }
- }
- else if (this.SelectEnter == ChooseStatus.isChoosing) {
- if (Number(x) < 6 && index1 != this.YCoordinate && index2 != this.XCoordinate) {
- Text(x.toString())
- .commonSquare().backgroundColor($r('app.color.green_100'))
- .onClick(() => {
- this.YCoordinateIn = index1
- this.XCoordinateIn = index2
- this.SelectEnter = ChooseStatus.Chosen
- this.numberEnable = 6 - Number(x)
- })
- }
- else {
- Text(x.toString())
- .commonSquare().backgroundColor($r('app.color.white_f1f3f5'))
- }
- }
- // 普通状态下 调出和调入都没有在选择的情况下展示的 小车
- if (this.SelectOut != ChooseStatus.isChoosing && this.SelectEnter != ChooseStatus.isChoosing) {
- Row() {
- Image((index1 === this.carYCoordinate && index2 === this.carXCoordinate) ? $r('app.media.robot_top') : (index1 === this.carYCoordinate && index2 === this.carXCoordinate + 1) ? $r("app.media.robot_arm") : (index1 === this.carYCoordinate1 && index2 === this.carXCoordinate1) ? $r('app.media.car_top') : (index1 === this.carYCoordinate1 && index2 === this.carXCoordinate1 - 1) ? $r('app.media.car_bottom') : '')
- .width(px2vp(55))
- .height(px2vp(55))
- .margin({ right: px2vp(55) })
- // .onClick(() => {
- // if (x !== -1 && this.SelectOut === 1) {
- // this.YCoordinate = index1
- // this.XCoordinate = index2
- // this.SelectOut = 2
- // this.SelectEnter = 3
- // this.outSvg = 1
- // this.storeyNumber = x
- // console.log('textTag' + '调出坐标' + this.XCoordinate + this.YCoordinate)
- // }
- // })
- }
- .justifyContent(FlexAlign.End)
- .width(px2vp(55))
- .height(px2vp(55))
- }
- // 展示调出的图标
- if (index1 === this.YCoordinate && index2 === this.XCoordinate && this.SelectOut == ChooseStatus.Chosen) {
- Image($r('app.media.Retrieve_grid'))
- .width(px2vp(55))
- .height(px2vp(55))
- }
- // 展示调入的图标
- if (this.SelectEnter == ChooseStatus.Chosen && index1 === this.YCoordinateIn && index2 === this.XCoordinateIn) {
- Image($r('app.media.Transfer_grid'))
- .width(px2vp(55))
- .height(px2vp(55))
- }
- }
- } else {
- Text()
- .width(px2vp(55))
- .height(px2vp(55))
- .fontColor($r('app.color.black_100'))
- .textAlign(TextAlign.Center)
- }
- }
- })
- }
- .listDirection(Axis.Horizontal)
- }
- })
- }
- .scrollBar(BarState.Off)
- }.width(px2vp(1020))
- .height(px2vp(800))
- }
- .width(px2vp(1020))
- .height(px2vp(800))
- .scrollable(ScrollDirection.Horizontal) // 滚动方向纵向
- if (this.JobHopping === 1) {
- Column() {
- Column() {
- Row() {
- Text('调出料格')
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_100'))
- .fontSize($r('app.float.fontSize_24'))
- .width(px2vp(410))
- .textAlign(TextAlign.Start)
- }
- Blank()
- if (this.SelectOut == ChooseStatus.Chosen) {
- Button('取消选择', { type: ButtonType.Normal, stateEffect: true })
- .choiceBtnSty()
- .backgroundColor($r('app.color.red_100'))
- .onClick(() => {
- this.SelectOut = ChooseStatus.Normal
- this.storeyNumber = -1
- this.selectStorey = -1
- })
- }
- else {
- Button('选调出料格', { type: ButtonType.Normal, stateEffect: true })
- .choiceBtnSty()
- .backgroundColor($r('app.color.blue_100'))
- .onClick(() => {
- this.SelectOut = ChooseStatus.isChoosing
- })
- }
- Blank()
- }
- .width(px2vp(450))
- .height(px2vp(188))
- .padding(px2vp(20))
- .alignItems(HorizontalAlign.Center)
- .borderRadius(px2vp(16))
- .backgroundColor($r('app.color.black_10'))
- .margin({ bottom: px2vp(48) })
- Column() {
- Text('调入料格')
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_100'))
- .fontSize($r('app.float.fontSize_24'))
- .width(px2vp(410))
- .textAlign(TextAlign.Start)
- Blank()
- if (this.SelectEnter == ChooseStatus.Chosen) {
- Button('取消选择', { type: ButtonType.Normal, stateEffect: true })
- .choiceBtnSty()
- .backgroundColor($r('app.color.red_100'))
- .onClick(() => {
- this.SelectEnter = ChooseStatus.Normal
- })
- }
- else {
- Button('选调入料格', { type: ButtonType.Normal, stateEffect: true })
- .choiceBtnSty()
- .backgroundColor($r('app.color.blue_100'))
- .enabled(this.SelectOut == ChooseStatus.Chosen)
- .onClick(() => {
- this.SelectEnter = ChooseStatus.isChoosing
- })
- }
- Blank()
- }
- .width(px2vp(450))
- .height(px2vp(188))
- .padding(px2vp(20))
- .alignItems(HorizontalAlign.Center)
- .borderRadius(px2vp(16))
- .backgroundColor($r('app.color.black_10'))
- .margin({ bottom: px2vp(48) })
- Column() {
- Text('调箱数量' + this.boxNumber)
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_100'))
- .fontSize($r('app.float.fontSize_24'))
- .width(px2vp(410))
- .textAlign(TextAlign.Start)
- }
- .width(px2vp(450))
- .padding(px2vp(20))
- .alignItems(HorizontalAlign.Center)
- .borderRadius(px2vp(16))
- .backgroundColor($r('app.color.black_10'))
- .margin({ bottom: px2vp(48) })
- Button('确认调仓', { type: ButtonType.Normal, stateEffect: true }).choiceBtnSty()
- .backgroundColor((this.SelectEnter == ChooseStatus.Chosen && this.SelectOut == ChooseStatus.Chosen) ? $r('app.color.blue_100') : $r('app.color.blue_20'))
- .enabled(this.SelectEnter == ChooseStatus.Chosen && this.SelectOut == ChooseStatus.Chosen)
- .onClick(() => {
- this.sureToChangeStore()
- })
- }.width(px2vp(450))
- .height(px2vp(800))
- .margin({ left: px2vp(24) })
- } else if (this.JobHopping === 1) {
- }
- }
- .width(px2vp(1920))
- .height(px2vp(800))
- .padding({ left: px2vp(24), right: px2vp(24) })
- .margin({ top: px2vp(20) })
- }
- sureToChangeStore = async () => {
- // 入的要比调箱数量大
- if (this.boxNumber > this.numberEnable) {
- promptAction.showToast({
- message: "调入料格剩余数量小于调箱的数量!",
- duration: 1800,
- bottom: '50%'
- })
- return
- }
- // console.log("jjjjjjj", this.XCoordinate, this.YCoordinate, this.XCoordinateIn, this.YCoordinateIn)
- await StorageRequest.post("/api/v1/wms/common/changePosition", {
- src: `${this.XCoordinate + 1}-${this.YCoordinate + 1}`,
- dest: `${this.XCoordinateIn + 1}-${this.YCoordinateIn + 1}`,
- num: this.boxNumber
- } as RequestParamModel)
- this.resetData()
- }
- stop = async () => {
- await JGRequest.get("api/v1/wms/common/startChangePosition/0")
- }
- aboutToDisappear(): void {
- this.stop()
- }
- }
- @CustomDialog
- ///无批次号物料详情弹窗
- struct prompt {
- @Link JobHopping: number
- controller: CustomDialogController
- start = async () => {
- await JGRequest.get("api/v1/wms/common/startChangePosition/1")
- this.JobHopping = 1
- this.controller.close()
- }
- build() {
- Column({ space: px2vp(50) }) {
- Text('调仓确认')
- .fontSize($r('app.float.fontSize_50'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_100'))
- .textAlign(TextAlign.Center)
- .width(px2vp(400))
- .margin({ top: px2vp(30) })
- Text('启动调仓后,其他工位将无法叫料,是否开始?')
- .fontSize($r('app.float.fontSize_24'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.black_100'))
- .textAlign(TextAlign.Center)
- .width(px2vp(400))
- Row() {
- Button('取消', { type: ButtonType.Normal, stateEffect: true })
- .borderRadius(8)
- .backgroundColor($r('app.color.blue_100'))
- .width(px2vp(252))
- .height(px2vp(69))
- .borderRadius(px2vp(76))
- .onClick(() => {
- this.controller.close()
- })
- Blank()
- Button('确认', { type: ButtonType.Normal, stateEffect: true })
- .borderRadius(8)
- .backgroundColor($r('app.color.warn_1'))
- .width(px2vp(252))
- .height(px2vp(69))
- .borderRadius(px2vp(76))
- .onClick(() => {
- this.start()
- })
- }.width(px2vp(600))
- .padding({ left: px2vp(30), right: px2vp(30) })
- }.width(px2vp(800))
- .height(px2vp(400))
- .backgroundColor($r('app.color.white_f1f3f5'))
- .borderRadius(16)
- }
- }
|