Commit b2fed91e by 陈桂东

commit

parent c9f56595
......@@ -7,5 +7,7 @@ export { Logger } from './src/main/ets/utils/Logger';
export { StatusBarManager } from './src/main/ets/components/StatusBarManager';
export {SQLiteContext} from './src/main/ets/db/SQLiteContext';
export {GldwDao} from './src/main/ets/db/dao/GldwDao';
export {HjInfoDao} from './src/main/ets/db/dao/HjInfoDao';
export {Gldw} from './src/main/ets/entity/Gldw'
export {HjInfo} from './src/main/ets/entity/HjInfo'
......@@ -48,4 +48,13 @@ export class HjInfoDao extends BaseTable<HjInfo> {
)`;
return hj_sql;
}
async getHjList(no: string): Promise<HjInfo[]> {
let wp = this.getPredicates();
if (no) {
wp.equalTo('HJH', no);
}
wp.orderByAsc('HJH');
return this.query(wp, this.getTableColumns())
}
}
\ No newline at end of file
......@@ -7,37 +7,37 @@ export interface Bzhx {
/**
* 10位品名代码(存放10位品名代码或6位无号配号加“0000”)
*/
pmdmten: string,
pmdmten?: string,
/**
* 6位品名代码
*/
pmdmsix: string,
pmdmsix?: string,
/**
* 物资品名
*/
wzpm: string,
wzpm?: string,
/**
* 无号配号品名填"无号配号"
*/
hxmc: string,
hxmc?: string,
/**
* 序号:1、2、3、4、5、6 ...,无号配号填-1
*/
xh: number,
xh?: number,
/**
* 关联品名GUID
*/
pmguid: string,
pmguid?: string,
/**
* 关联号型GUID
*/
hxguid: string,
hxguid?: string,
/**
* 管理品名旧的GUID
*/
pmguid_old: string,
pmguid_old?: string,
/**
* 货位状态|是否删除(11111111SF2禁用,11111111SF1正常)
*/
hwzt: string
hwzt?: string
}
\ No newline at end of file
......@@ -6,13 +6,13 @@ export interface Gldw {
/**
* 单位代码
*/
dwfh: string,
dwfh?: string,
/**
* 单位名称
*/
dwdm: string,
dwdm?: string,
/**
* 单位性质
*/
dwxz: string
dwxz?: string
}
\ No newline at end of file
......@@ -6,25 +6,25 @@ export interface QyInfo {
/**
* 管理仓库编号
*/
ckdwguid: string,
ckdwguid?: string,
/**
* 库房代码
*/
kfdm: string,
kfdm?: string,
/**
* 库房GUID
*/
kfguid: string,
kfguid?: string,
/**
* 区域代码
*/
qydm: string,
qydm?: string,
/**
* 区域名称
*/
qymc: string,
qymc?: string,
/**
* 区域备注
*/
qybz: string
qybz?: string
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import http from '@ohos.net.http';
import CommonConstant from '../constants/CommonConstants';
import axios from '@ohos/axios'
import type { AxiosInstance } from '@ohos/axios'
import type { AxiosRequestConfig } from '@ohos/axios'
import CommonConstant from '../constants/CommonConstants'
import promptAction from '@ohos.promptAction'
/**
* Initiates an HTTP request to a given URL.
*
* @param url URL for initiating an HTTP request.
* @returns the result of HTTPS.
*/
export async function httpPost(url: string, extraData) {
if (!url) {
return undefined;
}
let request = http.createHttp();
let options = {
method: http.RequestMethod.POST,
extraData: extraData,
header: { 'Content-Type': 'application/json' },
readTimeout: CommonConstant.READ_TIMEOUT,
connectTimeout: CommonConstant.CONNECT_TIMEOUT
} as http.HttpRequestOptions;
try {
console.error('--------DDD--------:' + CommonConstant.SERVER + url, options)
let result = await request.request(CommonConstant.SERVER + url, options);
if (result && result.responseCode === CommonConstant.SUCCESS_CODE) {
return result;
}
} catch (error) {
class Request {
instance: AxiosInstance
constructor(config: AxiosRequestConfig) {
this.instance = axios.create(config)
// 响应拦截器
this.instance.interceptors.request.use(
(config) => {
return config
},
(err) => {
promptAction.showToast({
message: $r('app.string.http_response_error')
})
}
)
// 请求拦截器
this.instance.interceptors.response.use(
(res) => {
return res.data.data
},
(err) => {
promptAction.showToast({
message: $r('app.string.http_response_error')
})
}
)
}
request<T = any>(config: AxiosRequestConfig<T>) {
return new Promise<T>((resolve, reject) => {
this.instance
.request<any, T>(config)
.then((res) => {
resolve(res)
})
.catch((err) => {
reject(err)
})
})
}
get<T = any>(config: AxiosRequestConfig) {
return this.request<T>({ ...config, method: 'GET' })
}
post<T = any>(config: AxiosRequestConfig) {
return this.request<T>({ ...config, method: 'POST' })
}
put<T = any>(config: AxiosRequestConfig) {
return this.request<T>({ ...config, method: 'PUT' })
}
delete<T = any>(config: AxiosRequestConfig) {
return this.request<T>({ ...config, method: 'DELETE' })
}
}
const defHttp = new Request({
baseURL: CommonConstant.SERVER,
timeout: CommonConstant.CONNECT_TIMEOUT
})
export default defHttp
\ No newline at end of file
import relationalStore from '@ohos.data.relationalStore';
import { setUpSql } from '../sql/index'
import demoSql from './demo'
class Database {
private dbName = 'GY_M_PMV3'
......@@ -36,7 +35,7 @@ class Database {
}
this.rdbStore = rdbStore
demoSql()
console.log('创建数据库成功,创建表成功')
} catch (error) {
......@@ -82,11 +81,12 @@ class Database {
// 添加
async set(sql: string, tableName?: string) {
try {
console.log(`${tableName}表执行添加操作sql语句: ${sql}`)
console.log(`${tableName}表执行添加操作sql语句>>: ${sql}`)
await this.rdbStore.executeSql(sql)
console.log(`${tableName}表添加数据成功`)
} catch (error) {
console.error(`${tableName}表添加数据失败原因: ` + error)
console.error(`${tableName}表添加数据失败 失败sql>>: ` + sql)
console.error(`${tableName}表添加数据失败原因: ` + JSON.stringify(error) )
}
}
......
import database from './database'
import { importSql, sqlCommon } from '../sql/index'
export default async function demoSql() {
const data = {
guid: 1,
dwfh: "365032",
dwdm: "钧普",
dwxz: '企业'
}
// 添加数据
const setSql = importSql.getGldwSql(data)
await database.set(setSql, 'TAB_BZGL_KNZY_APP_BGDDW')
// 查询数据
const querySql = sqlCommon.getGldw({})
await database.query(querySql, ["guid", "dwfh", "dwdm", "dwxz"], 'TAB_BZGL_KNZY_APP_BGDDW')
}
......@@ -10,7 +10,7 @@ export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
// 初始化数据库
// database.initDB(this.context)
database.initDB(this.context)
}
onDestroy() {
......
import database from '../database/database'
import { Bzhx } from '@ohos/common/src/main/ets/entity/Bzhx'
import { importSql } from '../sql/index'
// 被装号型
class BzhxModal {
private tableName = 'TAB_XTWH_JCSJ_BZHX'
// 添加号型
async set(data: Bzhx[]) {
for (let index = 0; index < data.length; index++) {
const item = data[index];
const sql = importSql.getBzhxSql(item)
await database.set(sql, this.tableName)
}
}
}
const bzhxModal = new BzhxModal()
export default bzhxModal
\ No newline at end of file
import database from '../database/database'
import { Gldw } from '@ohos/common/src/main/ets/entity/Gldw'
import { importSql } from '../sql/index'
// 管理单位
class GldwModal {
private tableName = 'TAB_BZGL_KNZY_APP_BGDDW'
// 添加单位
async set(data: Gldw[]) {
for (let index = 0; index < data.length; index++) {
const item = data[index];
const sql = importSql.getGldwSql(item)
await database.set(sql, this.tableName)
}
}
}
const gldwModal = new GldwModal()
export default gldwModal
\ No newline at end of file
import database from '../database/database'
import { HjInfo, SQLiteContext, HjInfoDao, Logger } from '@ohos/common'
import { importSql } from '../sql/index'
// 货架管理
class HjModal {
private tableName = 'TAB_BZGL_KNZY_APP_HJB'
// 添加货位
async set(data: HjInfo[]) {
SQLiteContext.with(HjInfoDao).batchInsert(data).then(result => {
Logger.info(this, "插入成功" + result);
if (result > 0) {
Logger.info(this, "插入成功" + result);
}
})
// for (let index = 0; index < data.length; index++) {
// const item = data[index];
// const sql = importSql.getHjSql(item)
//
// //await database.set(sql, this.tableName)
// }
}
async query(no?: string):Promise< HjInfo[]> {
let res = await SQLiteContext.with(HjInfoDao).getHjList(no);
return res;
}
}
const hjModal = new HjModal()
export default hjModal
\ No newline at end of file
import database from '../database/database'
import { HwInfo } from '@ohos/common/src/main/ets/entity/HwInfo'
import { importSql } from '../sql/index'
// 货位管理
class HwModal {
private tableName = 'TAB_BZGL_KNZY_APP_HWB'
// 添加货位
async set(data: HwInfo[]) {
for (let index = 0; index < data.length; index++) {
const item = data[index];
const sql = importSql.getHwSql(item)
await database.set(sql, this.tableName)
}
}
}
const hwModal = new HwModal()
export default hwModal
\ No newline at end of file
import database from '../database/database'
import { KfInfo } from '@ohos/common/src/main/ets/entity/KfInfo'
import { importSql, sqlCommon } from '../sql/index'
// 库房管理
class KfModal {
private tableName = 'TAB_BZGL_KNZY_APP_DWKF'
// 添加库房
async set(data: KfInfo[]) {
for (let index = 0; index < data.length; index++) {
const item = data[index];
const sql = importSql.getCkkfSql(item)
await database.set(sql, this.tableName)
}
}
// 查询库房
async query(kfmc?: string) {
const sql = sqlCommon.getKf({ kfmc })
return await database.query<KfInfo>(sql, ['guid', 'kfdm', 'kfmc', 'kflx', 'yxj', 'isdefault'] ,this.tableName)
}
}
const kfModal = new KfModal()
export default kfModal
\ No newline at end of file
import database from '../database/database'
import { QyInfo } from '@ohos/common/src/main/ets/entity/QyInfo'
import { importSql } from '../sql/index'
// 区域
class QyModal {
private tableName = 'TAB_BZGL_KNZY_APP_QYB'
// 查询区域
async set(data: QyInfo[]) {
for (let index = 0; index < data.length; index++) {
const item = data[index];
const sql = importSql.getQySql(item)
await database.set(sql, this.tableName)
}
}
}
const qyModal = new QyModal()
export default qyModal
\ No newline at end of file
......@@ -2,8 +2,16 @@ import { DividerTitle } from '../../../view/DividerTitle/DividerTitle'
import { TitleBar } from '../../../view/title/TitleBar'
import { TipDialog } from '../../../view/TipDialog/TipDialog'
import { ListDialog } from './ListDialog'
import { listData } from './sync.data'
import { httpPost } from "@ohos/common/src/main/ets/utils/HttpUtil"
import { listData, IProductName } from './sync.data'
import { getPmList, getBaseList } from './sync.api'
import { Bzhx } from '@ohos/common/src/main/ets/entity/Bzhx'
import bzhxModal from '../../../model/BzhxModel'
import kfModel from '../../../model/KfModel'
import gldwModel from '../../../model/GldwModel'
import qyModel from '../../../model/QyModel'
import hjModel from '../../../model/HjModel'
import hwModel from '../../../model/HwModel'
import promptAction from '@ohos.promptAction'
@Extend(Button) function CommonButtonStyle() {
.borderWidth(2)
......@@ -23,6 +31,9 @@ import { httpPost } from "@ohos/common/src/main/ets/utils/HttpUtil"
@Component
export struct DataSynchronism {
@State content: string = ''
@State showProgress: boolean = false
@State dwguid: string = '' // 单位代码
dialogController: CustomDialogController = new CustomDialogController({
builder: TipDialog({
cancel: this.onCancel,
......@@ -35,8 +46,6 @@ export struct DataSynchronism {
gridCount: 4,
customStyle: false
})
listController: CustomDialogController = new CustomDialogController({
builder: ListDialog({
cancel: this.onCancel,
......@@ -64,8 +73,48 @@ export struct DataSynchronism {
switch (item.title) {
case "基础信息":
const res = await httpPost("/template/billOfDocument",{})
console.log("基础信息参数:", JSON.stringify(res))
try {
this.showProgress = true
const res = await getPmList({ rows: 5000, page: 1 })
// 获取品名
const allData = JSON.parse(res).bzhxList as Bzhx[]
// 添加品名
await bzhxModal.set(allData)
// 获取基础信息
const baseRes = await getBaseList({ dwguid: this.dwguid })
const { bzdw, ckkfList, ddwAndJw, hjList, hwList, qyList} = JSON.parse(baseRes)
// 添加库房
await kfModel.set(ckkfList)
// 区域添加
await qyModel.set(qyList)
// 货架添加
await hjModel.set(hjList)
// 货位添加
await hwModel.set(hwList)
// 添加管理单位
await gldwModel.set(ddwAndJw)
promptAction.showToast({
message: '同步数据成功'
})
} catch (error) {
promptAction.showToast({
message: '同步数据失败'
})
} finally {
this.showProgress = false
}
break;
case "删除表结构":
......@@ -127,11 +176,10 @@ export struct DataSynchronism {
build() {
Column() {
Column() {
TitleBar({ title: "数据同步" })
Row() {
this.renderLeft()
this.renderRight()
}.justifyContent(FlexAlign.SpaceBetween).margin({ top: 6 })
......@@ -141,5 +189,24 @@ export struct DataSynchronism {
repeating: true,
colors: [['#36a3c0', 0.0], ['#97c6a6', 1.0], ['#c7d799', 2.0]]
})
if (this.showProgress) {
Column() {
}
.width('100%')
.height('100%')
.position({ x: 0, y: 0 })
.backgroundColor('#000')
.opacity(0.2)
LoadingProgress()
.width(50)
.height(60)
.zIndex(100)
.position({ x: 150, y: 350 })
.zIndex(99)
.color(Color.Blue)
}
}
}
}
\ No newline at end of file
import defHttp from "@ohos/common/src/main/ets/utils/HttpUtil"
enum Api {
pmList = '/api/integrate/knzy/infrastructurePm',
baseList = '/api/integrate/knzy/infrastructure'
}
// 获取品名信息
export const getPmList = (data) => defHttp.post({url: Api.pmList, data})
// 获取基础信息
export const getBaseList = (data) => defHttp.post({url: Api.baseList, data})
\ No newline at end of file
......@@ -67,3 +67,21 @@ export const itemData = [
index: 5
},
]
// 基础品名
export interface IProductName {
// 无号配号品名填"无号配号"
hxmc?: string
// 六位品名代码
pmdmSix?: string
// 十位位品名代码
pmdmTen?: string
// 品名名称
wzpm?: string
// '1、2、3、4、5、6 ...,无号配号填-1'
xh?: string
}
\ No newline at end of file
import { Logger } from '@ohos/common/src/main/ets/utils/Logger'
import hjModal from '../../model/HjModel'
import { BasicTable } from '../../view/BasicTable/BasicTable'
import { TitleBar } from '../../view/title/TitleBar'
......@@ -7,6 +9,13 @@ export struct GoodsShelf {
@State searchValue: string = ''
controller: SearchController = new SearchController()
//
aboutToAppear() {
hjModal.query().then(res => {
Logger.info(this, "货架数据>" + JSON.stringify(res));
})
}
build() {
Column() {
Flex({ direction: FlexDirection.Column }) {
......@@ -24,6 +33,7 @@ export struct GoodsShelf {
.margin(20)
.borderRadius(5)
}
Column() {
BasicTable({ dataSource: [], emptyTitle: '暂无货架数据' })
}
......@@ -34,5 +44,4 @@ export struct GoodsShelf {
colors: [['#36a3c0', 0.0], ['#97c6a6', 1.0], ['#c7d799', 2.0]]
})
}
}
\ No newline at end of file
import { KfInfo } from '@ohos/common/src/main/ets/entity/KfInfo'
@Entry
@Component
export struct Demo {
data: KfInfo[]
arr = [1,2,3,4,5]
build() {
Column() {
List(){
ForEach(this.arr, (item, index) => {
ListItem(){
Row() {
Column() {
Row(){
Text("库房代码:")
Text("2")
}
Row(){
Text("库房名称:")
Text("2")
}
}.width('30%')
Column() {
Row() {
Text('凭证号: ')
Text('1')
}.alignSelf(ItemAlign.Start).padding({ top: 8, bottom: 8 })
Row() {
Text("数量: ")
Text('0').fontColor('#ff3d43')
Text('/').fontColor('#ff3d43')
Text('500').fontColor('#ff3d43')
}.alignSelf(ItemAlign.Start)
}.width("30%").padding({ top: 8, bottom: 8 })
Row() {
Text("状态: ")
Text("未完成").fontColor('#ff3d43')
}
}.margin({ top: 10 }).border({ width: { bottom: '1lpx' }, color: "#717171" })
}
})
}
}.width('100%').height('100%')
}
}
\ No newline at end of file
import { BasicTable } from '../../view/BasicTable/BasicTable'
import { TitleBar } from '../../view/title/TitleBar'
import { BasicTable } from '../../../view/BasicTable/BasicTable'
import { TitleBar } from '../../../view/title/TitleBar'
import kfModel from '../../../model/KfModel'
@Entry
@Component
......@@ -7,6 +8,15 @@ export struct Warehouse {
@State searchValue: string = ''
controller: SearchController = new SearchController()
aboutToAppear(){
this.getWarehouseList()
}
// 获取库存数据
async getWarehouseList() {
const res = await kfModel.query()
}
build() {
Column() {
Flex({ direction: FlexDirection.Column }) {
......
......@@ -4,6 +4,11 @@
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
}
],
"deviceTypes": [
"phone",
"tablet"
......
......@@ -15,7 +15,7 @@
"pages/metailmange/AddTemporaryInPage",
"pages/metailmange/AddTemporaryOutPage",
"pages/sub_systemMaintenance/Unit",
"pages/sub_systemMaintenance/Warehouse",
"pages/sub_systemMaintenance/Warehouse/Warehouse",
"pages/sub_systemMaintenance/GoodsShelf",
"pages/sub_systemMaintenance/Pmhx",
"pages/sub_systemMaintenance/Setting",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论