2024-6-1 设备-备品备件-增删改查换表

master
A0010407 1 year ago
parent dfa5730cb3
commit 9ca999e0e1

@ -83,4 +83,6 @@ public interface SparePartsLedgerMapper {
* @param apply
*/
void updateSpareNumAdd(EquSpareApply apply);
void updateAmount(SparePartsLedger sparePartsLedger);
}

@ -146,7 +146,7 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService {
BigDecimal applyNum = equSpareApply.getSpareQuantity();
BigDecimal amount = equSpareApply.getAmount();
sparePartsLedger.setAmount(amount.subtract(applyNum));
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
sparePartsLedgerMapper.updateAmount(sparePartsLedger);
}
return success("新增申领记录成功!");
}

@ -3,6 +3,9 @@ package com.op.device.service.impl;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.device.mapper.SparePartsLedgerMapper;
@ -41,7 +44,6 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService {
@Override
@DS("#header.poolName")
public List<SparePartsLedger> selectSparePartsLedgerList(SparePartsLedger sparePartsLedger) {
sparePartsLedger.setStorageType("SP");
return sparePartsLedgerMapper.selectSparePartsLedgerList(sparePartsLedger);
}
@ -54,6 +56,9 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService {
@Override
@DS("#header.poolName")
public int insertSparePartsLedger(SparePartsLedger sparePartsLedger) {
sparePartsLedger.setStorageId(IdUtils.fastSimpleUUID());
sparePartsLedger.setGmtCreate(DateUtils.getNowDate());//创建时间
sparePartsLedger.setCreateBy(SecurityUtils.getUsername());
return sparePartsLedgerMapper.insertSparePartsLedger(sparePartsLedger);
}
@ -66,6 +71,8 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService {
@Override
@DS("#header.poolName")
public int updateSparePartsLedger(SparePartsLedger sparePartsLedger) {
sparePartsLedger.setLastModifiedBy(SecurityUtils.getUsername());//最后更新人
sparePartsLedger.setGmtModified(DateUtils.getNowDate());//最后更新时间
return sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}

@ -9,9 +9,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="storageType" column="storage_type" />
<result property="materialCode" column="material_code" />
<result property="materialDesc" column="material_desc" />
<result property="userDefined1" column="user_defined1" />
<result property="amount" column="amount" />
<result property="storageAmount" column="storage_amount" />
<result property="storageType" column="storage_type" />
<result property="spareUseLife" column="spare_use_life" />
<result property="spareName" column="spare_name" />
<result property="spareMode" column="spare_mode" />
@ -32,10 +32,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="factoryCode" column="factory_code" />
<result property="sapFactoryCode" column="sap_factory_code" />
<result property="delFlag" column="del_flag" />
<!--附属表-->
<result property="id" column="id" />
<result property="primaryCode" column="primary_code" />
<result property="ownEquipmentName" column="own_equipment_name" />
<result property="unitQuantity" column="unit_quantity" />
<result property="safeStock" column="safe_stock" />
@ -47,24 +43,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="inputRecords" column="input_records" />
<result property="endInventory" column="end_inventory" />
<result property="endMoney" column="end_money" />
<result property="createBy" column="create_by" />
<result property="factoryCode" column="factory_code" />
<result property="substituteParts" column="substitute_parts" />
<result property="ownEquipmentCode" column="own_equipment_code" />
</resultMap>
<sql id="selectSparePartsLedgerVo">
select
select
storage_id,
storage_type,
material_code,
material_desc,
amount,
storage_amount,
sap_factory_code,
wl_name,
del_flag,
user_defined1,
spare_use_life,
spare_name,
spare_mode,
@ -82,103 +73,74 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
last_modified_by,
gmt_modified,
active_flag,
factory_code
from wms_ods_mate_storage_news
factory_code,
sap_factory_code,
del_flag,
own_equipment_name,
unit_quantity,
safe_stock,
unit_price,
procurement_method,
procurement_cycle,
opening_balance,
output_records,
input_records,
end_inventory,
end_money,
substitute_parts,
own_equipment_code
from equ_spareparts_ledger
</sql>
<select id="selectSparePartsLedgerList" parameterType="SparePartsLedger" resultMap="SparePartsLedgerResult">
select
womsn.storage_id,
womsn.storage_type,
womsn.material_code,
womsn.material_desc,
womsn.amount,
womsn.storage_amount,
womsn.sap_factory_code,
womsn.wl_name,
womsn.del_flag,
womsn.spare_use_life,
womsn.spare_name,
womsn.spare_mode,
womsn.spare_manufacturer,
womsn.spare_supplier,
womsn.spare_replacement_cycle,
womsn.spare_measurement_unit,
womsn.spare_conversion_unit,
womsn.spare_conversion_ratio,
womsn.spare_inventory_floor,
womsn.spare_inventory_upper,
womsn.spare_type,
womsn.create_by,
womsn.gmt_create,
womsn.last_modified_by,
womsn.gmt_modified,
womsn.active_flag,
womsn.factory_code,
womsna.id,
womsna.primary_code,
womsna.own_equipment_name,
womsna.unit_quantity,
womsna.safe_stock,
womsna.unit_price,
womsna.procurement_method,
womsna.procurement_cycle,
womsna.opening_balance,
womsna.output_records,
womsna.input_records,
womsna.end_inventory,
womsna.end_money,
womsna.substitute_parts,
womsna.own_equipment_code
from wms_ods_mate_storage_news womsn
left join wms_ods_mate_storage_news_attached womsna on womsn.material_code = womsna.primary_code
<include refid="selectSparePartsLedgerVo"/>
<where>
<if test="storageId != null and storageId != ''"> and womsn.storage_id = #{storageId}</if>
<if test="whCode != null and whCode != ''"> and womsn.wh_code = #{whCode}</if>
<if test="regionCode != null and regionCode != ''"> and womsn.region_code = #{regionCode}</if>
<if test="waCode != null and waCode != ''"> and womsn.wa_code = #{waCode}</if>
<if test="storageType != null and storageType != ''"> and womsn.storage_type = #{storageType}</if>
<if test="wlCode != null and wlCode != ''"> and womsn.wl_code = #{wlCode}</if>
<if test="materialCode != null and materialCode != ''"> and womsn.material_code like concat('%', #{materialCode}, '%')</if>
<if test="materialDesc != null and materialDesc != ''"> and womsn.material_desc like concat('%', #{materialDesc}, '%')</if>
<if test="amount != null "> and womsn.amount = #{amount}</if>
<if test="storageAmount != null "> and womsn.storage_amount = #{storageAmount}</if>
<if test="occupyAmount != null "> and womsn.occupy_amount = #{occupyAmount}</if>
<if test="lpn != null and lpn != ''"> and womsn.lpn = #{lpn}</if>
<if test="productBatch != null and productBatch != ''"> and womsn.product_batch = #{productBatch}</if>
<if test="receiveDate != null "> and womsn.receive_date = #{receiveDate}</if>
<if test="productDate != null "> and womsn.product_date = #{productDate}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and womsn.user_defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and womsn.user_defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and womsn.user_defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''"> and womsn.user_defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and womsn.user_defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and womsn.user_defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and womsn.user_defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and womsn.user_defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and womsn.user_defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and womsn.user_defined10 = #{userDefined10}</if>
<if test="gmtCreate != null "> and womsn.gmt_create = #{gmtCreate}</if>
<if test="lastModifiedBy != null and lastModifiedBy != ''"> and womsn.last_modified_by = #{lastModifiedBy}</if>
<if test="gmtModified != null "> and womsn.gmt_modified = #{gmtModified}</if>
<if test="activeFlag != null and activeFlag != ''"> and womsn.active_flag = #{activeFlag}</if>
<if test="factoryCode != null and factoryCode != ''"> and womsn.factory_code = #{factoryCode}</if>
<if test="sapFactoryCode != null and sapFactoryCode != ''"> and womsn.sap_factory_code = #{sapFactoryCode}</if>
<if test="wlName != null and wlName != ''"> and womsn.wl_name like concat('%', #{wlName}, '%')</if>
<if test="spareUseLife != null and spareUseLife != ''"> and womsn.spare_use_life = #{spareUseLife}</if>
<if test="spareName != null and spareName != ''"> and womsn.spare_name like concat('%', #{spareName}, '%')</if>
<if test="spareMode != null and spareMode != ''"> and womsn.spare_mode like concat('%', #{spareMode}, '%')</if>
<if test="spareManufacturer != null and spareManufacturer != ''"> and womsn.spare_manufacturer = #{spareManufacturer}</if>
<if test="spareSupplier != null and spareSupplier != ''"> and womsn.spare_supplier like concat('%', #{spareSupplier}, '%')</if>
<if test="spareReplacementCycle != null and spareReplacementCycle != ''"> and womsn.spare_replacement_cycle = #{spareReplacementCycle}</if>
<if test="spareMeasurementUnit != null and spareMeasurementUnit != ''"> and womsn.spare_measurement_unit = #{spareMeasurementUnit}</if>
<if test="spareConversionUnit != null and spareConversionUnit != ''"> and womsn.spare_conversion_unit = #{spareConversionUnit}</if>
<if test="spareConversionRatio != null and spareConversionRatio != ''"> and womsn.spare_conversion_ratio = #{spareConversionRatio}</if>
<if test="spareInventoryFloor != null and spareInventoryFloor != ''"> and womsn.spare_inventory_floor = #{spareInventoryFloor}</if>
<if test="spareInventoryUpper != null and spareInventoryUpper != ''"> and womsn.spare_inventory_upper = #{spareInventoryUpper}</if>
<if test="spareType != null and spareType != ''"> and womsn.spare_type = #{spareType}</if>
<if test="ownEquipmentName != null and ownEquipmentName != ''"> and womsna.own_equipment_name like concat('%', #{ownEquipmentName}, '%')</if>
and womsn.del_flag = '0'
<if test="storageId != null and storageId != ''"> and storage_id = #{storageId}</if>
<if test="whCode != null and whCode != ''"> and wh_code = #{whCode}</if>
<if test="regionCode != null and regionCode != ''"> and region_code = #{regionCode}</if>
<if test="waCode != null and waCode != ''"> and wa_code = #{waCode}</if>
<if test="storageType != null and storageType != ''"> and storage_type = #{storageType}</if>
<if test="wlCode != null and wlCode != ''"> and wl_code = #{wlCode}</if>
<if test="materialCode != null and materialCode != ''"> and material_code like concat('%', #{materialCode}, '%')</if>
<if test="materialDesc != null and materialDesc != ''"> and material_desc like concat('%', #{materialDesc}, '%')</if>
<if test="amount != null "> and amount = #{amount}</if>
<if test="storageAmount != null "> and storage_amount = #{storageAmount}</if>
<if test="occupyAmount != null "> and occupy_amount = #{occupyAmount}</if>
<if test="lpn != null and lpn != ''"> and lpn = #{lpn}</if>
<if test="productBatch != null and productBatch != ''"> and product_batch = #{productBatch}</if>
<if test="receiveDate != null "> and receive_date = #{receiveDate}</if>
<if test="productDate != null "> and product_date = #{productDate}</if>
<if test="userDefined1 != null and userDefined1 != ''"> and user_defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''"> and user_defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''"> and user_defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''"> and user_defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''"> and user_defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''"> and user_defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''"> and user_defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''"> and user_defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''"> and user_defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''"> and user_defined10 = #{userDefined10}</if>
<if test="gmtCreate != null "> and gmt_create = #{gmtCreate}</if>
<if test="lastModifiedBy != null and lastModifiedBy != ''"> and last_modified_by = #{lastModifiedBy}</if>
<if test="gmtModified != null "> and gmt_modified = #{gmtModified}</if>
<if test="activeFlag != null and activeFlag != ''"> and active_flag = #{activeFlag}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="sapFactoryCode != null and sapFactoryCode != ''"> and sap_factory_code = #{sapFactoryCode}</if>
<if test="wlName != null and wlName != ''"> and wl_name like concat('%', #{wlName}, '%')</if>
<if test="spareUseLife != null and spareUseLife != ''"> and spare_use_life = #{spareUseLife}</if>
<if test="spareName != null and spareName != ''"> and spare_name like concat('%', #{spareName}, '%')</if>
<if test="spareMode != null and spareMode != ''"> and spare_mode like concat('%', #{spareMode}, '%')</if>
<if test="spareManufacturer != null and spareManufacturer != ''"> and spare_manufacturer = #{spareManufacturer}</if>
<if test="spareSupplier != null and spareSupplier != ''"> and spare_supplier like concat('%', #{spareSupplier}, '%')</if>
<if test="spareReplacementCycle != null and spareReplacementCycle != ''"> and spare_replacement_cycle = #{spareReplacementCycle}</if>
<if test="spareMeasurementUnit != null and spareMeasurementUnit != ''"> and spare_measurement_unit = #{spareMeasurementUnit}</if>
<if test="spareConversionUnit != null and spareConversionUnit != ''"> and spare_conversion_unit = #{spareConversionUnit}</if>
<if test="spareConversionRatio != null and spareConversionRatio != ''"> and spare_conversion_ratio = #{spareConversionRatio}</if>
<if test="spareInventoryFloor != null and spareInventoryFloor != ''"> and spare_inventory_floor = #{spareInventoryFloor}</if>
<if test="spareInventoryUpper != null and spareInventoryUpper != ''"> and spare_inventory_upper = #{spareInventoryUpper}</if>
<if test="spareType != null and spareType != ''"> and spare_type = #{spareType}</if>
<if test="ownEquipmentName != null and ownEquipmentName != ''"> and own_equipment_name like concat('%', #{ownEquipmentName}, '%')</if>
and del_flag = '0'
</where>
</select>
@ -186,15 +148,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSparePartsLedgerVo"/>
where storage_id = #{storageId}
and del_flag = '0'
and storage_tpye = 'SP'
</select>
<select id="selectRealAmountByMaterialCode" resultType="com.op.device.domain.EquPlanEquSpare">
select amount AS 'amount',storage_amount AS 'storageAmount' from wms_ods_mate_storage_news where material_code = #{materialCode}
select amount AS 'amount',storage_amount AS 'storageAmount' from equ_spareparts_ledger where material_code = #{materialCode}
</select>
<insert id="insertSparePartsLedger" parameterType="SparePartsLedger">
insert into wms_ods_mate_storage_news
insert into equ_spareparts_ledger
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="storageId != null and storageId != ''">storage_id,</if>
<if test="whCode != null">wh_code,</if>
@ -204,7 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wlCode != null">wl_code,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialDesc != null">material_desc,</if>
<if test="amount != null">amount,</if>
amount,
<if test="storageAmount != null">storage_amount,</if>
<if test="occupyAmount != null">occupy_amount,</if>
<if test="lpn != null">lpn,</if>
@ -242,6 +203,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spareInventoryFloor != null">spare_inventory_floor,</if>
<if test="spareInventoryUpper != null">spare_inventory_upper,</if>
<if test="spareType != null">spare_type,</if>
<if test="ownEquipmentName != null">own_equipment_name,</if>
<if test="unitQuantity != null">unit_quantity,</if>
<if test="safeStock != null">safe_stock,</if>
unit_price,
<if test="procurementMethod != null">procurement_method,</if>
<if test="procurementCycle != null">procurement_cycle,</if>
<if test="openingBalance != null">opening_balance,</if>
<if test="outputRecords != null">output_records,</if>
<if test="inputRecords != null">input_records,</if>
<if test="endInventory != null">end_inventory,</if>
end_money,
<if test="substituteParts != null">substitute_parts,</if>
<if test="ownEquipmentCode != null">own_equipment_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="storageId != null and storageId != ''">#{storageId},</if>
@ -252,7 +226,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wlCode != null">#{wlCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="amount != null">#{amount},</if>
#{amount},
<if test="storageAmount != null">#{storageAmount},</if>
<if test="occupyAmount != null">#{occupyAmount},</if>
<if test="lpn != null">#{lpn},</if>
@ -290,11 +264,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spareInventoryFloor != null">#{spareInventoryFloor},</if>
<if test="spareInventoryUpper != null">#{spareInventoryUpper},</if>
<if test="spareType != null">#{spareType},</if>
<if test="ownEquipmentName != null">#{ownEquipmentName},</if>
<if test="unitQuantity != null">#{unitQuantity},</if>
<if test="safeStock != null">#{safeStock},</if>
#{unitPrice},
<if test="procurementMethod != null">#{procurementMethod},</if>
<if test="procurementCycle != null">#{procurementCycle},</if>
<if test="openingBalance != null">#{openingBalance},</if>
<if test="outputRecords != null">#{outputRecords},</if>
<if test="inputRecords != null">#{inputRecords},</if>
<if test="endInventory != null">#{endInventory},</if>
#{endMoney},
<if test="substituteParts != null">#{substituteParts},</if>
<if test="ownEquipmentCode != null">#{ownEquipmentCode},</if>
</trim>
</insert>
<update id="updateSparePartsLedger" parameterType="SparePartsLedger">
update wms_ods_mate_storage_news
update equ_spareparts_ledger
<trim prefix="SET" suffixOverrides=",">
<if test="whCode != null">wh_code = #{whCode},</if>
<if test="regionCode != null">region_code = #{regionCode},</if>
@ -303,7 +290,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wlCode != null">wl_code = #{wlCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialDesc != null">material_desc = #{materialDesc},</if>
<if test="amount != null">amount = #{amount},</if>
amount = #{amount},
<if test="storageAmount != null">storage_amount = #{storageAmount},</if>
<if test="occupyAmount != null">occupy_amount = #{occupyAmount},</if>
<if test="lpn != null">lpn = #{lpn},</if>
@ -341,28 +328,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spareInventoryFloor != null">spare_inventory_floor = #{spareInventoryFloor},</if>
<if test="spareInventoryUpper != null">spare_inventory_upper = #{spareInventoryUpper},</if>
<if test="spareType != null">spare_type = #{spareType},</if>
<if test="ownEquipmentName != null">own_equipment_name = #{ownEquipmentName},</if>
<if test="unitQuantity != null">unit_quantity = #{unitQuantity},</if>
<if test="safeStock != null">safe_stock = #{safeStock},</if>
unit_price = #{unitPrice},
<if test="procurementMethod != null">procurement_method = #{procurementMethod},</if>
<if test="procurementCycle != null">procurement_cycle = #{procurementCycle},</if>
<if test="openingBalance != null">opening_balance = #{openingBalance},</if>
<if test="outputRecords != null">output_records = #{outputRecords},</if>
<if test="inputRecords != null">input_records = #{inputRecords},</if>
<if test="endInventory != null">end_inventory = #{endInventory},</if>
end_money = #{endMoney},
<if test="substituteParts != null">substitute_parts = #{substituteParts},</if>
<if test="ownEquipmentCode != null">own_equipment_code = #{ownEquipmentCode},</if>
</trim>
where storage_id = #{storageId}
</update>
<update id="updateAmount" parameterType="SparePartsLedger">
update equ_spareparts_ledger
set amount = #{amount}
where storage_id = #{storageId}
</update>
<update id="updateSpareNumReduce">
update wms_ods_mate_storage_news
update equ_spareparts_ledger
set amount = ( amount - #{spareQuantity} ) where material_code = #{spareCode}
</update>
<update id="updateSpareNumAdd">
update wms_ods_mate_storage_news
update equ_spareparts_ledger
set amount = ( amount + #{spareQuantity} ) where material_code = #{spareCode}
</update>
<delete id="deleteSparePartsLedgerByStorageId" parameterType="String">
delete from wms_ods_mate_storage_news where storage_id = #{storageId}
</delete>
<update id="deleteSparePartsLedgerByStorageId" parameterType="String">
update equ_spareparts_ledger
set del_flag = '1'
where storage_id = #{storageId}
</update>
<delete id="deleteSparePartsLedgerByStorageIds" parameterType="String">
delete from wms_ods_mate_storage_news where storage_id in
<update id="deleteSparePartsLedgerByStorageIds" parameterType="String">
update equ_spareparts_ledger
set del_flag = '1'
where storage_id in
<foreach item="storageId" collection="array" open="(" separator="," close=")">
#{storageId}
</foreach>
</delete>
</update>
</mapper>
Loading…
Cancel
Save