123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- import { TitleStateComp } from '../common/component/TitleStateComp'
- import EquipmentRequest from '../common/util/request/EquipmentRequest'
- import StorageRequest from '../common/util/request/StorageRequest'
- import { MaterialInformationModel } from '../model/MaterialInformation'
- import { boxMaterialClass, controlClass } from '../view/CompleteSet'
- import { IntelligentWarehousingGo, stat1 } from '../view/IntelligentWarehousingGo'
- import { ManualWarehousing } from '../view/ManualWarehousing'
- import { Statistics } from '../view/Statistics'
- import RequestParamModel from '../viewmodel/RequestParamModel'
- import { ScanStorageclass } from './Storage'
- @Entry
- @Component
- struct Warehousing {
- @State private controlList: Array<controlClass> = []
- //工序id
- @State orderId: string = ''
- //自动入库开关
- @State automaticWarehousing: number = 0
- //有无违禁品
- @State contraband: number = 0
- //料箱等级(类型)
- @State vehicleLevel: string = ''
- //暂时固定的料箱编码
- @State binCode: string = ''
- //重量
- @State weight: number = 0
- ///料箱状态
- @State materialBox: number = 0
- //取料箱中物料信息
- @State private boxMaterials: Array<boxMaterialClass> = []
- //定义物料信息
- @State private MaterialInformation: Array<MaterialInformationModel> = []
- @State private entranceWaiting: Array<stat1> = []
- //后端控制系统料箱出库
- controlHttp = async (): Promise<controlClass[]> => {
- let res: controlClass[] = await StorageRequest.post("/api/v1/wms/common/receiveResult", {
- //任务单号id
- orderId: this.orderId,
- state: 1
- } as RequestParamModel)
- console.log('testTag', 'aaaaaaaa1' + JSON.stringify(res));
- this.controlList = res
- return res
- }
- //硬件stat1位置接口
- locationRequest = async (): Promise<stat1> => {
- let res: stat1 = await EquipmentRequest.get("api/v1/wcs/stat/stat1")
- console.log('testTag1' + '-------------' + JSON.stringify(res))
- return res
- }
- //todo
- //暂时扫的是库存里的料箱编码信息
- //查询取出料箱里面的物料信息
- boxMaterialHttp = async (): Promise<MaterialInformationModel[]> => {
- let res: MaterialInformationModel[] = await StorageRequest.post("/api/v1/stock/list", {
- //todo 读取RFId的料箱编码,要根据硬件读到的改
- vehicleCode: this.binCode
- } as RequestParamModel)
- console.log('testTag', 'aaaaaaaa2' + JSON.stringify(res));
- this.MaterialInformation = res
- return res
- }
- //硬件请求入库操作
- warehousingHttp = async (): Promise<boxMaterialClass> => {
- let res: boxMaterialClass = await StorageRequest.post("/api/v1/wcs/stockin", {
- boxNo: this.entranceWaiting[0].rfid!,
- position: "stat2",
- mtype: this.vehicleLevel
- } as RequestParamModel)
- console.log('testTag1', '----------' + JSON.stringify(res));
- return res
- }
- //后端入库操作
- Warehousing = async (): Promise<boxMaterialClass[]> => {
- let res: boxMaterialClass[] = await StorageRequest.post("/api/v1/wmsOrder/inBox", {
- houseNo: '1',
- vehicleCode: this.entranceWaiting[0].rfid!,
- detailsList: this.boxMaterials
- } as RequestParamModel)
- console.log('testTag', 'aaaaaaaa1' + JSON.stringify(res));
- return res
- }
- //todo。暂时关闭
- //打开页面0.5s请求一次硬件,当io(有无料箱)和weight(重量)发送变化时执行改变数据,同时通过RFID请求读取料箱里面物料信息
- async aboutToAppear() {
- // setInterval(async () => {
- // console.log('testTag1'+'-------------')
- // //第一步
- // this.locationRequest().then((res:stat1)=>{
- // this.entranceWaiting.push(res)
- // console.log('testTag1'+'-------------'+JSON.stringify(res))
- // })
- // //第二步
- // //当料箱状态和重量发生改变时才会执行
- // if (Number(this.entranceWaiting[0].io)!==this.materialBox||this.weight!==Number(this.entranceWaiting[0].weight!)/1000) {
- // this.materialBox=Number(this.entranceWaiting[0].io!)
- // this.weight=Number(this.entranceWaiting[0].weight!)/1000
- // //当rfid长度等于0,但是读取到有箱子说明rfid读取失败
- // //第三步
- // if (this.entranceWaiting[0].rfid!.length===0&&Number(this.entranceWaiting[0].io)===1){
- // this.RfidCarController.open()
- // }
- // //第四步
- // //todo 通过rfid获得料箱编码现在写死的
- // this.binCode="ZJ-JG013"
- // //this.binCode=this.entranceWaiting[0].rfid!
- //
- // console.log('testTag1'+this.materialBox)
- // //料箱来了执行请求
- // this.boxMaterialHttp().then((res :MaterialInformationList[]) => {
- // console.log('testTag', 'result cccccc22'+JSON.stringify(res))
- // if (res && res.length > 0) {
- // this.MaterialInformation = res
- // this.vehicleLevel=res[0].vehicleLevel!
- // }
- //
- // })
- // //todo
- // //第五步
- // //一直执行判定是否有违禁品
- // let len=this.MaterialInformation.length
- // for (let i = 0; i < len; i++) {
- // if (this.MaterialInformation[i].materialNo==="42944402000591") {
- // this.contraband=1
- // }
- // }
- // //第六步
- // //自动入库
- // if (this.contraband===0&&this.automaticWarehousing===0&&this.weight<=15&&this.automaticWarehousing===0) {
- // //执行硬件入库
- // this.warehousingHttp().then((res:boxMaterialClass)=>{
- // console.log('testTag1', '-------result cccccc11'+JSON.stringify(res))
- //
- // })
- // //执行后端入库操作
- // this.Warehousing().then((res :boxMaterialClass[]) => {
- // console.log('testTag', 'result cccccc'+JSON.stringify(res))
- // if (res && res.length > 0) {
- // }
- //控制终端
- // this.controlHttp().then((res:controlClass[])=>{
- // console.log('testTag1', '-------result cccccc11'+JSON.stringify(res))
- // })
- // })
- //
- //
- // }
- // }
- // }, 500);
- }
- //料箱里的物料
- @State private scanStorageList: Array<ScanStorageclass> = []
- @State isHomePage: boolean = false
- //0:主动入库,1:手动入库,2:统计按钮
- @State inboundButton: number = 0
- //仓储和其他仓储点击按钮变色
- @State warehouseButton: number = 0
- //RFID卡读取失败弹窗
- RfidCarController: CustomDialogController = new CustomDialogController({
- builder: RfidCar({}),
- alignment: DialogAlignment.Center,
- gridCount: 4,
- customStyle: true,
- })
- build() {
- Column() {
- TitleStateComp({ isHomePage: this.isHomePage, })
- Column() {
- Row() {
- Row() {
- Text('智能仓储')
- .textAlign(TextAlign.Center)
- .borderRadius(px2vp(16))
- .width('292px')
- .height('80px')
- .fontWeight(FontWeight.Medium)
- .fontSize(px2vp(24))
- .fontColor(this.warehouseButton === 0 ? $r('app.color.black_90') : $r('app.color.black_60'))
- .backgroundColor(this.warehouseButton === 0 ? $r('app.color.process_divider_white_color') : '')
- .onClick(() => {
- this.warehouseButton = 0
- })
- Blank()
- // Text('xxxxxx')
- // .textAlign(TextAlign.Center)
- // .borderRadius(px2vp(16))
- // .width('292px')
- // .height('80px')
- // .fontWeight(FontWeight.Medium)
- // .fontSize(px2vp(24))
- // .fontColor(this.warehouseButton === 1 ? $r('app.color.black_90') : $r('app.color.black_60'))
- // .backgroundColor(this.warehouseButton === 1 ? $r('app.color.process_divider_white_color') : '')
- // .onClick(() => {
- // this.warehouseButton = 1
- // })
- }
- .width(px2vp(608))
- .borderRadius(px2vp(15))
- .height(px2vp(80))
- .backgroundColor($r('app.color.black_10'))
- .margin({ right: px2vp(24) })
- Row() {
- Text('自动入库')
- .textAlign(TextAlign.Center)
- .borderRadius(px2vp(16))
- .width('33%')
- .height('100%')
- .fontWeight(FontWeight.Medium)
- .fontSize(px2vp(24))
- .fontColor(this.inboundButton === 0 ? $r('app.color.black_90') : $r('app.color.black_60'))
- .backgroundColor(this.inboundButton === 0 ? $r('app.color.process_divider_white_color') : '')
- .onClick(() => {
- this.inboundButton = 0
- })
- Blank()
- Text('手动入库')
- .textAlign(TextAlign.Center)
- .borderRadius(px2vp(16))
- .width('33%')
- .height('100%')
- .fontWeight(FontWeight.Medium)
- .fontSize(px2fp(24))
- .fontColor(this.inboundButton === 1 ? $r('app.color.black_90') : $r('app.color.black_60'))
- .backgroundColor(this.inboundButton === 1 ? $r('app.color.process_divider_white_color') : '')
- .onClick(() => {
- this.inboundButton = 1
- })
- Blank()
- Text('统计')
- .textAlign(TextAlign.Center)
- .borderRadius(px2vp(16))
- .width('33%')
- .height('100%')
- .fontWeight(FontWeight.Medium)
- .fontSize(px2vp(24))
- .fontColor(this.inboundButton === 2 ? $r('app.color.black_90') : $r('app.color.black_60'))
- .backgroundColor(this.inboundButton === 2 ? $r('app.color.process_divider_white_color') : '')
- .onClick(() => {
- this.inboundButton = 2
- })
- }.width(px2vp(923))
- .borderRadius(px2vp(15))
- .height(px2vp(80))
- .backgroundColor($r('app.color.black_10'))
- }.width('100%')
- .height('8%')
- .padding({ left: px2vp(24), right: px2vp(24) })
- if (this.inboundButton === 0 && this.warehouseButton === 0) {
- //自动入库
- IntelligentWarehousingGo({
- scanStorageList: this.scanStorageList,
- entranceWaiting: this.entranceWaiting,
- ///料箱状态
- materialBox: this.materialBox,
- weight: this.weight,
- binCode: this.binCode,
- MaterialInformation: this.MaterialInformation,
- vehicleLevel: this.vehicleLevel,
- contraband: this.contraband,
- automaticWarehousing: this.automaticWarehousing,
- boxMaterials: this.boxMaterials
- })
- } else if (this.inboundButton === 2 && this.warehouseButton === 0) {
- //统计
- Column() {
- Statistics()
- }.width('100%')
- .height('92%')
- } else if (this.inboundButton === 1 && this.warehouseButton === 0) {
- //手动入库
- ManualWarehousing()
- }
- }.width('100%')
- .height('92%')
- }.width('100%')
- .height('100%')
- .backgroundColor($r('app.color.title_bar_background'))
- }
- }
- //RFID读取失败弹窗
- @CustomDialog
- struct RfidCar {
- controller: CustomDialogController
- build() {
- Column() {
- Text('RFID读取失败')
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_50'))
- Blank()
- Text('请检查RFID读卡器或料箱底部识别卡片是否正常!')
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.fontSize_38'))
- Blank()
- Button('取消', { type: ButtonType.Normal, stateEffect: true })
- .width(px2vp(252))
- .height(px2vp(70))
- .borderRadius(px2vp(75))
- .fontSize($r('app.float.fontSize_20'))
- .onClick(() => {
- this.controller.close()
- })
- }
- .width(px2vp(924))
- .height(px2vp(536))
- .padding({ top: px2vp(60), bottom: px2vp(60) })
- .borderRadius($r('app.float.borderRadius_16'))
- .backgroundColor($r('app.color.white_100'))
- }
- }
|