Commit 45800e0d by 江和松

生产领料增加选择库存数据进行勾选

parent ecbe68db
package com.baosight.hggp.hg.kc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.common.InventTypeDetailEnum;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.cg.domain.HGCG002;
import com.baosight.hggp.hg.cg.domain.HGCG002B;
import com.baosight.hggp.hg.cg.domain.HGCG003;
import com.baosight.hggp.hg.cg.tools.HGCGTools;
import com.baosight.hggp.hg.cg.utils.HGCGUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.kc.domain.HGKC008;
import com.baosight.hggp.hg.kc.domain.HGKC008A;
import com.baosight.hggp.hg.kc.domain.HGKC010;
import com.baosight.hggp.hg.kc.utils.HGKCUtils;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.pz.domain.HGPZ007;
import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.hg.yx.domain.HGYX001A;
import com.baosight.hggp.util.*;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XLocalManager;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.math.BigDecimal;
import java.util.*;
/**
* @author:songx
* @date:2024/5/9,11:04
*/
public class ServiceHGKC008B extends ServiceBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "综合库存", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("inventTypeDetails", InventTypeDetailEnum.getInentTypeTwo());
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.COMPANY_CODE_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_TYPE_BLOCK_ID),paramMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_RECORD_BLOCK_ID),paramMap);
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.WH_RECORD_BLOCK_ID),paramMap);
EiInfoUtils.addBlock(inInfo,"roleCompany", UserSessionUtils.getRoleCompany(), Company.class);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGKC010().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询操作
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "综合库存", operType = "查询", operDesc = "查询")
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, "inventTypeDetails", InventTypeDetailEnum.getInentTypeTwo());
inInfo = super.query(inInfo, HGKC010.QUERY, new HGKC010());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 确认操作.
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "实时库存", operType = "查询", operDesc = "确认")
public EiInfo confirm(EiInfo inInfo) {
try {
String receiveId = inInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGKC008A.FIELD_RECEIVE_ID);
List<HGKC010> hgkc010s = MapUtils.toDaoEPBases(inInfo, HGKC010.class);
// db数据
Map<Long, HGKC010> dbHgkc010Map = HGKCUtils.HgKc010.lockGetDataEp(hgkc010s);
List<HGKC008A> hgkc008AList = HGKCUtils.HgKc008A.listByPrimaryId(receiveId);
HGKC008 hgkc008 = HGKCUtils.HgKc008.get(receiveId);
// 数据校验
this.checkConfirmData(hgkc008AList, dbHgkc010Map,hgkc008);
// 保存数据
this.confirmData(dbHgkc010Map, hgkc008);
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + hgkc010s.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
private void confirmData(Map<Long, HGKC010> dbHgkc010Map, HGKC008 hgkc008) {
List<HGKC008A> hgkc008AList = new LinkedList<>();
dbHgkc010Map.forEach((k,v) ->{
HGKC008A hgkc008A = new HGKC008A();
BeanUtils.copyProperties(hgkc008,hgkc008A,"id","createdBy","createdName","createdTime","updatedBy","updatedName","updatedTime");
hgkc008A.setReceiveId(hgkc008.getId());
hgkc008A.setInvLength(v.getLength());
hgkc008A.setInvThick(v.getThick());
hgkc008A.setInvUnitWeight(v.getInvUnitWeight());
hgkc008A.setInvWeight(v.getInvWeight());
hgkc008A.setInvWidth(v.getWidth());
hgkc008A.setInvSpec(v.getSpec());
hgkc008A.setInventType(v.getInventType());
hgkc008A.setInventTypeDetail(v.getInventTypeDetail());
hgkc008A.setInventCode(v.getInventCode());
hgkc008A.setInventName(v.getInventName());
hgkc008A.setInvQty(v.getInvQty());
hgkc008AList.add(hgkc008A);
});
DaoUtils.insertBatch(HGKC008A.INSERT, hgkc008AList);
}
private void checkConfirmData(List<HGKC008A> hgkc008AList, Map<Long, HGKC010> dbHgkc010Map, HGKC008 hgkc008) {
AssertUtils.isTrue(hgkc008.getStatus().compareTo(HGConstant.ProductStatus.YTJ) == 0,"领料单已提交,不可修改");
hgkc008AList.forEach(o -> {
dbHgkc010Map.forEach((k,v) ->{
AssertUtils.isTrue(o.getInventCode().equals(v.getInventCode()), "此领料单已选择存货:"+v.getInventCode());
});
});
}
}
...@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.kc.utils; ...@@ -3,6 +3,7 @@ package com.baosight.hggp.hg.kc.utils;
import com.baosight.hggp.core.dao.DaoBase; import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils; import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum; import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.hg.cg.domain.HGCG003B;
import com.baosight.hggp.hg.constant.HGSqlConstant; import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.kc.domain.*; import com.baosight.hggp.hg.kc.domain.*;
import com.baosight.hggp.hg.kc.tools.HGKCTools; import com.baosight.hggp.hg.kc.tools.HGKCTools;
...@@ -204,6 +205,52 @@ public class HGKCUtils { ...@@ -204,6 +205,52 @@ public class HGKCUtils {
queryRow.put(HGKC007.FIELD_OTHER_OUT_DATE, DateUtils.formatShort(otherOutDate)); queryRow.put(HGKC007.FIELD_OTHER_OUT_DATE, DateUtils.formatShort(otherOutDate));
} }
} }
/**
* 查询
*
* @param primaryId
* @return
*/
public static List<HGCG003B> listByPrimaryId(Long primaryId) {
AssertUtils.isNull(primaryId, "收货单id不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("primaryId", primaryId);
return DaoBase.getInstance().query(HGCG003B.QUERY, paramMap);
}
}
public static class HgKc008 {
/**
* 查询
*
* @param receiveId
* @return
*/
public static HGKC008 get(String receiveId) {
AssertUtils.isNull(receiveId, "领料单id不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("id", receiveId);
List<HGKC008> hgkc008List = DaoBase.getInstance().query(HGKC008.QUERY, paramMap);
return hgkc008List.get(0);
}
}
public static class HgKc008A {
/**
* 查询
*
* @param receiveId
* @return
*/
public static List<HGKC008A> listByPrimaryId(String receiveId) {
AssertUtils.isEmpty(receiveId, "领料单id不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put("receiveId", receiveId);
return DaoBase.getInstance().query(HGKC008A.QUERY, paramMap);
}
} }
/** /**
* HGKC010 工具类 * HGKC010 工具类
......
...@@ -264,11 +264,13 @@ function showDetail(id,whCode,companyCode,status) { ...@@ -264,11 +264,13 @@ function showDetail(id,whCode,companyCode,status) {
JSColorbox.open({ JSColorbox.open({
href: "HGKC008A?methodName=initLoad&inqu_status-0-receiveId=" + id+"&inqu_status-0-whCode="+whCode+"&inqu_status-0-companyCode="+companyCode+"&inqu_status-0-status="+status, href: "HGKC008A?methodName=initLoad&inqu_status-0-receiveId=" + id+"&inqu_status-0-whCode="+whCode+"&inqu_status-0-companyCode="+companyCode+"&inqu_status-0-status="+status,
title: "<div style='text-align: center;'>领料详情</div>", title: "<div style='text-align: center;'>领料详情</div>",
width: "80%", width: "90%",
height: "80%", height: "90%",
}); });
} }
function loadChange(grid,e,field) { function loadChange(grid,e,field) {
var cell_label = field,that = grid; var cell_label = field,that = grid;
// locked 表示是否为固定列 // locked 表示是否为固定列
......
...@@ -142,7 +142,8 @@ $(function (){ ...@@ -142,7 +142,8 @@ $(function (){
}, },
} }
} }
// 选择合同
$("#SELECT_INVENT").on("click", selectInvent);
downKeyUp(); downKeyUp();
}) })
...@@ -217,6 +218,30 @@ let save = function (btnNode) { ...@@ -217,6 +218,30 @@ let save = function (btnNode) {
} }
} }
/**
* 选择
*/
let selectInvent = function () {
JSColorbox.open({
href: "HGKC008B?methodName=initLoad&inqu_status-0-receiveId="+$("#inqu_status-0-receiveId").val()+"&inqu_status-0-companyCode="+$("#inqu_status-0-companyCode").val(),
title: "<div style='text-align: center;'>综合实时库存</div>",
width: "90%",
height: "90%",
callbackName: selectInventCallback
});
}
/**
* 选择回调
*/
let selectInventCallback = function () {
// 刷新页面
query();
// 关闭弹窗
JSColorbox.close();
}
function loadChange(grid,e,field) { function loadChange(grid,e,field) {
var cell_label = field,that = grid; var cell_label = field,that = grid;
// locked 表示是否为固定列 // locked 表示是否为固定列
......
$(function () {
IPLATUI.EFGrid = {
"result": {
exportGrid: false, // 隐藏右侧自定义导出按钮
columns: []
},
};
// 查询
$("#QUERY").on("click", query);
// 确认
$("#CONFIRM").on("click", confirm);
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 查询
query();
//存货编号查询条件
initInventCode();
});
/**
* 查询
*/
let query = function () {
resultGrid.dataSource.page(1); // 点击查询按钮,从第1页开始查询
}
/**
* 选择
*/
let confirm = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据")
return;
}
for (let i = 0; i < rows.length; i++) {
let invQty = rows[i]['invQty'];
let invWeight = rows[i]['invWeight'];
if (!isPositiveNumber(invQty)) {
message("勾选的第" + (i + 1) + "行库存数量必须大于0");
return;
}
if (!isPositiveNumber(invWeight)) {
message("勾选的第" + (i + 1) + "行库存总重必须大于0");
return;
}
}
JSUtils.confirm("确定对勾选的[" + rows.length + "]条数据生成\"采购收货\"吗? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGKC008B", "confirm",
true, function (e) {
var status = e.getStatus();
if (status !== -1) {
parent.JSColorbox.setValueCallback();
}
}
);
}
});
}
/**
* 存货编号
*/
let initInventCode = function () {
//物料信息下拉
var inInfo=new EiInfo();
EiCommunicator.send("HGPZ005", "queryComboBox", inInfo, {
onSuccess: function (ei) {
let dataSource;
var input=$("#inqu_status-0-inventCode");
dataSource=ei.getBlock("invent_record_block_id").getMappedRows();
input.kendoDropDownList({
valuePrimitive: true,
dataTextField: "textField",
dataValueField: "valueField",
optionLabel:"请选择",
dataSource: dataSource,
template: "[#:valueField#]#:textField#|#:param2Field#",
filter: "contains"
});
}, onFail: function (ei) {
}
}, {async: false});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<EF:EFPage title="综合库存管理">
<EF:EFRegion id="inqu" title="查询条件">
<EF:EFInput ename="inqu_status-0-companyCode" cname="公司编号" colWidth="3" type="hidden"/>
<EF:EFInput ename="inqu_status-0-receiveId" cname="领料单id" colWidth="3" type="hidden"/>
<div class="row">
<EF:EFSelect cname="仓库名称" blockId="inqu_status" ename="whCode" row="0" colWidth="3"
optionLabel="全部" defultValue="" filter="contains">
<EF:EFOptions blockId="wh_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="存货类型" blockId="inqu_status" ename="inventType" row="0" colWidth="3"
optionLabel="全部" defultValue="" filter="contains">
<EF:EFOptions blockId="invent_type_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFSelect cname="存货编号" blockId="inqu_status" ename="inventCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="" template="[#=valueField#]#=textField#">
<EF:EFOptions blockId="invent_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="row">
<EF:EFColumn ename="id" cname="内码" hidden="true"/>
<EF:EFColumn ename="companyCode" cname="公司编码" enable="false" width="100" align="center" hidden="true"/>
<EF:EFColumn ename="companyName" cname="公司名称" enable="false" width="130" align="center" hidden="true"/>
<EF:EFComboColumn ename="whCode" cname="仓库名称" enable="false" width="120" align="center"
blockName="wh_record_block_id" textField="textField" valueField="valueField">
</EF:EFComboColumn>
<EF:EFComboColumn ename="inventType" cname="存货类型" enable="false" width="100" align="center"
blockName="invent_type_block_id" textField="textField" valueField="valueField">
</EF:EFComboColumn>
<EF:EFColumn ename="inventCode" cname="存货编码" enable="false" width="100" align="center"/>
<EF:EFColumn ename="inventName" cname="存货名称" enable="false" width="100" align="center"/>
<EF:EFColumn ename="specId" cname="规格ID" enable="false" width="100" align="center" hidden="true"/>
<EF:EFColumn ename="spec" cname="规格" enable="false" width="120" align="center"/>
<EF:EFColumn ename="invQty" cname="库存数量" enable="false" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="invUnitWeight" cname="单重(KG)" enable="false" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="invWeight" cname="库存总重(KG)" enable="false" width="120" align="right" format="{0:N3}"/>
<EF:EFColumn ename="material" cname="材质" enable="false" width="80" align="center"/>
<EF:EFColumn ename="unit" cname="单位" enable="false" width="80" align="center"/>
<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:EFColumn ename="updatedName" cname="更新人" enable="false" width="100" align="center"/>
<EF:EFColumn ename="updatedTime" cname="更新时刻" enable="false" width="140" align="center"
editType="datetime" parseFormats="['yyyyMMddHHmmss']"/>
</EF:EFGrid>
</EF:EFRegion>
</EF:EFPage>
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