From 9142bdf0e1862e64f5254b696d0c702e0c3a86eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=99=93=E8=BF=AA?= <2596750866@qq.com> Date: Tue, 31 Dec 2024 13:42:44 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E5=B7=A5=E7=A8=8B=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?bom=E4=BF=A1=E6=81=AF=20=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0bom?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=89=A9=E6=96=99=E5=AD=90=E8=A1=A8=E6=8D=9F?= =?UTF-8?q?=E8=80=97=E7=8E=87=E8=A1=A8=E6=A0=BC=E5=86=85=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E6=96=B9=E6=B3=95=EF=BC=8C=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E7=99=BE=E5=88=86=E5=8F=B7=E5=88=9D=E5=A7=8B=E5=8C=96=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=EF=BC=9B=20=E4=BF=AE=E6=94=B9bom=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=AD=90=E8=A1=A8=E8=A1=A8=E6=A0=BC=E6=8D=9F?= =?UTF-8?q?=E8=80=97=E7=8E=87=E7=99=BE=E5=88=86=E5=8F=B7=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=B3=95=EF=BC=9B=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=BC=96=E8=BE=91bom=E9=A1=B5=E9=9D=A2=E6=8D=9F=E8=80=97?= =?UTF-8?q?=E7=8E=87=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8F=8A=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=9B=20=E4=BF=AE=E6=94=B9bom=E6=8D=9F?= =?UTF-8?q?=E8=80=97=E7=8E=87=E5=AD=97=E6=AE=B5=E4=B8=BAdouble=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=EF=BC=9B=20=E4=BF=AE=E6=94=B9bom=E5=AF=BC=E5=85=A5ser?= =?UTF-8?q?vice=E6=96=B9=E6=B3=95=EF=BC=8C=E8=AE=BE=E7=BD=AE=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=9E=8B=E5=8F=B7=EF=BC=8C=E5=AF=BC=E5=85=A5=E6=8D=9F?= =?UTF-8?q?=E8=80=97=E7=8E=87=E4=B8=BA=E7=A9=BA=E6=97=B6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA0=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E4=B8=BB=E7=AE=A1=E3=80=81=E5=B7=A5=E7=A8=8B=E7=BB=8F=E7=90=86?= =?UTF-8?q?=E3=80=81=E7=A0=94=E5=8F=91=E6=80=BB=E7=9B=91=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8D=9F=E8=80=97=E7=8E=87=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/erp/domain/ErpBom.java | 14 +++--- .../erp/service/impl/ErpBomServiceImpl.java | 9 +++- .../main/resources/templates/erp/bom/add.html | 38 ++++++--------- .../main/resources/templates/erp/bom/bom.html | 43 ++++++++--------- .../resources/templates/erp/bom/edit.html | 48 +++++++------------ .../templates/erp/bom/taskGcjlVerify.html | 16 +++---- .../templates/erp/bom/taskGczgVerify.html | 16 +++---- .../templates/erp/bom/taskYfzjVerify.html | 16 +++---- 8 files changed, 82 insertions(+), 118 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpBom.java b/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpBom.java index 258526ae..b5162cd1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpBom.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpBom.java @@ -76,7 +76,7 @@ public class ErpBom extends BaseEntity private Integer useNum; /** 损耗率 */ - private String lossRate; + private Double lossRate; /** 父级id */ private Long parentId; @@ -294,16 +294,16 @@ public class ErpBom extends BaseEntity { return useNum; } - public void setLossRate(String lossRate) + public void setLossRate(Double lossRate) { - String[] lossRateArr = lossRate.split("\\%"); - if(lossRateArr.length>0){ - this.lossRate = lossRateArr[0]; - } +// String[] lossRateArr = lossRate.split("\\%"); +// if(lossRateArr.length>0){ +// this.lossRate = lossRateArr[0]; +// } this.lossRate = lossRate; } - public String getLossRate() + public Double getLossRate() { return lossRate; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java index ba94d8d5..797ba421 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java @@ -619,6 +619,7 @@ private ISysAttachService attachService; * @param updateSupport 是否更新支持,如果已存在,则进行更新数据 * @return 结果 */ + @Transactional(rollbackFor = Exception.class) @Override public String importData(List bomImportVos, boolean updateSupport) { @@ -671,7 +672,7 @@ private ISysAttachService attachService; ErpBomImportVo bomImportVo = bomImportVos.get(i); String materialNo = bomImportVo.getMaterialNo(); Integer useNum = bomImportVo.getUseNum(); - Double lossRate = bomImportVo.getLossRate(); + Double lossRate = Optional.ofNullable(bomImportVo.getLossRate()).orElse(0.00); String remark = bomImportVo.getRemark(); ErpMaterialVo erpMaterialVo = materialMapper.selectErpMaterialByMaterialNo(materialNo); try @@ -725,6 +726,7 @@ private ISysAttachService attachService; fatherBom.setMaterialName(erpMaterialVo.getMaterialName()); fatherBom.setMaterialType(erpMaterialVo.getMaterialType()); fatherBom.setProcessMethod(erpMaterialVo.getProcessMethod()); + fatherBom.setMaterialModel(erpMaterialVo.getMaterialModel()); fatherBom.setFileCode(erpMaterialVo.getFileCode()); fatherBom.setUnit(erpMaterialVo.getUnit()); fatherBom.setBrand(erpMaterialVo.getBrand()); @@ -750,6 +752,7 @@ private ISysAttachService attachService; subBom.setMaterialNo(materialNo); subBom.setMaterialName(erpMaterialVo.getMaterialName()); subBom.setMaterialType(erpMaterialVo.getMaterialType()); + subBom.setMaterialModel(erpMaterialVo.getMaterialModel()); subBom.setProcessMethod(erpMaterialVo.getProcessMethod()); subBom.setUnit(erpMaterialVo.getUnit()); subBom.setBrand(erpMaterialVo.getBrand()); @@ -757,7 +760,7 @@ private ISysAttachService attachService; subBom.setWarehouseDept(erpMaterialVo.getWarehouseDept()); subBom.setFileCode(erpMaterialVo.getFileCode()); subBom.setUseNum(useNum); - subBom.setLossRate(String.valueOf(lossRate)); + subBom.setLossRate(lossRate); subBom.setParentId(parentId); subBom.setLevel(1L); subBom.setSortNo(i+0L); @@ -804,6 +807,8 @@ private ISysAttachService attachService; erpBom1.setParentId(id); erpBom1.setCreateBy(ShiroUtils.getLoginName()); erpBom1.setCreateTime(DateUtils.getNowDate()); + Double lossRate = Optional.ofNullable(erpBom1.getLossRate()).orElse(0.00); + erpBom1.setLossRate(lossRate); // 新添加,理论上,刚添加的一阶物料默认审核通过,使用状态为是 // erpBom1.setAuditStatus("1"); // erpBom1.setUseStatus("1"); diff --git a/ruoyi-admin/src/main/resources/templates/erp/bom/add.html b/ruoyi-admin/src/main/resources/templates/erp/bom/add.html index 44d8bc24..6f33046c 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/bom/add.html +++ b/ruoyi-admin/src/main/resources/templates/erp/bom/add.html @@ -323,7 +323,6 @@ type : 'text', //默认text title : '用量', - mode:'inline', validate : function(value) { if (!value) { return '用量不能为空'; @@ -345,38 +344,30 @@ editor: { defaultValue: '%', title: '损耗率(%)', - mode: 'inline', type: 'text', - // 编辑时同样附带百分比符号 - formatter: function (value) { - return value + '%'; - }, - // 编辑后去除百分比符号 - custom_getter: function (value) { - return value.replace('%', ''); - } }, validate : function (value) { if (!value) { return '损耗率不能为空'; } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (!match) { - return '损耗率必须以百分比结尾'; - } - var num = value.replace('%', ''); - if (num < 0 || num > 100) { + if (isNaN(value)) return '损耗率必须是数字'; + // const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 + // const match = value.match(regex); // 使用match方法查找所有匹配 + // if (!match) { + // return '损耗率必须以百分比结尾'; + // } + // var num = value.replace('%', ''); + if (value < 0 || value > 100) { return '损耗率必须大于等于0小于等于100'; } } }, - formatter: function (value,row,index){ - if(value == null || value == ""){ - return "0%"; - } - return value + "%"; - }, + // formatter: function (value,row,index){ + // if(value == null || value == ""){ + // return "0%"; + // } + // return value + "%"; + // }, }, { field: 'processMethod', @@ -407,7 +398,6 @@ editable : { type : 'text', title : '备注', - mode:'inline', validate : function(value) { if (!value) { return '备注不能为空'; diff --git a/ruoyi-admin/src/main/resources/templates/erp/bom/bom.html b/ruoyi-admin/src/main/resources/templates/erp/bom/bom.html index 9ec802fc..34b7aa61 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/bom/bom.html +++ b/ruoyi-admin/src/main/resources/templates/erp/bom/bom.html @@ -387,15 +387,10 @@ title: '损耗率', formatter: function (value,row,index){ if (value == null || value == ''){ - return "%"; - } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (match) { - return value; - }else{ - return value + "%"; + return "0.00%"; } + value = parseFloat(value).toFixed(2); + return value + "%"; } }, { @@ -533,16 +528,21 @@ field: 'lossRate', title: '损耗率', formatter: function (value,row,index){ + // if (value == null || value == ''){ + // return "0%"; + // } + // const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 + // const match = value.match(regex); // 使用match方法查找所有匹配 + // if (match) { + // return value; + // }else{ + // return value + "%"; + // } if (value == null || value == ''){ - return "0%"; - } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (match) { - return value; - }else{ - return value + "%"; + return "0.00%"; } + value = parseFloat(value).toFixed(2); + return value + "%"; } }, { @@ -696,15 +696,10 @@ title: '损耗率', formatter: function (value,row,index){ if (value == null || value == ''){ - return "0%"; - } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (match) { - return value; - }else{ - return value + "%"; + return "0.00%"; } + value = parseFloat(value).toFixed(2); + return value + "%"; } }, { diff --git a/ruoyi-admin/src/main/resources/templates/erp/bom/edit.html b/ruoyi-admin/src/main/resources/templates/erp/bom/edit.html index 454646f0..db57df33 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/bom/edit.html +++ b/ruoyi-admin/src/main/resources/templates/erp/bom/edit.html @@ -240,7 +240,6 @@ editable : { type : 'text', title : '用量', - mode:'inline', validate : function(value) { if (!value) { return '用量不能为空'; @@ -261,45 +260,32 @@ editable : { editor: { defaultValue: '%', - title : '损耗率(%)', - mode:'inline', + title: '损耗率(%)', type: 'text', - // 编辑时同样附带百分比符号 - formatter: function(value) { - return value + '%'; - }, - // 编辑后去除百分比符号 - custom_getter: function(value) { - return value.replace('%', ''); - } }, - validate : function(value) { + validate : function (value) { if (!value) { return '损耗率不能为空'; } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (!match) { - return '损耗率必须以百分比结尾'; - } - var num = value.replace('%', ''); - if (num < 0 || num > 100) { + if (isNaN(value)) return '损耗率必须是数字'; + // const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 + // const match = value.match(regex); // 使用match方法查找所有匹配 + // if (!match) { + // return '损耗率必须以百分比结尾'; + // } + // var num = value.replace('%', ''); + if (value < 0 || value > 100) { return '损耗率必须大于等于0小于等于100'; } - }, - }, - formatter: function (value,row,index){ - if (value == null || value == ''){ - return "%"; - } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (match) { - return value; - }else{ - return value + "%"; } }, + // formatter: function (value,row,index){ + // if (value == null || value == ''){ + // return "0.00%"; + // } + // value = parseFloat(value).toFixed(2); + // return value + "%"; + // }, }, { field: 'processMethod', diff --git a/ruoyi-admin/src/main/resources/templates/erp/bom/taskGcjlVerify.html b/ruoyi-admin/src/main/resources/templates/erp/bom/taskGcjlVerify.html index c4848c68..c5705fcc 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/bom/taskGcjlVerify.html +++ b/ruoyi-admin/src/main/resources/templates/erp/bom/taskGcjlVerify.html @@ -281,7 +281,8 @@ }, columns: [{ field: 'id', - title: '主键id' + title: '主键id', + visible: false, }, { field: 'level', @@ -386,16 +387,11 @@ field: 'lossRate', title: '损耗率', formatter: function (value, row, index) { - if (value == null || value == '') { - return "%"; - } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (match) { - return value; - } else { - return value + "%"; + if (value == null || value == ''){ + return "0.00%"; } + value = parseFloat(value).toFixed(2); + return value + "%"; } }, { diff --git a/ruoyi-admin/src/main/resources/templates/erp/bom/taskGczgVerify.html b/ruoyi-admin/src/main/resources/templates/erp/bom/taskGczgVerify.html index 0143ffb3..9870e271 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/bom/taskGczgVerify.html +++ b/ruoyi-admin/src/main/resources/templates/erp/bom/taskGczgVerify.html @@ -281,7 +281,8 @@ }, columns: [{ field: 'id', - title: '主键id' + title: '主键id', + visible: false, }, { field: 'level', @@ -386,16 +387,11 @@ field: 'lossRate', title: '损耗率', formatter: function (value, row, index) { - if (value == null || value == '') { - return "%"; - } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (match) { - return value; - } else { - return value + "%"; + if (value == null || value == ''){ + return "0.00%"; } + value = parseFloat(value).toFixed(2); + return value + "%"; } }, { diff --git a/ruoyi-admin/src/main/resources/templates/erp/bom/taskYfzjVerify.html b/ruoyi-admin/src/main/resources/templates/erp/bom/taskYfzjVerify.html index d0033035..2ceb09a8 100644 --- a/ruoyi-admin/src/main/resources/templates/erp/bom/taskYfzjVerify.html +++ b/ruoyi-admin/src/main/resources/templates/erp/bom/taskYfzjVerify.html @@ -280,7 +280,8 @@ }, columns: [{ field: 'id', - title: '主键id' + title: '主键id', + visible: false, }, { field: 'level', @@ -385,16 +386,11 @@ field: 'lossRate', title: '损耗率', formatter: function (value, row, index) { - if (value == null || value == '') { - return "%"; - } - const regex = /(\d+(?:\.\d+)?)%/g; // 创建正则表达式,g标志表示全局匹配 - const match = value.match(regex); // 使用match方法查找所有匹配 - if (match) { - return value; - } else { - return value + "%"; + if (value == null || value == ''){ + return "0.00%"; } + value = parseFloat(value).toFixed(2); + return value + "%"; } }, {