Commit 69135b39 by 宋祥

1.物料数据库增加排产系数批量修改功能

parent 9b5b24db
package com.baosight.hggp.hg.pz.constant;
/**
* @author:songx
* @date:2024/9/3,14:43
*/
public class HgPzSqlConstant {
/**
* @author:songx
* @date:2024/9/3,14:43
*/
public class HgPz005A {
// 模块名称
public static final String MODULE = "HGPZ005A.";
// 修改排产系数
public static final String UPDATE_COMPOSING_COEFF = MODULE + "updateComposingCoeff";
}
}
package com.baosight.hggp.hg.pz.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.constant.CommonConstant;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.pz.constant.HgPzSqlConstant;
import com.baosight.hggp.hg.pz.domain.HGPZ004;
import com.baosight.hggp.hg.pz.domain.HGPZ005;
import com.baosight.hggp.hg.pz.domain.HGPZ005A;
import com.baosight.hggp.hg.pz.tools.HGPZTools;
import com.baosight.hggp.hg.sj.domain.HGSJ003;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.CommonMethod;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.ObjectUtils;
import com.baosight.hggp.util.StringUtils;
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.ServiceEPBase;
import org.apache.commons.collections.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:songx
* @date:2024/9/3,14:28
*/
public class ServiceHGPZ005D extends ServiceEPBase {
/**
* 初始化
*
* @param inInfo
* @return
*/
@Override
public EiInfo initLoad(EiInfo inInfo) {
try {
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.PROCESS_CODE_BLOCK_ID));
CommonMethod.initBlock(inInfo, Arrays.asList(DdynamicEnum.INVENT_TYPE_BLOCK_ID));
inInfo.addBlock(EiConstant.resultBlock).addBlockMeta(new HGPZ005().eiMetadata);
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
/**
* 查询
*
* @param inInfo
* @return
*/
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String processCode = MapUtils.getString(queryMap, HGPZ005A.FIELD_PROCESS_CODE);
if (ObjectUtils.isNullBlank(processCode)) {
return inInfo;
}
inInfo = super.query(inInfo, HGPZ005.QUERY, new HGPZ005());
// 填充排产系数
List<Map> results = inInfo.getBlock(EiConstant.resultBlock).getRows();
if (CollectionUtils.isEmpty(results)) {
return inInfo;
}
List<String> inventCodes = results.stream().map(item -> MapUtils.getString(item, HGPZ005.FIELD_INVENT_CODE))
.collect(Collectors.toList());
Map<String, HGPZ005A> dbPz005AMap = HGPZTools.HgPz005A.mapByCode(inventCodes, processCode);
for (Map resultMap : results) {
String inventCode = MapUtils.getString(resultMap, HGPZ005.FIELD_INVENT_CODE);
HGPZ005A dbPz005A = dbPz005AMap.get(inventCode);
resultMap.put(HGPZ005A.FIELD_COMPOSING_COEFF, dbPz005A == null ? 1 : dbPz005A.getComposingCoeff());
}
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
}
return inInfo;
}
/**
* 保存操作
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "工序设置", operType = "保存", operDesc = "保存操作")
public EiInfo save(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String processCode = MapUtils.getString(queryMap, HGPZ005A.FIELD_PROCESS_CODE);
AssertUtils.isEmpty(processCode, "请选择工序");
BigDecimal composingCoeff = MapUtils.getBigDecimal(queryMap, HGPZ005A.FIELD_COMPOSING_COEFF);
AssertUtils.isGe(BigDecimal.ZERO, composingCoeff, "排产系数必须大于0");
List<HGPZ005> fPz005s = MapUtils.toDaoEPBases(inInfo, HGPZ005.class);
List<String> inventCodes = ObjectUtils.listEpKey(fPz005s, HGPZ005A.FIELD_INVENT_CODE);
AssertUtils.isEmpty(inventCodes, "请选择材料");
// 写入数据
queryMap.put("inventCodes", inventCodes);
DaoUtils.update(HgPzSqlConstant.HgPz005A.UPDATE_COMPOSING_COEFF, queryMap);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + fPz005s.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
}
<?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"> <!-- table information
Generate time : 2024-05-07 16:07:42
Version : 1.0
schema : hggp
tableName : HGPZ005
ID BIGINT NOT NULL primarykey,
ACCOUNT_CODE VARCHAR,
DEP_CODE VARCHAR,
INVENT_TYPE TINYINT NOT NULL,
INVENT_CODE VARCHAR NOT NULL,
INVENT_NAME VARCHAR NOT NULL,
SPEC VARCHAR,
LENGTH DECIMAL,
WIDTH DECIMAL,
THICK DECIMAL,
MATERIAL VARCHAR,
COEFFICIENT DECIMAL,
UNIT VARCHAR,
STATUS TINYINT NOT NULL,
CREATED_BY VARCHAR,
CREATED_NAME VARCHAR,
CREATED_TIME VARCHAR,
UPDATED_BY VARCHAR,
UPDATED_NAME VARCHAR,
UPDATED_TIME VARCHAR,
DELETE_FLAG TINYINT
-->
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HGPZ005">
<typeAlias alias="HGPZ005" type="com.baosight.hggp.hg.pz.domain.HGPZ005"/>
<sql id="column">
ID as "id",
ACCOUNT_CODE as "accountCode", <!-- 帐套编码 -->
......@@ -153,12 +128,17 @@
<isEqual prepend=" AND " property="isFlowId" compareValue="0">
FLOW_ID = #isFlowId#
</isEqual>
<isNotEmpty prepend=" AND " property="processCode">
INVENT_CODE IN (SELECT INVENT_CODE FROM ${hggpSchema}.HGPZ005A WHERE PROCESS_CODE = #processCode#)
</isNotEmpty>
</sql>
<select id="query" parameterClass="java.util.HashMap" resultClass="HGPZ005">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGPZ005 WHERE 1=1 AND DELETE_FLAG = 0
FROM ${hggpSchema}.HGPZ005
WHERE 1=1
AND DELETE_FLAG = 0
<include refid="condition" />
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
......@@ -175,79 +155,6 @@
<include refid="condition" />
</select>
<!--<select id="get" resultClass="HGPZ005">
SELECT
<include refid="column"/>
FROM ${hggpSchema}.HGPZ005 WHERE 1=1
<include refid="condition"/>
</select>-->
<!--
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventType">
INVENT_TYPE = #inventType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventCode">
INVENT_CODE = #inventCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="inventName">
INVENT_NAME = #inventName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="spec">
SPEC = #spec#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="length">
LENGTH = #length#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="width">
WIDTH = #width#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="thick">
THICK = #thick#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="material">
MATERIAL = #material#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="coefficient">
COEFFICIENT = #coefficient#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unit">
UNIT = #unit#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="status">
STATUS = #status#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deleteFlag">
DELETE_FLAG = #deleteFlag#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO ${hggpSchema}.HGPZ005 (ID,
ACCOUNT_CODE, <!-- 帐套编码 -->
......@@ -463,6 +370,7 @@
<include refid="condition"/>
ORDER BY ID
</select>
<!-- 规格下拉框(无ID) -->
<select id="queryComboBoxSpecName" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT DISTINCT
......
<?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">
<!-- table information
Generate time : 2024-05-15 18:59:20
Version : 1.0
schema : hggp
tableName : HGPZ005A
ID BIGINT NOT NULL primarykey,
ACCOUNT_CODE VARCHAR,
DEP_CODE VARCHAR,
CREATED_BY VARCHAR,
CREATED_NAME VARCHAR,
CREATED_TIME VARCHAR,
UPDATED_BY VARCHAR,
UPDATED_NAME VARCHAR,
UPDATED_TIME VARCHAR,
DELETE_FLAG TINYINT,
PROCESS_CODE VARCHAR NOT NULL,
PROCESS_NAME VARCHAR NOT NULL,
COMPOSING_COEFF VARCHAR,
UNIT_COEFF VARCHAR,
PARENT_ID BIGINT
-->
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="HGPZ005A">
<sql id="condition">
......@@ -90,8 +69,7 @@
</isNotEmpty>
</sql>
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hggp.hg.pz.domain.HGPZ005A">
<select id="query" resultClass="com.baosight.hggp.hg.pz.domain.HGPZ005A">
SELECT
ID as "id",
ACCOUNT_CODE as "accountCode", <!-- 帐套编码 -->
......@@ -132,57 +110,6 @@
<include refid="condition" />
</select>
<!--
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deleteFlag">
DELETE_FLAG = #deleteFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processCode">
PROCESS_CODE = #processCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processName">
PROCESS_NAME = #processName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="composingCoeff">
COMPOSING_COEFF = #composingCoeff#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="unitCoeff">
UNIT_COEFF = #unitCoeff#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="processClass">
PROCESS_CLASS = #processClass#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="parentId">
PARENT_ID = #parentId#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO ${hggpSchema}.HGPZ005A (ID,
ACCOUNT_CODE, <!-- 帐套编码 -->
......@@ -259,4 +186,15 @@
</isNotEmpty>
</select>
<!-- 修改排产系数 -->
<update id="updateComposingCoeff">
UPDATE ${hggpSchema}.HGPZ005A
SET
COMPOSING_COEFF = #composingCoeff#,
<include refid="SqlBase.updateRevise"/>
WHERE DELETE_FLAG = 0
AND PROCESS_CODE = #processCode#
AND INVENT_CODE IN <iterate close=")" open="(" conjunction="," property="inventCodes">#inventCodes[]#</iterate>
</update>
</sqlMap>
......@@ -699,12 +699,16 @@ public class HGPZTools {
pz005.setStatus(1); //默认启用
jointSpec(pz005);
DaoUtils.insert(HGPZ005.INSERT,pz005);
DaoUtils.insert(HGPZ005.INSERT, pz005);
return pz005;
}
}
/**
* @author:songx
* @date:2024/9/3,16:35
*/
public static class HgPz005A {
/**
......@@ -748,6 +752,33 @@ public class HGPZTools {
List<HGPZ005A> results = DaoBase.getInstance().query(HGPZ005A.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results;
}
/**
* @param inventCodes
* @param processCode
* @return
*/
public static List<HGPZ005A> listByCode(List<String> inventCodes, String processCode) {
AssertUtils.isEmpty(inventCodes, "存货编码不能为空");
AssertUtils.isEmpty(processCode, "工序编码不能为空");
Map queryMap = new HashMap();
queryMap.put("inventCodes", inventCodes);
queryMap.put("processCode", processCode);
return DaoBase.getInstance().query(HGPZ005A.QUERY, queryMap);
}
/**
* @param inventCodes
* @param processCode
* @return
*/
public static Map<String, HGPZ005A> mapByCode(List<String> inventCodes, String processCode) {
List<HGPZ005A> results = listByCode(inventCodes, processCode);
if (CollectionUtils.isEmpty(results)) {
return null;
}
return results.stream().collect(Collectors.toMap(HGPZ005A::getInventCode, item -> item));
}
}
/**
......
......@@ -49,6 +49,7 @@
</sql>
<sql id="condition">
AND DELETE_FLAG = 0
<include refid="authCondition"/>
<isNotEmpty prepend=" AND " property="id">
ID = #id#
......@@ -307,7 +308,8 @@
STATUS as "status",
DELETE_FLAG as "deleteFlag",
COST_WEIGHT as "costWeight"
FROM ${hggpSchema}.HGGY001 WHERE 1=1
FROM ${hggpSchema}.HGGY001
WHERE 1=1
<include refid="condition" />
group by PROCESS_CODE, PROCESS_NAME, FACTORY_CODE, FACTORY_NAME, UNIT, STATUS, DELETE_FLAG, COST_WEIGHT
</select>
......
......@@ -183,7 +183,7 @@ public class AssertUtils {
* @param message
*/
public static void isGt(BigDecimal a, BigDecimal b, String message) {
if (a.compareTo(b) == 1) {
if (a == null || b == null || a.compareTo(b) == 1) {
throw new PlatException(message);
}
}
......@@ -195,7 +195,7 @@ public class AssertUtils {
* @param b
*/
public static void isGe(BigDecimal a, BigDecimal b, String message) {
if (a.compareTo(b) > -1) {
if (a == null || b == null || a.compareTo(b) > -1) {
throw new PlatException(message);
}
}
......
......@@ -9,6 +9,9 @@ $(function() {
batchFlow();
});
// 排产系数
$("#BATCH_COE").on("click", batchCoe);
IPLATUI.EFGrid.result = {
pageable: {
pageSize: 20,
......@@ -274,6 +277,22 @@ let deleteFunc = function () {
});
}
/**
* 排产系数
*
* @param id
* @param inventCode
* @param flowId
*/
function batchCoe() {
JSColorbox.open({
href: "HGPZ005D",
title: "<div style='text-align: center;'>排产系数</div>",
width: "80%",
height: "90%"
});
}
function showDetail(id) {
JSColorbox.open({
href: "HGPZ005A?methodName=initLoad&inqu_status-0-parentId=" + id,
......
$(function () {
IPLATUI.EFSelect = {
"inqu_status-0-processCode": {
change: function (e) {
query();
}
}
}
IPLATUI.EFGrid = {
"result": {
exportGrid: false, // 隐藏右侧自定义导出按钮
pageable: {
pageSize: 10,
pageSizes: [10, 20, 50, 100],
},
columns: [],
loadComplete: function (grid) {
},
}
}
// 查询
$("#QUERY").on("click", query);
// 保存
$("#SAVE").on("click", save);
// 按键
downKeyUp();
})
/**
* 页面加载时执行
*/
$(window).load(function () {
// 查询
let processCode = $("#inqu_status-0-processCode").val();
if (!isBlank(processCode)) {
query();
}
});
/**
* 查询
*/
let query = function () {
let processCode = $("#inqu_status-0-processCode").val();
if (isBlank(processCode)) {
message("请选择工序");
return;
}
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function () {
let processCode = $("#inqu_status-0-processCode").val();
if (isBlank(processCode)) {
message("请选择工序");
return;
}
let composingCoeff = $("#inqu_status-0-composingCoeff").val();
if (isBlank(composingCoeff)) {
message("请填写排产系数");
return;
}
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGPZ005D", "save",
false, function (res) {
message(res.msg);
}
);
}
});
}
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ 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:EFSelect cname="存货类型" ename="inventType" blockId="inqu_status" row="0" colWidth="3" filter="contains">
<EF:EFOption label="全部" value=""/>
<EF:EFOptions blockId="invent_type_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFInput cname="存货编码" ename="inventCodeLike" blockId="inqu_status" row="0" colWidth="3"/>
<EF:EFInput cname="存货名称" ename="inventName" blockId="inqu_status" row="0" colWidth="3"/>
<EF:EFInput cname="规格" ename="spec" blockId="inqu_status" row="0" colWidth="3"/>
</div>
</EF:EFRegion>
<EF:EFRegion id="detail" title="编辑区域">
<div class="row">
<EF:EFSelect cname="工序" ename="processCode" blockId="inqu_status" row="0" colWidth="6" ratio="2:10"
filter="contains" required="true">
<EF:EFOptions blockId="processCode_block_id" textField="textField" valueField="valueField"/>
</EF:EFSelect>
<EF:EFInput cname="排产系数" ename="composingCoeff" blockId="inqu_status" row="0" colWidth="6" ratio="2:10"
required="true"/>
</div>
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息" fitHeight="true">
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" height="60vh">
<EF:EFColumn cname="排产系数" ename="composingCoeff" enable="false" width="100" align="center"/>
<EF:EFColumn cname="存货编码" ename="inventCode" enable="false" width="140" align="center"/>
<EF:EFComboColumn ename="inventType" cname="存货类型" enable="false" width="120" align="center"
blockName="invent_type_block_id" textField="textField" valueField="valueField"
columnTemplate="#=textField#" itemTemplate="#=textField#">
</EF:EFComboColumn>
<EF:EFColumn ename="inventName" cname="存货名称" enable="false" width="120" align="center"/>
<EF:EFColumn ename="spec" cname="规格" enable="false" width="140" align="center"/>
<EF:EFColumn ename="length" cname="长(MM)" enable="false" width="100" align="right" format="{0:N2}"/>
<EF:EFColumn ename="width" cname="宽(MM)" enable="false" width="100" align="right" format="{0:N2}"/>
<EF:EFColumn ename="thick" cname="厚(MM)" enable="false" width="100" align="right" format="{0:N2}"/>
<EF:EFColumn ename="material" cname="材质" enable="false" width="100" align="center"/>
<EF:EFColumn ename="coefficient" cname="系数" enable="false" width="80" align="right" format="{0:N2}"
defaultValue="1"/>
<EF:EFColumn ename="unit" cname="单位" enable="false" width="80" align="center"/>
</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