Warehousing.ets 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. import { SureToDoDialog } from '../common/component/SureToDoDialog'
  2. import { TitleStateComp } from '../common/component/TitleStateComp'
  3. import EquipmentRequest from '../common/util/request/EquipmentRequest'
  4. import StorageRequest from '../common/util/request/StorageRequest'
  5. import { MaterialInformationModel } from '../model/MaterialInformation'
  6. import { boxMaterialClass, controlClass } from '../view/CompleteSet'
  7. import { IntelligentWarehousingGo, stat1 } from '../view/IntelligentWarehousingGo'
  8. import { ManualWarehousing } from '../view/ManualWarehousing'
  9. import { Statistics } from '../view/Statistics'
  10. import RequestParamModel from '../viewmodel/RequestParamModel'
  11. import { ScanStorageclass } from './Storage'
  12. @Entry
  13. @Component
  14. struct Warehousing {
  15. @State private controlList: Array<controlClass> = []
  16. //工序id
  17. @State orderId: string = ''
  18. //自动入库开关
  19. @State automaticWarehousing: number = 0
  20. //有无违禁品
  21. @State contraband: number = 0
  22. //料箱等级(类型)
  23. @State vehicleLevel: string = ''
  24. //暂时固定的料箱编码
  25. @State binCode: string = ''
  26. //重量
  27. @State weight: number = 0
  28. ///料箱状态
  29. @State materialBox: number = 0
  30. //取料箱中物料信息
  31. @State private boxMaterials: Array<boxMaterialClass> = []
  32. //定义物料信息
  33. @State private MaterialInformation: Array<MaterialInformationModel> = []
  34. @State private entranceWaiting: Array<stat1> = []
  35. //后端控制系统料箱出库
  36. controlHttp = async (): Promise<controlClass[]> => {
  37. let res: controlClass[] = await StorageRequest.post("/api/v1/wms/common/receiveResult", {
  38. //任务单号id
  39. orderId: this.orderId,
  40. state: 1
  41. } as RequestParamModel)
  42. console.log('testTag', 'aaaaaaaa1' + JSON.stringify(res));
  43. this.controlList = res
  44. return res
  45. }
  46. //硬件stat1位置接口
  47. // locationRequest = async (): Promise<stat1> => {
  48. // let res: stat1 = await EquipmentRequest.get("api/v1/wcs/stat/stat1")
  49. // console.log('testTag1' + '-------------' + JSON.stringify(res))
  50. // return res
  51. // }
  52. //todo
  53. //暂时扫的是库存里的料箱编码信息
  54. //查询取出料箱里面的物料信息
  55. boxMaterialHttp = async (): Promise<MaterialInformationModel[]> => {
  56. let res: MaterialInformationModel[] = await StorageRequest.post("/api/v1/stock/list", {
  57. //todo 读取RFId的料箱编码,要根据硬件读到的改
  58. vehicleCode: this.binCode
  59. } as RequestParamModel)
  60. console.log('testTag', 'aaaaaaaa2' + JSON.stringify(res));
  61. this.MaterialInformation = res
  62. return res
  63. }
  64. //硬件请求入库操作
  65. warehousingHttp = async (): Promise<boxMaterialClass> => {
  66. let res: boxMaterialClass = await StorageRequest.post("/api/v1/wcs/stockin", {
  67. boxNo: this.entranceWaiting[0].rfid!,
  68. position: "stat2",
  69. mtype: this.vehicleLevel
  70. } as RequestParamModel)
  71. console.log('testTag1', '----------' + JSON.stringify(res));
  72. return res
  73. }
  74. //后端入库操作
  75. Warehousing = async (): Promise<boxMaterialClass[]> => {
  76. let res: boxMaterialClass[] = await StorageRequest.post("/api/v1/wmsOrder/inBox", {
  77. houseNo: '1',
  78. vehicleCode: this.entranceWaiting[0].rfid!,
  79. detailsList: this.boxMaterials
  80. } as RequestParamModel)
  81. console.log('testTag', 'aaaaaaaa1' + JSON.stringify(res));
  82. return res
  83. }
  84. //todo。暂时关闭
  85. //打开页面0.5s请求一次硬件,当io(有无料箱)和weight(重量)发送变化时执行改变数据,同时通过RFID请求读取料箱里面物料信息
  86. async aboutToAppear() {
  87. // setInterval(async () => {
  88. // console.log('testTag1'+'-------------')
  89. // //第一步
  90. // this.locationRequest().then((res:stat1)=>{
  91. // this.entranceWaiting.push(res)
  92. // console.log('testTag1'+'-------------'+JSON.stringify(res))
  93. // })
  94. // //第二步
  95. // //当料箱状态和重量发生改变时才会执行
  96. // if (Number(this.entranceWaiting[0].io)!==this.materialBox||this.weight!==Number(this.entranceWaiting[0].weight!)/1000) {
  97. // this.materialBox=Number(this.entranceWaiting[0].io!)
  98. // this.weight=Number(this.entranceWaiting[0].weight!)/1000
  99. // //当rfid长度等于0,但是读取到有箱子说明rfid读取失败
  100. // //第三步
  101. // if (this.entranceWaiting[0].rfid!.length===0&&Number(this.entranceWaiting[0].io)===1){
  102. // this.RfidCarController.open()
  103. // }
  104. // //第四步
  105. // //todo 通过rfid获得料箱编码现在写死的
  106. // this.binCode="ZJ-JG013"
  107. // //this.binCode=this.entranceWaiting[0].rfid!
  108. //
  109. // console.log('testTag1'+this.materialBox)
  110. // //料箱来了执行请求
  111. // this.boxMaterialHttp().then((res :MaterialInformationList[]) => {
  112. // console.log('testTag', 'result cccccc22'+JSON.stringify(res))
  113. // if (res && res.length > 0) {
  114. // this.MaterialInformation = res
  115. // this.vehicleLevel=res[0].vehicleLevel!
  116. // }
  117. //
  118. // })
  119. // //todo
  120. // //第五步
  121. // //一直执行判定是否有违禁品
  122. // let len=this.MaterialInformation.length
  123. // for (let i = 0; i < len; i++) {
  124. // if (this.MaterialInformation[i].materialNo==="42944402000591") {
  125. // this.contraband=1
  126. // }
  127. // }
  128. // //第六步
  129. // //自动入库
  130. // if (this.contraband===0&&this.automaticWarehousing===0&&this.weight<=15&&this.automaticWarehousing===0) {
  131. // //执行硬件入库
  132. // this.warehousingHttp().then((res:boxMaterialClass)=>{
  133. // console.log('testTag1', '-------result cccccc11'+JSON.stringify(res))
  134. //
  135. // })
  136. // //执行后端入库操作
  137. // this.Warehousing().then((res :boxMaterialClass[]) => {
  138. // console.log('testTag', 'result cccccc'+JSON.stringify(res))
  139. // if (res && res.length > 0) {
  140. // }
  141. //控制终端
  142. // this.controlHttp().then((res:controlClass[])=>{
  143. // console.log('testTag1', '-------result cccccc11'+JSON.stringify(res))
  144. // })
  145. // })
  146. //
  147. //
  148. // }
  149. // }
  150. // }, 500);
  151. }
  152. //料箱里的物料
  153. @State private scanStorageList: Array<ScanStorageclass> = []
  154. @State isHomePage: boolean = false
  155. //0:主动入库,1:手动入库,2:统计按钮
  156. @State inboundButton: number = 0
  157. //仓储和其他仓储点击按钮变色
  158. @State warehouseButton: number = 0
  159. //RFID卡读取失败弹窗
  160. RfidCarController: CustomDialogController = new CustomDialogController({
  161. builder: RfidCar({}),
  162. alignment: DialogAlignment.Center,
  163. gridCount: 4,
  164. customStyle: true,
  165. })
  166. fourWidth: number = 290
  167. twoWidth: number = 150
  168. // 切换tab添加提示
  169. goingToChangeTabIndex: number = 0
  170. goingToChangeTab = (tabIndex: number) => {
  171. if (this.inboundButton == 2) {
  172. this.inboundButton = tabIndex
  173. }
  174. else {
  175. this.goingToChangeTabIndex = tabIndex
  176. this.changeTabController.open()
  177. }
  178. }
  179. sureToChangeTab = () => {
  180. this.inboundButton = this.goingToChangeTabIndex
  181. }
  182. cancel = () => {
  183. this.changeTabController.close()
  184. }
  185. changeTabController: CustomDialogController = new CustomDialogController({
  186. builder: SureToDoDialog(
  187. {
  188. cancel: this.cancel,
  189. confirm: this.sureToChangeTab,
  190. title: "提示",
  191. info: '切换会中断当前的操作'
  192. }
  193. ),
  194. alignment: DialogAlignment.Center,
  195. customStyle: true,
  196. autoCancel: false,
  197. })
  198. build() {
  199. Column() {
  200. TitleStateComp({ isHomePage: this.isHomePage, })
  201. Column() {
  202. Row() {
  203. Row() {
  204. Text('智能仓储')
  205. .textAlign(TextAlign.Center)
  206. .borderRadius(px2vp(16))
  207. .width(px2vp(this.fourWidth))
  208. .height('80px')
  209. .fontWeight(FontWeight.Medium)
  210. .fontSize(px2vp(24))
  211. .fontColor(this.warehouseButton === 0 ? $r('app.color.black_90') : $r('app.color.black_60'))
  212. .backgroundColor(this.warehouseButton === 0 ? $r('app.color.process_divider_white_color') : '')
  213. .onClick(() => {
  214. this.warehouseButton = 0
  215. })
  216. // Blank()
  217. // Text('xxxxxx')
  218. // .textAlign(TextAlign.Center)
  219. // .borderRadius(px2vp(16))
  220. // .width('292px')
  221. // .height('80px')
  222. // .fontWeight(FontWeight.Medium)
  223. // .fontSize(px2vp(24))
  224. // .fontColor(this.warehouseButton === 1 ? $r('app.color.black_90') : $r('app.color.black_60'))
  225. // .backgroundColor(this.warehouseButton === 1 ? $r('app.color.process_divider_white_color') : '')
  226. // .onClick(() => {
  227. // this.warehouseButton = 1
  228. // })
  229. }
  230. .width(px2vp(this.fourWidth))
  231. .borderRadius(px2vp(15))
  232. .height(px2vp(80))
  233. .backgroundColor($r('app.color.black_10'))
  234. .margin({ right: px2vp(24) })
  235. Row() {
  236. Text('自动入库')
  237. .textAlign(TextAlign.Center)
  238. .borderRadius(px2vp(16))
  239. .width('33%')
  240. .height('100%')
  241. .fontWeight(FontWeight.Medium)
  242. .fontSize(px2vp(24))
  243. .fontColor(this.inboundButton === 0 ? $r('app.color.black_90') : $r('app.color.black_60'))
  244. .backgroundColor(this.inboundButton === 0 ? $r('app.color.process_divider_white_color') : '')
  245. .onClick(() => {
  246. this.goingToChangeTab(0)
  247. })
  248. Blank()
  249. Text('手动入库')
  250. .textAlign(TextAlign.Center)
  251. .borderRadius(px2vp(16))
  252. .width('33%')
  253. .height('100%')
  254. .fontWeight(FontWeight.Medium)
  255. .fontSize(px2fp(24))
  256. .fontColor(this.inboundButton === 1 ? $r('app.color.black_90') : $r('app.color.black_60'))
  257. .backgroundColor(this.inboundButton === 1 ? $r('app.color.process_divider_white_color') : '')
  258. .onClick(() => {
  259. this.goingToChangeTab(1)
  260. })
  261. Blank()
  262. Text('统计')
  263. .textAlign(TextAlign.Center)
  264. .borderRadius(px2vp(16))
  265. .width('33%')
  266. .height('100%')
  267. .fontWeight(FontWeight.Medium)
  268. .fontSize(px2vp(24))
  269. .fontColor(this.inboundButton === 2 ? $r('app.color.black_90') : $r('app.color.black_60'))
  270. .backgroundColor(this.inboundButton === 2 ? $r('app.color.process_divider_white_color') : '')
  271. .onClick(() => {
  272. this.goingToChangeTab(2)
  273. })
  274. }.width(px2vp(923))
  275. .borderRadius(px2vp(15))
  276. .height(px2vp(80))
  277. .backgroundColor($r('app.color.black_10'))
  278. }.width('100%')
  279. .height('8%')
  280. .padding({ left: px2vp(24), right: px2vp(24) })
  281. if (this.inboundButton === 0 && this.warehouseButton === 0) {
  282. //自动入库
  283. IntelligentWarehousingGo({
  284. scanStorageList: this.scanStorageList,
  285. entranceWaiting: this.entranceWaiting,
  286. ///料箱状态
  287. materialBox: this.materialBox,
  288. weight: this.weight,
  289. binCode: this.binCode,
  290. MaterialInformation: this.MaterialInformation,
  291. vehicleLevel: this.vehicleLevel,
  292. contraband: this.contraband,
  293. automaticWarehousing: this.automaticWarehousing,
  294. boxMaterials: this.boxMaterials
  295. })
  296. } else if (this.inboundButton === 2 && this.warehouseButton === 0) {
  297. //统计
  298. Column() {
  299. Statistics()
  300. }.width('100%')
  301. .height('92%')
  302. } else if (this.inboundButton === 1 && this.warehouseButton === 0) {
  303. //手动入库
  304. ManualWarehousing()
  305. }
  306. }.width('100%')
  307. .height('92%')
  308. }.width('100%')
  309. .height('100%')
  310. .backgroundColor($r('app.color.title_bar_background'))
  311. }
  312. }
  313. //RFID读取失败弹窗
  314. @CustomDialog
  315. struct RfidCar {
  316. controller: CustomDialogController
  317. build() {
  318. Column() {
  319. Text('RFID读取失败')
  320. .fontWeight(FontWeight.Medium)
  321. .fontSize($r('app.float.fontSize_50'))
  322. Blank()
  323. Text('请检查RFID读卡器或料箱底部识别卡片是否正常!')
  324. .fontWeight(FontWeight.Medium)
  325. .fontSize($r('app.float.fontSize_38'))
  326. Blank()
  327. Button('取消', { type: ButtonType.Normal, stateEffect: true })
  328. .width(px2vp(252))
  329. .height(px2vp(70))
  330. .borderRadius(px2vp(75))
  331. .fontSize($r('app.float.fontSize_20'))
  332. .onClick(() => {
  333. this.controller.close()
  334. })
  335. }
  336. .width(px2vp(924))
  337. .height(px2vp(536))
  338. .padding({ top: px2vp(60), bottom: px2vp(60) })
  339. .borderRadius($r('app.float.borderRadius_16'))
  340. .backgroundColor($r('app.color.white_100'))
  341. }
  342. }