Commit 4f664e8c by huangqy

保存提交

parent 440c774a
...@@ -109,4 +109,11 @@ export interface TestRkHwWzDto { ...@@ -109,4 +109,11 @@ export interface TestRkHwWzDto {
kfguid: string, kfguid: string,
zmlx: string, zmlx: string,
kfdm: string kfdm: string
}
export interface DkTestDto {
pmdmcode: string,
wzpm: string,
crksl: number
} }
\ No newline at end of file
...@@ -422,4 +422,12 @@ export class WzcrkDao extends BaseTable<Wzcrk> { ...@@ -422,4 +422,12 @@ export class WzcrkDao extends BaseTable<Wzcrk> {
} }
// 入库时间修改
async updateWzmxTime(params) {
let val_sql = NativeSql.updateWzmxTime(params);
let db = await this.futureDb;
return await db.executeSql(val_sql)
}
} }
\ No newline at end of file
...@@ -5,7 +5,7 @@ import { Table } from '../decorator/Decorators'; ...@@ -5,7 +5,7 @@ import { Table } from '../decorator/Decorators';
import { Logger } from '../../utils/Logger'; import { Logger } from '../../utils/Logger';
import { NativeSql } from '../sql/NativeSql'; import { NativeSql } from '../sql/NativeSql';
import { WzcrkDetailDto, WzcrkMxRefWzDto } from '../../bean/dto/WzcrkMxRefWzDto'; import { WzcrkDetailDto, WzcrkMxRefWzDto } from '../../bean/dto/WzcrkMxRefWzDto';
import { CommonHxPzMxDto, PzMxDto, PzMxItemDto, RecommendHwDto, TestHwWzDto } from '../../bean/dto/RecommendHwDto.ts'; import { CommonHxPzMxDto, DkTestDto, PzMxDto, PzMxItemDto, RecommendHwDto, TestHwWzDto } from '../../bean/dto/RecommendHwDto.ts';
/** /**
...@@ -461,4 +461,33 @@ export class WzcrkmxDao extends BaseTable<Wzcrkmx> { ...@@ -461,4 +461,33 @@ export class WzcrkmxDao extends BaseTable<Wzcrkmx> {
} }
} }
async getDkTest(params): Promise<DkTestDto[]>{
try {
let val_sql = NativeSql.getDkTestSql(params);
Logger.info(this,"查询sql====>"+val_sql)
let db = await this.futureDb;
let rs = await db.querySql(val_sql);
let items = []
if (rs.goToFirstRow()) {
do {
items.push(this.toDkTest(rs))
} while (rs.goToNextRow())
}
Logger.info(this, 'queryAll items=' + JSON.stringify(items))
return items;
} catch (e) {
throw new Error('[查询异常]|' + e)
}
}
toDkTest(cursor: relationalStore.ResultSet): DkTestDto {
let info: DkTestDto = {
pmdmcode: cursor.getString(cursor.getColumnIndex('pmdmcode')),
wzpm: cursor.getString(cursor.getColumnIndex('wzpm')),
crksl: cursor.getLong(cursor.getColumnIndex('crksl'))
};
return info;
}
} }
\ No newline at end of file
...@@ -180,6 +180,19 @@ WHERE ...@@ -180,6 +180,19 @@ WHERE
return sql return sql
} }
// 倒库验证
static getDkTestSql(params): string {
const sql =
`select pmdmcode ,max(hx.WZPM) wzpm ,sum(ifnull(crksl,0)) crksl from TAB_BZGL_KNZY_APP_WZCRKMX mx left join TAB_XTWH_JCSJ_BZHX hx on hx.PMDMTEN = pmdmcode where mx.WZCRKGUID = '${params.wzcrkguid}' group by pmdmcode having sum(ifnull(crksl,0)) <> 0`
return sql
}
// 入库时间修改
static updateWzmxTime(params): string {
const time = dateUtils.formatDateTime(new Date(), '')
return `update tab_bzgl_knzy_app_wzcrk set crkrq = '${time}',ydh = '${params.ydh}' ,dec = '${params.dec}' where guid = '${params.wzcrkguid}'`
}
/** /**
* 包裹管理表 * 包裹管理表
*/ */
......
...@@ -142,6 +142,11 @@ class WzcrkModel { ...@@ -142,6 +142,11 @@ class WzcrkModel {
return res return res
} }
async updateWzmxTime(params) {
let res = await SQLiteContext.with(WzcrkDao).updateWzmxTime(params);
return res
}
// 清空表 // 清空表
async clear() { async clear() {
await SQLiteContext.with(WzcrkDao).clearTable() await SQLiteContext.with(WzcrkDao).clearTable()
......
...@@ -94,6 +94,11 @@ class WzcrkmxModel { ...@@ -94,6 +94,11 @@ class WzcrkmxModel {
let res = await SQLiteContext.with(WzcrkmxDao).insertWzBing(params) let res = await SQLiteContext.with(WzcrkmxDao).insertWzBing(params)
return res return res
} }
// 倒库验证
async getDkTest(params) {
let res = await SQLiteContext.with(WzcrkmxDao).getDkTest(params)
return res
}
// 清空表 // 清空表
async clear() { async clear() {
await SQLiteContext.with(WzcrkmxDao).clearTable() await SQLiteContext.with(WzcrkmxDao).clearTable()
......
...@@ -26,7 +26,8 @@ import { WzcrkDetailDto } from '@ohos/common/src/main/ets/bean/dto/WzcrkMxRefWzD ...@@ -26,7 +26,8 @@ import { WzcrkDetailDto } from '@ohos/common/src/main/ets/bean/dto/WzcrkMxRefWzD
interface params { interface params {
wzcrk: Wzcrk, wzcrk: Wzcrk,
isUpdate: boolean pzlx: string,
tab: string
} }
/*入库详情*/ /*入库详情*/
@Entry @Entry
...@@ -35,19 +36,63 @@ struct WzinDetail { ...@@ -35,19 +36,63 @@ struct WzinDetail {
@State fontColor: string = '#0FA983' @State fontColor: string = '#0FA983'
@State selectedFontColor: string = '#fff' @State selectedFontColor: string = '#fff'
@State currentIndex: number = 0 @State currentIndex: number = 0
@State isUpdate: boolean = false
@State dataType: boolean = false
@State isHaveButton: boolean = false // 完成状态, 未完成是true, 其他false
@State pageType: string = '入库'
@State pzxqGuild: string = ''
@State wzcrk: WzClass = null // 物资出入库单据信息 @State wzcrk: WzClass = null // 物资出入库单据信息
@State historicalInformation: historicalInformationClass[] = [] // 物资出入库明细 @State historicalInformation: historicalInformationClass[] = [] // 物资出入库明细
@State pzForm: PzFormClass = null // 物资出入库表单详情 @State pzForm: PzFormClass = null // 物资出入库表单详情
@State flag: boolean = true
private controller: TabsController = new TabsController() private controller: TabsController = new TabsController()
onPageShow() { onPageShow() {
const params = router.getParams() as params const params = router.getParams() as params
this.isUpdate = params.isUpdate
this.wzcrk = new WzClass(params.wzcrk) this.wzcrk = new WzClass(params.wzcrk)
if (this.isUpdate) { console.log('------------显示的params:' + JSON.stringify(params));
this.getWzFormDetail() this.pzxqGuild = params.wzcrk.guid
//根据单据状态控制提交按钮显示隐藏
if (params.tab == '导入') {
this.dataType = true
} else {
this.dataType = false
}
if (params.wzcrk.wczt == '完成') {
this.isHaveButton = false
} else if (params.wzcrk.wczt == '未完成') {
this.isHaveButton = true
} else {
// 过度
this.isHaveButton = true
} }
// 根据凭证类型设置提交按钮类型
switch (params.pzlx) {
case '1':
this.pageType = '入库'
break;
case '2':
this.pageType = '出库'
break;
case '3':
this.pageType = '盘库'
break;
case '4':
this.pageType = '调号'
break;
case '5':
this.pageType = '倒库'
// this.currentModel = true
break;
case 'HW44':
this.pageType = '换位'
break;
default:
this.pageType = '入库'
break;
}
this.getWzFormDetail()
this.getWzmxList() this.getWzmxList()
this.scanCodeListen() this.scanCodeListen()
IdentifyService.openScanPort() IdentifyService.openScanPort()
...@@ -69,6 +114,89 @@ struct WzinDetail { ...@@ -69,6 +114,89 @@ struct WzinDetail {
Logger.info('接收到出入库物资明细信息>>', JSON.stringify(pzmxRes)) Logger.info('接收到出入库物资明细信息>>', JSON.stringify(pzmxRes))
} }
/***
* @description: 保存
* @param {*}
* @return {*}
* @author: 王弘钢
*/
async submit() {
try {
if (this.pageType == '倒库' || this.pageType == '调号' || this.pageType == '换位') {
const params = {
wzcrkguid: this.pzxqGuild
}
const testDkSql = await wzcrkmxModel.getDkTest(params)
// const testDkSql = await selectInformationType("GY_M_PMV3", getDkTestSql(
// params))
console.log('调号验证', testDkSql)
this.flag = false
if (testDkSql && testDkSql.length > 0) {
const testDkSqlData = testDkSql.map(item => item.crksl)
var statistics = 0
statistics = testDkSqlData.reduce(function(prev, cur, index, array) {
return Number(prev) + Number(cur);
})
console.log('倒库验证', statistics)
if (statistics != 0) {
if (this.pageType == '调号') {
promptAction.showToast({
message: '请检查当前单据物资明细合计是否为0'
})
return
} else {
promptAction.showToast({
message: '请检查当前单据物资明细合计是否为0'
})
}
}
}
}
const params = {
wzcrkguid: this.pzxqGuild,
ydh: this.wzcrk.ydh,
dec: this.wzcrk.dec
}
// console.log('入库时间修改', updateWzmxTime(params))
//createOrFindSQL("GY_M_PMV3", updateWzmxTime(params))
await wzcrkModel.updateWzmxTime(params)
//const hjData = await selectInformationType("GY_M_PMV3", selectZs(params))
const hjData = await wzcrkModel.selectZs(params)
const {
crksl,
pzsl
} = hjData[0]
const hjParams = {
wzcrkguid: this.pzxqGuild,
crksl,
pzsl
}
// console.log('更新总数', updateZs(hjParams))
// createOrFindSQL("GY_M_PMV3", updateZs(hjParams))
await wzcrkModel.updateZs(hjParams)
// if (this.pageType == '入库') {
// this.setData(newDataSource)
// } else {
// this.overFun()
// }
promptAction.showToast({
message: this.pageType + '成功'
})
setTimeout(() => {
router.back()
}, 1500)
} catch (e) {
//TODO handle the exception
promptAction.showToast({
message: '保存失败'
})
}
}
@Builder TabBuilder(index: number, name: string) { @Builder TabBuilder(index: number, name: string) {
Column() { Column() {
Text(name) Text(name)
...@@ -90,13 +218,7 @@ struct WzinDetail { ...@@ -90,13 +218,7 @@ struct WzinDetail {
Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
TabContent() { TabContent() {
Column() { Column() {
PzInfo({ wzcrk: this.wzcrk })
if (this.isUpdate) {
PzInfo({ wzcrk: this.wzcrk })
} else {
AddWzin({ wzcrk: this.wzcrk })
}
}.width("100%") }.width("100%")
}.tabBar(this.TabBuilder(0, '凭证信息')) }.tabBar(this.TabBuilder(0, '凭证信息'))
...@@ -108,12 +230,12 @@ struct WzinDetail { ...@@ -108,12 +230,12 @@ struct WzinDetail {
// isHaveButton 必传 完成状态 未完成是true, 其他为false // isHaveButton 必传 完成状态 未完成是true, 其他为false
WzInfo({ WzInfo({
wzcrk: this.wzcrk, wzcrk: this.wzcrk,
getDetail: this.getWzmxList,
pageType: "入库",
pzForm: this.pzForm, pzForm: this.pzForm,
getDetail: this.getWzmxList,
historicalInformation: this.historicalInformation, historicalInformation: this.historicalInformation,
dataType: this.isUpdate ? true : false, pageType: this.pageType,
isHaveButton: this.wzcrk.wczt == '未完成' ? true : false dataType: this.dataType,
isHaveButton: this.isHaveButton
}) })
}.width("100%") }.width("100%")
}.tabBar(this.TabBuilder(1, '物资信息')) }.tabBar(this.TabBuilder(1, '物资信息'))
...@@ -134,39 +256,8 @@ struct WzinDetail { ...@@ -134,39 +256,8 @@ struct WzinDetail {
.onClick(async () => { .onClick(async () => {
try { try {
Logger.info('保存的入库明细数据>>', JSON.stringify(this.historicalInformation)) Logger.info('保存的入库明细数据>>', JSON.stringify(this.historicalInformation))
this.submit()
if (this.isUpdate) {
const crksl = this.historicalInformation.map(v => Number(v.crksl)).reduce((a, b) => a + b, 0)
await wzcrkModel.updateWcztByData(this.wzcrk.guid, {
dec: this.wzcrk.dec,
ydh: this.wzcrk.ydh,
crksl
})
for (let index = 0; index < this.historicalInformation.length; index++) {
const element = this.historicalInformation[index];
try {
let val1 = await wzcrkmxModel.updateWcztmxByData(element.mxguid, { crksl: element.crksl })
} catch (e) {
Logger.error(this, '保存失败了>>' + JSON.stringify(e))
}
}
}
else {
this.wzcrk.guid = uuid()
this.wzcrk.gznd = new Date().getFullYear() + ''
this.wzcrk.sjlx = '新建'
await wzcrkModel.setOne(this.wzcrk)
Logger.info('添加的入库数据>>', JSON.stringify(this.wzcrk))
}
promptAction.showToast({
message: '保存入库数据成功',
bottom: 300
})
setTimeout(() => {
router.back({ url: 'pages/metailmange/WzInPage/WzInPage' })
}, 300)
} catch (e) { } catch (e) {
promptAction.showToast({ promptAction.showToast({
message: '保存入库数据失败', message: '保存入库数据失败',
......
...@@ -576,7 +576,9 @@ export struct WzInPage { ...@@ -576,7 +576,9 @@ export struct WzInPage {
WzList({ item, checkedList: $checkedList }).width('100%').backgroundColor('#fff') WzList({ item, checkedList: $checkedList }).width('100%').backgroundColor('#fff')
}.onClick(() => { }.onClick(() => {
router.pushUrl({ url: 'pages/metailmange/Common/WzDetail', params: { router.pushUrl({ url: 'pages/metailmange/Common/WzDetail', params: {
wzcrk: item,isUpdate:true wzcrk: item,
pzlx: 1,
tab: (this.currentIndex === 0 ? "导入" : "临时收物"),
}}) }})
}) })
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论