Commit 754800bb by liuyang

2024-10-19

1.委外加工单详情的材料明细,取消增加功能,增加选择功能,点击选择弹窗显示材料的库存明细,逻辑、限制条件跟生产领料选择仓库的库存
2.成品信息增加字段,为材料编码和材料名称,下拉选择当前材料信息的数据
parent 3c1e8b68
......@@ -52,6 +52,8 @@ public class HGSC010A extends DaoEPBase {
public static final String FIELD_REMAINING_UNIT_WEIGHT = "remainingUnitWeight"; /* 剩余单量*/
public static final String FIELD_REMAINING_WEIGHT = "remainingWeight"; /* 剩余重量*/
public static final String FIELD_DELIVER_QTY = "deliverQty"; /* 退货数量*/
public static final String FIELD_INVENT_CODE = "inventCode"; /* 原料编码*/
public static final String FIELD_INVENT_NAME = "inventName"; /* 原料名称*/
public static final String COL_ID = "ID"; /* ID*/
public static final String COL_ACCOUNT_CODE = "ACCOUNT_CODE"; /* 账套*/
......@@ -79,6 +81,8 @@ public class HGSC010A extends DaoEPBase {
public static final String COL_REMAINING_QTY = "REMAINING_QTY"; /* 剩余数量*/
public static final String COL_REMAINING_WEIGHT = "REMAINING_WEIGHT"; /* 剩余重量*/
public static final String COL_DELIVER_WEIGHT = "DELIVER_WEIGHT"; /* 退货数量*/
public static final String COL_INVENT_CODE = "INVENT_CODE"; /* 原料编码*/
public static final String COL_INVENT_NAME = "INVENT_NAME"; /* 原料名称*/
public static final String QUERY = "HGSC010A.query";
public static final String COUNT = "HGSC010A.count";
......@@ -116,6 +120,8 @@ public class HGSC010A extends DaoEPBase {
private BigDecimal remainingUnitWeight = new BigDecimal("0"); /* 剩余单量*/
private BigDecimal remainingWeight = new BigDecimal("0"); /* 剩余重量*/
private BigDecimal deliverQty = new BigDecimal("0"); /* 退货数量*/
private String inventCode = " "; /* 原料编码*/
private String inventName = " "; /* 原料名称*/
/**
* initialize the metadata.
......@@ -273,6 +279,14 @@ public class HGSC010A extends DaoEPBase {
eiColumn.setFieldLength(17);
eiColumn.setDescName("退货数量");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INVENT_CODE);
eiColumn.setDescName("原料编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_INVENT_NAME);
eiColumn.setDescName("原料名称");
eiMetadata.addMeta(eiColumn);
}
/**
......@@ -722,7 +736,23 @@ public class HGSC010A extends DaoEPBase {
public void setDeliverQty(BigDecimal deliverQty) {
this.deliverQty = deliverQty;
}
public String getInventCode() {
return inventCode;
}
public void setInventCode(String inventCode) {
this.inventCode = inventCode;
}
public String getInventName() {
return inventName;
}
public void setInventName(String inventName) {
this.inventName = inventName;
}
/**
* get the value from Map.
*
......@@ -761,6 +791,8 @@ public class HGSC010A extends DaoEPBase {
setRemainingUnitWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_REMAINING_UNIT_WEIGHT)), remainingUnitWeight));
setRemainingWeight(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_REMAINING_WEIGHT)), remainingWeight));
setDeliverQty(NumberUtils.toBigDecimal(StringUtils.toString(map.get(FIELD_DELIVER_QTY)), deliverQty));
setInventCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_CODE)), inventCode));
setInventName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_INVENT_NAME)), inventName));
}
/**
......@@ -800,6 +832,8 @@ public class HGSC010A extends DaoEPBase {
map.put(FIELD_REMAINING_UNIT_WEIGHT, StringUtils.toString(remainingUnitWeight, eiMetadata.getMeta(FIELD_REMAINING_UNIT_WEIGHT)));
map.put(FIELD_REMAINING_WEIGHT, StringUtils.toString(remainingWeight, eiMetadata.getMeta(FIELD_REMAINING_WEIGHT)));
map.put(FIELD_DELIVER_QTY, StringUtils.toString(deliverQty, eiMetadata.getMeta(FIELD_DELIVER_QTY)));
map.put(FIELD_INVENT_CODE, StringUtils.toString(inventCode, eiMetadata.getMeta(FIELD_INVENT_CODE)));
map.put(FIELD_INVENT_NAME, StringUtils.toString(inventName, eiMetadata.getMeta(FIELD_INVENT_NAME)));
return map;
}
......
......@@ -4,8 +4,11 @@ import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.common.InventTypeDetailEnum;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.kc.domain.HGKC010;
import com.baosight.hggp.hg.kc.tools.HGKCTools;
import com.baosight.hggp.hg.pz.domain.HGPZ004;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.sc.domain.HGSC010;
......@@ -20,11 +23,13 @@ import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.resource.I18nMessages;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import org.apache.commons.collections.CollectionUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LiuYang
......@@ -99,10 +104,20 @@ public class ServiceHGSC010B extends ServiceEPBase {
HGSC010 hgsc010 = HGSCTools.Hgsc010.getById(Long.parseLong(queryMap.get("parentId").toString()));
AssertUtils.isTrue(hgsc010.getSubStatus().equals(CommonConstant.YesNo.YES_1), "当前委外任务已提交,不允许修改保存!");
List<Map> resultRows = inInfo.getBlock(CommonConstant.Field.DETAIL).getRows();
List<String> inventCodes =resultRows.stream().map(map -> map.get(HGSC010B.FIELD_INVENT_CODE).toString()).distinct().collect(Collectors.toList());
Map paramMap = new HashMap();
paramMap.put("companyCode", hgsc010.getCompanyCode());
paramMap.put("inventCodes", inventCodes);
List<HGKC010> results = DaoBase.getInstance().query(HGKC010.QUERY, paramMap);
// 写入数据
for (Map resultRow : resultRows) {
HGSC010B hgsc010B = new HGSC010B();
hgsc010B.fromMap(resultRow);
List<HGKC010> kc010 = results.stream().filter(hgkc010 -> hgkc010.getInventCode().equals(hgsc010B.getInventCode())).collect(Collectors.toList());
AssertUtils.isEmpty(kc010, "库存不足!");
if (kc010.get(0).getInvQty().compareTo(hgsc010B.getPcsQty()) < 0) {
throw new PlatException("库存不足,无法保存!");
}
if (hgsc010B.getId() == null || hgsc010B.getId() == 0) {
hgsc010B.setCompanyCode(queryMap.get("companyCode").toString());
hgsc010B.setCompanyName(queryMap.get("companyName").toString());
......
......@@ -32,7 +32,9 @@
REMAINING_QTY as "remainingQty", <!-- 剩余数量 -->
REMAINING_UNIT_WEIGHT as "remainingUnitWeight", <!-- 剩余单量 -->
REMAINING_WEIGHT as "remainingWeight", <!-- 剩余重量 -->
DELIVER_QTY as "deliverQty" <!-- 退货数量 -->
DELIVER_QTY as "deliverQty", <!-- 退货数量 -->
INVENT_CODE as "inventCode", <!-- 原料编码 -->
INVENT_NAME as "inventName" <!-- 原料名称 -->
</sql>
<sql id="condition">
......@@ -129,6 +131,12 @@
COMPANY_CODE = #companyCode#
</isNotEmpty>)
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME like #inventName#
</isNotEmpty>
</sql>
<sql id="idCondition">
......@@ -186,12 +194,14 @@
DEPOSIT_WEIGHT, <!-- 入库重量 -->
REMAINING_QTY, <!-- 剩余数量 -->
REMAINING_UNIT_WEIGHT,
REMAINING_WEIGHT <!-- 剩余重量 -->
REMAINING_WEIGHT, <!-- 剩余重量 -->
INVENT_CODE, <!-- 原料编码 -->
INVENT_NAME <!-- 原料名称 -->
)
VALUES (#id#, #accountCode#, #depCode#, #createdBy#, #createdName#, #createdTime#, #deleteFlag#,
#companyCode#, #companyName#, #parentId#, #contractCode#, #inventType#,
#productCode#, #productName#, #specId#, #spec#, #unit#, #pcsQty#, #pcsUnitWeight#, #pcsWeight#, #depositQty#, #depositUnitWeight#, #depositWeight#,
#remainingQty#, #remainingUnitWeight#, #remainingWeight#)
#remainingQty#, #remainingUnitWeight#, #remainingWeight#, #inventCode#, #inventName#)
</insert>
<delete id="delete">
......@@ -227,7 +237,9 @@
DEPOSIT_WEIGHT = #depositWeight#, <!-- 入库重量 -->
REMAINING_QTY = #remainingQty#, <!-- 剩余数量 -->
REMAINING_UNIT_WEIGHT = #remainingUnitWeight#,
REMAINING_WEIGHT = #remainingWeight# <!-- 剩余重量 -->
REMAINING_WEIGHT = #remainingWeight#, <!-- 剩余重量 -->
INVENT_CODE = #inventCode#, <!-- 原料编码 -->
INVENT_NAME = #inventName# <!-- 原料名称 -->
WHERE
ID = #id#
</update>
......
......@@ -98,6 +98,9 @@
<isNotEmpty prepend=" AND " property="specIds">
SPEC_ID NOT IN <iterate close=")" open="(" conjunction="," property="specIds">#specIds[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCodes">
INVENT_CODE IN <iterate close=")" open="(" conjunction="," property="inventCodes">#inventCodes[]#</iterate>
</isNotEmpty>
</sql>
<!--<sql id="customCondition">
......
......@@ -4,7 +4,10 @@ $(function () {
$("#QUERY").on("click", function () {
resultGrid.dataSource.page(1);
});
/**
* 选择明细
*/
$("#BNT_CHOICE").on("click", addDetail);
IPLATUI.EFGrid = {
"result":{
......@@ -35,6 +38,24 @@ $(function () {
}
return dataItem["productCode"];
}
}, {
field: "inventCode",
filter: function (option) {
let dataItems = detailGrid.getDataItems();
if (!isBlank(dataItems)){
let rows = [];
dataItems.forEach(function (item){
item["textField"] = item["inventName"];
item["valueField"] = item["inventCode"];
rows.push(item);
});
return rows;
}else {
return _.filter(inventRecordBox, function (item) {
return item["param1Field"]=='1';
})
}
}
}
],
loadComplete: function (grid) {
......@@ -66,6 +87,12 @@ $(function () {
resultGrid.setCellValue(e.items[0],"remainingWeight",pcsWeight);
resultGrid.setCellValue(e.items[0],"remainingUnitWeight",pcsUnitWeight.toFixed(3));
resultGrid.setCellValue(e.items[0],"pcsUnitWeight",pcsUnitWeight.toFixed(3));
}else if (e.field == "inventCode"){
for (let i = 0; i < inventRecordBox.length; i++) {
if (inventRecordBox[i]['valueField'] === e.items[0]['inventCode']) {
resultGrid.setCellValue(e.items[0],"inventName",inventRecordBox[i]['textField']);
}
}
}
});
},
......@@ -182,10 +209,13 @@ let saveResult = function (btnNode) {
message("请选择数据");
return;
}
let detailRows = resultGrid.getDataItems();
let flag = true;
$.each(rows, function (index, item) {
let inventType = item.get("inventType");
let productCode = item.get("productCode");
let pcsQty = item.get("pcsQty");
let pcsWeight = item.get("pcsWeight");
if (isBlank(inventType)) {
message("选中的第" + (index + 1) + "行\"存货类型\",不能为空!");
flag = false;
......@@ -196,6 +226,21 @@ let saveResult = function (btnNode) {
flag = false;
return false;
}
if (!isPositiveInteger(pcsQty)) {
message("勾选的第" + (index + 1) + "行加工数量必须是大于0");
flag = false;
return false;
}
if (!isPositiveInteger(pcsWeight)) {
message("勾选的第" + (index + 1) + "行加工重量必须是大于0");
flag = false;
return false;
}
if (detailRows.length>0 && isBlank(item.get("inventCode"))){
message("选中的第" + (index + 1) + "行\"原料编码\",不能为空!");
flag = false;
return false;
}
});
if (flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
......@@ -242,4 +287,48 @@ let saveDetail = function (btnNode) {
};
/**
* 选择材料明细
*/
function addDetail() {
let inventCodes = [];
let rows = resultGrid.getDataItems();
let companyCode = $("#inqu_status-0-companyCode").val();
if (rows.length > 0){
$.each(rows, function(index, item) {
inventCodes.push(item.inventCode)
});
}
JSColorbox.open({
href: "HGSC010C?methodName=initLoad&inqu_status-0-companyCode="+companyCode+"&inqu_status-0-inventCodes="+inventCodes.join(','),
title: "<div style='text-align: center;'>选择委外材料</div>",
width: "90%",
height: "80%",
callbackName: detailCallback
});
}
function detailCallback(result) {
let rows = detailGrid.getDataItems();
if (result.length> 0) {
for (let i = 0; i < result.length; i++) {
let filters = rows.filter(row => row.inventCode == result[i].inventCode
&& row.spec == result[i].spec);
if (filters.length > 0){
message("无法重复添加!");
return false;
}
result[i].id = 0;
result[i].pcsQty = result[i].consQuantity;
result[i].pcsUnitWeight = result[i].consUnitWeight;
result[i].pcsWeight = result[i].consWeight;
result[i].remainingQty = result[i].consQuantity;
result[i].remainingUnitWeight = result[i].consUnitWeight;
result[i].remainingWeight = result[i].consWeight;
}
detailGrid.addRows(result);
}
}
......@@ -27,14 +27,15 @@
<EF:EFComboColumn ename="productCode" cname="成品编码" width="120" align="center" required="true" readonly="false"
blockName="invent_record_box_block_id" textField="textField" valueField="valueField"
columnTemplate="#=textField#" itemTemplate="#=valueField#-#=textField#"
filter="contains">
</EF:EFComboColumn>
filter="contains" />
<EF:EFColumn ename="productName" cname="成品名称" width="120" align="center" required="true"/>
<EF:EFComboColumn ename="inventType" cname="存货类型" width="120" align="center" required="true"
blockName="invent_type_block_id" textField="textField" valueField="valueField"
columnTemplate="#=textField#" itemTemplate="#=textField#" readonly="false"
filter="contains">
</EF:EFComboColumn>
columnTemplate="#=textField#" itemTemplate="#=textField#" readonly="false" filter="contains" />
<EF:EFComboColumn ename="inventCode" cname="材料编码" width="120" align="center" required="false" readonly="false"
blockName="invent_record_box_block_id" textField="textField" valueField="valueField"
columnTemplate="#=valueField#" itemTemplate="#=valueField#-#=textField#" filter="contains" />
<EF:EFColumn ename="inventName" cname="材料名称" enable="false" width="120" align="center" required="false"/>
<EF:EFColumn ename="specId" cname="规格ID" width="140" align="center" maxLength="50" hidden="true"/>
<EF:EFColumn ename="spec" cname="规格" width="140" align="center" maxLength="50"/>
<EF:EFColumn ename="unit" cname="单位" width="80" align="center"/>
......@@ -81,22 +82,23 @@
</EF:EFGrid>
</EF:EFRegion>
<EF:EFRegion id="detail" title="原料信息">
<EF:EFGrid blockId="detail" autoDraw="override" isFloat="true" needAuth="false" serviceName="HGSC010B">
<EF:EFGrid blockId="detail" autoDraw="override" isFloat="true" needAuth="true" serviceName="HGSC010B">
<EF:EFColumn ename="id" primaryKey="true" cname="内码" hidden="true"/>
<EF:EFComboColumn ename="inventCode" cname="原料编码" width="120" align="center" required="true" readonly="false"
<%--<EF:EFComboColumn ename="inventCode" cname="原料编码" width="120" align="center" required="true" readonly="false"
blockName="invent_record_box_block_id" textField="textField" valueField="valueField"
columnTemplate="#=textField#" itemTemplate="#=valueField#-#=textField#"
filter="contains">
</EF:EFComboColumn>
<EF:EFColumn ename="inventName" cname="原料名称" width="120" align="center" required="true"/>
<EF:EFComboColumn ename="inventType" cname="存货类型" width="100" align="center" required="true"
</EF:EFComboColumn>--%>
<EF:EFColumn ename="inventCode" cname="原料编码" enable="false" width="120" align="center" required="true"/>
<EF:EFColumn ename="inventName" cname="原料名称" enable="false" width="120" align="center" required="true"/>
<EF:EFComboColumn ename="inventType" cname="存货类型" enable="false" width="100" align="center" required="true"
blockName="invent_type_block_id" textField="textField" valueField="valueField"
columnTemplate="#=textField#" itemTemplate="#=textField#" readonly="false"
filter="contains">
</EF:EFComboColumn>
<EF:EFColumn ename="specId" cname="规格ID" width="140" align="center" maxLength="50" hidden="true"/>
<EF:EFColumn ename="spec" cname="规格" width="140" align="center" maxLength="50"/>
<EF:EFColumn ename="unit" cname="单位" width="80" align="center"/>
<EF:EFColumn ename="spec" cname="规格" enable="false" width="140" align="center" maxLength="50"/>
<EF:EFColumn ename="unit" cname="单位" enable="false" width="80" align="center"/>
<EF:EFColumn ename="pcsQty" cname="加工数量" width="120" enable="true" format="{0:N0}" editType="text"
displayType="0" sort="true" align="right" maxLength="17" required="true" defaultValue="0"
data-regex="/^-?[0-9]{1,17}$/" readonly="false"
......
......@@ -418,6 +418,7 @@ function detailCallback(result) {
result[i].quantity = result[i].consQuantity;
result[i].unitWeight = result[i].consUnitWeight;
result[i].weight = result[i].consWeight;
result[i].inventRecordId = result[i].specId
resultGrid.addRows(result[i]);
}
}
......
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