1
0

RfidAllocation.ets 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. import { TitleStateComp } from '../common/component/TitleStateComp';
  2. import { ScanStorageclass } from './Storage';
  3. import StorageRequest from '../common/util/request/StorageRequest';
  4. import router from '@ohos.router';
  5. import { WorkstationInfo } from './LoginPage';
  6. import CommonConstants from '../common/constants/CommonConstants';
  7. import EquipmentRequest from '../common/util/request/EquipmentRequest';
  8. import RequestParamModel from '../viewmodel/RequestParamModel';
  9. import { StationInfoModel } from '../model/StorageSpace';
  10. @Entry
  11. @CustomDialog
  12. export struct RfidAllocation {
  13. //todo 读写器编号
  14. @State ReadingWriting: string = 'SGHRI3LR48500'
  15. //写入rfid
  16. @State InRfid: string = ''
  17. @State workstation: WorkstationInfo = {}
  18. //新建料箱最后两位
  19. @State newBox: number = 0
  20. //点击选择
  21. @State onclick: number = -1
  22. //打印机在线状态
  23. @State onlineStatus: number = 0
  24. //RFID在线状态
  25. @State RfidOnlineStatus: number = 0
  26. //箱子编码
  27. @State boxCode: string = ''
  28. //扫码控制器
  29. textcontroller: TextInputController = new TextInputController()
  30. //新建料箱list
  31. @State private scanStorageList: Array<ScanStorageclass> = []
  32. @State isHomePage: boolean = false
  33. RfidController?: CustomDialogController;
  34. //料箱容量
  35. @State capacity: string = '9999'
  36. //料箱类别
  37. @State category: string = '0'
  38. //载具编号
  39. @State code: string = ''
  40. //载具名称
  41. @State name: string = ''
  42. //资产编号
  43. @State propertyCode: string = 'YXJ-4610'
  44. //时间
  45. @State coding: string = ''
  46. //料箱创建日期
  47. @State MaterialBoxData: string = ''
  48. //料箱创建时间
  49. @State MaterialBoxTime: string = ''
  50. //新建料箱表
  51. @State private newMaterial: Array<newMaterialBoxList> = []
  52. @State private newMaterialBin: Array<newMaterialBin> = []
  53. //读取到的rfid信息
  54. @State private httpRfid: RfidClass = {}
  55. //获取rfid
  56. @State private recentlyRecordObject: StationInfoModel = {}
  57. RfidHttp = async (): Promise<RfidClass> => {
  58. //todo SGHRI3LR48500设备编号,从后端数据获取,暂时写死
  59. let res: RfidClass = await EquipmentRequest.get("/api/v1/device/data/recentlyRecord/SGHRI3LR48500", {})
  60. // let result: StationInfoModel = await StorageRequest.post("api/v1/wms/common/queryStationInfo", {
  61. // stanCode: CommonConstants.STATION_CODE
  62. // } as RequestParamModel)
  63. // this.recentlyRecordObject = result
  64. this.httpRfid = res
  65. this.RfidOnlineStatus = 1
  66. console.log('textTag', 'rfid请求结果' + JSON.stringify(res)
  67. );
  68. return res
  69. }
  70. //写入rfid
  71. InRfidHttp = async (): Promise<InRfidClass> => {
  72. //todo SGHRI3LR48500设备编号,从后端数据获取,暂时写死
  73. let res: InRfidClass = await EquipmentRequest.post("/api/v1/device/setup", {
  74. deviceNo: this.ReadingWriting,
  75. data: {
  76. rfid0: this.InRfid
  77. }
  78. } as RequestParamModel)
  79. console.log('textTag', 'rfid写入结果' + JSON.stringify(res)
  80. );
  81. return res
  82. }
  83. currentTimer: number = -1
  84. aboutToAppear(): void {
  85. this.currentTimer = setInterval(async () => {
  86. this.RfidHttp().then((res: RfidClass) => {
  87. console.log('textTag', '-------rfid获取信息' + JSON.stringify(res))
  88. })
  89. }, 5000);
  90. }
  91. aboutToDisappear(): void {
  92. clearInterval(this.currentTimer)
  93. }
  94. //后端料箱绑定
  95. newMaterialBox = async (): Promise<newMaterialBoxList> => {
  96. let obj: newMaterialBoxList = {}
  97. let res: newMaterialBoxList = await StorageRequest.post("/api/v1/wms/vehicle/add", {
  98. capacity: '9999',
  99. category: '0',
  100. code: this.coding,
  101. name: this.coding,
  102. propertyCode: this.coding,
  103. universal: '0'
  104. } as newMaterialBoxList)
  105. console.log('testTag', 'Tasklist成功' + JSON.stringify(res))
  106. obj = JSON.parse(JSON.stringify(res))
  107. console.log('testTag', 'aaaaaaaa' + JSON.stringify(obj));
  108. return obj
  109. }
  110. build() {
  111. Column() {
  112. Stack({ alignContent: Alignment.Start }) {
  113. TitleStateComp({ isHomePage: this.isHomePage, })
  114. Row() {
  115. Image($r('app.media.return'))
  116. .width(px2vp(56))
  117. .height(px2vp(56))
  118. .onClick(() => {
  119. if (CommonConstants.stationDictValue === '5') {
  120. router.pushUrl({
  121. url: 'pages/Warehousing'
  122. })
  123. } else if (CommonConstants.stationDictValue === '6') {
  124. router.pushUrl({
  125. url: 'pages/OutboundStation',
  126. })
  127. }
  128. else {
  129. router.pushUrl({
  130. url: 'pages/process/ProcessHome',
  131. })
  132. }
  133. })
  134. }.width('20%')
  135. .height('8%')
  136. .padding({ left: px2vp(24) })
  137. .backgroundColor($r('app.color.title_bar_background'))
  138. }
  139. Row() {
  140. Column() {
  141. Column() {
  142. Column() {
  143. Text('已有料盒' + "[" + this.newMaterialBin.length.toString() + ']')
  144. .fontSize($r('app.float.fontSize_30'))
  145. .fontWeight(FontWeight.Medium)
  146. .fontColor($r('app.color.black_90'))
  147. .width('40%')
  148. .height(px2vp(80))
  149. }
  150. .width('100%')
  151. .height(px2vp(80))
  152. .alignItems(HorizontalAlign.Start)
  153. Row() {
  154. Button('新建料箱')
  155. .width(px2vp(292))
  156. .height(px2vp(80))
  157. .fontSize($r('app.float.fontSize_24'))
  158. .fontWeight(FontWeight.Medium)
  159. .fontColor($r('app.color.process_divider_white_color'))
  160. .backgroundColor($r('app.color.blue_100'))
  161. .onClick(() => {
  162. this.newBox++
  163. //日期时间
  164. let dateTime = new Date()
  165. let coding = dateTime.getFullYear() + (dateTime.getMonth() + 1).toString().padStart(2, '0')
  166. + (dateTime.getDate().toString().padStart(2, '0')) +
  167. (dateTime.getHours()).toString().padStart(2, '0') + (dateTime.getMinutes() + 1).toString()
  168. .padStart(2, '0')
  169. + (dateTime.getSeconds()).toString().padStart(2, '0') + (this.newBox < 10 ? 0 : '') + this.newBox
  170. this.coding = coding
  171. let data = dateTime.getFullYear() + '-' + (dateTime.getMonth() + 1).toString().padStart(2, '0')
  172. + '-' + (dateTime.getDate().toString().padStart(2, '0'))
  173. this.MaterialBoxData = data
  174. let time = dateTime.getHours() + ':' + (dateTime.getMinutes() + 1).toString().padStart(2, '0')
  175. + ':' + (dateTime.getSeconds().toString().padStart(2, '0'))
  176. this.MaterialBoxTime = time
  177. //todo 后台接口完善后要放开注释
  178. // this.newMaterialBox().then((res:newMaterialBoxList)=>{
  179. // this.newMaterial.push(res)
  180. // })
  181. let obj: newMaterialBin = {
  182. MaterialBoxData: this.MaterialBoxData,
  183. MaterialBoxTime: this.MaterialBoxTime,
  184. coding: this.coding
  185. }
  186. this.newMaterialBin.unshift(obj)
  187. })
  188. Blank()
  189. Row() {
  190. Image($r('app.media.shaoma'))
  191. .width(px2vp(32))
  192. .height(px2vp(32))
  193. .margin({ left: $r('app.float.fontSize_30') })
  194. TextInput({ text: this.boxCode,
  195. placeholder: '请点击扫码或者输入物料编码',
  196. controller: this.textcontroller })
  197. .width('92%')
  198. .height('100%')
  199. .width(px2vp(450))
  200. .fontWeight(FontWeight.Medium)
  201. .fontSize($r('app.float.fontSize_24'))
  202. .backgroundColor("#ffff")
  203. .borderRadius(21)
  204. .onSubmit(() => {
  205. })
  206. Image($r('app.media.search'))
  207. .width(px2vp(32))
  208. .height(px2vp(32))
  209. .margin({ right: $r('app.float.fontSize_30') })
  210. }
  211. .width(px2vp(608))
  212. .height(px2vp(80))
  213. .borderRadius(px2vp(100))
  214. .alignItems(VerticalAlign.Center)
  215. .backgroundColor($r('app.color.process_divider_white_color'))
  216. }
  217. .margin({ right: $r('app.float.Margins_24') })
  218. .width('100%')
  219. .height(px2vp(80))
  220. }
  221. .width('100%')
  222. .height(px2vp(160))
  223. .margin({ right: $r('app.float.Margins_24'), bottom: px2vp(20) })
  224. Column() {
  225. List() {
  226. ForEach(this.newMaterialBin, (item: newMaterialBin, index: number) => {
  227. ListItem() {
  228. Column() {
  229. Text(item.coding)
  230. .fontSize($r('app.float.fontSize_24'))
  231. .fontWeight(FontWeight.Medium)
  232. .fontColor($r('app.color.black_90'))
  233. .width('100%')
  234. .height('40%')
  235. Row() {
  236. Text(item.MaterialBoxData + ' ' + item.MaterialBoxTime)
  237. .fontSize($r('app.float.fontSize_20'))
  238. .fontWeight(FontWeight.Medium)
  239. .fontColor($r('app.color.black_60'))
  240. .width('100%')
  241. .height('100%')
  242. .textAlign(TextAlign.Start)
  243. }
  244. .width('100%')
  245. .height('40%')
  246. }
  247. .justifyContent(FlexAlign.Center)
  248. .width(px2vp(608))
  249. .height(px2vp(88))
  250. .margin({ right: $r('app.float.Margins_24'), bottom: $r('app.float.topMargins_20') })
  251. .padding({ left: $r('app.float.leftMargins_30') })
  252. .backgroundColor(this.onclick === index ? $r('app.color.blue_100') : $r('app.color.process_divider_white_color'))
  253. .borderRadius(px2vp(16))
  254. .onClick(() => {
  255. this.onclick = index
  256. this.InRfid = item.coding!
  257. })
  258. }
  259. .margin({ right: $r('app.float.Margins_24') })
  260. })
  261. }
  262. .lanes(2)
  263. }.width('100%')
  264. .height('80%')
  265. }.width('66%')
  266. .height('100%')
  267. .borderRadius($r('app.float.borderRadius_16'))
  268. .alignItems(HorizontalAlign.Start)
  269. //.margin({right:$r('app.float.Margins_24')})
  270. Column() {
  271. Column() {
  272. Text('条码打印')
  273. .fontSize($r('app.float.fontSize_30'))
  274. .fontWeight(FontWeight.Medium)
  275. .fontColor($r('app.color.black_90'))
  276. .textAlign(TextAlign.Start)
  277. .width('100%')
  278. .height('15%')
  279. .margin({ left: $r('app.float.leftMargins_30') })
  280. Column() {
  281. Row({ space: 10 }) {
  282. Text('打印机状态')
  283. .fontSize($r('app.float.fontSize_20'))
  284. .fontWeight(FontWeight.Medium)
  285. .fontColor($r('app.color.black_60'))
  286. .textAlign(TextAlign.End)
  287. .width('40%')
  288. .height('100%')
  289. if (this.onlineStatus === 0) {
  290. Text().width(px2vp(12))
  291. .height(px2vp(12))
  292. .borderRadius(px2vp(50))
  293. .backgroundColor($r('app.color.green_100'))
  294. Text('在线')
  295. .fontSize($r('app.float.fontSize_20'))
  296. .fontWeight(FontWeight.Medium)
  297. .fontColor($r('app.color.black_90'))
  298. .textAlign(TextAlign.Start)
  299. .width('35%')
  300. .height('100%')
  301. } else if (this.onlineStatus === 1) {
  302. Text().width('5%')
  303. .height('30%')
  304. .borderRadius(px2vp(50))
  305. .backgroundColor($r('app.color.grey_100'))
  306. Text('不在线')
  307. .fontSize($r('app.float.fontSize_20'))
  308. .fontWeight(FontWeight.Medium)
  309. .fontColor($r('app.color.black_90'))
  310. .textAlign(TextAlign.Start)
  311. .width('35%')
  312. .height('100%')
  313. }
  314. }
  315. .width('100%')
  316. .height('30%')
  317. Row({ space: 10 }) {
  318. Text('打印机RFID编号')
  319. .fontSize($r('app.float.fontSize_20'))
  320. .fontWeight(FontWeight.Medium)
  321. .fontColor($r('app.color.black_60'))
  322. .textAlign(TextAlign.End)
  323. .width('40%')
  324. .height('100%')
  325. Text('6537289495783').width('40%')
  326. .height('30%')
  327. .borderRadius(px2vp(50))
  328. .fontColor($r('app.color.blue_100'))
  329. }
  330. .width('100%')
  331. .height('30%')
  332. }.width('100%')
  333. .height('60%')
  334. .justifyContent(FlexAlign.Center)
  335. .alignItems(HorizontalAlign.Center)
  336. Blank()
  337. Button('打印条码')
  338. .fontColor($r('app.color.process_divider_white_color'))
  339. .fontSize($r('app.float.fontSize_20'))
  340. .fontWeight(FontWeight.Medium)
  341. .backgroundColor($r('app.color.blue_100'))
  342. .width(px2vp(292))
  343. .height(px2vp(80))
  344. .margin({ bottom: $r('app.float.topMargins_20') })
  345. }
  346. .width('100%')
  347. .height('49%')
  348. .borderRadius(px2vp(16))
  349. .backgroundColor($r('app.color.white_E3E5E7'))
  350. .margin({ bottom: $r('app.float.topMargins_20') })
  351. Column() {
  352. Text('写入RFID')
  353. .fontSize($r('app.float.fontSize_30'))
  354. .fontWeight(FontWeight.Medium)
  355. .fontColor($r('app.color.black_90'))
  356. .textAlign(TextAlign.Start)
  357. .width('100%')
  358. .height('15%')
  359. .margin({ left: $r('app.float.leftMargins_30') })
  360. Column() {
  361. Row({ space: 10 }) {
  362. Text('RFID状态')
  363. .fontSize($r('app.float.fontSize_20'))
  364. .fontWeight(FontWeight.Medium)
  365. .fontColor($r('app.color.black_60'))
  366. .textAlign(TextAlign.End)
  367. .width('40%')
  368. .height('100%')
  369. if (this.RfidOnlineStatus === 1) {
  370. Text().width(px2vp(12))
  371. .height(px2vp(12))
  372. .borderRadius(px2vp(50))
  373. .backgroundColor($r('app.color.green_100'))
  374. Text('在线')
  375. .fontSize($r('app.float.fontSize_20'))
  376. .fontWeight(FontWeight.Medium)
  377. .fontColor($r('app.color.black_90'))
  378. .textAlign(TextAlign.Start)
  379. .width('35%')
  380. .height('100%')
  381. } else if (this.RfidOnlineStatus === 0) {
  382. Text().width('5%')
  383. .height('30%')
  384. .borderRadius(px2vp(50))
  385. .backgroundColor($r('app.color.grey_100'))
  386. Text('不在线')
  387. .fontSize($r('app.float.fontSize_20'))
  388. .fontWeight(FontWeight.Medium)
  389. .fontColor($r('app.color.black_90'))
  390. .textAlign(TextAlign.Start)
  391. .width('35%')
  392. .height('100%')
  393. }
  394. }
  395. .width('100%')
  396. .height('30%')
  397. Row({ space: 10 }) {
  398. Text('当前RFID编号')
  399. .fontSize($r('app.float.fontSize_20'))
  400. .fontWeight(FontWeight.Medium)
  401. .fontColor($r('app.color.black_60'))
  402. .textAlign(TextAlign.End)
  403. .width('40%')
  404. .height('100%')
  405. Text(this.httpRfid.data?.RFID!).width('40%')
  406. .height('30%')
  407. .borderRadius(px2vp(50))
  408. .fontColor($r('app.color.blue_100'))
  409. }
  410. .width('100%')
  411. .height('30%')
  412. Row({ space: 10 }) {
  413. Text('写入RFID编号')
  414. .fontSize($r('app.float.fontSize_20'))
  415. .fontWeight(FontWeight.Medium)
  416. .fontColor($r('app.color.black_60'))
  417. .textAlign(TextAlign.End)
  418. .width('40%')
  419. .height('100%')
  420. Text(this.InRfid.toString()).width('40%')
  421. .height('30%')
  422. .borderRadius(px2vp(50))
  423. .fontColor($r('app.color.blue_100'))
  424. }
  425. .width('100%')
  426. .height('30%')
  427. }.width('100%')
  428. .height('60%')
  429. .justifyContent(FlexAlign.Center)
  430. .alignItems(HorizontalAlign.Center)
  431. Blank()
  432. Button('写入RFID')
  433. .fontColor($r('app.color.process_divider_white_color'))
  434. .fontSize($r('app.float.fontSize_20'))
  435. .fontWeight(FontWeight.Medium)
  436. .backgroundColor($r('app.color.blue_100'))
  437. .width(px2vp(292))
  438. .height(px2vp(80))
  439. .margin({ bottom: $r('app.float.topMargins_20') })
  440. .onClick(() => {
  441. this.InRfidHttp().then((res: InRfidClass) => {
  442. console.log('textTag', '-------rfid写入信息' + JSON.stringify(res))
  443. })
  444. })
  445. }.width('100%')
  446. .height('49%')
  447. .borderRadius(px2vp(16))
  448. .backgroundColor($r('app.color.white_E3E5E7'))
  449. }.width('33%')
  450. .height('100%')
  451. }.width('100%')
  452. .height('92%')
  453. .justifyContent(FlexAlign.Center)
  454. .padding({
  455. left: $r('app.float.Margins_24'),
  456. right: $r('app.float.Margins_24'),
  457. top: $r('app.float.topMargins_20'),
  458. bottom: $r('app.float.topMargins_20')
  459. })
  460. }.width('100%')
  461. .height('100%')
  462. .backgroundColor($r('app.color.white_f1f3f5'))
  463. }
  464. }
  465. export interface newMaterialBoxList {
  466. capacity?: string
  467. category?: string
  468. code?: string
  469. name?: string
  470. propertyCode?: string
  471. universal?: string
  472. }
  473. export interface newMaterialBin {
  474. MaterialBoxData?: string
  475. MaterialBoxTime?: string
  476. coding?: string
  477. }
  478. export interface RfidClass {
  479. data?: datalass
  480. }
  481. export interface datalass {
  482. RFID?: string
  483. UID?: string
  484. errCode?: string
  485. }
  486. export interface InRfidClass {
  487. deviceNo?: string
  488. data?: InDataClass
  489. }
  490. export interface InDataClass {
  491. rfid0?: string
  492. }