1
0

Warehousing.ets 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 { MaterialInformationList } 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<MaterialInformationList>=[]
  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<MaterialInformationList[]> => {
  55. let res:MaterialInformationList[] = 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. }),
  162. alignment: DialogAlignment.Center,
  163. gridCount: 4,
  164. customStyle: true,
  165. })
  166. build() {
  167. Column(){
  168. TitleStateComp({ isHomePage: this.isHomePage,})
  169. Column(){
  170. Row(){
  171. Row(){
  172. Text('智能仓储')
  173. .textAlign(TextAlign.Center)
  174. .borderRadius(px2vp(16))
  175. .width('292px')
  176. .height('80px')
  177. .fontWeight(FontWeight.Medium)
  178. .fontSize(px2vp(24))
  179. .fontColor(this.warehouseButton===0?$r('app.color.black_90'):$r('app.color.black_60'))
  180. .backgroundColor(this.warehouseButton===0?$r('app.color.process_divider_white_color'):'')
  181. .onClick(()=>{
  182. this.warehouseButton=0
  183. })
  184. Blank()
  185. Text('其他仓储')
  186. .textAlign(TextAlign.Center)
  187. .borderRadius(px2vp(16))
  188. .width('292px')
  189. .height('80px')
  190. .fontWeight(FontWeight.Medium)
  191. .fontSize(px2vp(24))
  192. .fontColor(this.warehouseButton===1?$r('app.color.black_90'):$r('app.color.black_60'))
  193. .backgroundColor(this.warehouseButton===1?$r('app.color.process_divider_white_color'):'')
  194. .onClick(()=>{
  195. this.warehouseButton=1
  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({scanStorageList:this.scanStorageList,entranceWaiting:this.entranceWaiting,
  251. ///料箱状态
  252. materialBox:this.materialBox,weight:this.weight,binCode:this.binCode,
  253. MaterialInformation:this.MaterialInformation,vehicleLevel:this.vehicleLevel,
  254. contraband:this.contraband,automaticWarehousing:this.automaticWarehousing,
  255. boxMaterials:this.boxMaterials})
  256. }else if (this.inboundButton===2&&this.warehouseButton===0){
  257. //统计
  258. Column(){
  259. Statistics()
  260. }.width('100%')
  261. .height('92%')
  262. }else if (this.inboundButton===1&&this.warehouseButton===0) {
  263. //手动入库
  264. ManualWarehousing()
  265. }
  266. }.width('100%')
  267. .height('92%')
  268. }.width('100%')
  269. .height('100%')
  270. .backgroundColor($r('app.color.title_bar_background'))
  271. }
  272. }
  273. //RFID读取失败弹窗
  274. @CustomDialog
  275. struct RfidCar{
  276. controller: CustomDialogController
  277. build() {
  278. Column(){
  279. Text('RFID读取失败')
  280. .fontWeight(FontWeight.Medium)
  281. .fontSize($r('app.float.fontSize_50'))
  282. Blank()
  283. Text('请检查RFID读卡器或料箱底部识别卡片是否正常!')
  284. .fontWeight(FontWeight.Medium)
  285. .fontSize($r('app.float.fontSize_38'))
  286. Blank()
  287. Button('取消', { type: ButtonType.Normal, stateEffect: true })
  288. .width(px2vp(252))
  289. .height(px2vp(70))
  290. .borderRadius(px2vp(75))
  291. .fontSize($r('app.float.fontSize_20'))
  292. .onClick(()=>{
  293. this.controller.close()
  294. })
  295. }.width(px2vp(924))
  296. .height(px2vp(536))
  297. .padding({top:px2vp(60),bottom:px2vp(60)})
  298. .borderRadius($r('app.float.borderRadius_16'))
  299. .backgroundColor($r('app.color.white_100'))
  300. }
  301. }