Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jump_hm_warehouse
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
毛勇泽
jump_hm_warehouse
Commits
3aaef1a8
Commit
3aaef1a8
authored
Jan 22, 2024
by
毛勇泽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RFID识别保存
parent
b18e0c58
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
156 行增加
和
44 行删除
+156
-44
WzcrkmxDao.ets
common/src/main/ets/db/dao/WzcrkmxDao.ets
+18
-1
WzcrkmxModel.ets
entry/src/main/ets/model/WzcrkmxModel.ets
+13
-9
GoodsSelectHwPage.ets
entry/src/main/ets/pages/metailmange/GoodsSelectHwPage.ets
+98
-20
UHFScanPage.ets
entry/src/main/ets/pages/metailmange/UHFScanPage.ets
+26
-13
WzinDetail.ets
entry/src/main/ets/pages/metailmange/WzInPage/WzinDetail/WzinDetail.ets
+1
-1
没有找到文件。
common/src/main/ets/db/dao/WzcrkmxDao.ets
View file @
3aaef1a8
...
@@ -123,12 +123,29 @@ export class WzcrkmxDao extends BaseTable<Wzcrkmx> {
...
@@ -123,12 +123,29 @@ export class WzcrkmxDao extends BaseTable<Wzcrkmx> {
return items;
return items;
}
}
async getWzcrkmx(wzcrkguid
:
string): Promise<Wzcrkmx[]> {
async getWzcrkmx(wzcrkguid
?: string,pmdmcode?:
string): Promise<Wzcrkmx[]> {
let wp = this.getPredicates();
let wp = this.getPredicates();
if(wzcrkguid){
wp.equalTo('WZCRKGUID', wzcrkguid)
wp.equalTo('WZCRKGUID', wzcrkguid)
}
if(pmdmcode){
wp.equalTo('PMDMCODE', pmdmcode)
}
return this.query(wp, this.getTableColumns());
return this.query(wp, this.getTableColumns());
}
}
/**
* 更新出入库明细
*/
async updateCrkMx(guid: string, hwh?: string,crksl?:string): Promise<number> {
const valueBucket = {
"HWH": hwh,
"CRKSL":crksl
};
let wp = this.getPredicates()
wp.equalTo('guid', guid)
return this.updateData(valueBucket, wp)
}
/**
/**
* 更新单据状态
* 更新单据状态
*/
*/
...
...
entry/src/main/ets/model/WzcrkmxModel.ets
View file @
3aaef1a8
import { WzcrkmxDao, WzcrkDao, Wzcrk, Wzcrkmx, SQLiteContext } from '@ohos/common'
import { WzcrkmxDao, WzcrkDao, Wzcrk, Wzcrkmx, SQLiteContext
} from '@ohos/common'
// 物资出库入库
// 物资出库入库
class WzcrkmxModel {
class WzcrkmxModel {
...
@@ -6,26 +6,31 @@ class WzcrkmxModel {
...
@@ -6,26 +6,31 @@ class WzcrkmxModel {
async set(data: Wzcrkmx[]) {
async set(data: Wzcrkmx[]) {
await SQLiteContext.with(WzcrkmxDao).batchInsert(data)
await SQLiteContext.with(WzcrkmxDao).batchInsert(data)
}
}
// 单条添加
async setInsert(data: Wzcrkmx) {
let res= await SQLiteContext.with(WzcrkmxDao).insert(data)
console.log("插入成功===》"+JSON.stringify(res))
}
// 查询
// 查询
async query(wzcrkguid: string): Promise<Wzcrkmx[]> {
async query(wzcrkguid?: string,pmdmcode?: string): Promise<Wzcrkmx[]> {
let res = await SQLiteContext.with(WzcrkmxDao).getWzcrkmx(wzcrkguid)
let res = await SQLiteContext.with(WzcrkmxDao).getWzcrkmx(wzcrkguid,pmdmcode)
return res;
}
async updateCrkMX(guid: string, hwh: string,crksl?:string):Promise<number> {
let res = await SQLiteContext.with(WzcrkmxDao).updateCrkMx(guid, hwh,crksl)
console.log("更新成功===》"+JSON.stringify(res))
return res;
return res;
}
}
// 更新单据信息
// 更新单据信息
async updateWcztmxByData(guid: string, data: Partial<Wzcrkmx>):Promise<number> {
async updateWcztmxByData(guid: string, data: Partial<Wzcrkmx>):Promise<number> {
let res = await SQLiteContext.with(WzcrkmxDao).updateWcztmxByData(guid, data)
let res = await SQLiteContext.with(WzcrkmxDao).updateWcztmxByData(guid, data)
return res;
return res;
}
}
// 清空表
// 清空表
async clear() {
async clear() {
await SQLiteContext.with(WzcrkmxDao).clearTable()
await SQLiteContext.with(WzcrkmxDao).clearTable()
}
}
}
}
const wzcrkmxModel = new WzcrkmxModel()
const wzcrkmxModel = new WzcrkmxModel()
export default wzcrkmxModel
export default wzcrkmxModel
\ No newline at end of file
entry/src/main/ets/pages/metailmange/GoodsSelectHwPage.ets
View file @
3aaef1a8
import { TitleBar } from '../../view/title/TitleBar'
import { TitleBar } from '../../view/title/TitleBar'
import promptAction from '@ohos.promptAction'
import promptAction from '@ohos.promptAction'
import hwModel from "../../model/HwModel"
import hwModel from "../../model/HwModel"
import { HwInfo, SQLiteContext, HwInfoDao,
Logger
} from '@ohos/common'
import { HwInfo, SQLiteContext, HwInfoDao,
DsRfid,Logger,Wzcrkmx
} from '@ohos/common'
import dsRfidModel from '../../model/DsRfidModel';
import dsRfidModel from '../../model/DsRfidModel';
import wzcrkmxModel from '../../model/WzcrkmxModel';
import { uuid } from '@ohos/common/src/main/ets/utils/util'
import router from '@ohos.router'
import router from '@ohos.router'
import IdentifyService from '../../identify/IdentifySerivce'
import emitter from '@ohos.events.emitter';
@Extend(Button) function CommonButtonStyle() {
@Extend(Button) function CommonButtonStyle() {
.borderWidth(2)
.borderWidth(2)
...
@@ -20,41 +24,90 @@ struct GoodsSelectHwPage{
...
@@ -20,41 +24,90 @@ struct GoodsSelectHwPage{
@State model: boolean = true
@State model: boolean = true
@State hwInfoList:HwInfo[]=[]
@State hwInfoList:HwInfo[]=[]
@State selectValue:Array<SelectOption>=[]
@State selectValue:Array<SelectOption>=[]
@State checkedList: Array<
string
> = []
@State checkedList: Array<
DsRfid
> = []
@State hwh:string=""
@State hwh:string=""
@State wzcrkguid:string=""
aboutToAppear(){
aboutToAppear(){
this.checkedList= router.getParams() as string[];
this.checkedList= router.getParams()["checkArray"];
this.model=router.getParams()["checkType"]
this.getHwList()
this.getHwList()
}
}
async getHwList(){
async getHwList(){
this.hwInfoList=await hwModel.queryHw("")
this.hwInfoList=await hwModel.queryHw("")
this.selectValue=this.hwInfoList.map(item =>{
this.selectValue=this.hwInfoList.map(item =>{
return {value:item.hwh}
return {value:item.hwh}
})
})
}
}
/*手动保存*/
/*手动保存*/
onSubmit() {
async
onSubmit() {
try {
try {
Logger.info("选择上架数据===》"+JSON.stringify(this.checkedList))
Logger.info("选择上架数据===》" + JSON.stringify(this.checkedList))
this.checkedList.forEach(async (element) => {
for (const element of this.checkedList) {
let num = await dsRfidModel.updateSJStatus(element, this.hwh)
Logger.info("上架数据====》" + JSON.stringify(element))
if (num) {// 如果更新成功就减少
promptAction.showToast({
let num = await dsRfidModel.updateSJStatus(element.guid, this.hwh);
message: "保存成功"
})
// 等待 saveCrkData 执行成功后再进行下一次迭代
}else{
await this.saveCrkData(element);
promptAction.showToast({
message: "保存失败"
if (!num) {
})
// 如果更新失败,可以在此处处理,例如记录日志
Logger.error("更新失败:" + JSON.stringify(element));
}
}
})
}
} catch (e) {
// 所有循环完成后再显示 showToast
promptAction.showToast({
message: "保存成功"
});
} catch (e) {
// 处理错误,如果需要
promptAction.showToast({
message: "保存失败"
});
} finally {
} finally {
router.back()
router.back()
this.checkedList = []
this.checkedList = []
}
}
}
}
/*出入库识别wz数据更新*/
async saveCrkData(row:DsRfid):Promise<number>{
Logger.info("出入库识别wz数据更新====》"+JSON.stringify(row))
const isCommon = await wzcrkmxModel.query(row.wzcrkguid,row.pmdmcode)
Logger.info("当前单据明显+++wzcrguid"+`${row.wzcrkguid}`+JSON.stringify(isCommon))
const [isHaveHwData] = isCommon.filter((HItem) => HItem.hwh === '' || HItem.hwh === this.hwh)
if (isHaveHwData) {
const newCrksl = Number(isHaveHwData.crksl) || 0
const newSl = Number(row.sl) || 0
const update_crksl = newCrksl + newSl
// 存在
const updateParams = {
mxguid: isHaveHwData.guid,
hwh: isHaveHwData.hwh || this.hwh,
crksl: update_crksl || 0
}
Logger.info("存在的明细物资======》正在更新JSON=====》"+JSON.stringify(updateParams))
/*更新crk明细*/
wzcrkmxModel.updateCrkMX(updateParams.mxguid,updateParams.hwh,updateParams.crksl.toString())
}else {
/*不存在*/
const wzcrxmx:Wzcrkmx = {
guid: uuid(),
gznd:"",
pzsl: Number(row.sl) || 0,
crksl: Number(row.sl) || 0,
pmdmcode: row.pmdmcode,
hwh: this.hwh,
wzcrkguid: row.wzcrkguid,
pzmxguid: ''
}
Logger.info("插入不存在数据===》"+JSON.stringify(wzcrxmx))
wzcrkmxModel.setInsert(wzcrxmx)
}
return 0
}
build(){
build(){
Column() {
Column() {
Flex({ direction: FlexDirection.Column }) {
Flex({ direction: FlexDirection.Column }) {
...
@@ -83,7 +136,7 @@ struct GoodsSelectHwPage{
...
@@ -83,7 +136,7 @@ struct GoodsSelectHwPage{
.backgroundColor('#fff')
.backgroundColor('#fff')
.type(ButtonType.Normal)
.type(ButtonType.Normal)
.onClick(() => {
.onClick(() => {
this.model = ! this.model
this.model = ! this.model
})
})
}.padding({left: 20, right: 20})
}.padding({left: 20, right: 20})
Column() {
Column() {
...
@@ -121,4 +174,28 @@ struct GoodsSelectHwPage{
...
@@ -121,4 +174,28 @@ struct GoodsSelectHwPage{
colors: [['#36a3c0', 0.0], ['#97c6a6', 1.0], ['#c7d799', 2.0]]// 数组末尾元素占比小于1时满足重复着色效果
colors: [['#36a3c0', 0.0], ['#97c6a6', 1.0], ['#c7d799', 2.0]]// 数组末尾元素占比小于1时满足重复着色效果
})
})
}
}
scanCodeListen() {
var innerEvent = { eventId: 2 }
emitter.on(innerEvent, (eventData) => {
if (innerEvent.eventId == 2) {
let result = eventData.data.scancode
console.log("扫码校验", "收到扫码信息:" + result)
this.showQRDetail(result)
}
})
}
async showQRDetail(data: string) {
Logger.info("扫码二维码===》"+data)
}
onPageShow() {
console.error("========onPageShow=========")
this.scanCodeListen()
IdentifyService.openScanPort()
}
onPageHide() {
IdentifyService.closeScan()
/*取消扫码订阅*/
emitter.off(2);
}
}
}
\ No newline at end of file
entry/src/main/ets/pages/metailmange/UHFScanPage.ets
View file @
3aaef1a8
...
@@ -7,7 +7,7 @@ import ProductEpc from '../../identify/analysis/label/ProductEpc';
...
@@ -7,7 +7,7 @@ import ProductEpc from '../../identify/analysis/label/ProductEpc';
import bzhxModal from '../../model/BzhxModel'
import bzhxModal from '../../model/BzhxModel'
import { uuid } from '@ohos/common/src/main/ets/utils/util'
import { uuid } from '@ohos/common/src/main/ets/utils/util'
import {
import {
DsRfid,Logger
DsRfid,Logger
,Wzcrk
} from '@ohos/common';
} from '@ohos/common';
import IdentifyService from '../../identify/IdentifySerivce'
import IdentifyService from '../../identify/IdentifySerivce'
import emitter from '@ohos.events.emitter';
import emitter from '@ohos.events.emitter';
...
@@ -31,17 +31,19 @@ struct UHFScanPage{
...
@@ -31,17 +31,19 @@ struct UHFScanPage{
@State rfidList:DsRfid[]=[]
@State rfidList:DsRfid[]=[]
private controller: TabsController = new TabsController()
private controller: TabsController = new TabsController()
private searchcontroller: SearchController = new SearchController()
private searchcontroller: SearchController = new SearchController()
@State checkedList: Array<string> = []
@State wzcrk: Wzcrk = null // 物资出入库单据信息
@State checkedList: Array<DsRfid> = []
@State doneEpcsList: string[] = []
@State doneEpcsList: string[] = []
@State pmTotal:number=0;
@State pmTotal:number=0;
@State hxTotal:number=0;
@State hxTotal:number=0;
@State xhTotal:number=0;
@State xhTotal:number=0;
@State sumTotal:number=0;
@State sumTotal:number=0;
aboutToAppear(){
aboutToAppear(){
this.getUPorDown()
// this.getUPorDown()
this.wzcrk=router.getParams()[""]
}
}
/*统计品种,号型,箱号,数量*/
/*统计品种,号型,箱号,数量*/
async countToal(){
async countToal(){
this.pmTotal=this.convertionRfid("pmdm")
this.pmTotal=this.convertionRfid("pmdm")
this.hxTotal=this.convertionRfid("hxmc")
this.hxTotal=this.convertionRfid("hxmc")
this.xhTotal=this.convertionRfid("xh")
this.xhTotal=this.convertionRfid("xh")
...
@@ -71,9 +73,9 @@ struct UHFScanPage{
...
@@ -71,9 +73,9 @@ struct UHFScanPage{
.selectedColor('#007DFF')
.selectedColor('#007DFF')
.onChange((value: boolean) => {
.onChange((value: boolean) => {
if (value) {
if (value) {
this.checkedList.push(item
.guid
)
this.checkedList.push(item)
} else {
} else {
this.checkedList = this.checkedList.filter(i => i !== item.guid);
this.checkedList = this.checkedList.filter(i => i
.guid
!== item.guid);
}
}
console.info('Checkbox1 change is' + value)
console.info('Checkbox1 change is' + value)
}).margin({ right: 10,left: 10 })
}).margin({ right: 10,left: 10 })
...
@@ -172,11 +174,21 @@ struct UHFScanPage{
...
@@ -172,11 +174,21 @@ struct UHFScanPage{
})
})
}else {
}else {
router.pushUrl({url:"pages/metailmange/GoodsSelectHwPage"
router.pushUrl({url:"pages/metailmange/GoodsSelectHwPage"
,params:
this.checkedList})
,params:
{checkArray:this.checkedList,
checkType:true}})
}
}
})
})
Button("扫货位码").CommonButtonStyle().width("45%")
Button("扫货位码").CommonButtonStyle().width("45%") .onClick(()=>{
if (this.checkedList.length == 0) {
promptAction.showToast({
message: '请至少选择一条单据'
})
}else {
router.pushUrl({url:"pages/metailmange/GoodsSelectHwPage"
,params:{checkArray:this.checkedList,
checkType:false}})
}
})
}
}
}.margin({left:10,right:10}).height(80)
}.margin({left:10,right:10}).height(80)
}.width("100%")
}.width("100%")
...
@@ -264,11 +276,11 @@ struct UHFScanPage{
...
@@ -264,11 +276,11 @@ struct UHFScanPage{
}
}
}
}
/*RFID统计*/
/*RFID统计*/
convertionRfid(rfidName:string):number{
convertionRfid(rfidName:string):number{
var finite = []
var finite = []
Logger.info("识别数据"+JSON.stringify(this.rfidList))
Logger.info("识别数据"+JSON.stringify(this.rfidList))
finite = this.rfidList.map(item => item[rfidName])
finite = this.rfidList.map(item => item[rfidName])
Logger.info("筛选"+JSON.stringify(finite))
Logger.info("筛选"+JSON.stringify(finite))
if (finite && finite.length > 0) {
if (finite && finite.length > 0) {
if (rfidName == 'pmdm' || rfidName == 'hxmc' || rfidName == 'xh') {
if (rfidName == 'pmdm' || rfidName == 'hxmc' || rfidName == 'xh') {
finite = [...new Set(finite)]
finite = [...new Set(finite)]
...
@@ -291,6 +303,7 @@ struct UHFScanPage{
...
@@ -291,6 +303,7 @@ struct UHFScanPage{
}
}
onPageShow() {
onPageShow() {
console.error("========onPageShow=========")
console.error("========onPageShow=========")
this.getUPorDown()
this.rfidInvListen()
this.rfidInvListen()
IdentifyService.openRfidPort()
IdentifyService.openRfidPort()
}
}
...
...
entry/src/main/ets/pages/metailmange/WzInPage/WzinDetail/WzinDetail.ets
View file @
3aaef1a8
...
@@ -105,7 +105,7 @@ struct WzinDetail {
...
@@ -105,7 +105,7 @@ struct WzinDetail {
Row() {
Row() {
Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Button("射频扫码").CommonButtonStyle().width("50%").onClick(() => {
Button("射频扫码").CommonButtonStyle().width("50%").onClick(() => {
router.pushUrl({
url: 'pages/metailmange/UHFScanPage'
})
router.pushUrl({
url:'pages/metailmange/UHFScanPage',params:{wzcrkItem:this.wzcrk}
})
})
})
Button("保存").CommonButtonStyle().width("50%")
Button("保存").CommonButtonStyle().width("50%")
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论