Commit 904ccbf9 by liuyang

2024-09-23 报表管理增加库存管理模块 采购入库明细

parent 0efb9a92
package com.baosight.hggp.hg.cg.service;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.hg.cg.domain.HGCG003;
import com.baosight.hggp.hg.cg.domain.HGCG004;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* @author LiuYang
* @version 1.0 2024/9/23
* @description
*/
public class ServiceHGCG004 extends ServiceEPBase {
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(
DdynamicEnum.PROJ_RECORD_BLOCK_ID,
DdynamicEnum.SUP_RECORD_BLOCK_ID)
);
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGCG004().eiMetadata);
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
@Override
public EiInfo query(EiInfo inInfo) {
builder(inInfo);
return super.query(inInfo, HGCG004.QUERY, new HGCG004());
}
public void builder(EiInfo eiInfo){
String[] orderBy = eiInfo.getBlock(EiConstant.resultBlock).getString(EiConstant.orderByStr).split(",");
if (orderBy.length>0){
StringBuilder orderByStr= new StringBuilder();
for (int i = 0; i < orderBy.length; i++) {
if (i != 0 && i != orderByStr.length() - 1) {
orderByStr.append(",");
}
switch (orderBy[i]) {
case "receiveDate asc":
orderByStr.append(orderBy[i].replace("receiveDate asc", "b.receiveDate asc"));
break;
case "receiveNo asc":
orderByStr.append(orderBy[i].replace("receiveNo asc", "b.receiveNo asc"));
break;
case "supCode asc":
orderByStr.append(orderBy[i].replace("supCode asc", "b.supCode asc"));
break;
case "projName asc":
orderByStr.append(orderBy[i].replace("projName asc", "b.projName asc"));
break;
case "contractNo asc":
orderByStr.append(orderBy[i].replace("contractNo asc", "b.contractNo asc"));
break;
case "inventName asc":
orderByStr.append(orderBy[i].replace("inventName asc", "a.inventName asc"));
break;
case "spec asc":
orderByStr.append(orderBy[i].replace("spec asc", "a.spec asc"));
break;
case "receiveQty asc":
orderByStr.append(orderBy[i].replace("receiveQty asc", "a.receiveQty asc"));
break;
case "receiveWeight asc":
orderByStr.append(orderBy[i].replace("receiveWeight asc", "a.receiveWeight asc"));
break;
case "amount asc":
orderByStr.append(orderBy[i].replace("amount asc", "a.amount asc"));
break;
case "receiveDate desc":
orderByStr.append(orderBy[i].replace("receiveDate desc", "b.receiveDate desc"));
break;
case "receiveNo desc":
orderByStr.append(orderBy[i].replace("receiveNo desc", "b.receiveNo desc"));
break;
case "supCode desc":
orderByStr.append(orderBy[i].replace("supCode desc", "b.supCode desc"));
break;
case "projName desc":
orderByStr.append(orderBy[i].replace("projName desc", "b.projName desc"));
break;
case "contractNo desc":
orderByStr.append(orderBy[i].replace("contractNo desc", "b.contractNo desc"));
break;
case "inventName desc":
orderByStr.append(orderBy[i].replace("inventName desc", "a.inventName desc"));
break;
case "spec desc":
orderByStr.append(orderBy[i].replace("spec desc", "a.spec desc"));
break;
case "receiveQty desc":
orderByStr.append(orderBy[i].replace("receiveQty desc", "a.receiveQty desc"));
break;
case "receiveWeight desc":
orderByStr.append(orderBy[i].replace("receiveWeight desc", "a.receiveWeight desc"));
break;
case "amount desc":
orderByStr.append(orderBy[i].replace("amount desc", "a.amount desc"));
break;
default:
if (!orderBy[i].isEmpty()){
orderByStr.append(orderBy[i]);
}else {
orderByStr.append(orderBy[i]);
}
break;
}
}
eiInfo.getBlock(EiConstant.resultBlock).set("orderBy",orderByStr);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="HGCG004">
<sql id="column">
A.ID as "id",
B.ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
B.DEP_CODE as "depCode", <!-- 部门编码 -->
A.CREATED_BY as "createdBy", <!-- 记录创建者 -->
A.CREATED_NAME as "createdName", <!-- 记录创建名称 -->
A.CREATED_TIME as "createdTime", <!-- 记录创建时间 -->
A.UPDATED_BY as "updatedBy", <!-- 记录修改者 -->
A.UPDATED_NAME as "updatedName", <!-- 记录修改名称 -->
A.UPDATED_TIME as "updatedTime", <!-- 记录修改时间 -->
B.DELETE_FLAG as "deleteFlag", <!-- 0-未删除,1-已删除 -->
B.COMPANY_CODE as "companyCode", <!-- 公司编码 -->
B.COMPANY_NAME as "companyName", <!-- 公司名称 -->
B.RECEIVE_DATE as "receiveDate", <!-- 收货日期 -->
B.RECEIVE_NO as "receiveNo", <!-- 收货单号 -->
B.CONTRACT_NO as "contractNo", <!-- 合同号 -->
A.INVENT_CODE as "inventCode", <!-- 存货编码 -->
A.INVENT_NAME as "inventName", <!-- 存货名称 -->
A.SPEC_ID as "specId", <!-- 规格ID -->
A.SPEC as "spec", <!-- 规格 -->
A.RECEIVE_QTY as "receiveQty", <!-- 收货数量 -->
A.RECEIVE_WEIGHT as "receiveWeight", <!-- 收货重量 -->
A.PRICE as "price", <!-- 单价 -->
A.AMOUNT as "amount", <!-- 金额(不含税金额) -->
A.TAX_INCLUDE_AMOUNT as "taxIncludeAmount", <!-- 含税金额 -->
A.TAX_AMOUNT as "taxAmount", <!-- 税额 -->
A.TAX_RATE as "taxRate", <!-- 税率 -->
B.PROJ_CODE as "projCode", <!-- 项目编码 -->
B.PROJ_NAME as "projName", <!-- 项目名称 -->
B.SUP_CODE as "supCode", <!-- 供应商编码 -->
B.SUP_NAME as "supName" <!-- 供应商名称 -->
</sql>
<sql id="condition">
AND B.DELETE_FLAG = 0
<isNotEmpty prepend=" AND " property="accountCode">
B.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
B.DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
A.CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
A.CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
A.CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
A.UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
A.UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
A.UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deleteFlag">
B.DELETE_FLAG = #deleteFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyCode">
B.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyName">
B.COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveDate">
B.RECEIVE_DATE = REPLACE(#receiveDate#, '-', '')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveNo">
B.RECEIVE_NO LIKE CONCAT('%', #receiveNo# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="contractNo">
B.CONTRACT_NO LIKE CONCAT('%', #contractNo# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
A.INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
A.INVENT_NAME LIKE CONCAT('%', #inventName# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="specId">
A.SPEC_ID = #specId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="spec">
A.SPEC LIKE CONCAT('%', #spec# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveQty">
A.RECEIVE_QTY LIKE CONCAT('%', #receiveQty# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="receiveWeight">
A.RECEIVE_WEIGHT LIKE CONCAT('%', #receiveWeight# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="price">
A.PRICE LIKE CONCAT('%', #price# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="amount">
A.AMOUNT LIKE CONCAT('%', #amount# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projCode">
B.PROJ_CODE = #projCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projName">
B.PROJ_NAME LIKE CONCAT('%', #projName# ,'%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="supCode">
B.SUP_CODE = #supCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="supName">
B.SUP_NAME like concat('%',#supName#,'%')
</isNotEmpty>
</sql>
<sql id="orderBy">
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
B.RECEIVE_DATE DESC
</isEmpty>
</dynamic>
</sql>
<select id="query" resultClass="com.baosight.hggp.hg.cg.domain.HGCG004">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGCG003A A
INNER JOIN ${hggpSchema}.HGCG003 B ON A.PRIMARY_ID = B.ID
WHERE 1=1
<include refid="condition"/>
<include refid="orderBy"/>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM ${hggpSchema}.HGCG003A A
INNER JOIN ${hggpSchema}.HGCG003 B ON A.PRIMARY_ID = B.ID
WHERE 1=1
<include refid="condition"/>
</select>
</sqlMap>
\ No newline at end of file
$(function () {
//var inventRecordBoxBlockId = __eiInfo.getBlock("invent_record_box_block_id").getMappedRows();
/* 页面查询框的尺寸设置 */
$.extend(true, IPLATUI.Config, {
EFGrid: {
height: $(document).height() - $("#inqu").height() - $("#ef_form_head").height() - 100,
}
});
IPLATUI.EFGrid = {
"result": {
exportGrid: false, // 隐藏右侧自定义导出按钮
pageable: {
pageSize: 10,
pageSizes: [10, 20, 50, 100],
},
columns: [],
beforeEdit: function (e) {
var status = $("#status").val();
if (status != '0' && status != '2') {
e.preventDefault();
}
var source = $("#source").val();
if (source === '0') {
//选择合同的明细不能修改存货信息
for (let i = 0; i < e.sender.columns.length; i++) {
//指定的列不让修改
if (e.sender.columns[i]["name"] === "inventCode") {
e.sender.columns[i]["enable"] = false;
e.sender.columns[i]["readonly"] = true;
}
if (e.sender.columns[i]["name"] === "price") {
e.sender.columns[i]["enable"] = false;
}
}
}
},
loadComplete: function (grid) {
// 此grid对象
grid.dataSource.bind("change", function (e) {
var item = e.items[0];
// 数量发生变化进行计算
if(e.field === "receiveQty"){
calAmount(item)
}
if(e.field === "price"){
calAmount(item)
}
if(e.field === "taxRate"){
calAmount(item)
}
if(e.field === "receiveWeight"){
calAmount(item)
}
if(e.field === "calculationMethod"){
calAmount(item)
}
if (e.field === "inventCode") {
for (let i = 0; i < inventRecordBoxBlockId.length; i++) {
if (inventRecordBoxBlockId[i]['valueField'] === e.items[0].inventCode) {
resultGrid.setCellValue(e.items[0], 'inventName',
inventRecordBoxBlockId[i]['textField']
)
resultGrid.setCellValue(e.items[0], 'inventTypeDetail',
inventRecordBoxBlockId[i]['param1Field']
)
resultGrid.setCellValue(e.items[0], 'inventType',
inventRecordBoxBlockId[i]['param3Field']
)
resultGrid.setCellValue(e.items[0], 'spec',
inventRecordBoxBlockId[i]['param4Field']
)
resultGrid.setCellValue(e.items[0], 'material',
inventRecordBoxBlockId[i]['param5Field']
)
resultGrid.setCellValue(e.items[0], 'unit',
inventRecordBoxBlockId[i]['param6Field']
)
resultGrid.setCellValue(e.items[0], 'length',
inventRecordBoxBlockId[i]['param7Field']
)
resultGrid.setCellValue(e.items[0], 'width',
inventRecordBoxBlockId[i]['param8Field']
)
resultGrid.setCellValue(e.items[0], 'thick',
inventRecordBoxBlockId[i]['param9Field']
)
// 系数
let coefficient = inventRecordBoxBlockId[i]['param10Field']
calUnitWeight(e.items[0], e.items[0].length, e.items[0].width,
e.items[0].thick, coefficient
);
break
}
}
}
})
},
onSave: function (e) {
// 阻止后台请求,使用自定义
e.preventDefault();
save();
},
onDelete: function (e) {
// 阻止后台请求,使用自定义
e.preventDefault();
remove();
}
}
}
// 查询
$("#QUERY").on("click", query);
downKeyUp();
});
/**
* 页面加载时执行
*/
$(window).load(function () {
// 查询
query();
//initInventCode();
});
/**
* 计算金额
*
* @param item
* @param length
* @param width
* @param thick
* @param coefficient
*/
let calAmount = function (item) {
let totalAmount;
let price = item.price;
//计算方式为重量乘单价
if (item.calculationMethod == 1) {
let receiveWeight = item.receiveWeight;
if (!isBlank(receiveWeight) && !isBlank(price)) {
// 重量*单价金额
totalAmount = parseFloat(receiveWeight) * parseFloat(price);
}
} else {
let receiveQty = item.receiveQty;
if (!isBlank(receiveQty) && !isBlank(price)) {
// 数量*单价金额
totalAmount = parseFloat(receiveQty) * parseFloat(price);
}
}
if (isBlank(totalAmount)) {
return;
}
// 不含税金额
let amount = isBlank(item.taxRate) ? totalAmount : totalAmount / (1 + item.taxRate / 100);
// 税额
let taxAmount = totalAmount - amount;
// 含税金额
let taxIncludeAmount = totalAmount;
resultGrid.setCellValue(item, 'amount', amount)
resultGrid.setCellValue(item, 'taxAmount', taxAmount)
resultGrid.setCellValue(item, 'taxIncludeAmount', taxIncludeAmount)
}
/**
* 查询
*/
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 存货编号
*/
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});
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
for (let i = 0; i < rows.length; i++) {
if (!isPositiveNumber(rows[i]['receiveQty'])) {
message("勾选的第" + (i + 1) + "行收货数量必须大于0");
return;
}
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCG003B", "save",
true, function (e) {
var status = e.getStatus();
if (status !== -1) {
parent.JSColorbox.setValueCallback();
}
}
);
}
});
}
/**
* 删除
*/
let remove = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"删除\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGCG003B", "remove",
true, function (e) {
var status = e.getStatus();
if (status !== -1) {
parent.JSColorbox.setValueCallback();
}
}
);
}
});
}
let calUnitWeight = function (item, length, width, thick, coefficient) {
let l = Number(length) || 1;
let w = Number(width) || 1;
let t = Number(thick) || 1;
let unitWeight = (l * w * t) > 1 ? l * w * t * Number(coefficient) / 100000 : 0;
//item['amount'] = amount.toString();
resultGrid.setCellValue(item, 'receiveUnitWeight', unitWeight);
resultGrid.setCellValue(item, 'receiveWeight', item.receiveQty * unitWeight);
}
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: 1
Date: 2024/9/23
Time: 13:54
To change this template use File | Settings | File Templates.
--%>
<!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="查询条件">
<div class="row">
<EF:EFDatePicker cname="收货日期" blockId="inqu_status" ename="receiveDate" row="0" colWidth="3"
role="date" format="yyyy-MM-dd" readonly="true"/>
<EF:EFInput cname="收货单号" blockId="inqu_status" ename="receiveNo" row="0" colWidth="3"/>
<EF:EFSelect cname="供应商名称" blockId="inqu_status" ename="supCode" row="0" colWidth="3"
filter="contains" optionLabel="全部" defultValue="">
<EF:EFOptions blockId="sup_record_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFInput cname="项目名称" blockId="inqu_status" ename="projName" row="0" colWidth="3"/>
<EF:EFInput cname="采购合同号" blockId="inqu_status" ename="contractNo" row="0" colWidth="3"/>
<EF:EFInput cname="存货名称" blockId="inqu_status" ename="inventName" row="0" colWidth="3"/>
<EF:EFInput cname="规格" blockId="inqu_status" ename="spec" row="0" colWidth="3"/>
<EF:EFInput cname="数量" blockId="inqu_status" ename="receiveQty" row="0" colWidth="3"/>
<EF:EFInput cname="重量" blockId="inqu_status" ename="receiveWeight" row="0" colWidth="3"/>
<EF:EFInput cname="金额" blockId="inqu_status" ename="amount" row="0" colWidth="3"/>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" sort="all" checkMode="row">
<EF:EFColumn ename="id" cname="内码" hidden="true"/>
<EF:EFColumn ename="receiveDate" cname="收货日期" width="100" align="center" editType="date"
dateFormat="yyyy-MM-dd" parseFormats="['yyyyMMdd']"/>
<EF:EFColumn ename="receiveNo" cname="收货单号" enable="false" width="120" align="center"/>
<EF:EFComboColumn ename="supCode" cname="供应商名称" width="120" align="center" defaultValue=""
filter="contains">
<EF:EFOptions blockId="sup_record_block_id" valueField="valueField" textField="textField"/>
</EF:EFComboColumn>
<EF:EFColumn ename="projName" cname="项目名称" width="120" align="center" enable="false"/>
<EF:EFColumn ename="contractNo" cname="采购合同号" enable="false" width="120" align="center"/>
<EF:EFColumn ename="inventName" cname="存货名称" width="120" align="center" enable="false" readonly="true"/>
<EF:EFColumn ename="spec" cname="规格" width="120" align="center" enable="false"/>
<EF:EFColumn ename="receiveQty" cname="数量" width="120" align="right" format="{0:N0}" sumType="page"
required="true"/>
<EF:EFColumn ename="receiveWeight" cname="重量" width="120" align="right" format="{0:N3}" sumType="page"
required="true"/>
<EF:EFColumn ename="amount" cname="金额" width="120" align="right" format="{0:C3}" sumType="page"
required="true"/>
</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