zhoulisky 7 months ago
parent
commit
d1d302f007

+ 3 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AssetMapper.java

@@ -41,7 +41,9 @@ public interface AssetMapper extends BaseMapper<AssetEntity> {
 	 * @param ids
 	 * @return
 	 */
-	boolean physicalDeleteByIds(List<Long> ids);
+	int physicalDeleteByIds(List<Long> ids);
+
+	int deleteAssesByZcbmAfterMonth(@Param("zcbm") String zcbm, @Param("yearAndMonth") String yearAndMonth);
 
 	/**
 	 * 折旧费用、长期待摊费用、无形资产摊销费用汇总表-按年月

+ 5 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AssetMapper.xml

@@ -97,6 +97,11 @@
         </foreach>
     </delete>
 
+    <delete id="deleteAssesByZcbmAfterMonth">
+        DELETE FROM kd_asset
+        WHERE zcbm = #{zcbm} and year_and_month <![CDATA[>=]]> #{yearAndMonth}
+    </delete>
+
     <select id="selectByYearAndMonthAndBmOrMc" resultMap="ResultVoMap">
         SELECT * FROM kd_asset
         WHERE year_and_month = #{yearAndMonth}

+ 2 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AssetServiceImpl.java

@@ -184,8 +184,9 @@ public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity>
 		for (Long assetId : ids) {
 			AssetEntity dbAsset = baseMapper.selectById(assetId);
 			canDeleteAsset(dbAsset, yearAndMonth);
+			baseMapper.deleteAssesByZcbmAfterMonth(dbAsset.getZcbm(), yearAndMonth);
 		}
-		return baseMapper.physicalDeleteByIds(ids);
+		return true;
 	}
 
 	private void canDeleteAsset(AssetEntity asset, String yearAndMonth) {