Commit f61d98f4 by 江和松

采购入库单审批操作

parent 403b12a0
package com.baosight.hpjx.common;
import com.baosight.iplat4j.core.ei.EiBlock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author jhs
* @Date 2024/1/22 18:23
*/
public enum ApprovalStatusEnum {
SAVED(1,"保存"),
SUBMIT(2,"已提交"),
APPROVED(3,"审批通过"),
REJECTION(4,"审批拒绝");
private Integer code;
private String value;
ApprovalStatusEnum(Integer code, String value) {
this.code = code;
this.value = value;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static EiBlock generatorEiBlock(){
EiBlock block = new EiBlock("approval_status_block_id");
List<Map<String,Object>> rows = new ArrayList<Map<String,Object>>(){{
add(new HashMap<String,Object>(){{
put(HPConstants.TEXT_FIELD,SAVED.code);
put(HPConstants.VALUE_FIELD,SAVED.value);
}});
add(new HashMap<String,Object>(){{
put(HPConstants.TEXT_FIELD,SUBMIT.code);
put(HPConstants.VALUE_FIELD,SUBMIT.value);
}});
add(new HashMap<String,Object>(){{
put(HPConstants.TEXT_FIELD,APPROVED.code);
put(HPConstants.VALUE_FIELD,APPROVED.value);
}});
add(new HashMap<String,Object>(){{
put(HPConstants.TEXT_FIELD,REJECTION.code);
put(HPConstants.VALUE_FIELD,REJECTION.value);
}});
}};
block.setRows(rows);
return block;
}
}
...@@ -42,7 +42,7 @@ public class HPKC001 extends DaoEPBase { ...@@ -42,7 +42,7 @@ public class HPKC001 extends DaoEPBase {
private Long quantity = 0L; /* 数量*/ private Long quantity = 0L; /* 数量*/
private BigDecimal weight = new BigDecimal("0"); /* 重量*/ private BigDecimal weight = new BigDecimal("0"); /* 重量*/
private String remarks = " "; /* 备注*/ private String remarks = " "; /* 备注*/
private int approvalStatus; /* 审批状态:0-未审核,1-已审核*/ private int approvalStatus; /* 审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝*/
private String custCode = " "; /* 供应商编码*/ private String custCode = " "; /* 供应商编码*/
private String custName = " "; /* 供应商名称*/ private String custName = " "; /* 供应商名称*/
...@@ -151,7 +151,7 @@ EiColumn eiColumn; ...@@ -151,7 +151,7 @@ EiColumn eiColumn;
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("approvalStatus"); eiColumn = new EiColumn("approvalStatus");
eiColumn.setDescName("审批状态:0-未审核,1-已审核"); eiColumn.setDescName("审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("custCode"); eiColumn = new EiColumn("custCode");
......
...@@ -42,7 +42,7 @@ public class HPKC002 extends DaoEPBase { ...@@ -42,7 +42,7 @@ public class HPKC002 extends DaoEPBase {
private Long quantity = 0L; /* 数量*/ private Long quantity = 0L; /* 数量*/
private BigDecimal weight = new BigDecimal("0"); /* 重量*/ private BigDecimal weight = new BigDecimal("0"); /* 重量*/
private String remarks = " "; /* 备注*/ private String remarks = " "; /* 备注*/
private int approvalStatus; /* 审批状态:0-未审核,1-已审核*/ private int approvalStatus; /* 审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝*/
private String custCode = " "; /* 供应商编码*/ private String custCode = " "; /* 供应商编码*/
private String custName = " "; /* 供应商名称*/ private String custName = " "; /* 供应商名称*/
...@@ -151,7 +151,7 @@ public class HPKC002 extends DaoEPBase { ...@@ -151,7 +151,7 @@ public class HPKC002 extends DaoEPBase {
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("approvalStatus"); eiColumn = new EiColumn("approvalStatus");
eiColumn.setDescName("审批状态:0-未审核,1-已审核"); eiColumn.setDescName("审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn("custCode"); eiColumn = new EiColumn("custCode");
......
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.hp.constant.HPConstant; import com.baosight.hpjx.hp.constant.HPConstant;
...@@ -80,7 +81,7 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -80,7 +81,7 @@ public class ServiceHPKC001 extends ServiceBase {
// 生成单据号 // 生成单据号
insertEntity.setDocumentCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC001_NUMBER)); insertEntity.setDocumentCode(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC001_NUMBER));
insertEntity.setStatus(1); insertEntity.setStatus(1);
insertEntity.setApprovalStatus(0); insertEntity.setApprovalStatus(ApprovalStatusEnum.SAVED.getCode());
dao.insert("HPKC001.insert", insertEntity); dao.insert("HPKC001.insert", insertEntity);
} }
inInfo = this.query(inInfo); inInfo = this.query(inInfo);
...@@ -114,6 +115,64 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -114,6 +115,64 @@ public class ServiceHPKC001 extends ServiceBase {
} }
} }
/**
* 校验提交的数据
*
* @param resultRows
*/
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("数据已经审批通过,不能重复审批");
}
}
}
}
/** /**
...@@ -153,6 +212,98 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -153,6 +212,98 @@ public class ServiceHPKC001 extends ServiceBase {
} }
/** /**
* 提交操作.
*/
public EiInfo submit(EiInfo eiInfo) {
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) {
try {
List<Map> resultRows = eiInfo.getBlock(EiConstant.resultBlock).getRows();
this.checkApproveData(resultRows,ApprovalStatusEnum.REJECTION.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.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;
}
/**
* 删除操作. * 删除操作.
*/ */
@Override @Override
...@@ -160,6 +311,8 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -160,6 +311,8 @@ public class ServiceHPKC001 extends ServiceBase {
HPKC001 HPKC001 = new HPKC001(); HPKC001 HPKC001 = new HPKC001();
EiBlock eiBlock = eiInfo.getBlock(EiConstant.resultBlock); EiBlock eiBlock = eiInfo.getBlock(EiConstant.resultBlock);
try { try {
List<Map> resultRows = eiInfo.getBlock(EiConstant.resultBlock).getRows();
this.checkDeleteData(resultRows);
for (int i = 0; i < eiBlock.getRowCount(); i++) { for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i); Map<?, ?> map = eiBlock.getRow(i);
HPKC001.fromMap(map); HPKC001.fromMap(map);
...@@ -178,4 +331,23 @@ public class ServiceHPKC001 extends ServiceBase { ...@@ -178,4 +331,23 @@ public class ServiceHPKC001 extends ServiceBase {
return eiInfo; return eiInfo;
} }
/**
* 校验审批的数据
*
* @param resultRows
*
*/
private void checkDeleteData(List<Map> resultRows) {
for (int i = 0; i < resultRows.size(); i++) {
HPKC001 entity = new HPKC001();
entity.fromMap(resultRows.get(i));
if(entity.getApprovalStatus() == ApprovalStatusEnum.SUBMIT.getCode()){
throw new PlatException("已提交采购入库单不能删除");
}
if(entity.getApprovalStatus() == ApprovalStatusEnum.APPROVED.getCode()){
throw new PlatException("已审批通过采购入库单不能删除");
}
}
}
} }
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
QUANTITY as "quantity", <!-- 数量 --> QUANTITY as "quantity", <!-- 数量 -->
WEIGHT as "weight", <!-- 重量 --> WEIGHT as "weight", <!-- 重量 -->
REMARKS as "remarks", <!-- 备注 --> REMARKS as "remarks", <!-- 备注 -->
APPROVAL_STATUS as "approvalStatus", <!-- 审批状态:0-未审核,1-已审核 --> APPROVAL_STATUS as "approvalStatus", <!-- 审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝 -->
CUST_CODE as "custCode", <!-- 供应商编码 --> CUST_CODE as "custCode", <!-- 供应商编码 -->
CUST_NAME as "custName" <!-- 供应商名称 --> CUST_NAME as "custName" <!-- 供应商名称 -->
FROM hpjx.t_hpkc001 WHERE 1=1 FROM hpjx.t_hpkc001 WHERE 1=1
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
QUANTITY, <!-- 数量 --> QUANTITY, <!-- 数量 -->
WEIGHT, <!-- 重量 --> WEIGHT, <!-- 重量 -->
REMARKS, <!-- 备注 --> REMARKS, <!-- 备注 -->
APPROVAL_STATUS, <!-- 审批状态:0-未审核,1-已审核 --> APPROVAL_STATUS, <!-- 审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝 -->
CUST_CODE, <!-- 供应商编码 --> CUST_CODE, <!-- 供应商编码 -->
CUST_NAME <!-- 供应商名称 --> CUST_NAME <!-- 供应商名称 -->
) )
...@@ -110,6 +110,12 @@ ...@@ -110,6 +110,12 @@
DELETE FROM hpjx.t_hpkc001 WHERE ID = #id# DELETE FROM hpjx.t_hpkc001 WHERE ID = #id#
</delete> </delete>
<update id="approvalStatusUpdate">
UPDATE hpjx.t_hpkc001
SET APPROVAL_STATUS = #approvalStatus#
WHERE ID = #id#
</update>
<update id="update"> <update id="update">
UPDATE hpjx.t_hpkc001 UPDATE hpjx.t_hpkc001
SET SET
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
QUANTITY as "quantity", <!-- 数量 --> QUANTITY as "quantity", <!-- 数量 -->
WEIGHT as "weight", <!-- 重量 --> WEIGHT as "weight", <!-- 重量 -->
REMARKS as "remarks", <!-- 备注 --> REMARKS as "remarks", <!-- 备注 -->
APPROVAL_STATUS as "approvalStatus", <!-- 审批状态:0-未审核,1-已审核 --> APPROVAL_STATUS as "approvalStatus", <!-- 审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝 -->
CUST_CODE as "custCode", <!-- 供应商编码 --> CUST_CODE as "custCode", <!-- 供应商编码 -->
CUST_NAME as "custName" <!-- 供应商名称 --> CUST_NAME as "custName" <!-- 供应商名称 -->
FROM hpjx.t_hpkc002 WHERE 1=1 FROM hpjx.t_hpkc002 WHERE 1=1
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
QUANTITY, <!-- 数量 --> QUANTITY, <!-- 数量 -->
WEIGHT, <!-- 重量 --> WEIGHT, <!-- 重量 -->
REMARKS, <!-- 备注 --> REMARKS, <!-- 备注 -->
APPROVAL_STATUS, <!-- 审批状态:0-未审核,1-已审核 --> APPROVAL_STATUS, <!-- 审批状态:1-保存,2-已提交,3-审批通过,4-审批拒绝 -->
CUST_CODE, <!-- 供应商编码 --> CUST_CODE, <!-- 供应商编码 -->
CUST_NAME <!-- 供应商名称 --> CUST_NAME <!-- 供应商名称 -->
) )
......
...@@ -221,6 +221,184 @@ $(function() { ...@@ -221,6 +221,184 @@ $(function() {
}); });
}); });
//提交
$("#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) { onSuccess: function (e) {
if (e.type != 'read') { if (e.type != 'read') {
......
...@@ -48,9 +48,18 @@ ...@@ -48,9 +48,18 @@
<EF:EFColumn ename="unit" cname="单位" width="80" readonly="false" align="center" enable="false" 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="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: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:EFColumn ename="remarks" cname="备注" width="100" readonly="false"/> <EF:EFColumn ename="remarks" cname="备注" width="100" readonly="false"/>
</EF:EFGrid> </EF:EFGrid>
</EF:EFRegion> </EF:EFRegion>
</EF:EFPage> </EF:EFPage>
<style>
.k-grid-REJECTION {
background-color: red;
}
</style>
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