feat(lease): 新增领用发布驳回功能并优化相关逻辑

- 新增领用发布驳回接口和相关服务方法
- 实现驳回时减少已发布数量和删除发布详情的功能
- 优化工程机具领用导出中的SQL逻辑,避免重复计算
This commit is contained in:
syruan 2025-07-24 16:27:38 +08:00
parent 344bbfaad0
commit 25d102c90a
8 changed files with 139 additions and 57 deletions

View File

@ -210,6 +210,15 @@ public class LeaseTaskController extends BaseController {
return service.addPublish(leaseApplyRequestVo);
}
/**
* 领用发布驳回
*/
@ApiOperation(value = "领用发布驳回")
@PostMapping("/leasePublishReject")
public AjaxResult leasePublishReject(@RequestBody LeaseApplyDetails leaseApplyDetails) {
return service.leasePublishReject(leaseApplyDetails);
}
/**
* 领用发布终结
* @param leaseApplyInfo

View File

@ -130,12 +130,26 @@ public interface LeaseTaskMapper {
int addPublish(LeaseApplyDetails applyDetails);
/**
* 领用申请发布详情修改
* 领用申请发布详情修改 -- 增加发布数量
* @param applyDetails
* @return
*/
int updatePublish(LeaseApplyDetails applyDetails);
/**
* 领用申请发布详情修改 -- 减少发布数量
* @param applyDetails
* @return
*/
int updatePublishSub(LeaseApplyDetails applyDetails);
/**
* 领用申请发布详情删除
* @param applyDetails
* @return
*/
int deletePublishDetails(LeaseApplyDetails applyDetails);
/**
* 根据当前年月查询最大序号
* @param year

View File

@ -116,6 +116,13 @@ public interface ILeaseTaskService {
*/
AjaxResult addPublish(LeaseApplyRequestVo leaseApplyRequestVo);
/**
* 领用发布驳回
* @param leaseApplyRequestVo
* @return
*/
AjaxResult leasePublishReject(LeaseApplyDetails leaseApplyRequestVo);
/**
* 领用发布终结
* @param leaseApplyInfo

View File

@ -173,6 +173,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
record.setOutNum(record.getInputNum());
record.setOutType(InputOutEnum.NUMBER_DEVICE.getTypeId());
}
// 检查库存数量是否足够
res = checkStorageNum(record);
if (res > 0) {

View File

@ -834,6 +834,32 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
}
}
/**
* 领用发布驳回
*
* @param leaseApplyDetails 领用任务详情
*/
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult leasePublishReject(LeaseApplyDetails leaseApplyDetails) {
if (leaseApplyDetails == null) {
return AjaxResult.error("参数不能为空");
}
// 根据parentId及typeId更新lease_apply_details表的发布数量
int result = mapper.updatePublishSub(leaseApplyDetails);
if (result == 0) {
return AjaxResult.error("发布驳回失败,请联系管理员");
}
// 根据parentId及typeId更新lease_apply_details表的发布数量
int details = mapper.deletePublishDetails(leaseApplyDetails);
if (details == 0) {
throw new ServiceException("发布驳回详情删除失败,请联系管理员");
}
return AjaxResult.success("驳回成功");
}
/**
* 发布数据保存
* @param leaseApplyRequestVo
@ -898,6 +924,7 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
}
}
/**
* 结束发布
* @param leaseApplyInfo

View File

@ -39,7 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
LEFT JOIN ma_type_manage mtm ON mt3.parent_id = mtm.type_id
-- 关键点:提前对 user_id 的 type_id 做去重
LEFT JOIN (
SELECT DISTINCT type_id
FROM ma_type_manage
<if test="userId != null">
WHERE user_id = #{userId}
</if>
) mtm ON mt3.parent_id = mtm.type_id
WHERE
1=1
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
@ -55,9 +62,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sd.dept_name like concat('%', #{keyWord}, '%')
)
</if>
<if test="userId != null">
and mtm.user_id = #{userId}
</if>
<if test="unitId != null">
and bu.unit_id = #{unitId}

View File

@ -700,6 +700,16 @@
where parent_id = #{parentId} and type_id = #{typeId}
</update>
<update id="updatePublishSub">
update
lease_apply_details
set
publish_num = IFNULL(publish_num, 0) - #{num}
where
parent_id = #{parentId}
and type_id = #{typeId}
</update>
<select id="getApplyInfo" resultType="com.bonus.common.biz.domain.lease.LeaseApplyInfo">
select
lai.code as code,lai.lease_person as leasePerson,lai.phone as phone,lai.create_by as createBy,
@ -782,59 +792,59 @@
<select id="getPublishList" resultType="com.bonus.common.biz.domain.lease.LeasePublishInfo"
resultMap="LeasePublishInfoResult">
select
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url,
lai.lease_sign_type,tt.task_id as taskId,
lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus,
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url,
lai.lease_sign_type,tt.task_id as taskId,
lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus,
case tt.task_status
when 1 then '未完成'
when 4 then '已终止'
when 3 then '已完成'
end as taskStatusName,
IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(sum(lad.al_num),0) as alNum,
GROUP_CONCAT(DISTINCT mt1.type_name) AS maTypeNames,
bp.contract_part as contractPart,
sd.dept_name as impUnitName,
GROUP_CONCAT(DISTINCT mt3.type_id) as firstId
case tt.task_status
when 1 then '未完成'
when 4 then '已终止'
when 3 then '已完成'
end as taskStatusName,
IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(sum(lad.al_num),0) as alNum,
GROUP_CONCAT(DISTINCT mt1.type_name) AS maTypeNames,
bp.contract_part as contractPart,
sd.dept_name as impUnitName,
GROUP_CONCAT(DISTINCT mt3.type_id) as firstId
from
lease_apply_info lai
left join tm_task tt on lai.task_id = tt.task_id
left join lease_apply_details lad on lai.id = lad.parent_id
left join tm_task_agreement tta on lai.task_id = tta.task_id
left join bm_unit bu on bu.unit_id = lai.unit_id
left join bm_project bp on bp.pro_id = lai.project_id
left join sys_dept sd on sd.dept_id = bp.imp_unit
left join sys_dict_data sda on tt.task_status = sda.dict_value
and sda.dict_type = 'lease_task_status'
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
left join ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = '0'
left join ma_type mt3 ON mt2.parent_id = mt3.type_id and mt3.del_flag = '0'
<if test="userId != null">
JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}
</if>
where tt.task_type = '19'
and tt.task_status in (1, 3, 4)
<if test="taskStatus != null and taskStatus != ''">
and tt.task_status = #{taskStatus}
</if>
<if test="taskId != null ">and lai.task_id = #{taskId}</if>
<if test="statusList != null and statusList.size() > 0">
and tt.task_status in
<foreach item="item" collection="statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if>
<if test="isApp != null and taskStatus==1">and (tt.task_status = 0 or tt.task_status = 1 or tt.task_status = 2) </if>
<if test="isApp != null and taskStatus==3">and (tt.task_status = 3 or tt.task_status = 4)</if>
lease_apply_info lai
left join tm_task tt on lai.task_id = tt.task_id
left join lease_apply_details lad on lai.id = lad.parent_id
left join tm_task_agreement tta on lai.task_id = tta.task_id
left join bm_unit bu on bu.unit_id = lai.unit_id
left join bm_project bp on bp.pro_id = lai.project_id
left join sys_dept sd on sd.dept_id = bp.imp_unit
left join sys_dict_data sda on tt.task_status = sda.dict_value and sda.dict_type = 'lease_task_status'
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
left join ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = '0'
left join ma_type mt3 ON mt2.parent_id = mt3.type_id and mt3.del_flag = '0'
<if test="userId != null">
JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}
</if>
where
tt.task_type = '19'
and tt.task_status in (1, 3, 4)
<if test="taskStatus != null and taskStatus != ''">
and tt.task_status = #{taskStatus}
</if>
<if test="taskId != null ">and lai.task_id = #{taskId}</if>
<if test="statusList != null and statusList.size() > 0">
and tt.task_status in
<foreach item="item" collection="statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if>
<if test="isApp != null and taskStatus==1">and (tt.task_status = 0 or tt.task_status = 1 or tt.task_status = 2) </if>
<if test="isApp != null and taskStatus==3">and (tt.task_status = 3 or tt.task_status = 4)</if>
GROUP BY lai.id
ORDER BY tt.create_time desc
</select>
@ -1011,4 +1021,14 @@
limit 1
</select>
<delete id="deletePublishDetails">
DELETE
FROM
lease_publish_details
WHERE
parent_id = #{parentId}
and type_id = #{typeId}
and publish_task = #{publishTask}
</delete>
</mapper>

View File

@ -1,6 +1,6 @@
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://bonus-mysql:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.url.0=jdbc:mysql://bonus-mysql:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=30000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=root
#db.password=password