Commit e6080774 by huangqy

所有的临时全写完了

parent 58a6326e
......@@ -88,5 +88,25 @@ export interface WzmxDto {
export interface PzhDto {
pzh: number
pzh: string
}
export interface SelectZsDto {
wzcrkguid: string,
pzsl: number,
crksl: number
}
export interface TestRkHwWzDto {
guid: string,
hwh: string,
pmdmcode: string,
hwsl: number,
hjguid: string,
hwzt: string,
hwxgsj: string,
gldwguid: string,
kfguid: string,
zmlx: string,
kfdm: string
}
\ No newline at end of file
import relationalStore from '@ohos.data.relationalStore';
import { DjcxDto, PzhDto, PzMxDto, WzmxDto } from '../../bean/dto/RecommendHwDto.ts';
import { DjcxDto, PzhDto, PzMxDto, SelectZsDto, TestRkHwWzDto, WzmxDto } from '../../bean/dto/RecommendHwDto.ts';
import { WzcrkDetailDto } from '../../bean/dto/WzcrkMxRefWzDto';
import { Wzcrk } from '../../entity/Wzcrk';
import { Wzcrkmx } from '../../entity/Wzcrkmx';
......@@ -84,14 +84,10 @@ export class WzcrkDao extends BaseTable<Wzcrk> {
/**
* 更新凭证列表中的总数量和日扫描数量
*/
async updateZs(pzsl: number, crksl: number, wzcrkguid: string): Promise<number> {
let item: Wzcrk
item.pzsl = pzsl
item.crksl = crksl
let predicates = this.getPredicates()
predicates.equalTo('guid', wzcrkguid)
return this.update(item, predicates)
async updateZs(params) {
let val_sql = NativeSql.updateZsSql(params);
let db = await this.futureDb;
return await db.executeSql(val_sql)
}
......@@ -340,9 +336,87 @@ export class WzcrkDao extends BaseTable<Wzcrk> {
toPzh(cursor: relationalStore.ResultSet): PzhDto {
let info: PzhDto = {
pzh: cursor.getLong(cursor.getColumnIndex('pzh')),
pzh: cursor.getString(cursor.getColumnIndex('pzh')),
};
return info;
}
async insertPz(params) {
let val_sql = NativeSql.insertPzSql(params);
let db = await this.futureDb;
return await db.executeSql(val_sql)
}
async selectZs(params) : Promise<SelectZsDto[]> {
try {
let val_sql = NativeSql.selectZsSql(params);
let db = await this.futureDb;
let rs = await db.querySql(val_sql);
let items = []
if (rs.goToFirstRow()) {
do {
items.push(this.toSelectZs(rs))
} while (rs.goToNextRow())
}
Logger.info(this, 'queryAll items22=' + JSON.stringify(items))
return items;
} catch (e) {
throw new Error('[查询异常]|' + e)
}
}
toSelectZs(cursor: relationalStore.ResultSet): SelectZsDto {
let info: SelectZsDto = {
wzcrkguid: cursor.getString(cursor.getColumnIndex('wzcrkguid')),
pzsl: cursor.getLong(cursor.getColumnIndex('pzsl')),
crksl: cursor.getLong(cursor.getColumnIndex('crksl'))
};
return info;
}
// 验证当前货位收否有物资(入库)
async testRkHwWz(params) : Promise<TestRkHwWzDto[]> {
try {
let val_sql = NativeSql.testRkHwWzSql(params);
let db = await this.futureDb;
let rs = await db.querySql(val_sql);
let items = []
if (rs.goToFirstRow()) {
do {
items.push(this.toTestRkHwWz(rs))
} while (rs.goToNextRow())
}
Logger.info(this, 'queryAll items22=' + JSON.stringify(items))
return items;
} catch (e) {
throw new Error('[查询异常]|' + e)
}
}
toTestRkHwWz(cursor: relationalStore.ResultSet): TestRkHwWzDto {
let info: TestRkHwWzDto = {
guid: cursor.getString(cursor.getColumnIndex('guid')),
hwh: cursor.getString(cursor.getColumnIndex('hwh')),
pmdmcode: cursor.getString(cursor.getColumnIndex('pmdmcode')),
hwsl: cursor.getLong(cursor.getColumnIndex('hwsl')),
hjguid: cursor.getString(cursor.getColumnIndex('hjguid')),
hwzt: cursor.getString(cursor.getColumnIndex('hwzt')),
hwxgsj: cursor.getString(cursor.getColumnIndex('hwxgsj')),
gldwguid: cursor.getString(cursor.getColumnIndex('gldwguid')),
kfguid: cursor.getString(cursor.getColumnIndex('kfguid')),
zmlx: cursor.getString(cursor.getColumnIndex('zmlx')),
kfdm: cursor.getString(cursor.getColumnIndex('kfdm'))
};
return info;
}
async updateRkWz(params) {
let val_sql = NativeSql.updateRkWzSql(params);
let db = await this.futureDb;
return await db.executeSql(val_sql)
}
}
\ No newline at end of file
......@@ -105,7 +105,7 @@ WHERE
// 不存在物资,进行物资新增
static insertWzSql(params): string {
const sql =
`insert into tab_bzgl_knzy_app_hwb (guid, hwh, pmdmcode, hwsl, hjguid, hwzt) values ('${params.guid}', '${params.hwh}', '${params.pmdmcode}', '${params.hwsl}', '${params.hjguid}','11111111SF1')`
`insert into tab_bzgl_knzy_app_hwb (guid, hwh, pmdmcode, hwsl, hjguid, hwzt) values ('${params.guid}', '${params.hwh}', '${params.pmdmcode}', ${params.hwsl}, '${params.hjguid}','11111111SF1')`
return sql
}
// -- -- - 物资列表详情
......@@ -141,7 +141,42 @@ WHERE
// 临时凭证号查询
static getPzhSql(params): string {
const sql =
`select 'LS' || (count(1) + 1) pzh from tab_bzgl_knzy_app_wzcrk where sjlx = '${params.sjlx}' and pzlx = ${params.pzlx}`
`select 'LS' || (count(1) + 1) pzh from tab_bzgl_knzy_app_wzcrk where sjlx = '${params.sjlx}' and pzlx = '${params.pzlx}'`
return sql
}
// -- - 物资出入库表:
// 物资出入盘库
// 物资出入库表:
static insertPzSql(params): string {
const sql =
`insert into tab_bzgl_knzy_app_wzcrk (guid, gznd, crkrq, ckdwguid, czr, qrzt, crklx, pzzbguid, pzlx, pzh, sjlx, pzszlx, sfdw, wczt, kfdm, rkkfdm,ydh,dec,fwgldwdm,swgldwdm,kfguid,zmlx) values ('${(params.guid)}', '${(params.gznd)}', '${(params.time)}', '${(params.cbdwdm)}', '${(params.czr)}', '${(params.qrzt)}', '${(params.crklx)}', '${(params.jhguid)}', '${(params.pzlx)}', '${(params.pzh)}', '${(params.sjlx)}', '${(params.pzszlx)}', '${(params.sfdw)}','未完成','${(params.kfdm)}','${(params.rkkfdm)}','${(params.ydh)}','${(params.dec)}', '${(params.fwgldwdm)}', '${(params.swgldwdm)}', '${(params.kfguid)}', '${(params.zmlx)}')`;
return sql
}
// 优化凭证列表显示速度,在出入库主表中加入pzs integex和crkalinteaer 两个学段存放凭证的总数量利
// 凭证列表展示时直接读取数据,修改pzh《凭证号)字段类型为integer
// 凭证导入、退出或保布时操作,导出不管
// --求某一凭证的总激量和扫描总 及量
static selectZsSql(params) {
return `select wzcrkguid, sum(case when ifnull(pzmxguid,'')<>'' then pzsl else 0 end) pzsl, sum(ifnull(crksl,0)) crksl from tab_bzgl_knzy_app_wzcrkmx where wzcrkguid = '${params.wzcrkguid}'`
}
// 更新凭证列表中的总数量和日描总数量
static updateZsSql(params) {
return `update tab_bzgl_knzy_app_wzcrk set pzsl=${params.pzsl}, crksl=${params.crksl} where guid = '${params.wzcrkguid}'`
}
// 验证当前货位收否有物资(入库)
static testRkHwWzSql(params) {
const sql =
`select * from (select hw.*,qy.kfdm kfdm from tab_bzgl_knzy_app_hwb hw left join tab_bzgl_knzy_app_hjb hj on hj.guid = hw.hjguid left join tab_bzgl_knzy_app_qyb qy on qy.guid = hj.qyguid
) where kfdm = '${(params.kfdm)}' and ( pmdmcode = '${(params.pmdmcode)}' or pmdmcode = '' or pmdmcode is null ) and hwh = '${(params.hwh)}' `
return sql
}
static updateRkWzSql(params) {
const sql =
`update tab_bzgl_knzy_app_hwb set hwsl = ifnull(hwsl,0) + ${params.hwsl} , pmdmcode = '${(params.pmdmcode)}' where guid = '${(params.hwguid)}' `
return sql
}
......
......@@ -39,7 +39,7 @@ export interface Wzcrk {
/**
* 凭证号
*/
pzh: number,
pzh: number | string,
/**
* 数据类型 导入/新建
*/
......
......@@ -59,6 +59,16 @@ class WzcrkModel {
// return res;
// }
async insertPz(params) {
let res = await SQLiteContext.with(WzcrkDao).insertPz(params)
return res;
}
async selectZs(params) {
let res = await SQLiteContext.with(WzcrkDao).selectZs(params)
return res;
}
/*获取物资出入库*/
async queryWzcrklist(sql?: string): Promise<Wzcrk[]> {
......@@ -90,6 +100,21 @@ class WzcrkModel {
return res
}
async updateZs(params) {
let res = await SQLiteContext.with(WzcrkDao).updateZs(params)
return res
}
async testRkHwWz(params) {
let res = await SQLiteContext.with(WzcrkDao).testRkHwWz(params)
return res
}
async updateRkWz(params) {
let res = await SQLiteContext.with(WzcrkDao).updateRkWz(params)
return res
}
// 获取单据明细(单据匹配)
async getDjcx() {
let res = await SQLiteContext.with(WzcrkDao).getDjcx()
......
......@@ -215,7 +215,6 @@ export struct WzInsertInfo {
// 在自定义组件即将析构销毁时将dialogController置空
aboutToDisappear() {
this.scanInfoDialog = undefined // 将dialogController置空
Logger.info('Aaaaa>>', JSON.stringify(this.historicalInformation))
}
scanCodeListen() {
......@@ -542,538 +541,6 @@ export struct WzInsertInfo {
/***
* @description: 单据明细新增/修改
*/
async handleSetInsertOrUpdate(res, ITEM) {
const [filterInsrtData] = res.data.filter(item => item.pmdmcode == ITEM.pmdmcode && item
.hxmc == ITEM.hxmc)
var testPmdmCodeSql = []
if (this.pageType == '倒库' || this.pageType == '调号' || this.pageType == '换位') {
testPmdmCodeSql = this.historicalInformation.filter((item) => item.pmdmcode ==
filterInsrtData.pmdmcode && (item.hwh == '' || item.hwh == this.wzcrk.hwh) && item
.currentModel == this.currentModel)
} else {
testPmdmCodeSql = this.historicalInformation.filter((item) => item.pmdmcode ==
filterInsrtData.pmdmcode && (item.hwh == '' || item.hwh == this.wzcrk.hwh))
}
console.log('testPmdmCodeSql', JSON.stringify(testPmdmCodeSql), this.currentModel)
if (testPmdmCodeSql && testPmdmCodeSql.length > 0) {
var update_crksl = 0
if (this.pageType == '倒库' || this.pageType == '调号' || this.pageType == '换位') {
if (this.currentModel) {
update_crksl = Number(testPmdmCodeSql[0].crksl) +
Number(filterInsrtData.srsl)
} else {
update_crksl = Number(testPmdmCodeSql[0].crksl) -
Number(filterInsrtData.srsl)
}
} else {
if (testPmdmCodeSql[0].crksl) {
update_crksl = Number(testPmdmCodeSql[0].crksl) +
Number(filterInsrtData.srsl)
} else {
update_crksl = filterInsrtData.srsl
}
}
const updateParams = {
mxguid: testPmdmCodeSql[0].mxguid,
hwh: testPmdmCodeSql[0].hwh || this.wzcrk.hwh,
crksl: update_crksl
}
console.log("updateParams", JSON.stringify(updateParams))
let s = await wzcrkmxModel.updateWzmx(updateParams)
console.log("updateParams执行成功或者失败:" + JSON.stringify(this.historicalInformation))
} else {
var insert_crksl = 0
if (this.pageType == '倒库' || this.pageType == '调号' || this.pageType == '换位') {
if (this.currentModel) {
insert_crksl = 0 + Number(filterInsrtData.srsl)
} else {
insert_crksl = 0 - Number(filterInsrtData.srsl)
}
} else {
insert_crksl = filterInsrtData.srsl
}
const insertParams = {
guid: uuid(),
pzsl: insert_crksl,
crksl: insert_crksl,
hwh: this.wzcrk.hwh,
wzcrkguid: this.pzxqGuild,
currentModel: this.currentModel,
...filterInsrtData
}
console.log("11.调试======", JSON.stringify(insertParams))
await wzcrkmxModel.insertWz(insertParams)
// createOrFindSQL("GY_M_PMV3", insertWz(insertParams))
ITEM.mxguid = insertParams.guid
}
// this.pageInit(ITEM, 'update')
Logger.info(this, "调试======")
if (res.data && res.data.length > 1) {
Logger.info(this, "调试======1")
this.pageInit(ITEM, 'update')
} else {
if (this.pageType == '倒库' || this.pageType == '调号' || this.pageType == '换位') {
this.pageInit(ITEM, 'update')
} else {
Logger.info(this, "调试======2")
this.setDkScan(ITEM, res.data)
}
}
}
/***
* @description: 修改物资数据
*/
setDkScan(ITEM, ScanData) {
// console.log('修改配置信息=============================================')
try {
if (this.historicalInformation && this.historicalInformation.length > 0) {
const [data] = this.historicalInformation.filter((item, index) =>
item.pmdmcode == ITEM.pmdmcode)
// console.log('判断有没有这条数据,没有新增=============================================')
// console.log(data)
// 判断有没有这条数据,没有新增
if (data) {
// 倒库单判断如果当前为倒出模式判断有没有这个pmdmcode/currentModel为1的
// 有覆盖/无新增(新增向缓存添加,向新增列表添加)
// 如果有这条数据,判断当前数据有没有货位号
if (data.hwh) {
// 如果有货位号,判断货位号和当前扫描货位号是否一致
if (data.hwh == this.wzcrk.hwh) {
if (this.pageType == '倒库') {
// 先检测是否存在,如果存在覆盖,如果没有新增
const newCurrentModel = this.currentModel
const [newIsDk] = this.historicalInformation.filter((item) =>
item.pmdmcode == data
.pmdmcode && item.currentModel == newCurrentModel)
if (newIsDk) {
// 如果一致,则覆盖这条数据货位并合计
this.historicalInformation.forEach(async (item,
index) => {
if (item.hwh == this.wzcrk.hwh && item
.pmdmcode == ITEM.pmdmcode && item
.currentModel ==
newCurrentModel) {
// item.currentModel = this.currentModel
let num = ITEM.srsl || 1
let hjsl = 0
if (this.pageType == '倒库') {
if (item.currentModel) {
hjsl = Number(item.crksl) +
Number(
num)
} else {
hjsl = Number(item.crksl) -
Number(
num)
}
} else {
hjsl = Number(item.crksl) + Number(
num)
}
item.crksl = hjsl
}
})
} else {
const params = {
guid: uuid(),
pzsl: ITEM.srsl,
crksl: ITEM.srsl,
hwh: this.wzcrk.hwh,
wzcrkguid: this.pzxqGuild,
currentModel: this.currentModel,
...ITEM
}
if (params.currentModel) {
params.pzsl = 0 + Number(ITEM.srsl)
params.crksl = 0 + Number(ITEM.srsl)
} else {
params.pzsl = 0 - Number(ITEM.srsl)
params.crksl = 0 - Number(ITEM.srsl)
}
// @ts-ignore
this.insertWzMxFun(params)
// this.historicalInformation.unshift(params)
// this.bufferFun(params)
// createOrFindSQL("GY_M_PMV3", insertWz(params))
// uni.showToast({
// title: '新增单据号型:' + ITEM.hxmc + '模式:' + this.currentModel ? '倒出' :
// '倒入',
// icon: 'none'
// })
}
} else {
// 如果一致,则覆盖这条数据货位并合计
this.historicalInformation.forEach(async (item,
index) => {
if (item.hwh == this.wzcrk.hwh && item
.pmdmcode == ITEM.pmdmcode) {
// item.currentModel = this.currentModel
let num = ITEM.srsl || 1
let hjsl = 0
if (this.pageType == '倒库') {
if (item.currentModel) {
hjsl = Number(item.crksl) +
Number(
num)
} else {
hjsl = Number(item.crksl) -
Number(
num)
}
} else {
hjsl = Number(item.crksl) + Number(num)
}
item.crksl = hjsl
// this.bufferFun(item)
}
})
}
} else {
if (this.pageType == '倒库') {
// 先检测是否存在,如果存在覆盖,如果没有新增
const newCurrentModel = this.currentModel
const [newIsDk] = this.historicalInformation.filter((item) =>
item.pmdmcode == data
.pmdmcode && item.currentModel == newCurrentModel)
if (newIsDk) {
// 如果不一致,则新增数据
const [newHwData] = this.historicalInformation.filter((
item) => item.hwh ==
this
.wzcrk
.hwh && item.pmdmcode == ITEM.pmdmcode)
if (newHwData) {
this.historicalInformation.forEach(async (item,
index) => {
if (item.hwh == this.wzcrk.hwh && item
.pmdmcode == ITEM
.pmdmcode && item.currentModel ==
newCurrentModel) {
let num = ITEM.srsl || 1
let hjsl = 0
if (this.pageType == '倒库') {
if (item.currentModel) {
hjsl = Number(item.crksl) +
Number(
num)
} else {
hjsl = Number(item.crksl) -
Number(
num)
}
} else {
hjsl = Number(item.crksl) +
Number(num)
}
item.crksl = hjsl
// this.bufferFun(item)
}
})
} else {
if (this.pageType == '倒库') {
Prompt.showToast({
message: '此单据号型:' + ITEM.hxmc + '不存在'
})
return
} else {
this.insertWzmxFun(ITEM)
}
}
} else {
const params = {
guid: uuid(),
pzsl: ITEM.srsl,
crksl: ITEM.srsl,
hwh: this.wzcrk.hwh,
wzcrkguid: this.pzxqGuild,
currentModel: this.currentModel,
...ITEM
}
if (params.currentModel) {
params.pzsl = 0 + Number(ITEM.srsl)
params.crksl = 0 + Number(ITEM.srsl)
} else {
params.pzsl = 0 - Number(ITEM.srsl)
params.crksl = 0 - Number(ITEM.srsl)
}
// @ts-ignore
this.insertWzMxFun(params)
// this.historicalInformation.unshift(params)
// this.bufferFun(params)
// createOrFindSQL("GY_M_PMV3", insertWz(params))
// uni.showToast({
// title: '新增单据号型:' + ITEM.hxmc + '模式:' + this.currentModel ? '倒出' :
// '倒入',
// icon: 'none'
// })
}
} else {
// 如果不一致,则新增数据
const [newHwData] = this.historicalInformation.filter((item) =>
item.hwh == this
.wzcrk
.hwh && item.pmdmcode == ITEM.pmdmcode)
if (newHwData) {
this.historicalInformation.forEach(async (item,
index) => {
if (item.hwh == this.wzcrk.hwh &&
item
.pmdmcode == ITEM.pmdmcode) {
let num = ITEM.srsl || 1
let hjsl = 0
if (this.pageType == '倒库') {
if (item.currentModel) {
hjsl = Number(item.crksl) +
Number(
num)
} else {
hjsl = Number(item.crksl) -
Number(
num)
}
} else {
hjsl = Number(item.crksl) + Number(
num)
}
item.crksl = hjsl
// this.bufferFun(item)
}
})
} else {
if (this.pageType == '倒库') {
Prompt.showToast({
message: '此单据号型:' + ITEM.hxmc + '不存在'
})
return
} else {
console.log(
'==========================不存在4==============='
)
this.insertWzmxFun(ITEM)
}
}
}
}
} else {
console.log('========================= 无货位 ======================')
if (this.pageType == '倒库') {
// 先检测是否存在,如果存在覆盖,如果没有新增
const newCurrentModel = this.currentModel
const [newIsDk] = this.historicalInformation.filter((item) => item
.pmdmcode == data
.pmdmcode && item.currentModel == newCurrentModel)
console.log('没有货位====================')
//console.log(newIsDk)
if (newIsDk) {
// console.log('==========================存在===============1')
// 如果没有货位号,则覆盖这条数据货位并合计
this.historicalInformation.forEach(async (item, index) => {
if (item.pmdmcode == data.pmdmcode && item
.currentModel ==
newCurrentModel) {
if (!item.hwh) {
item.hwh = this.wzcrk.hwh
// @ts-ignore
item.hjguid = this.wzcrk.hjguid
}
let num = ITEM.srsl || 1
let hjsl = 0
if (this.pageType == '倒库') {
if (item.currentModel) {
hjsl = Number(item.crksl) +
Number(
num)
} else {
hjsl = Number(item.crksl) -
Number(
num)
}
} else {
hjsl = Number(item.crksl) + Number(num)
}
item.crksl = hjsl
// this.bufferFun(item)
}
})
} else {
console.log('==========================不存在5===============2')
const params = {
guid: uuid(),
pzsl: ITEM.srsl,
crksl: ITEM.srsl,
hwh: this.wzcrk.hwh,
wzcrkguid: this.pzxqGuild,
currentModel: this.currentModel,
...ITEM
}
if (params.currentModel) {
params.pzsl = 0 + Number(ITEM.srsl)
params.crksl = 0 + Number(ITEM.srsl)
} else {
params.pzsl = 0 - Number(ITEM.srsl)
params.crksl = 0 - Number(ITEM.srsl)
}
console.log('===========params5', params)
// @ts-ignore
this.insertWzMxFun(params)
// this.historicalInformation.unshift(params)
// this.bufferFun(params)
// createOrFindSQL("GY_M_PMV3", insertWz(params))
// uni.showToast({
// title: '新增单据号型:' + ITEM.hxmc + '模式:' + this.currentModel ? '倒出' : '倒入',
// icon: 'none'
// })
}
} else {
// 如果没有货位号,则覆盖这条数据货位并合计
this.calcWzmxFun(data, ITEM)
}
}
} else {
// 倒库单 判断有没有这条数据,没有提示
if (this.pageType == '倒库') {
Prompt.showToast({
message: '此单据号型:' + ITEM.hxmc + '不存在'
})
return
} else {
console.log('==========================不存在6===============')
this.insertWzmxFun(ITEM)
}
}
} else {
// console.log('========================= 列表无数据新增 ======================')
if (this.pageType == '倒库') {
Prompt.showToast({
message: '此单据号型:' + ITEM.hxmc + '不存在'
})
return
} else {
console.log('==========================不存在7===============')
this.insertWzmxFun(ITEM)
}
}
const newData = ScanData.map((item) => {
const [filterData] = this.historicalInformation.filter((fLe) => fLe.pmdmcode ==
item.pmdmcode && fLe.hwh == this.currentHwh)
return filterData
}) as ScanWzClass []
console.log('this.newData', JSON.stringify(newData))
this.currentWZInfo = []
newData.forEach(i => {
this.currentWZInfo.push(new ScanWzClass(i))
})
console.log('this.currentWZInfo', JSON.stringify(this.currentWZInfo))
Logger.info(this, '手动修改结束', dateUtils.formatDate(new Date()))
} catch (e) {
//TODO handle the exception
Prompt.showToast({
message: '修改物资失败'
})
}
}
/***
* @description: 新增物资明细
* @param {*}
* @return {*}
* @author: 王弘钢
*/
insertWzmxFun(ITEM) {
try {
var insert_crksl = 0
if (this.pageType == '倒库') {
if (this.currentModel) {
insert_crksl = 0 + Number(ITEM.srsl)
} else {
insert_crksl = 0 - Number(ITEM.srsl)
}
} else {
insert_crksl = ITEM.srsl
}
const params = {
guid: uuid(),
pzsl: insert_crksl,
crksl: insert_crksl,
hwh: this.wzcrk.hwh,
wzcrkguid: this.pzxqGuild,
currentModel: this.currentModel,
...ITEM
}
// console.log('新增单据号型', params)
// console.log('开始新增物资明细', dateUtils.formatDate(new Date()))
// createOrFindSQL("GY_M_PMV3", insertWz(params))
// console.log('新增物资明细结束', dateUtils.formatDate(new Date()))
// this.insertWzMxFun(params)
this.historicalInformation.unshift(params)
console.log("==========================", JSON.stringify(this.historicalInformation))
// this.historicalInformation.forEach((item) => {
// if (item.pmdmcode == params.pmdmcode) {
// console.log('筛选ITEM', item)
// if (item.children && item.children.length > 0) {
// const [filterPmData] = item.children.filter((ELEMENT) => ELEMENT.pmdmcode == params
// .pmdmcode && ELEMENT.hwh == params.hwh)
// if (filterPmData) {
// item.children.forEach(newItem => {
// if (newItem.pmdmcode == params.pmdmcode && ELEMENT.hwh == params
// .hwh) {
// newItem.crksl = Number(newItem.crksl) + Number(insert_crksl)
// newItem.pzsl = Number(newItem.pzsl) + Number(insert_crksl)
// console.log('筛选ITEM.===', item.children)
// }
// })
// // item.children.(params)
// } else {
// item.children.push(params)
// console.log('筛选ITEM.push', item.children)
// }
// } else {
// item.children = []
// item.children.push(params)
// console.log('筛选ITEM.push', item.children)
// }
// }
// })
// createOrFindSQL("GY_M_PMV3", insertWz(params))
// uni.showToast({
// title: '新增单据号型:' + ITEM.hxmc,
// icon: 'none'
// })
} catch (e) {
//TODO handle the exception
Prompt.showToast({
message: '物资新增失败'
})
}
}
/***
* @description: 计算合计数
* @param {*}
* @return {*}
......
......@@ -40,7 +40,7 @@ export class WzClass {
/**
* 凭证号
*/
pzh: number
pzh: string | number
/**
* 数据类型 导入/新建
*/
......@@ -101,33 +101,38 @@ export class WzClass {
* 备注
*/
dec: string
/**
* 货位号
*/
hwh: string
constructor(data: {
gznd: string;
crkrq: string;
ckdwguid: string;
czr: string;
qrzt: string;
crklx: string;
pzzbguid: string;
pzlx: string;
sjlx: string;
pzszlx: string;
sfdw: string;
wczt: string;
kfdm: string;
rkkfdm: string;
ydh: string;
fwgldwdm: string;
swgldwdm: string;
kfguid: string;
zmlx: string;
bdguid: string;
dec: string;
gznd?: string;
crkrq?: string;
ckdwguid?: string;
czr?: string;
qrzt?: string;
crklx?: string;
pzzbguid?: string;
pzlx?: string;
sjlx?: string;
pzszlx?: string;
sfdw?: string;
wczt?: string;
kfdm?: string;
rkkfdm?: string;
ydh?: string;
fwgldwdm?: string;
swgldwdm?: string;
kfguid?: string;
zmlx?: string;
bdguid?: string;
dec?: string;
guid?: string;
pzh?: number;
pzh?: number | string;
pzsl?: number;
crksl?: number;
hwh?: string
}) {
this.guid = data.guid || '';
this.gznd = data.gznd || '';
......@@ -154,6 +159,7 @@ export class WzClass {
this.zmlx = data.zmlx || '';
this.bdguid = data.bdguid || '';
this.dec = data.dec || '';
this.hwh = data.hwh || ''
}
}
......@@ -251,38 +257,46 @@ export class WzmxClass {
// 物资明细
@Observed
export class historicalInformationClass {
wzpm: string
pmdmsix: string
pmdmcode: string
hxmc: string
pzsl: number
crksl: number
hwh: string
mxguid: string
pzmxguid: string
guid?: string
wzcrkguid?: string
wzpm?: string
pmdmsix?: string
pmdmcode?: string
pmdm?: string
hxmc?: string
pzsl?: number
crksl?: number
hwh?: string
mxguid?: string
pzmxguid?: string
currentModel?: boolean
srsl?: number
hwsl?: number
constructor(data: {
wzpm: string
pmdmsix: string
pmdmcode: string
hxmc: string
pzsl: number
crksl: number
hwh: string
mxguid: string
pzmxguid: string
guid?: string
wzcrkguid?: string
wzpm?: string
pmdmsix?: string
pmdmcode?: string
pmdm?: string
hxmc?: string
pzsl?: number
crksl?: number
hwh?: string
mxguid?: string
pzmxguid?: string
currentModel?: boolean
srsl?: number
hwsl?: number
}) {
this.guid = data.guid
this.wzcrkguid = data.wzcrkguid
this.wzpm = data.wzpm
this.pmdmsix = data.pmdmsix
this.pmdmcode = data.pmdmcode
this.pmdm = data.pmdm
this.hxmc = data.hxmc
this.pzsl = data.pzsl
this.crksl = data.crksl
......
......@@ -59,7 +59,7 @@ export struct WzInPage {
pzh: this.pzh,
page: this.page,
rows: this.rows,
sjlx: this.currentIndex === 0 ? "导入" : "新建",
sjlx: this.currentIndex === 0 ? "导入" : "临时收物",
wczt: "未完成"
}
......
......@@ -38,16 +38,14 @@ struct WzinsertDetail {
@State currentSjlx: string = '临时收物'
@State pageType: string = "入库"
@State wzcrk: WzClass = null // 物资出入库单据信息
@State uuId: string = ''
@State historicalInformation: historicalInformationClass[] = [] // 物资出入库明细
@State pzForm: PzFormClass = null // 物资出入库表单详情
private controller: TabsController = new TabsController()
onPageShow() {
const params = router.getParams() as params
this.wzcrk = new WzClass({})
this.setMilitaryGoodsType(params)
// 获取凭证号
//
// this.wzcrk = new WzClass(params.wzcrk)
this.scanCodeListen()
IdentifyService.openScanPort()
}
......@@ -62,22 +60,22 @@ struct WzinsertDetail {
if (data.sjlx) {
this.currentSjlx = data.sjlx
}
// this.pzForm.zmlx = zmlx_dict[0].value
this.wzcrk.zmlx = zmlx_dict[0].value
let newType = 'rkd'
switch (data.pzlx) {
case '1':
this.pageType = '入库'
newType = 'rkd'
this.pzForm.pzlx = '14'
this.pzForm.pzszlx = 'DR'
this.hanleGetDefaultPzh(this.pzForm.pzlx)
this.wzcrk.pzlx = '14'
this.wzcrk.pzszlx = 'DR'
this.hanleGetDefaultPzh(this.wzcrk.pzlx)
break;
case '2':
this.pageType = '出库'
newType = 'ckd'
this.pzForm.pzlx = '17'
this.pzForm.pzszlx = 'DC'
this.hanleGetDefaultPzh(this.pzForm.pzlx)
this.wzcrk.pzlx = '17'
this.wzcrk.pzszlx = 'DC'
this.hanleGetDefaultPzh(this.wzcrk.pzlx)
break;
case '3':
this.pageType = '盘库'
......@@ -86,15 +84,15 @@ struct WzinsertDetail {
case '4':
this.pageType = '调号'
newType = 'thd'
this.pzForm.pzlx = '41'
this.pzForm.pzszlx = 'HXTH'
this.hanleGetDefaultPzh(this.pzForm.pzlx)
this.wzcrk.pzlx = '41'
this.wzcrk.pzszlx = 'HXTH'
this.hanleGetDefaultPzh(this.wzcrk.pzlx)
break;
case 'HW44':
this.pageType = '换位'
newType = 'wzhw'
this.pzForm.pzlx = 'HW44'
this.hanleGetDefaultPzh(this.pzForm.pzlx)
this.wzcrk.pzlx = 'HW44'
this.hanleGetDefaultPzh(this.wzcrk.pzlx)
// uni.setNavigationBarTitle({
// title: '物资换位', // 设置页签名称
// });
......@@ -102,9 +100,9 @@ struct WzinsertDetail {
default:
this.pageType = '入库'
newType = 'rkd'
this.pzForm.pzlx = '14'
this.pzForm.pzszlx = 'DR'
this.hanleGetDefaultPzh(this.pzForm.pzlx)
this.wzcrk.pzlx = '14'
this.wzcrk.pzszlx = 'DR'
this.hanleGetDefaultPzh(this.wzcrk.pzlx)
break;
}
}
......@@ -122,21 +120,89 @@ struct WzinsertDetail {
}
const res = await wzcrkModel.getLhPzh(params)
if (res && res.length > 0) {
this.pzForm.pzh = res[0].pzh
this.wzcrk.pzh = res[0].pzh
}
}
setData(data) {
this.looperFun(data, 0)
}
async looperFun(data, count) {
const params = {
...data[count],
kfdm: this.wzcrk.kfdm
}
const testRk = await wzcrkModel.testRkHwWz(params)
// const testRk = await selectInformationType("GY_M_PMV3", testRkHwWzSql(params));
if (testRk && testRk.length > 0) {
testRk.forEach(async (tItem) => {
await wzcrkModel.updateRkWz({
...data[count],
hwguid: tItem.guid
})
// await createOrFindSQL("GY_M_PMV3",
// updateRkWzSql({
// ...data[count],
// hwguid: tItem.GUID
// }))
})
} else {
await wzcrkmxModel.insertWz(data[count])
// await createOrFindSQL("GY_M_PMV3", insertWzSql(data[count]))
}
if (data && data.length > 0) {
const num = data.length - 1
if (num > count) {
setTimeout(() => {
count++
this.looperFun(data, count)
}, 500)
} else {
this.overFun()
}
}
}
async overFun() {
// const uuId = uuid()
// 获取物资列表详情信息
async getWzmxList(wzpm?) {
const pzmxRes = await wzcrkModel.getPzMx({ guid: this.wzcrk.guid })
pzmxRes.forEach((element) => {
this.historicalInformation.push(new historicalInformationClass(element))
const params = {
crkrq: new Date().toLocaleString(),
guid: this.uuId,
sjlx: this.currentSjlx || '新建',
...this.wzcrk
}
await wzcrkModel.insertPz(params)
// await createOrFindSQL("GY_M_PMV3", insertPz(params))
const zsParams = {
wzcrkguid: this.uuId
}
wzcrkModel.selectZs(zsParams).then(async (hjData) => {
// selectInformationType("GY_M_PMV3", selectZs(zsParams)).then((hjData) => {
if (hjData && hjData.length > 0) {
const {
crksl,
pzsl
} = hjData[0]
const hjParams = {
wzcrkguid: this.uuId,
crksl,
pzsl
}
await wzcrkModel.updateZs(hjParams)
// createOrFindSQL("GY_M_PMV3", updateZs(hjParams))
}
})
promptAction.showToast({
message: this.pageType + '成功'
})
Logger.info('接收到出入库物资明细信息>>', JSON.stringify(pzmxRes))
setTimeout(() => {
router.back()
}, 1500)
}
@Builder TabBuilder(index: number, name: string) {
Column() {
Text(name)
......@@ -170,10 +236,8 @@ struct WzinsertDetail {
// isHaveButton 必传 完成状态 未完成是true, 其他为false
WzInsertInfo({
wzcrk: this.wzcrk as PzFormClass,
getDetail: this.getWzmxList,
pageType: "入库",
historicalInformation: this.historicalInformation,
isHaveButton: this.wzcrk.wczt == '未完成' ? true : false
pageType: this.pageType,
historicalInformation: this.historicalInformation
})
}.width("100%")
}.tabBar(this.TabBuilder(1, '物资信息'))
......@@ -194,35 +258,170 @@ struct WzinsertDetail {
.onClick(async () => {
try {
Logger.info('保存的入库明细数据>>', JSON.stringify(this.historicalInformation))
if (!this.wzcrk.hwh) {
promptAction.showToast({
message: '请先扫描货位'
})
return
}
if (this.historicalInformation.length == 0) {
promptAction.showToast({
message: '请扫描物资'
})
return
}
const uuId = uuid()
this.uuId = uuId
// const params = {
// crkrq: new Date().toLocaleString(),
// guid: uuId,
// ...this.pzFrom
// }
// await createOrFindSQL("GY_M_PMV3", insertPz(params))
// if (this.pageType == '出库') {
// const newKcList = [...new Set(this.kcList)]
// newKcList.forEach(async (item) => {
// await createOrFindSQL("GY_M_PMV3", updateCkWzSql(item))
// })
// }
const uid = uuid()
this.wzcrk.guid = uid
this.wzcrk.gznd = new Date().getFullYear() + ''
this.wzcrk.sjlx = '新建'
await wzcrkModel.setOne(this.wzcrk)
Logger.info('添加的入库数据>>', JSON.stringify(this.wzcrk))
var newDataSource = []
this.historicalInformation.forEach(async (item) => {
item.guid = uuid()
item.wzcrkguid = this.uuId
if (this.pageType == '调号') {
if (item.currentModel) {
// 调出
item.pzsl = item.srsl
item.crksl = item.srsl
// item.crksl = 0 - Number(item.srsl)
} else {
// 调入
item.pzsl = 0 - Number(item.srsl)
item.crksl = 0 - Number(item.srsl)
// item.crksl = item.srsl
}
} else if (this.pageType == '换位') {
if (item.currentModel) {
// 换入
item.pzsl = 0 - Number(item.srsl)
item.crksl = 0 - Number(item.srsl)
// item.crksl = item.srsl
} else {
// 换出
item.pzsl = item.srsl
item.crksl = item.srsl
// item.crksl = 0 - Number(item.srsl)
}
} else {
item.pzsl = item.srsl
item.crksl = item.srsl
}
item.hwsl = item.srsl
if (this.pageType == '入库') {
newDataSource.push(item)
}
})
if (this.pageType == '调号') {
// currentModel
const fArr = this.historicalInformation.map((item) => Number(item.pzsl))
const sArr = this.historicalInformation.map((item) => Number(item.crksl))
const res1 = fArr.reduce((x, y) => x + y);
const res2 = sArr.reduce((x, y) => x + y);
if (res1 !== 0 || res2 !== 0) {
promptAction.showToast({
message: '调号总数不一致,不可提交'
})
return
} else {
const pmdmList = this.historicalInformation.map((pmdmItem) => pmdmItem
.pmdm)
const setPmdmList = [...new Set(pmdmList)]
const thzhjs = setPmdmList.map((setItem) => {
const pmdmJhList = this.historicalInformation.map((
pmdmItem) => {
if (pmdmItem.pmdm == setItem) {
return Number(pmdmItem.crksl)
} else {
return 0
}
})
const itemHj = pmdmJhList.reduce((x, y) => x + y);
return itemHj
})
var thzhjssl = true
thzhjs.forEach((thzhjsItem) => {
if (thzhjsItem != 0) {
thzhjssl = false
}
})
if (thzhjssl) {
this.historicalInformation.forEach(async (item) => {
await wzcrkmxModel.insertWzBing(item)
// await createOrFindSQL("GY_M_PMV3", insertWz(item))
})
} else {
promptAction.showToast({
message: '同品种调号数量不一致,不可提交'
})
return
}
const data = this.historicalInformation.map((v => {
return {
guid: uuid(),
gznd: new Date().getFullYear() + '',
pmdmcode: v.pmdmcode,
pzsl: v.pzsl,
crksl: v.crksl,
wzcrkguid: uid,
hwh: v.hwh,
pzmxguid: v.pzmxguid
}
}))
} else if (this.pageType == '换位') {
const fArr = this.historicalInformation.map((item) => Number(item.pzsl))
const sArr = this.historicalInformation.map((item) => Number(item.crksl))
const res1 = fArr.reduce((x, y) => x + y);
const res2 = sArr.reduce((x, y) => x + y);
if (res1 !== 0 || res2 !== 0) {
promptAction.showToast({
message: '总数不一致,不可提交'
})
return
} else {
const pmdmcodeData = this.historicalInformation.map((item) => item
.pmdmcode)
const newPmdmcodeData = [...new Set(pmdmcodeData)]
const testHw = newPmdmcodeData.map((item) => {
const npdList = this.historicalInformation.filter(ele => ele
.pmdmcode == item)
const hwTjArr = npdList.map((item) => Number(item.crksl))
const hwTj = hwTjArr.reduce((x, y) => x + y);
console.log('hwTj', hwTj)
if (hwTj == 0) {
return true
} else {
return false
}
})
console.log('testHw', testHw)
const isTestHw = testHw.every(item => item)
console.log('isTestHw', isTestHw)
if (isTestHw) {
this.historicalInformation.forEach(async (item) => {
await wzcrkmxModel.insertWzBing(item)
// await createOrFindSQL("GY_M_PMV3", insertWz(item))
})
} else {
promptAction.showToast({
message: '同品种号型换位数量不一致,不可提交'
})
return
}
}
} else {
this.historicalInformation.forEach(async (item) => {
await wzcrkmxModel.insertWzBing(item)
// await createOrFindSQL("GY_M_PMV3", insertWz(item))
})
}
if (this.pageType == '入库') {
this.setData(newDataSource)
} else {
this.overFun()
}
await wzcrkmxModel.set(data)
promptAction.showToast({
message: '保存入库数据成功',
bottom: 300
})
setTimeout(() => {
router.back({ url: 'pages/metailmange/WzInPage/WzInPage' })
}, 300)
} catch (e) {
promptAction.showToast({
message: '保存入库数据失败',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论