From 691ae79503012cad04c9dd1d87597f9d70811227 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Mon, 3 Nov 2025 19:07:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A6=86=E7=9B=96=E5=8E=9F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../part/mapper/PartInformationMapper.java | 2 ++ .../impl/PartInformationServiceImpl.java | 18 ++++++++++++++++++ .../mapper/part/PartInformationMapper.xml | 13 +++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/main/java/com/xujie/sys/modules/part/mapper/PartInformationMapper.java b/src/main/java/com/xujie/sys/modules/part/mapper/PartInformationMapper.java index 7fa91106..703d84ef 100644 --- a/src/main/java/com/xujie/sys/modules/part/mapper/PartInformationMapper.java +++ b/src/main/java/com/xujie/sys/modules/part/mapper/PartInformationMapper.java @@ -85,6 +85,8 @@ public interface PartInformationMapper extends BaseMapper void addPartItem(PartSubPropertiesValueData itemDate); + void updatePartItemValue(PartSubPropertiesValueData itemDate); + void deletePartItem(PartSubPropertiesValueData itemDate); List queryCodeNo(PartInformationEntity data); diff --git a/src/main/java/com/xujie/sys/modules/part/service/impl/PartInformationServiceImpl.java b/src/main/java/com/xujie/sys/modules/part/service/impl/PartInformationServiceImpl.java index 055ff378..d203f758 100644 --- a/src/main/java/com/xujie/sys/modules/part/service/impl/PartInformationServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/part/service/impl/PartInformationServiceImpl.java @@ -941,10 +941,28 @@ public class PartInformationServiceImpl extends ServiceImpl checkDetail = partInformationMapper.checkPartItem(itemDate); if (!checkDetail.isEmpty()) { + // 参数已存在,检查是否需要更新值 + PartSubPropertiesValueData existingItem = checkDetail.get(0); + boolean needUpdate = itemDate.getTextValue() != null && !itemDate.getTextValue().isEmpty(); + + // 如果新值不为空,则需要更新 + if (itemDate.getNumValue() != null) { + needUpdate = true; + } + + if (needUpdate) { + // 更新现有参数的值 + itemDate.setItemNo(existingItem.getItemNo()); + partInformationMapper.updatePartItemValue(itemDate); + } continue; } + + // 参数不存在,新增 List checkItem = partInformationMapper.checkItem(itemDate); if (checkItem.isEmpty()) { throw new RuntimeException("该项目编码不存在!"); diff --git a/src/main/resources/mapper/part/PartInformationMapper.xml b/src/main/resources/mapper/part/PartInformationMapper.xml index b70f9fc2..17c8fd9f 100644 --- a/src/main/resources/mapper/part/PartInformationMapper.xml +++ b/src/main/resources/mapper/part/PartInformationMapper.xml @@ -591,6 +591,19 @@ values (#{partNo}, #{site}, #{buNo}, #{codeNo}, #{subCodeSeqNo,jdbcType=FLOAT}, #{codeDesc}, #{itemNo, jdbcType=FLOAT}, #{itNo}, #{textValue}, #{numValue, jdbcType=FLOAT}, #{recordType}) + + UPDATE part_sub_properties_value + SET text_value = #{textValue}, + num_value = #{numValue, jdbcType=FLOAT} + WHERE part_no = #{partNo} + AND site = #{site} + AND bu_no = #{buNo} + AND record_type = #{recordType} + AND code_no = #{codeNo} + AND sub_code_seq_no = #{subCodeSeqNo} + AND item_no = #{itemNo} + + delete from part_sub_properties_value where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType} and code_no = #{codeNo} and sub_code_seq_no = #{subCodeSeqNo} and item_no = #{itemNo}