Commit 80620a6b by wuwenlong

采购订单;

parent 55d67351
...@@ -16,6 +16,8 @@ public class HPSqlConstant { ...@@ -16,6 +16,8 @@ public class HPSqlConstant {
// 统计 // 统计
public static final String STAT_DATE = "HPKC001.statDate"; public static final String STAT_DATE = "HPKC001.statDate";
// 锁
public static final String LOCK = "HPKC001.lock";
} }
/** /**
......
...@@ -34,6 +34,7 @@ public class HPKC001 extends DaoEPBase { ...@@ -34,6 +34,7 @@ public class HPKC001 extends DaoEPBase {
public static final String FIELD_UPDATED_NAME = "updatedName"; /* 更新人名称*/ public static final String FIELD_UPDATED_NAME = "updatedName"; /* 更新人名称*/
public static final String FIELD_UPDATED_TIME = "updatedTime"; /* 更新时间*/ public static final String FIELD_UPDATED_TIME = "updatedTime"; /* 更新时间*/
public static final String FIELD_PURCHASE_CODE = "purchaseCode"; /* 采购单号*/ public static final String FIELD_PURCHASE_CODE = "purchaseCode"; /* 采购单号*/
public static final String FIELD_OLD_PURCHASE_CODE = "oldPurchaseCode"; /* 原采购单号*/
public static final String FIELD_RECEIPT_DATE = "receiptDate"; /* 单据日期*/ public static final String FIELD_RECEIPT_DATE = "receiptDate"; /* 单据日期*/
public static final String FIELD_WH_CODE = "whCode"; /* 仓库编码*/ public static final String FIELD_WH_CODE = "whCode"; /* 仓库编码*/
public static final String FIELD_WH_NAME = "whName"; /* 仓库名称*/ public static final String FIELD_WH_NAME = "whName"; /* 仓库名称*/
...@@ -55,7 +56,7 @@ public class HPKC001 extends DaoEPBase { ...@@ -55,7 +56,7 @@ public class HPKC001 extends DaoEPBase {
public static final String COL_UPDATED_BY = "UPDATED_BY"; /* 更新人*/ public static final String COL_UPDATED_BY = "UPDATED_BY"; /* 更新人*/
public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 更新人名称*/ public static final String COL_UPDATED_NAME = "UPDATED_NAME"; /* 更新人名称*/
public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 更新时间*/ public static final String COL_UPDATED_TIME = "UPDATED_TIME"; /* 更新时间*/
public static final String COL_PURCHASE_CODE = "PURCHASE_CODE"; /* 采购单号*/ public static final String COL_OLD_PURCHASE_CODE = "OLD_PURCHASE_CODE"; /* 原采购单号*/
public static final String COL_RECEIPT_DATE = "RECEIPT_DATE"; /* 单据日期*/ public static final String COL_RECEIPT_DATE = "RECEIPT_DATE"; /* 单据日期*/
public static final String COL_WH_CODE = "WH_CODE"; /* 仓库编码*/ public static final String COL_WH_CODE = "WH_CODE"; /* 仓库编码*/
public static final String COL_WH_NAME = "WH_NAME"; /* 仓库名称*/ public static final String COL_WH_NAME = "WH_NAME"; /* 仓库名称*/
...@@ -84,6 +85,7 @@ public class HPKC001 extends DaoEPBase { ...@@ -84,6 +85,7 @@ public class HPKC001 extends DaoEPBase {
private String updatedName = " "; /* 更新人名称*/ private String updatedName = " "; /* 更新人名称*/
private String updatedTime ; /* 更新时间*/ private String updatedTime ; /* 更新时间*/
private String purchaseCode = " "; /* 采购单号*/ private String purchaseCode = " "; /* 采购单号*/
private String oldPurchaseCode = " "; /* 原采购单号*/
private String receiptDate ; /* 单据日期*/ private String receiptDate ; /* 单据日期*/
private String whCode = " "; /* 仓库编码*/ private String whCode = " "; /* 仓库编码*/
private String whName = " "; /* 仓库名称*/ private String whName = " "; /* 仓库名称*/
...@@ -143,6 +145,10 @@ public class HPKC001 extends DaoEPBase { ...@@ -143,6 +145,10 @@ public class HPKC001 extends DaoEPBase {
eiColumn.setDescName("采购单号"); eiColumn.setDescName("采购单号");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_OLD_PURCHASE_CODE);
eiColumn.setDescName("原采购单号");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_RECEIPT_DATE); eiColumn = new EiColumn(FIELD_RECEIPT_DATE);
eiColumn.setDescName("单据日期"); eiColumn.setDescName("单据日期");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
...@@ -363,6 +369,23 @@ public class HPKC001 extends DaoEPBase { ...@@ -363,6 +369,23 @@ public class HPKC001 extends DaoEPBase {
public void setPurchaseCode(String purchaseCode) { public void setPurchaseCode(String purchaseCode) {
this.purchaseCode = purchaseCode; this.purchaseCode = purchaseCode;
} }
/**
* set the oldPurchaseCode - 原采购单号.
*
* @param oldPurchaseCode - 原采购单号
*/
public void setOldPurchaseCode(String oldPurchaseCode) {
this.oldPurchaseCode = oldPurchaseCode;
}
/**
* get the oldPurchaseCode - 原采购单号.
* @return the oldPurchaseCode
*/
public String getOldPurchaseCode() {
return this.oldPurchaseCode;
}
/** /**
* get the receiptDate - 单据日期. * get the receiptDate - 单据日期.
* @return the receiptDate * @return the receiptDate
...@@ -557,6 +580,7 @@ public class HPKC001 extends DaoEPBase { ...@@ -557,6 +580,7 @@ public class HPKC001 extends DaoEPBase {
setUpdatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_NAME)), updatedName)); setUpdatedName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_NAME)), updatedName));
setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime)); setUpdatedTime(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_UPDATED_TIME)), updatedTime));
setPurchaseCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PURCHASE_CODE)), purchaseCode)); setPurchaseCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_PURCHASE_CODE)), purchaseCode));
setOldPurchaseCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_OLD_PURCHASE_CODE)), oldPurchaseCode));
setReceiptDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_RECEIPT_DATE)), receiptDate)); setReceiptDate(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_RECEIPT_DATE)), receiptDate));
setWhCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_WH_CODE)), whCode)); setWhCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_WH_CODE)), whCode));
setWhName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_WH_NAME)), whName)); setWhName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_WH_NAME)), whName));
...@@ -587,6 +611,7 @@ public class HPKC001 extends DaoEPBase { ...@@ -587,6 +611,7 @@ public class HPKC001 extends DaoEPBase {
map.put(FIELD_UPDATED_NAME, StringUtils.toString(updatedName, eiMetadata.getMeta(FIELD_UPDATED_NAME))); map.put(FIELD_UPDATED_NAME, StringUtils.toString(updatedName, eiMetadata.getMeta(FIELD_UPDATED_NAME)));
map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME))); map.put(FIELD_UPDATED_TIME, StringUtils.toString(updatedTime, eiMetadata.getMeta(FIELD_UPDATED_TIME)));
map.put(FIELD_PURCHASE_CODE, StringUtils.toString(purchaseCode, eiMetadata.getMeta(FIELD_PURCHASE_CODE))); map.put(FIELD_PURCHASE_CODE, StringUtils.toString(purchaseCode, eiMetadata.getMeta(FIELD_PURCHASE_CODE)));
map.put(FIELD_OLD_PURCHASE_CODE, StringUtils.toString(oldPurchaseCode, eiMetadata.getMeta(FIELD_OLD_PURCHASE_CODE)));
map.put(FIELD_RECEIPT_DATE, StringUtils.toString(receiptDate, eiMetadata.getMeta(FIELD_RECEIPT_DATE))); map.put(FIELD_RECEIPT_DATE, StringUtils.toString(receiptDate, eiMetadata.getMeta(FIELD_RECEIPT_DATE)));
map.put(FIELD_WH_CODE, StringUtils.toString(whCode, eiMetadata.getMeta(FIELD_WH_CODE))); map.put(FIELD_WH_CODE, StringUtils.toString(whCode, eiMetadata.getMeta(FIELD_WH_CODE)));
map.put(FIELD_WH_NAME, StringUtils.toString(whName, eiMetadata.getMeta(FIELD_WH_NAME))); map.put(FIELD_WH_NAME, StringUtils.toString(whName, eiMetadata.getMeta(FIELD_WH_NAME)));
......
package com.baosight.hpjx.hp.kc.service; package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.common.ApprovalStatusEnum;
import com.baosight.hpjx.common.DdynamicEnum; import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnun; import com.baosight.hpjx.common.InventTypeEnun;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant; import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC001; import com.baosight.hpjx.hp.kc.domain.HPKC001;
import com.baosight.hpjx.hp.pz.domain.HPPZ007; import com.baosight.hpjx.hp.kc.tools.HPKCTools;
import com.baosight.hpjx.util.AssertUtils; import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.util.CommonMethod; import com.baosight.hpjx.util.*;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator; import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.collections.MapUtils;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
/** /**
...@@ -26,18 +25,25 @@ import java.util.*; ...@@ -26,18 +25,25 @@ import java.util.*;
*/ */
public class ServiceHPKC001 extends ServiceBase { public class ServiceHPKC001 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnun.MATERIAL.getCode(),
InventTypeEnun.CONSUMABLE.getCode()};
/** /**
* 画面初始化. * 画面初始化
*
* @param inInfo
* @return
*/ */
@Override
public EiInfo initLoad(EiInfo inInfo) { public EiInfo initLoad(EiInfo inInfo) {
try { try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), null); Map queryMap = new HashMap();
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), null); queryMap.put("inventTypes", DEFAULT_INVENT_CODE);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID), null); CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_SPEC_BLOCK_ID), null); CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_NAME_BLOCK_ID), queryMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_ALL_BLOCK_ID), queryMap, false);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC001().eiMetadata); inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HPKC001().eiMetadata);
inInfo.setBlock(InventTypeEnun.generatorEiBlock());
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败"); LogUtils.setDetailMsg(inInfo, e, "初始化失败");
} }
...@@ -45,309 +51,171 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -45,309 +51,171 @@ public class ServiceHPKC001 extends ServiceBase {
} }
/** /**
* 查询操作. * 查询操作
*
* @param inInfo
* @return
*/ */
@Override @Override
public EiInfo query(EiInfo inInfo) { public EiInfo query(EiInfo inInfo) {
String documentTime = inInfo.getCellStr(EiConstant.queryBlock,0,"documentTime"); try {
if(StringUtils.isNotBlank(documentTime)){ Map queryRow = EiInfoUtils.getFirstRow(inInfo);
inInfo.setCell(EiConstant.queryBlock,0,"documentTime", StringUtil.removeHorizontalLine(documentTime)); String receiptDate = MapUtils.getString(queryRow, "receiptDate");
queryRow.put("receiptDate", StringUtil.removeSpecifiedCharacter(receiptDate,
StringUtil.DEFAULT_CHARACTER_TO_BE_REMOVED));
queryRow.put("inventTypes", DEFAULT_INVENT_CODE);
inInfo = super.query(inInfo, HPKC001.QUERY, new HPKC001());
// List sum = dao.query(HPSqlConstant.HPKC001.QUERY_SUM, queryRow);
// inInfo.getBlock(EiConstant.resultBlock).set(EiConstant.COLUMN_TOTAL_SUM, sum.get(0));
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
} }
/* 调用EI查询方法.*/ return inInfo;
return super.query(inInfo, "HPKC001.query", new HPKC001());
} }
/** /**
* 新增操作. * 新增操作
*
* @param inInfo
* @return
*/ */
@Override @Override
public EiInfo insert(EiInfo inInfo) { public EiInfo insert(EiInfo inInfo) {
try { try {
CommonMethod.creatorInfo(inInfo,EiConstant.resultBlock);
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 数据校验
this.checkSaveData(resultRows); this.checkSaveData(resultRows);
// 写入数据 // 数据写入
for (int i = 0; i < resultRows.size(); i++) { for (int i = 0; i < resultRows.size(); i++) {
HPKC001 insertEntity = new HPKC001(); HPKC001 fKc001 = new HPKC001();
insertEntity.fromMap(resultRows.get(i)); fKc001.fromMap(resultRows.get(i));
// 仓库名称 // 设置基础信息
Map params = new HashMap<>(); this.setBaseInfo(fKc001);
params.put("whCode", insertEntity.getWhCode()); // 生成入库单号
List query = dao.query("HPPZ007.queryByWhCode", params); fKc001.setPurchaseCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.OTHER_ENTER_NO));
insertEntity.setWhName(((HPPZ007) query.get(0)).getWhName()); DaoUtils.insert(HPKC001.INSERT, fKc001);
//存货类型 // 修改库存
insertEntity.setMaterialTypeName(InventTypeEnun.getNameByCode(insertEntity.getMaterialType())); HPKCTools.updateStock(fKc001.getWhCode(), fKc001.getInventRecordId(), fKc001.getAmount(),
// 生成单据号 fKc001.getWeight());
insertEntity.setDocumentCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC001_NUMBER));
insertEntity.setStatus(1);
insertEntity.setApprovalStatus(ApprovalStatusEnum.SAVED.getCode());
dao.insert("HPKC001.insert", insertEntity);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_SUCCESS); inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!"); inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据新增成功!");
} catch (Exception e) {
} catch (PlatException e) { LogUtils.setDetailMsg(inInfo, e, "新增失败");
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("操作失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("新增失败", e.getMessage());
return inInfo;
} }
return inInfo; return inInfo;
} }
/** /**
* 校验保存的数据 * 修改操作
*
* @param resultRows
*/
private void checkSaveData(List<Map> resultRows) {
for (int i = 0; i < resultRows.size(); i++) {
HPKC001 entity = new HPKC001();
entity.fromMap(resultRows.get(i));
AssertUtils.isEmpty(entity.getMaterialType(), "存货类型不能为空");
AssertUtils.isEmpty(entity.getMaterialCode(), "物料不能为空");
AssertUtils.isEmpty(entity.getWhCode(), "仓库不能为空");
}
}
/**
* 校验提交的数据
* *
* @param resultRows * @param inInfo
*/ * @return
private void checkSubmitData(List<Map> resultRows) {
for (int i = 0; i < resultRows.size(); i++) {
HPKC001 entity = new HPKC001();
entity.fromMap(resultRows.get(i));
AssertUtils.isNull(entity.getId(), "请先保存再提交");
if(entity.getApprovalStatus() == ApprovalStatusEnum.SUBMIT.getCode()){
throw new PlatException("单据已提交,不能重复提交");
}
if(entity.getApprovalStatus() == ApprovalStatusEnum.APPROVED.getCode()){
throw new PlatException("单据审批通过,不能再次提交");
}
}
}
/**
* 校验审批的数据
*
* @param resultRows
* @param approvalFlag
*
*/
private void checkApproveData(List<Map> resultRows,int approvalFlag) {
for (int i = 0; i < resultRows.size(); i++) {
HPKC001 entity = new HPKC001();
entity.fromMap(resultRows.get(i));
AssertUtils.isNull(entity.getId(), "请先保存数据");
//审批通过操作
if(approvalFlag == ApprovalStatusEnum.APPROVED.getCode()){
if(entity.getApprovalStatus() == ApprovalStatusEnum.SAVED.getCode()){
throw new PlatException("已保存的数据,请先提交");
}
if(entity.getApprovalStatus() == ApprovalStatusEnum.REJECTION.getCode()){
throw new PlatException("审批拒绝的数据,请先提交");
}
if(entity.getApprovalStatus() == ApprovalStatusEnum.APPROVED.getCode()){
throw new PlatException("数据已经审批通过,不能重复审批");
}
}
//审批拒绝操作
if(approvalFlag == ApprovalStatusEnum.REJECTION.getCode()){
if(entity.getApprovalStatus() == ApprovalStatusEnum.SAVED.getCode()){
throw new PlatException("已保存的数据,请先提交");
}
if(entity.getApprovalStatus() == ApprovalStatusEnum.REJECTION.getCode()){
throw new PlatException("审批拒绝的数据,请先提交");
}
if(entity.getApprovalStatus() == ApprovalStatusEnum.APPROVED.getCode()){
throw new PlatException("数据已经审批通过,不能重复审批");
}
}
}
}
/**
* 修改操作.
*/ */
@Override
public EiInfo update(EiInfo inInfo) { public EiInfo update(EiInfo inInfo) {
try { try {
CommonMethod.udpateInfo(inInfo,EiConstant.resultBlock);
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows(); List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 数据校验
this.checkSaveData(resultRows); this.checkSaveData(resultRows);
// 写入数据 // 入库单号
List<String> otherEnterNos = ObjectUtils.listKey(resultRows, "otherEnterNo");
// 锁记录
HPKCTools.lockKc001(otherEnterNos);
// 查询数据库记录
Map<String, HPKC001> mapKc001 = HPKCTools.mapKc001(otherEnterNos);
for (int i = 0; i < resultRows.size(); i++) { for (int i = 0; i < resultRows.size(); i++) {
HPKC001 updateEntity = new HPKC001(); HPKC001 fKc001 = new HPKC001();
updateEntity.fromMap(resultRows.get(i)); fKc001.fromMap(resultRows.get(i));
// 仓库名称 // 设置基础信息
Map params = new HashMap<>(); this.setBaseInfo(fKc001);
params.put("whCode", updateEntity.getWhCode()); DaoUtils.update(HPKC001.UPDATE, fKc001);
List query = dao.query("HPPZ007.queryByWhCode", params); // 计算差异数量与重量
updateEntity.setWhName(((HPPZ007) query.get(0)).getWhName()); HPKC001 dbKc001 = mapKc001.get(fKc001.getPurchaseCode());
//存货类型 BigDecimal diffAmount = fKc001.getAmount().subtract(dbKc001.getAmount());
updateEntity.setMaterialTypeName(InventTypeEnun.getNameByCode(updateEntity.getMaterialType())); BigDecimal diffWeight = fKc001.getWeight().subtract(dbKc001.getWeight());
dao.insert("HPKC001.update", updateEntity); // 修改库存
HPKCTools.updateStock(fKc001.getWhCode(), fKc001.getInventRecordId(), diffAmount, diffWeight);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_SUCCESS); inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!"); inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据修改成功!");
} catch (PlatException e) { } catch (PlatException e) {
inInfo.setStatus(EiConstant.STATUS_FAILURE); LogUtils.setDetailMsg(inInfo, e, "修改失败");
inInfo.setMsg("操作失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("修改失败", e.getMessage());
return inInfo;
} }
return inInfo; return inInfo;
} }
/** /**
* 提交操作. * 校验保存的数据
*/ *
public EiInfo submit(EiInfo eiInfo) { * @param resultRows
try {
List<Map> resultRows = eiInfo.getBlock(EiConstant.resultBlock).getRows();
this.checkSubmitData(resultRows);
HPKC001 HPKC001 = new HPKC001();
EiBlock eiBlock = eiInfo.getBlock(EiConstant.resultBlock);
List<HPKC001> entityList = new ArrayList<>();
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPKC001.fromMap(map);
HPKC001.setApprovalStatus(ApprovalStatusEnum.SUBMIT.getCode());
entityList.add(HPKC001);
}
this.dao.updateBatch("HPKC001.approvalStatusUpdate", entityList);
} catch (PlatException e) {
eiInfo.setStatus(EiConstant.STATUS_FAILURE);
eiInfo.setMsg("提交失败!"+e.getMessage());
eiInfo.setDetailMsg(e.getMessage());
logError("提交失败!", e.getMessage());
return eiInfo;
}
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("删除成功!");
return eiInfo;
}
/**
* 审批通过操作.
*/
public EiInfo approved(EiInfo eiInfo) {
try {
List<Map> resultRows = eiInfo.getBlock(EiConstant.resultBlock).getRows();
this.checkApproveData(resultRows,ApprovalStatusEnum.APPROVED.getCode());
HPKC001 HPKC001 = new HPKC001();
EiBlock eiBlock = eiInfo.getBlock(EiConstant.resultBlock);
List<HPKC001> entityList = new ArrayList<>();
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPKC001.fromMap(map);
HPKC001.setApprovalStatus(ApprovalStatusEnum.APPROVED.getCode());
entityList.add(HPKC001);
}
this.dao.updateBatch("HPKC001.approvalStatusUpdate", entityList);
} catch (PlatException e) {
eiInfo.setStatus(EiConstant.STATUS_FAILURE);
eiInfo.setMsg("审批失败!"+e.getMessage());
eiInfo.setDetailMsg(e.getMessage());
logError("审批失败!", e.getMessage());
return eiInfo;
}
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("审批成功!");
return eiInfo;
}
/**
* 审批拒绝操作.
*/ */
public EiInfo rejection(EiInfo eiInfo) { private void checkSaveData(List<Map> resultRows) {
try { for (int i = 0; i < resultRows.size(); i++) {
List<Map> resultRows = eiInfo.getBlock(EiConstant.resultBlock).getRows(); HPKC001 fKc001 = new HPKC001();
this.checkApproveData(resultRows,ApprovalStatusEnum.REJECTION.getCode()); fKc001.fromMap(resultRows.get(i));
AssertUtils.isEmpty(fKc001.getWhCode(), "仓库名称不能为空");
HPKC001 HPKC001 = new HPKC001(); AssertUtils.isNull(fKc001.getInventCode(), "存货名称不能为空");
EiBlock eiBlock = eiInfo.getBlock(EiConstant.resultBlock); AssertUtils.isNull(fKc001.getInventRecordId(), "规格不能为空");
List<HPKC001> entityList = new ArrayList<>(); AssertUtils.isGt(BigDecimal.ZERO, fKc001.getAmount(), "数量必须大于0");
for (int i = 0; i < eiBlock.getRowCount(); i++) { AssertUtils.isGt(BigDecimal.ZERO, fKc001.getWeight(), "重量必须大于0");
Map<?, ?> map = eiBlock.getRow(i);
HPKC001.fromMap(map);
HPKC001.setApprovalStatus(ApprovalStatusEnum.REJECTION.getCode());
entityList.add(HPKC001);
}
this.dao.updateBatch("HPKC001.approvalStatusUpdate", entityList);
} catch (PlatException e) {
eiInfo.setStatus(EiConstant.STATUS_FAILURE);
eiInfo.setMsg("审批失败!"+e.getMessage());
eiInfo.setDetailMsg(e.getMessage());
logError("审批失败!", e.getMessage());
return eiInfo;
} }
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("审批成功!");
return eiInfo;
} }
/** /**
* 删除操作. * 设置基础信息
*
* @param fKc001
*/ */
@Override private void setBaseInfo(HPKC001 fKc001) {
public EiInfo delete(EiInfo eiInfo) { // 去除日期字符串中的-
HPKC001 HPKC001 = new HPKC001(); fKc001.setReceiptDate(StringUtil.removeHorizontalLine(fKc001.getReceiptDate()));
EiBlock eiBlock = eiInfo.getBlock(EiConstant.resultBlock); // 仓库名称
try { fKc001.setWhName(HPPZTools.getPz007ByCode(fKc001.getWhCode()).getWhName());
List<Map> resultRows = eiInfo.getBlock(EiConstant.resultBlock).getRows(); // 存货名称
this.checkDeleteData(resultRows); fKc001.setInventName(HPPZTools.getPz004ByCode(fKc001.getInventCode()).getInventName());
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPKC001.fromMap(map);
this.dao.delete("HPKC001.delete", HPKC001.toMap());
}
} catch (PlatException e) {
eiInfo.setStatus(EiConstant.STATUS_FAILURE);
eiInfo.setMsg("删除失败,原因参见详细错误描述!");
eiInfo.setDetailMsg(e.getMessage());
logError("删除失败!", e.getMessage());
return eiInfo;
}
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("删除成功!");
return eiInfo;
} }
/** /**
* 校验审批的数据 * 删除操作
*
* @param resultRows
* *
* @param inInfo
* @return
*/ */
private void checkDeleteData(List<Map> resultRows) { public EiInfo delete(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 入库单号
List<String> otherEnterNos = ObjectUtils.listKey(resultRows, "otherEnterNo");
// 锁记录
HPKCTools.lockKc001(otherEnterNos);
// 查询数据库记录
Map<String, HPKC001> mapKc001 = HPKCTools.mapKc001(otherEnterNos);
for (int i = 0; i < resultRows.size(); i++) { for (int i = 0; i < resultRows.size(); i++) {
HPKC001 entity = new HPKC001(); HPKC001 fKc001 = new HPKC001();
entity.fromMap(resultRows.get(i)); fKc001.fromMap(resultRows.get(i));
if(entity.getApprovalStatus() == ApprovalStatusEnum.SUBMIT.getCode()){ DaoUtils.update(HPKC001.DELETE, fKc001);
throw new PlatException("已提交采购入库单不能删除"); // 生成红冲记录
} HPKC001 dbKc001 = mapKc001.get(fKc001.getPurchaseCode());
if(entity.getApprovalStatus() == ApprovalStatusEnum.APPROVED.getCode()){ HPKC001 newKc006 = BeanUtils.copy(dbKc001, HPKC001.class);
throw new PlatException("已审批通过采购入库单不能删除"); newKc006.setPurchaseCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.OTHER_ENTER_NO));
newKc006.setAmount(newKc006.getAmount().negate());
newKc006.setWeight(newKc006.getWeight().negate());
newKc006.setOldPurchaseCode(newKc006.getPurchaseCode());
newKc006.setDeleteFlag(CommonConstant.YesNo.YES_1);
DaoUtils.insert(HPKC001.INSERT, newKc006);
// 修改库存
HPKCTools.updateStock(dbKc001.getWhCode(), dbKc001.getInventRecordId(), dbKc001.getAmount().negate(),
dbKc001.getWeight().negate());
} }
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据删除成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "删除失败");
} }
return inInfo;
} }
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
UPDATED_NAME as "updatedName", <!-- 更新人名称 --> UPDATED_NAME as "updatedName", <!-- 更新人名称 -->
UPDATED_TIME as "updatedTime", <!-- 更新时间 --> UPDATED_TIME as "updatedTime", <!-- 更新时间 -->
PURCHASE_CODE as "purchaseCode", <!-- 采购单号 --> PURCHASE_CODE as "purchaseCode", <!-- 采购单号 -->
OLD_PURCHASE_CODE as "oldPurchaseCode", <!-- 原采购单号 -->
RECEIPT_DATE as "receiptDate", <!-- 单据日期 --> RECEIPT_DATE as "receiptDate", <!-- 单据日期 -->
WH_CODE as "whCode", <!-- 仓库编码 --> WH_CODE as "whCode", <!-- 仓库编码 -->
WH_NAME as "whName", <!-- 仓库名称 --> WH_NAME as "whName", <!-- 仓库名称 -->
...@@ -123,6 +124,7 @@ ...@@ -123,6 +124,7 @@
CREATED_NAME, <!-- 创建人名称 --> CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 --> CREATED_TIME, <!-- 创建时间 -->
PURCHASE_CODE, <!-- 采购单号 --> PURCHASE_CODE, <!-- 采购单号 -->
OLD_PURCHASE_CODE, <!-- 原采购单号 -->
RECEIPT_DATE, <!-- 单据日期 --> RECEIPT_DATE, <!-- 单据日期 -->
WH_CODE, <!-- 仓库编码 --> WH_CODE, <!-- 仓库编码 -->
WH_NAME, <!-- 仓库名称 --> WH_NAME, <!-- 仓库名称 -->
...@@ -136,7 +138,7 @@ ...@@ -136,7 +138,7 @@
DELETE_FLAG <!-- 是否删除0.否1.是 --> DELETE_FLAG <!-- 是否删除0.否1.是 -->
) VALUES ( ) VALUES (
#companyCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #companyCode#, #depCode#, #createdBy#, #createdName#, #createdTime#,
#purchaseCode#, #receiptDate#, #whCode#, #whName#, #inventType#, #oldPurchaseCode#,#purchaseCode#, #receiptDate#, #whCode#, #whName#, #inventType#,
#inventCode#, #inventName#, #inventRecordId#, #amount#, #weight#, #inventCode#, #inventName#, #inventRecordId#, #amount#, #weight#,
#remarks#, #deleteFlag# #remarks#, #deleteFlag#
) )
......
...@@ -2,10 +2,7 @@ package com.baosight.hpjx.hp.kc.tools; ...@@ -2,10 +2,7 @@ package com.baosight.hpjx.hp.kc.tools;
import com.baosight.hpjx.core.dao.DaoBase; import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.hp.constant.HPSqlConstant; import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC005; import com.baosight.hpjx.hp.kc.domain.*;
import com.baosight.hpjx.hp.kc.domain.HPKC006;
import com.baosight.hpjx.hp.kc.domain.HPKC007;
import com.baosight.hpjx.hp.kc.domain.HPKC010;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
...@@ -74,6 +71,50 @@ public class HPKCTools { ...@@ -74,6 +71,50 @@ public class HPKCTools {
* @param otherEnterNos * @param otherEnterNos
* @return * @return
*/ */
public static void lockKc001(List<String> otherEnterNos) {
if (CollectionUtils.isEmpty(otherEnterNos)) {
return;
}
Map queryMap = new HashMap();
queryMap.put("otherEnterNos", otherEnterNos);
DaoBase.getInstance().update(HPSqlConstant.HPKC001.LOCK, queryMap);
}
/**
* 查询其他入库信息
*
* @param otherEnterNos
* @return
*/
public static List<HPKC001> listKc001(List<String> otherEnterNos) {
if (CollectionUtils.isEmpty(otherEnterNos)) {
return null;
}
Map queryMap = new HashMap();
queryMap.put("otherEnterNos", otherEnterNos);
return DaoBase.getInstance().query(HPKC001.QUERY, queryMap);
}
/**
* 查询其他入库信息
*
* @param otherEnterNos
* @return
*/
public static Map<String, HPKC001> mapKc001(List<String> otherEnterNos) {
List<HPKC001> results = listKc001(otherEnterNos);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.toMap(HPKC001::getPurchaseCode, item -> item));
}
/**
* 锁
*
* @param otherEnterNos
* @return
*/
public static void lockKc006(List<String> otherEnterNos) { public static void lockKc006(List<String> otherEnterNos) {
if (CollectionUtils.isEmpty(otherEnterNos)) { if (CollectionUtils.isEmpty(otherEnterNos)) {
return; return;
......
let materialCodeGlobalData = []; let whNameGlobalData = [];
let whCodeGlobalData = []; let inventNameGlobalData = [];
let specGlobalData = []; let inventAllGlobalData = [];
$(function() { $(function() {
var editorModel0 = '';
var eiInfo = new EiInfo();
// 查询
$("#QUERY").on("click", function () {
resultGrid.dataSource.page(1); // 点击查询按钮,从第1页开始查询
});
IPLATUI.EFGrid.result = { IPLATUI.EFGrid = {
pageable: { pageable: {
pageSize: 20, pageSize: 20,
pageSizes: [10, 20, 30, 50, 100, 200], pageSizes: [10, 20, 50, 70, 100],
}, },
columns: [ "result": {
{ columns: [{
field: "materialCode", field: "whCode",
template: function(dataItem) { template: function (dataItem) {
for (var i = 0 ; i < materialCodeGlobalData.length ; i++) { for (let i = 0; i < whNameGlobalData.length; i++) {
if ( materialCodeGlobalData[i]['valueField'] === dataItem['materialCode']) { if (whNameGlobalData[i]['valueField'] === dataItem['whCode']) {
return materialCodeGlobalData[i]['textField']; return whNameGlobalData[i]['textField'];
} }
} }
return ""; return "";
}, },
editor: function (container, options) { editor: function (container, options) {
var grid = container.closest(".k-grid").data("kendoGrid"); let inInfo = new EiInfo();
var cellIndex = grid.cellIndex(container); inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
var input = $('<input />'); inInfo.set("inqu_status-0-whType", options.model["inventType"]);
input.attr("name", options.field); inInfo.set("serviceName", "HPPZ007");
input.attr("id", options.field); inInfo.set("methodName", "queryComboBox");
input.appendTo(container); inInfo.set("blockId", "wh_record_block_id");
inInfo.set("field", options.field);
eiInfo.set("inventType", options.model["materialType"]); refreshSelect(container, inInfo);
var dataSource; }
}, {
EiCommunicator.send("HPPZ004", "queryComboBox", eiInfo, { field: "inventCode",
onSuccess: function (ei) { template: function (dataItem) {
dataSource = ei.getBlock("invent_name_block_id").getMappedRows(); for (let i = 0; i < inventNameGlobalData.length; i++) {
materialCodeGlobalData = dataSource; if (inventNameGlobalData[i]['valueField'] === dataItem['inventCode']) {
}, onFail: function (ei) { return inventNameGlobalData[i]['textField'];
}
}, {async: false});
input.kendoDropDownList({
valuePrimitive: true,
dataTextField: "textField",
dataValueField: "valueField",
dataSource: dataSource,
template: "#=textField#"
});
},
},
{
field: "whCode",
template: function(dataItem) {
for (var i = 0 ; i < whCodeGlobalData.length ; i++) {
if ( whCodeGlobalData[i]['valueField'] === dataItem['whCode']) {
return whCodeGlobalData[i]['textField'];
} }
} }
return ""; return "";
}, },
editor: function (container, options) { editor: function (container, options) {
var input = $('<input />'); let inInfo = new EiInfo();
input.attr("name", options.field); inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
input.attr("id", options.field); inInfo.set("inqu_status-0-inventType", options.model["inventType"]);
input.appendTo(container); inInfo.set("serviceName", "HPPZ006");
inInfo.set("methodName", "queryMaterialComboBox");
var whEiInfo = new EiInfo(); inInfo.set("blockId", "material_record_block_id");
whEiInfo.set("whType", options.model["materialType"]); inInfo.set("field", options.field);
var dataSource; refreshSelect(container, inInfo);
EiCommunicator.send("HPPZ007", "queryComboBox", whEiInfo, { }
onSuccess: function (ei) { }, {
dataSource = ei.getBlock("wh_record_block_id").getMappedRows(); field: "spe",
whCodeGlobalData = dataSource; template: function (dataItem) {
}, onFail: function (ei) { for (let i = 0; i < inventAllGlobalData.length; i++) {
} if (inventAllGlobalData[i]['valueField'] === dataItem['inventRecordId']) {
}, {async: false}); return inventAllGlobalData[i]['textField'];
input.kendoDropDownList({
valuePrimitive: true,
dataTextField: "textField",
dataValueField: "valueField",
dataSource: dataSource,
template: "#=textField#"
});
},
},
{
field: "spec",
template: function(dataItem) {
for (var i = 0 ; i < specGlobalData.length ; i++) {
if ( specGlobalData[i]['valueField'] === dataItem['spec']) {
return specGlobalData[i]['textField'];
} }
} }
return ""; return "";
}, },
editor: function (container, options) { editor: function (container, options) {
var input = $('<input />'); let inInfo = new EiInfo();
input.attr("name", options.field); inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
input.attr("id", options.field); inInfo.set("inqu_status-0-inventCode", options.model["inventCode"]);
input.appendTo(container); inInfo.set("serviceName", "HPPZ006");
inInfo.set("methodName", "queryComboBoxSpec");
var specEiInfo = new EiInfo(); inInfo.set("blockId", "invent_spec_block_id");
specEiInfo.set("inqu_status-0-inventCode", options.model["materialCode"]); inInfo.set("field", options.field);
specEiInfo.set("inqu_status-0-inventType", options.model["materialType"]); refreshSelect(container, inInfo);
var dataSource; }
EiCommunicator.send("HPPZ006", "queryComboBoxSpec", specEiInfo, { }, {
onSuccess: function (ei) { field: "unit",
dataSource = ei.getBlock("invent_spec_block_id").getMappedRows(); template: function (dataItem) {
specGlobalData = dataSource; for (let i = 0; i < inventAllGlobalData.length; i++) {
}, onFail: function (ei) { if (inventAllGlobalData[i]['valueField'] === dataItem['inventRecordId']) {
} return inventAllGlobalData[i]['param2Field'];
}, {async: false});
input.kendoDropDownList({
valuePrimitive: true,
dataTextField: "textField",
dataValueField: "valueField",
dataSource: dataSource,
template: "#=textField#"
});
},
}
],
onRowClick : function(e) {
editorModel0 = e.row;
$("input[name='materialType']").on('change', function (me) {
//清空物料信息
resultGrid.setCellValue(editorModel0, "materialName", "");
resultGrid.setCellValue(editorModel0, "materialCode", "");
resultGrid.setCellValue(editorModel0, "whCode", "");
resultGrid.setCellValue(editorModel0, "whName", "");
resultGrid.setCellValue(editorModel0, "spec", "");
resultGrid.setCellValue(editorModel0, "unit", "");
});
$("input[name='materialCode']").on('change', function (me) {
var materialCode = $("input[name='materialCode']").val();
var queryEiInfo = new EiInfo();
queryEiInfo.set("inventCode", materialCode);
EiCommunicator.send("HPPZ004", "query", eiInfo, {
onSuccess: function (eiInfo) {
var status = eiInfo.getStatus();
if (status != "-1") {
console.log(eiInfo)
var materialName = eiInfo.blocks.result.rows[0][14];
resultGrid.setCellValue(e.row, "materialName", materialName);
//清空物料信息
resultGrid.setCellValue(editorModel0, "spec", "");
resultGrid.setCellValue(editorModel0, "unit", "");
}
}, onFail: function (ei) {
} }
}, {async: false});
});
$("input[name='spec']").on('change', function (me) {
var spec = $("input[name='spec']").val();
var materialCode = $("input[name='materialCode']").val();
var queryEiInfo = new EiInfo();
queryEiInfo.set("inventCode", materialCode);
queryEiInfo.set("spec", spec);
EiCommunicator.send("HPPZ006", "query", eiInfo, {
onSuccess: function (eiInfo) {
var status = eiInfo.getStatus();
if (status != "-1") {
console.log(eiInfo)
var unit = eiInfo.blocks.result.rows[0][23];
resultGrid.setCellValue(editorModel0, "unit", unit);
} }
}, onFail: function (ei) { return "";
} }
}, {async: false}); }],
});
},
loadComplete: function (grid) { loadComplete: function (grid) {
//删除
$("#DELETE").on("click", function () {
var btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
var dataItems = resultGrid.getCheckedRows();
if (dataItems == null || dataItems == "") {
NotificationUtil({
msg: '选择要删除的数据'
}, "warning");
//释放禁用按钮
btnNode.attr("disabled", false);
return false;
}
IPLAT.submitNode($("#HPKC001"), "HPKC001", "delete", {
onSuccess: function (ei) {
if (ei["status"] == -1) {
NotificationUtil(ei, "error");
} else {
NotificationUtil({
msg: '删除成功'
});
// 绑定grid
resultGrid.setEiInfo(ei);
}
//释放禁用按钮
btnNode.attr("disabled", false);
resultGrid.dataSource.page(1);
},
onFail: function (ei) {// onFail
// 表示失败回调函数
// 发生异常
console.log(ei);
//释放禁用按钮
btnNode.attr("disabled", false);
}
});
});
//提交
$("#SUBMIT").on("click", function () {
var btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
var dataItems = resultGrid.getCheckedRows();
if (dataItems == null || dataItems == "") {
NotificationUtil({
msg: '选择要提交的数据'
}, "warning");
//释放禁用按钮
btnNode.attr("disabled", false);
return false;
}
IPLAT.confirm({
title: "提交",
message: "确认提交这些数据么?",
okFn: function () {
IPLAT.submitNode($("#HPKC001"), "HPKC001", "submit", {
onSuccess: function (ei) {
if (ei["status"] === -1) {
IPLAT.alert({
message: '<b>' + ei.msg + '</b>',
okFn: function (e) {
},
title: '提示'
});
} else {
IPLAT.alert({
message: '<b>提交成功!</b>',
okFn: function (e) {
},
title: '提示'
});
// 绑定grid
resultGrid.setEiInfo(ei);
//释放禁用按钮
btnNode.attr("disabled", false);
resultGrid.dataSource.page(1);
} }
}, onFail: function (eMsg) {
IPLAT.alert({
message: '<b>' + eMsg + '</b>',
okFn: function (e) {
},
title: '提示'
});
}
});
},
cancelFn: function () {
IPLAT.NotificationUtil("提交已取消!", "warning");
},
minWidth: 250
})
});
//审批通过
$("#APPROVED").on("click", function () {
var btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
var dataItems = resultGrid.getCheckedRows();
if (dataItems == null || dataItems == "") {
NotificationUtil({
msg: '选择要审批通过的数据'
}, "warning");
//释放禁用按钮
btnNode.attr("disabled", false);
return false;
}
IPLAT.confirm({
title: "审批通过",
message: "确认通过审批么?",
okFn: function () {
IPLAT.submitNode($("#HPKC001"), "HPKC001", "approved", {
onSuccess: function (ei) {
if (ei["status"] === -1) {
IPLAT.alert({
message: '<b>' + ei.msg + '</b>',
okFn: function (e) {
},
title: '提示'
});
} else {
IPLAT.alert({
message: '<b>审批完成!</b>',
okFn: function (e) {
},
title: '提示'
});
// 绑定grid
resultGrid.setEiInfo(ei);
//释放禁用按钮
btnNode.attr("disabled", false);
resultGrid.dataSource.page(1);
}
}, onFail: function (eMsg) {
IPLAT.alert({
message: '<b>' + eMsg + '</b>',
okFn: function (e) {
},
title: '提示'
});
}
});
},
cancelFn: function () {
IPLAT.NotificationUtil("提交已取消!", "warning");
},
minWidth: 250
})
});
//审批拒绝
$("#REJECTION").on("click", function () {
var btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
var dataItems = resultGrid.getCheckedRows();
if (dataItems == null || dataItems == "") {
NotificationUtil({
msg: '选择要审批拒绝的数据'
}, "warning");
//释放禁用按钮
btnNode.attr("disabled", false);
return false;
}
IPLAT.confirm({
title: "审批拒绝",
message: "确认通过拒绝么?",
okFn: function () {
IPLAT.submitNode($("#HPKC001"), "HPKC001", "rejection", {
onSuccess: function (ei) {
if (ei["status"] === -1) {
IPLAT.alert({
message: '<b>' + ei.msg + '</b>',
okFn: function (e) {
},
title: '提示'
});
} else {
IPLAT.alert({
message: '<b>审批完成!</b>',
okFn: function (e) {
},
title: '提示'
});
// 绑定grid
resultGrid.setEiInfo(ei);
//释放禁用按钮
btnNode.attr("disabled", false);
resultGrid.dataSource.page(1);
}
}, onFail: function (eMsg) {
IPLAT.alert({
message: '<b>' + eMsg + '</b>',
okFn: function (e) {
},
title: '提示'
});
}
});
},
cancelFn: function () {
IPLAT.NotificationUtil("提交已取消!", "warning");
},
minWidth: 250
})
});
},
onSuccess: function (e) {
if (e.type != 'read') {
// 不显示notifications
e.preventDefault();
// 重新查询Grid前,把新增、修改、删除操作成功的信息先弹出。
// 弹窗关闭后重新查询Grid
//resultGrid.dataSource.page(1);
IPLAT.alert({
// e.eiInfo 是EiInfo对象,可从浏览器F12的Console中查看。
message: e.eiInfo.getMsg(),
okFn: function (e) {
parent.window.location.href = IPLATUI.CONTEXT_PATH+'/web/HPKC001';
},
title: '成功'
});
} }
} }
}; // 查询
$("#QUERY").on("click", query);
// 保存
$("#BTN_SAVE").on("click", save);
}); });
/** /**
* 页面加载时执行 * 页面加载时执行
*/ */
$(window).load(function () { $(window).load(function () {
// 存货名称 // 仓库名称
let eiInfo = new EiInfo(); let inInfo = new EiInfo();
EiCommunicator.send("HPPZ004", "queryComboBox", eiInfo, { inInfo.set("inqu_status-0-inventTypes", [1, 2, 5]);
EiCommunicator.send("HPPZ007", "queryComboBox", inInfo, {
onSuccess: function (ei) { onSuccess: function (ei) {
materialCodeGlobalData = ei.getBlock("invent_name_block_id").getMappedRows(); whNameGlobalData = ei.getBlock("wh_record_block_id").getMappedRows();
}, },
onFail: function (ei) { onFail: function (ei) {
} }
}, {async: false}); }, {async: false});
let speceiInfo = new EiInfo(); // 存货名称
EiCommunicator.send("HPPZ006", "queryComboBoxSpec", speceiInfo, { EiCommunicator.send("HPPZ004", "queryComboBox", inInfo, {
onSuccess: function (ei) { onSuccess: function (ei) {
specGlobalData = ei.getBlock("invent_spec_block_id").getMappedRows(); inventNameGlobalData = ei.getBlock("invent_name_block_id").getMappedRows();
}, },
onFail: function (ei) { onFail: function (ei) {
} }
}, {async: false}); }, {async: false});
// 规格
let wheiInfo = new EiInfo(); EiCommunicator.send("HPPZ006", "queryComboBoxAll", inInfo, {
EiCommunicator.send("HPPZ007", "queryComboBox", wheiInfo, {
onSuccess: function (ei) { onSuccess: function (ei) {
whCodeGlobalData = ei.getBlock("wh_record_block_id").getMappedRows(); inventAllGlobalData = ei.getBlock("invent_all_block_id").getMappedRows();
}, },
onFail: function (ei) { onFail: function (ei) {
} }
...@@ -460,6 +130,22 @@ $(window).load(function () { ...@@ -460,6 +130,22 @@ $(window).load(function () {
* 查询 * 查询
*/ */
let query = function () { let query = function () {
resultGrid.dataSource.page(1); resultGrid.dataSource.page(1); // 点击查询按钮,从第1页开始查询
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPKC006", "save", true);
}
});
} }
...@@ -9,49 +9,50 @@ ...@@ -9,49 +9,50 @@
<EF:EFRegion id="inqu" title="查询条件"> <EF:EFRegion id="inqu" title="查询条件">
<div class="row"> <div class="row">
<EF:EFDatePicker ename="inqu_status-0-documentTime" cname="单据日期" format="yyyy-MM-dd" required="true"/> <EF:EFDatePicker cname="单据日期" ename="inqu_status-0-receiptDate" colWidth="3"
<EF:EFInput ename="inqu_status-0-documentCode" cname="采购入库单号" colWidth="4" readonly="false"/> role="date" format="yyyy-MM-dd" readonly="true"/>
<EF:EFSelect cname="存货类型" blockId="inqu_status" ename="materialType" row="0" colWidth="3"> <EF:EFInput cname="采购单号" ename="inqu_status-0-chpurchaseCodeeckNo" colWidth="3"/>
<EF:EFSelect cname="存货类型" ename="inqu_status-0-inventType" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/> <EF:EFOption label="全部" value=""/>
<EF:EFCodeOption codeName="hpjx.hpkc.inventType" /> <EF:EFCodeOption codeName="hpjx.hpkc.inventType"/>
</EF:EFSelect> </EF:EFSelect>
<EF:EFSelect ename="inqu_status-0-whCode" cname="仓库名称" <EF:EFSelect cname="仓库名称" ename="inqu_status-0-whCode" colWidth="3" filter="contains" defultValue="">
valueTemplate="#=textField#" filter="contains" <EF:EFOption label="全部" value=""/>
required="false" defultValue="ALL"
template="#=textField#">
<EF:EFOption label="请选择" value=""></EF:EFOption>
<EF:EFOptions blockId="wh_record_block_id" textField="textField" valueField="valueField"/> <EF:EFOptions blockId="wh_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect> </EF:EFSelect>
<EF:EFSelect ename="inqu_status-0-materialCode" cname="存货名称" </div>
valueTemplate="#=textField#" filter="contains" <div class="row">
required="false" defultValue="ALL" <EF:EFSelect cname="存货名称" ename="inqu_status-0-inventCode" colWidth="3" filter="contains" defultValue="">
template="#=textField#"> <EF:EFOption label="全部" value=""/>
<EF:EFOption label="请选择" value=""></EF:EFOption>
<EF:EFOptions blockId="invent_name_block_id" textField="textField" valueField="valueField"/> <EF:EFOptions blockId="invent_name_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect> </EF:EFSelect>
<EF:EFSelect cname="规格" ename="inqu_status-0-spec" colWidth="3" filter="contains" defultValue="">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="spec_name_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</div> </div>
</EF:EFRegion> </EF:EFRegion>
<EF:EFRegion id="result" title="明细信息"> <EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="false" isFloat="true" autoFit="true"> <EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="row">
<EF:EFColumn ename="id" cname="主键id" hidden="true"/> <EF:EFColumn ename="id" cname="内码" hidden="true"/>
<EF:EFColumn ename="documentTime" cname="单据日期" editType="date" dateFormat="yyyy-MM-dd" parseFormats="['yyyy-MM-dd']" width="100" required="true"/> <EF:EFColumn ename="purchaseCode" cname="采购单号" enable="false" width="140" align="center"/>
<EF:EFColumn ename="documentCode" cname="采购入库单号" width="100" readonly="false" align="center" required="false" enable="false" /> <EF:EFColumn ename="receiptDate" cname="单据日期" width="90" align="center" editType="date"
<EF:EFComboColumn ename="materialType" cname="存货类型" width="90" align="center"> dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']" required="true"/>
<EF:EFCodeOption codeName="hpjx.hpkc.inventType" /> <EF:EFComboColumn ename="inventType" cname="存货类型" width="100" align="center" required="true">
</EF:EFComboColumn> <EF:EFCodeOption codeName="hpjx.hpkc.inventType"/>
<EF:EFColumn ename="whCode" cname="仓库名称" width="100" readonly="false" required="true"/>
<EF:EFColumn ename="whName" cname="仓库名称" width="100" readonly="false" hidden="true"/>
<EF:EFColumn ename="materialCode" cname="存货名称" width="100" readonly="false" required="true"/>
<EF:EFColumn ename="materialName" cname="存货名称" width="100" readonly="false" hidden="true"/>
<EF:EFColumn ename="spec" cname="规格" width="120" readonly="false" align="center" required="true"/>
<EF:EFColumn ename="unit" cname="单位" width="80" readonly="false" align="center" enable="false" required="true"/>
<EF:EFColumn ename="quantity" cname="数量" width="80" defaultValue="0" data-regex="/^[0-9]\\\d*$/" data-errorprompt="请输入正整数" readonly="false" align="right" required="true"/>
<EF:EFColumn ename="weight" cname="重量" defaultValue="0" data-rules="number" maxLength="20" width="100" align="right" readonly="false"/>
<EF:EFComboColumn ename="approvalStatus" cname="审批状态" width="90" align="center">
<EF:EFCodeOption codeName="hpjx.hpjx.approvalStatus" />
</EF:EFComboColumn> </EF:EFComboColumn>
<EF:EFColumn ename="remarks" cname="备注" width="100" readonly="false"/> <EF:EFColumn ename="whCode" cname="仓库名称" width="120" align="center" required="true" readonly="true"/>
<EF:EFColumn ename="inventCode" cname="存货名称" width="120" align="center" required="true" readonly="true"/>
<EF:EFColumn ename="spec" cname="规格" width="120" align="center"/>
<EF:EFColumn ename="material" cname="材质" width="120" align="center"/>
<EF:EFColumn ename="unit" cname="单位" width="120" align="center"/>
<EF:EFColumn ename="amount" cname="数量" format="{0:N3}" maxLength="20" width="90" align="right"/>
<EF:EFColumn ename="weight" cname="重量" format="{0:N3}" maxLength="20" width="90" align="right"/>
<EF:EFColumn ename="remark" cname="备注" width="150" readonly="true"/>
<EF:EFColumn ename="createdName" cname="创建人" enable="false" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时刻" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss']"/>
</EF:EFGrid> </EF:EFGrid>
</EF:EFRegion> </EF:EFRegion>
......
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