Commit 2afb21b7 by liuyang

2024-04-26 新增采购申请

parent 925e8d5a
......@@ -81,7 +81,7 @@ public class HPCG001 extends DaoEPBase {
public static final String INSERT = "HPCG001.insert";
public static final String UPDATE = "HPCG001.update";
public static final String DELETE = "HPCG001.delete";
public static final String DELETE_FLAG = "HPCG001.deleteFlag";
public static final String DELETE_FLAG = "HPCG001.daleteFlag";
public static final String UPDATE_PRO_APPLY_STATUS = "HPCG001.updateProApplyStatus";
private Long id = new Long(0); /* 主键id*/
......@@ -102,8 +102,8 @@ public class HPCG001 extends DaoEPBase {
private String inventName = " "; /* 存货名称*/
private Long inventRecordId = new Long(0); /* 存货档案ID*/
private BigDecimal applyAmount = new BigDecimal(0); /* 申请数量*/
private BigDecimal unitWeight = new BigDecimal(0.000000); /* 单重*/
private BigDecimal weight = new BigDecimal(0.000000); /* 重量*/
private BigDecimal unitWeight = new BigDecimal(0.000); /* 单重*/
private BigDecimal weight = new BigDecimal(0.000); /* 重量*/
private String remark = " "; /* 备注*/
private String oldPurchaseNo = " "; /* 原采购单号*/
private Integer deleteFlag = 0; /* 是否删除0.否1.是*/
......@@ -195,14 +195,14 @@ public class HPCG001 extends DaoEPBase {
eiColumn = new EiColumn(FIELD_UNIT_WEIGHT);
eiColumn.setType("N");
eiColumn.setScaleLength(6);
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(15);
eiColumn.setDescName("单重");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_WEIGHT);
eiColumn.setType("N");
eiColumn.setScaleLength(6);
eiColumn.setScaleLength(3);
eiColumn.setFieldLength(15);
eiColumn.setDescName("重量");
eiMetadata.addMeta(eiColumn);
......
......@@ -26,6 +26,7 @@ import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import java.math.BigDecimal;
......@@ -98,7 +99,6 @@ public class ServiceHPCG001 extends ServiceEPBase {
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsgByKey("ep.1000", new String[]{String.valueOf(i), I18nMessages.getText("label.delete", "删除")});
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
......@@ -159,6 +159,8 @@ public class ServiceHPCG001 extends ServiceEPBase {
* 修改操作
*/
public void modify(HPCG001 hpcg001) {
// 计算重量
this.calcWeight(hpcg001);
DaoUtils.update(HPCG001.UPDATE, hpcg001);
}
......@@ -169,6 +171,9 @@ public class ServiceHPCG001 extends ServiceEPBase {
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
List<Map<Object,Object>> list = eiBlock.getRows();
Map<Object,List<Map>> listMap = list.stream().collect(Collectors.groupingBy(map -> map.get(HPCG001.FIELD_INVENT_TYPE)));
List<HPKC010> hpkc010s = this.dao.query(HPKC010.QUERY,new HashMap<String,Object>(){{
put(HPCG002A.FIELD_DELETE_FLAG,CommonConstant.YesNo.NO_0);
}});
for (Object str: listMap.keySet()) {
HPCG002 hpcg002 = new HPCG002();
hpcg002.toMap();
......@@ -196,7 +201,7 @@ public class ServiceHPCG001 extends ServiceEPBase {
hpcg002a.setApplyWeight(hpcg001.getWeight());
hpcg002a.setId(0L);
//计算采购计划重量
this.calcPurchaseWeight(hpcg002a);
this.calcPurchaseWeight(hpcg002a,hpkc010s);
DaoUtils.insert(HPCG002A.INSERT, hpcg002a);
//修改提交状态
hpcg001.setProApplyStatus(CommonConstant.YesNo.YES_1);
......@@ -246,21 +251,36 @@ public class ServiceHPCG001 extends ServiceEPBase {
* 计算采购计划重量
* @param hpcg002a
*/
private void calcPurchaseWeight(HPCG002A hpcg002a){
BigDecimal applyAmount = new BigDecimal(0);
List<HPKC010> hpkc010s = this.dao.query(HPKC010.QUERY,new HashMap<String,Object>(){{
put(HPCG002A.FIELD_INVENT_RECORD_ID,hpcg002a.getInventRecordId());
put(HPCG002A.FIELD_INVENT_CODE,hpcg002a.getInventCode());
put(HPCG002A.FIELD_INVENT_TYPE,hpcg002a.getInventType());
put(HPCG002A.FIELD_WH_CODE,hpcg002a.getWhCode());
put(HPCG002A.FIELD_FACTORY_CODE,hpcg002a.getFactoryCode());
put(HPCG002A.FIELD_DELETE_FLAG,CommonConstant.YesNo.NO_0);
}});
for (HPKC010 hpkc010 : hpkc010s) {
applyAmount = applyAmount.add(hpkc010.getAmount());
private void calcPurchaseWeight(HPCG002A hpcg002a,List<HPKC010> hpkc010List){
BigDecimal applyAmount = BigDecimal.ZERO;
if (CollectionUtils.isNotEmpty(hpkc010List)) {
for (HPKC010 hpkc010 : hpkc010List) {
if ( hpkc010.getFactoryCode().equals(hpcg002a.getFactoryCode())
&& hpkc010.getInventRecordId().equals(hpcg002a.getInventRecordId())
&& hpkc010.getWhCode().equals(hpcg002a.getWhCode())
&& hpkc010.getInventType().equals(hpcg002a.getInventType())
&& hpkc010.getInventCode().equals(hpcg002a.getInventCode())) {
applyAmount = applyAmount.add(hpkc010.getAmount());
}
}
}
hpcg002a.setPlanAmount(hpcg002a.getApplyAmount().subtract(applyAmount));
BigDecimal planWeight = hpcg002a.getApplyAmount().subtract(applyAmount).multiply(hpcg002a.getApplyUnitWeight()).divide(new BigDecimal("1000"),3,BigDecimal.ROUND_UP);
hpcg002a.setPlanWeight(planWeight);
//判断库存数和申请数
int result = applyAmount.compareTo(hpcg002a.getApplyAmount());
BigDecimal value = BigDecimal.ZERO;
if (result > 0) {
value = applyAmount.subtract(hpcg002a.getApplyAmount());
}
for (HPKC010 hpkc010 : hpkc010List) {
if ( hpkc010.getFactoryCode().equals(hpcg002a.getFactoryCode())
&& hpkc010.getInventRecordId().equals(hpcg002a.getInventRecordId())
&& hpkc010.getWhCode().equals(hpcg002a.getWhCode())
&& hpkc010.getInventType().equals(hpcg002a.getInventType())
&& hpkc010.getInventCode().equals(hpcg002a.getInventCode())) {
hpkc010.setAmount(value);
}
}
}
}
......@@ -201,6 +201,11 @@ $(function () {
btnNode.attr("disabled", true);
save(btnNode);
},
onDelete: function (e) {
// 阻止默认请求,使用自定义删除
e.preventDefault();
deleteFunc();
},
onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'save'
||e.eiInfo.extAttr.methodName == 'delete'
......@@ -303,6 +308,12 @@ let save = function (btnNode) {
flag = false;
return false;
}
let status= item.get("proApplyStatus");
if(status=="1"){
message("选中的第"+(index+1)+"行记录已提交,不能修改!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
......@@ -341,6 +352,36 @@ function approveFunc() {
}
}
/**
* 删除明细
*/
function deleteFunc() {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let status= item.get("proApplyStatus");
if(status=="1"){
message("选中的第"+(index+1)+"行记录已提交,不能删除!");
flag = false;
return false;
}
});
if(flag){
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPCG001", "delete", true,
function (e) {
query();
});
}
});
}
}
function updateStatus(id) {
let inEiInfo = new EiInfo();
inEiInfo.set("result-0-id", id);
......
......@@ -74,16 +74,16 @@
<EF:EFColumn ename="inventName" cname="存货名称" width="150" align="center" required="true" readonly="true"/>
<EF:EFColumn ename="inventRecordId" cname="规格ID" width="120" align="center" readonly="true" hidden="true"/>
<EF:EFColumn ename="spec" cname="规格" width="120" align="center" readonly="true"/>
<EF:EFColumn ename="applyAmount" cname="申请数量" format="{0:N0}" maxLength="20" width="100" align="right" required="true" readonly="true"/>
<EF:EFColumn ename="unitWeight" cname="单重(KG)" enable="false" width="100" align="right" format="{0:N6}"/>
<EF:EFColumn ename="weight" cname="总重(T)" enable="false" width="100" align="right" format="{0:N6}"/>
<EF:EFColumn ename="applyAmount" cname="申请数量" format="{0:N0}" maxLength="20" width="100" align="right" required="true"/>
<EF:EFColumn ename="unitWeight" cname="单重(KG)" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFColumn ename="weight" cname="总重(T)" enable="false" width="100" align="right" format="{0:N3}"/>
<EF:EFColumn ename="length" cname="长(MM)" width="80" align="right" format="{0:N3}" readonly="true"/>
<EF:EFColumn ename="width" cname="宽(MM)" width="80" align="right" format="{0:N3}" readonly="true"/>
<EF:EFColumn ename="thick" cname="厚(MM)" width="80" align="right" format="{0:N3}" readonly="true"/>
<EF:EFColumn ename="coefficient" cname="系数" width="80" align="right" format="{0:N3}" readonly="true"/>
<EF:EFColumn ename="material" cname="材质" width="80" align="center" readonly="true"/>
<EF:EFColumn ename="unit" cname="单位" width="80" align="center" readonly="true"/>
<EF:EFColumn ename="remark" cname="备注" width="150" readonly="true"/>
<EF:EFColumn ename="remark" cname="备注" width="150"/>
<EF:EFComboColumn ename="proApplyStatus" cname="提交状态" width="80" align="center" enable="false" defaultValue="0">
<EF:EFOption label="未提交" value="0"/>
<EF:EFOption label="已提交" value="1"/>
......
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