RfidAllocation.ets 19 KB

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