Commit 122ca764 by 宋祥

1.其他入库选择规格逻辑错误问题修复

parent 568fe980
...@@ -45,6 +45,7 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -45,6 +45,7 @@ public class ServiceHPKC001 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@Override
@OperationLogAnnotation(operModul = "采购入库单", operType = "查询", operDesc = "初始化") @OperationLogAnnotation(operModul = "采购入库单", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) { public EiInfo initLoad(EiInfo inInfo) {
try { try {
...@@ -67,8 +68,8 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -67,8 +68,8 @@ public class ServiceHPKC001 extends ServiceBase {
* @param inInfo * @param inInfo
* @return * @return
*/ */
@OperationLogAnnotation(operModul = "采购入库单", operType = "查询", operDesc = "查询")
@Override @Override
@OperationLogAnnotation(operModul = "采购入库单", operType = "查询", operDesc = "查询")
public EiInfo query(EiInfo inInfo) { public EiInfo query(EiInfo inInfo) {
try { try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo); Map queryRow = EiInfoUtils.getFirstRow(inInfo);
...@@ -86,76 +87,59 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -86,76 +87,59 @@ public class ServiceHPKC001 extends ServiceBase {
} }
/** /**
* 新增操作 * 保存操作.
* *
* @param inInfo * @param inInfo
* @return * @return
*/ */
@Override @OperationLogAnnotation(operModul = "采购入库单", operType = "插入", operDesc = "保存")
@OperationLogAnnotation(operModul = "采购入库单", operType = "插入", operDesc = "插入") public EiInfo save(EiInfo inInfo) {
public EiInfo insert(EiInfo inInfo) {
try { try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 数据校验 // 数据校验
this.checkSaveData(resultRows); this.checkSaveData(resultRows);
// 数据写入 // 写入数据
this.insertData(resultRows); this.saveData(resultRows);
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据新增成功!"); inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "新增失败"); LogUtils.setDetailMsg(inInfo, e, "保存失败");
} }
return inInfo; return inInfo;
} }
/** /**
* 写入数据 * 保存数据
* *
* @param resultRows * @param resultRows
*/ */
private void insertData(List<Map> resultRows) { private void saveData(List<Map> resultRows) {
for (Map resultRow : resultRows) { for (Map resultRow : resultRows) {
HPKC001 fKc001 = new HPKC001(); HPKC001 fKc001 = new HPKC001();
fKc001.fromMap(resultRow); fKc001.fromMap(resultRow);
// 设置基础信息 if (fKc001.getId() == null || fKc001.getId() == 0) {
this.setBaseInfo(fKc001); this.addData(fKc001);
// 生成入库单号 } else {
fKc001.setPurchaseNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC001_NUMBER)); // TODO 采购入库不支持修改
DaoUtils.insert(HPKC001.INSERT, fKc001); }
// 修改库存
HPKCTools.updateStock(fKc001.getWhCode(), fKc001.getInventRecordId(), fKc001.getAmount(),
fKc001.getUnitWeight(), fKc001.getWeight());
} }
} }
/** /**
* 修改操作 * 写入数据
* *
* @param inInfo * @param fKc001
* @return
*/ */
@OperationLogAnnotation(operModul = "采购入库单", operType = "修改", operDesc = "修改") private void addData(HPKC001 fKc001) {
public EiInfo update(EiInfo inInfo) { // 设置基础信息
try { this.setBaseInfo(fKc001);
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); // 生成入库单号
// 数据校验 fKc001.setPurchaseNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC001_NUMBER));
this.checkSaveData(resultRows); DaoUtils.insert(HPKC001.INSERT, fKc001);
// 入库单号 // 修改库存
List<String> otherEnterNos = ObjectUtils.listKey(resultRows, "otherEnterNo"); HPKCTools.updateStock(fKc001.getWhCode(), fKc001.getInventRecordId(), fKc001.getAmount(),
// 锁记录 fKc001.getUnitWeight(), fKc001.getWeight());
HPKCTools.HpKc001.lock(otherEnterNos);
// 查询数据库记录
Map<String, HPKC001> mapKc001 = HPKCTools.HpKc001.map(otherEnterNos);
// 保存数据
this.saveData(resultRows, mapKc001);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据修改成功!");
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "修改失败");
}
return inInfo;
} }
/** /**
...@@ -164,9 +148,9 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -164,9 +148,9 @@ public class ServiceHPKC001 extends ServiceBase {
* @param resultRows * @param resultRows
*/ */
private void checkSaveData(List<Map> resultRows) { private void checkSaveData(List<Map> resultRows) {
for (int i = 0; i < resultRows.size(); i++) { for (Map resultRow : resultRows) {
HPKC001 fKc001 = new HPKC001(); HPKC001 fKc001 = new HPKC001();
fKc001.fromMap(resultRows.get(i)); fKc001.fromMap(resultRow);
AssertUtils.isEmpty(fKc001.getWhCode(), "仓库名称不能为空"); AssertUtils.isEmpty(fKc001.getWhCode(), "仓库名称不能为空");
AssertUtils.isEmpty(fKc001.getInventCode(), "存货名称不能为空"); AssertUtils.isEmpty(fKc001.getInventCode(), "存货名称不能为空");
AssertUtils.isNull(fKc001.getInventRecordId(), "规格不能为空"); AssertUtils.isNull(fKc001.getInventRecordId(), "规格不能为空");
...@@ -176,29 +160,6 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -176,29 +160,6 @@ public class ServiceHPKC001 extends ServiceBase {
} }
/** /**
* 保存数据
*
* @param resultRows
* @param mapKc001
*/
private void saveData(List<Map> resultRows, Map<String, HPKC001> mapKc001) {
for (Map resultRow : resultRows) {
HPKC001 fKc001 = new HPKC001();
fKc001.fromMap(resultRow);
// 设置基础信息
this.setBaseInfo(fKc001);
DaoUtils.update(HPKC001.UPDATE, fKc001);
// 计算差异数量与重量
HPKC001 dbKc001 = mapKc001.get(fKc001.getPurchaseNo());
BigDecimal diffAmount = fKc001.getAmount().subtract(dbKc001.getAmount());
BigDecimal diffWeight = fKc001.getWeight().subtract(dbKc001.getWeight());
// 修改库存
HPKCTools.updateStock(fKc001.getWhCode(), fKc001.getInventRecordId(), diffAmount, fKc001.getUnitWeight(),
diffWeight);
}
}
/**
* 设置基础信息 * 设置基础信息
* *
* @param fKc001 * @param fKc001
......
...@@ -11,6 +11,9 @@ $(function() { ...@@ -11,6 +11,9 @@ $(function() {
"result": { "result": {
columns: [{ columns: [{
field: "receiptDate", field: "receiptDate",
attributes: {
class: "i-input-readonly"
},
defaultValue: function () { defaultValue: function () {
return currShortDate(); return currShortDate();
} }
...@@ -116,6 +119,11 @@ $(function() { ...@@ -116,6 +119,11 @@ $(function() {
} }
}); });
}, },
onSave: function (e) {
// 阻止后台保存请求,使用自定义保存
e.preventDefault();
save();
},
onSuccess: function (e) { onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'update' if(e.eiInfo.extAttr.methodName == 'update'
||e.eiInfo.extAttr.methodName == 'insert' ||e.eiInfo.extAttr.methodName == 'insert'
...@@ -214,8 +222,23 @@ let save = function () { ...@@ -214,8 +222,23 @@ let save = function () {
return; return;
} }
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
let amount = rows[i]['amount']; if (isBlank(rows[i]['inventType'])) {
if (!isPositiveInteger(amount)) { message("勾选的第" + (i + 1) + "行存货类型不能为空");
return;
}
if (isBlank(rows[i]['whCode'])) {
message("勾选的第" + (i + 1) + "行仓库名称不能为空");
return;
}
if (isBlank(rows[i]['inventCode'])) {
message("勾选的第" + (i + 1) + "行存货名称不能为空");
return;
}
if (isBlank(rows[i]['inventRecordId'])) {
message("勾选的第" + (i + 1) + "行规格不能为空");
return;
}
if (!isPositiveInteger(rows[i]['amount'])) {
message("勾选的第" + (i + 1) + "行数量必须是大于0的整数"); message("勾选的第" + (i + 1) + "行数量必须是大于0的整数");
return; return;
} }
......
let whNameGlobalData = []; let whNameGlobalData = [];
let inventNameGlobalData = []; let inventNameGlobalData = [];
let specGlobalData = []; let inventAllGlobalData = [];
let firstLoad = 0; let firstLoad = 0;
$(function() { $(function() {
IPLATUI.EFGrid = { IPLATUI.EFGrid = {
...@@ -12,6 +13,9 @@ $(function() { ...@@ -12,6 +13,9 @@ $(function() {
"result": { "result": {
columns: [{ columns: [{
field: "receiptDate", field: "receiptDate",
attributes: {
class: "i-input-readonly"
},
defaultValue: function () { defaultValue: function () {
return currShortDate(); return currShortDate();
} }
...@@ -28,6 +32,7 @@ $(function() { ...@@ -28,6 +32,7 @@ $(function() {
}, },
editor: function (container, options) { editor: function (container, options) {
let inInfo = new EiInfo(); let inInfo = new EiInfo();
// 1.原料,2.耗材,5.废料
inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]); inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
inInfo.set("inqu_status-0-whType", options.model["inventType"]); inInfo.set("inqu_status-0-whType", options.model["inventType"]);
inInfo.set("inqu_status-0-isSplicingSymbol", false); inInfo.set("inqu_status-0-isSplicingSymbol", false);
...@@ -41,98 +46,41 @@ $(function() { ...@@ -41,98 +46,41 @@ $(function() {
field: "inventName", field: "inventName",
title: "存货名称", title: "存货名称",
template: function (dataItem) { template: function (dataItem) {
//let flag = false;
for (let i = 0; i < inventNameGlobalData.length; i++) { for (let i = 0; i < inventNameGlobalData.length; i++) {
if (inventNameGlobalData[i]['textField'] === dataItem['inventName']) { if (inventNameGlobalData[i]['textField'] === dataItem['inventName']) {
dataItem.inventCode = inventNameGlobalData[i]['valueField'] dataItem['inventCode'] = inventNameGlobalData[i]['valueField']
//flag= true;
return inventNameGlobalData[i]['textField']; return inventNameGlobalData[i]['textField'];
} else {
dataItem['inventCode'] = '';
} }
} }
return dataItem.inventName; return dataItem['inventName'];
}, },
editor: function (container, options) { editor: function (container, options) {
var grid = container.closest(".k-grid").data("kendoGrid");
var input = $('<input />');
var dataSource;
input.attr("name", options.field);
input.attr("id", options.field);
input.appendTo(container);
var eiInfo = new EiInfo();
eiInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
eiInfo.set("inventType", options.model["inventType"]);
eiInfo.set("isSplicingSymbol", false);
//eiInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
//eiInfo.set("inqu_status-0-inventCode", options.model["inventCode"]);
//eiInfo.set("inqu_status-0-company_name", options.model["company_name"]);
EiCommunicator.send("HPPZ004", "queryComboBox", eiInfo, {
onSuccess: function (ei) {
dataSource = ei.getBlock("invent_name_block_id").getMappedRows();
inventNameGlobalData = dataSource;
}, onFail: function (ei) {
}
}, {async: false});
input.kendoAutoComplete({
valuePrimitive: true,
dataSource: dataSource,
dataTextField: "textField",
dataValueField: "valueField",
required: "true",
optionLabelTemplate: "#:textField#",
valueTemplate: "#:valueField#",
template: "#:textField#",
filter: "contains"
});
}
/*editor: function (container, options) {
let inInfo = new EiInfo(); let inInfo = new EiInfo();
// 1.原料,2.耗材,5.废料
inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]); inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
inInfo.set("inqu_status-0-inventType", options.model["inventType"]); inInfo.set("inqu_status-0-inventType", options.model["inventType"]);
inInfo.set("serviceName", "HPPZ006"); inInfo.set("inqu_status-0-isSplicingSymbol", false);
inInfo.set("methodName", "queryMaterialComboBox"); inInfo.set("serviceName", "HPPZ004");
inInfo.set("blockId", "material_record_block_id"); inInfo.set("methodName", "queryComboBox");
inInfo.set("blockId", "invent_name_block_id");
inInfo.set("field", options.field); inInfo.set("field", options.field);
refreshSelect(container, inInfo); refreshInputSelect(container, inInfo);
}*/ }
}, { }, {
field: "inventRecordId", field: "inventRecordId",
title: "规格",
template: function (dataItem) { template: function (dataItem) {
for (let i = 0; i < specGlobalData.length; i++) { for (let i = 0; i < inventAllGlobalData.length; i++) {
if (specGlobalData[i]['valueField'] === dataItem['inventRecordId']) { if (inventAllGlobalData[i]['valueField'] === dataItem['inventRecordId']) {
let inventRecordId = specGlobalData[i]['textField']; return inventAllGlobalData[i]['textField'];
/*if (firstLoad === 1){
let inInfo = new EiInfo();
inInfo.set("inqu_status-0-id", dataItem['inventRecordId']);
EiCommunicator.send("HPPZ006", "query", inInfo, {
onSuccess: function (ei) {
let data = ei.blocks.result.rows;
var id = "#datacell__5";
$(id).text(e.model.inventCode)
dataItem["length"] = data[0][8]
dataItem["width"] = data[0][9]
dataItem["thick"] = data[0][10]
dataItem["material"] = data[0][11]
dataItem["coefficient"] = data[0][12]
dataItem["unit"] = data[0][13]
firstLoad = 0;
},
onFail: function (ei) {
}
}, {async: false});
//queryHPPZ006(inInfo,dataItem)
}*/
return inventRecordId;
} }
} }
return ""; return "";
}, },
editor: function (container, options) { editor: function (container, options) {
let inInfo = new EiInfo(); let inInfo = new EiInfo();
// 1.原料,2.耗材,5.废料
inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]); inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
inInfo.set("inqu_status-0-inventCode", options.model["inventCode"]); inInfo.set("inqu_status-0-inventCode", options.model["inventCode"]);
inInfo.set("serviceName", "HPPZ006"); inInfo.set("serviceName", "HPPZ006");
...@@ -144,7 +92,6 @@ $(function() { ...@@ -144,7 +92,6 @@ $(function() {
}], }],
loadComplete: function (grid) { loadComplete: function (grid) {
}, },
//beforeAdd:function(){firstLoad = 1},
onSave: function (e) { onSave: function (e) {
// 阻止后台保存请求,使用自定义保存 // 阻止后台保存请求,使用自定义保存
e.preventDefault(); e.preventDefault();
...@@ -152,41 +99,29 @@ $(function() { ...@@ -152,41 +99,29 @@ $(function() {
}, },
afterEdit: function (e) { afterEdit: function (e) {
if (e.field === "inventRecordId") { if (e.field === "inventRecordId") {
let inventRecordId = e.model.inventRecordId;
if (isBlank(inventRecordId)) {
return;
}
let inInfo = new EiInfo(); let inInfo = new EiInfo();
inInfo.set("inqu_status-0-id", e.model.inventRecordId); // ID为空的情况下需要返回一条空数据
inInfo.set("inqu_status-0-id", inventRecordId);
EiCommunicator.send("HPPZ006", "query", inInfo, { EiCommunicator.send("HPPZ006", "query", inInfo, {
onSuccess: function (ei) { onSuccess: function (ei) {
let data = ei.blocks.result.rows; let data = ei.blocks.result.rows;
//var id = "#datacell__5"; if (data.length > 0) {
//$(id).text(e.model.inventCode) resultGrid.setCellValue(e.model, "length", data[0][8])
resultGrid.setCellValue(e.model,"length",data[0][8]) resultGrid.setCellValue(e.model, "width", data[0][9])
resultGrid.setCellValue(e.model,"width",data[0][9]) resultGrid.setCellValue(e.model, "thick", data[0][10])
resultGrid.setCellValue(e.model,"thick",data[0][10]) resultGrid.setCellValue(e.model, "material", data[0][11])
resultGrid.setCellValue(e.model,"material",data[0][11]) resultGrid.setCellValue(e.model, "coefficient", data[0][12])
resultGrid.setCellValue(e.model,"coefficient",data[0][12]) resultGrid.setCellValue(e.model, "unit", data[0][13])
resultGrid.setCellValue(e.model,"unit",data[0][13]) }
//dataItem["length"] = data[0][8]
//dataItem["width"] = data[0][9]
//dataItem["thick"] = data[0][10]
//dataItem["material"] = data[0][11]
//dataItem["coefficient"] = data[0][12]
//dataItem["unit"] = data[0][13]
firstLoad = 0; firstLoad = 0;
}, },
onFail: function (ei) { onFail: function (ei) {
} }
}, {async: false}); }, {async: false});
//firstLoad = 1;
/*var id = "#datacell_"+e.row+"_5";
$(id).text(e.model.inventCode)
resultGrid.setCellValue({
list:7,
field:"inventRecordId",
cellValue:e.model.inventCode
})
console.log(e.model.inventCode);*/
//e.preventDefault(); // 不关闭单元格
} }
}, },
onSuccess: function (e) { onSuccess: function (e) {
...@@ -211,7 +146,22 @@ $(function() { ...@@ -211,7 +146,22 @@ $(function() {
*/ */
$(window).load(function () { $(window).load(function () {
// 仓库名称 // 仓库名称
initWh()
// 存货名称
initInvent()
// 规格
initSpec()
// 查询
query();
});
/**
* 初始化仓库
*/
let initWh = function () {
let inInfo = new EiInfo(); let inInfo = new EiInfo();
// 1.原料,2.耗材,5.废料
inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]); inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
inInfo.set("inqu_status-0-isSplicingSymbol", false); inInfo.set("inqu_status-0-isSplicingSymbol", false);
EiCommunicator.send("HPPZ007", "queryComboBox", inInfo, { EiCommunicator.send("HPPZ007", "queryComboBox", inInfo, {
...@@ -221,7 +171,16 @@ $(window).load(function () { ...@@ -221,7 +171,16 @@ $(window).load(function () {
onFail: function (ei) { onFail: function (ei) {
} }
}, {async: false}); }, {async: false});
// 存货名称 }
/**
* 初始化存货
*/
let initInvent = function () {
let inInfo = new EiInfo();
// 1.原料,2.耗材,5.废料
inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
inInfo.set("inqu_status-0-isSplicingSymbol", false);
EiCommunicator.send("HPPZ004", "queryComboBox", inInfo, { EiCommunicator.send("HPPZ004", "queryComboBox", inInfo, {
onSuccess: function (ei) { onSuccess: function (ei) {
inventNameGlobalData = ei.getBlock("invent_name_block_id").getMappedRows(); inventNameGlobalData = ei.getBlock("invent_name_block_id").getMappedRows();
...@@ -229,17 +188,24 @@ $(window).load(function () { ...@@ -229,17 +188,24 @@ $(window).load(function () {
onFail: function (ei) { onFail: function (ei) {
} }
}, {async: false}); }, {async: false});
// 规格 }
EiCommunicator.send("HPPZ006", "queryComboBoxSpec", inInfo, {
/**
* 初始化规格
*/
let initSpec = function () {
let inInfo = new EiInfo();
// 1.原料,2.耗材,5.废料
inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
inInfo.set("inqu_status-0-isSplicingSymbol", false);
EiCommunicator.send("HPPZ006", "queryComboBoxAll", inInfo, {
onSuccess: function (ei) { onSuccess: function (ei) {
specGlobalData = ei.getBlock("invent_spec_block_id").getMappedRows(); inventAllGlobalData = ei.getBlock("invent_all_block_id").getMappedRows();
}, },
onFail: function (ei) { onFail: function (ei) {
} }
}, {async: false}); }, {async: false});
// 查询 }
query();
});
/** /**
* 查询 * 查询
...@@ -259,8 +225,19 @@ let save = function () { ...@@ -259,8 +225,19 @@ let save = function () {
return; return;
} }
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
let amount = rows[i]['amount']; if (isBlank(rows[i]['inventType'])) {
if (!isPositiveInteger(amount)) { message("勾选的第" + (i + 1) + "行存货类型不能为空");
return;
}
if (isBlank(rows[i]['whCode'])) {
message("勾选的第" + (i + 1) + "行仓库名称不能为空");
return;
}
if (isBlank(rows[i]['inventCode'])) {
message("勾选的第" + (i + 1) + "行存货名称不能为空");
return;
}
if (!isPositiveInteger(rows[i]['amount'])) {
message("勾选的第" + (i + 1) + "行数量必须是大于0的整数"); message("勾选的第" + (i + 1) + "行数量必须是大于0的整数");
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment