Warehousing.ets 12 KB

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