材料站领料删除优化

This commit is contained in:
mashuai 2025-08-19 18:20:36 +08:00
parent 7bf95da044
commit c1348ed43d
5 changed files with 62 additions and 1 deletions

View File

@ -357,4 +357,11 @@ public interface MaterialLeaseInfoMapper {
* @return
*/
List<MaterialLeaseMaCodeDto> getList(@Param("id") Long id, @Param("typeId") Long typeId);
/**
* 根据任务id查询领料任务ID
* @param ids
* @return
*/
List<Long> getTaskIds(Long[] ids);
}

View File

@ -1176,7 +1176,22 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
*/
@Override
public int deleteLeaseApplyInfoByIds(Long[] ids) {
int result = materialLeaseInfoMapper.deleteLeaseApplyInfoByIds(ids);
int result = 0;
// 根据ids查询任务id
List<Long> taskIds = materialLeaseInfoMapper.getTaskIds(ids);
if (!CollectionUtils.isEmpty(taskIds)) {
// 根据任务id删除任务表数据
result = tmTaskMapper.deleteTaskByIds(taskIds);
if (result < 1) {
throw new ServiceException("删除任务信息失败");
}
// 根据任务id删除任务协议表数据
result = tmTaskMapper.deleteAgreementId(taskIds);
if (result < 1) {
throw new ServiceException("删除任务协议信息失败");
}
}
result = materialLeaseInfoMapper.deleteLeaseApplyInfoByIds(ids);
if (result > 0) {
// 删除lease_apply_details表数据
result += materialLeaseInfoMapper.deleteLeaseApplyDetailsByParentIds(ids);

View File

@ -145,4 +145,18 @@ public interface TmTaskMapper {
* @return
*/
List<LeaseApplyInfo> selectLeaseApplyInfoByTaskNo(String code);
/**
* 批量删除任务
* @param taskIds
* @return
*/
int deleteTaskByIds(@Param("taskIds") List<Long> taskIds);
/**
* 批量删除协议id
* @param taskIds
* @return
*/
int deleteAgreementId(@Param("taskIds") List<Long> taskIds);
}

View File

@ -1202,4 +1202,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND su.sign_type IS NOT NULL
AND su.sign_url IS NOT NULL
</select>
<select id="getTaskIds" resultType="java.lang.Long">
SELECT
task_id
FROM
clz_lease_apply_info
WHERE
id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

View File

@ -139,6 +139,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</delete>
<delete id="deleteTaskByIds">
delete from tm_task where task_id in
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
<delete id="deleteAgreementId">
delete from tm_task_agreement where task_id in
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">
#{taskId}
</foreach>
</delete>
<select id="selectTaskNumByMonths" resultType="java.lang.String">
SELECT SUBSTRING(`code`, - 3) as code
FROM tm_task