领料需求发布量更改

This commit is contained in:
mashuai 2025-11-26 14:19:33 +08:00
parent ca6e97dab7
commit b9e55c1619
6 changed files with 186 additions and 25 deletions

View File

@ -212,6 +212,8 @@ public class LeaseApplyDetails extends BaseEntity {
@ApiModelProperty(value = "任务唯一标识单号")
private String keyId;
private List<String> oldTypeIdList;
@ApiModelProperty(value = "领料物资名称汇总")
private String maTypeNames;
public LeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) {

View File

@ -240,4 +240,11 @@ public interface LeaseApplyDetailsMapper {
List<LeaseApplyDetailExport> selectLeaseApplyLL(LeaseApplyInfo bean);
List<LeaseApplyDetailExport> selectLeaseApplyLY(LeaseApplyInfo bean);
/**
* 根据oldTypeId和parentId查询领用待发布数量
* @param detail
* @return
*/
LeaseApplyDetails getPublishNum(LeaseApplyDetails detail);
}

View File

@ -247,7 +247,7 @@ public interface LeaseApplyInfoMapper {
* @param leaseApplyDetails
* @return
*/
LeaseApplyDetails getPublishNum(LeaseApplyDetails leaseApplyDetails);
List<LeaseApplyDetails> getPublishNum(LeaseApplyDetails leaseApplyDetails);
/**
* 修改领用单的领用单出库数量
@ -319,4 +319,32 @@ public interface LeaseApplyInfoMapper {
* @return
*/
List<Long> selectPublishSignList(LeaseApplyInfo applyInfo);
/**
* 根据parentId及newTypeId查询发布数量
* @param leaseApplyDetails
* @return
*/
List<LeaseApplyDetails> getPublishNumTwo(LeaseApplyDetails leaseApplyDetails);
/**
* 删除该条发布数据
* @param publishDetails
* @return
*/
int deletePublish(LeaseApplyDetails publishDetails);
/**
* 减去该条发布数据
* @param publishDetails
* @return
*/
int subtractLeasePublish(LeaseApplyDetails publishDetails);
/**
* 修改该条发布数据
* @param publishDetails
* @return
*/
int updateLeaseApplyDetails(LeaseApplyDetails publishDetails);
}

View File

@ -227,6 +227,17 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
LeaseApplyDetails pendingOutNum = mapper.selectPendingOutNum(detail);
detail.setPendingOutNum(pendingOutNum.getPendingOutNum());
detail.setStorageNum(pendingOutNum.getStorageNum());
if (StringUtils.isNotBlank(publishTask)) {
// 根据oldTypeId和parentId查询领用待发布数量
if (StringUtils.isNotBlank(detail.getOldTypeId())) {
List<String> oldTypeIdList = Arrays.asList(detail.getOldTypeId().split(","));
detail.setOldTypeIdList(oldTypeIdList);
}
LeaseApplyDetails applyDetails = leaseApplyDetailsMapper.getPublishNum(detail);
if (applyDetails != null) {
detail.setPendingPublishNum(applyDetails.getPendingPublishNum().add(detail.getPreNum()));
}
}
}
}
stepTimes.put("领用发布查询", System.currentTimeMillis() - step81Start);
@ -1102,23 +1113,77 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
@Transactional(rollbackFor = Exception.class)
public AjaxResult updateLeaseNum(LeaseApplyDetails leaseApplyDetails) {
try {
if (leaseApplyDetails.getNewTypeId()!= null){
// 根据parentId查询发布数量
//LeaseApplyDetails applyDetails = leaseApplyInfoMapper.getPublishNum(leaseApplyDetails);
// 根据传入的值判断少了多少发布数量
leaseApplyDetails.setPublishNum(leaseApplyDetails.getPreNum());
int res = leaseApplyInfoMapper.updateLeaseNum(leaseApplyDetails);
if (res <= 0){
return AjaxResult.error("修改领用表失败");
}
res = leaseApplyInfoMapper.updateLeasePublish(leaseApplyDetails);
if (res <= 0){
return AjaxResult.error("修改领料发布表失败");
if (leaseApplyDetails.getNewTypeId()!= null) {
// 根据parentId及oldTypeIdList查询需求数量
List<LeaseApplyDetails> applyDetailsList = leaseApplyInfoMapper.getPublishNum(leaseApplyDetails);
// 根据parentId及newTypeId查询发布及待发布数量
List<LeaseApplyDetails> publishDetailsList = leaseApplyInfoMapper.getPublishNumTwo(leaseApplyDetails);
// 根据传入的值判断发布数量是增加还是减少
// 新数量
BigDecimal preNum = leaseApplyDetails.getPreNum();
// 老数量
BigDecimal publishNum = leaseApplyDetails.getPublishNum();
if (preNum.compareTo(publishNum) > 0) {
// 差值
BigDecimal subtractNum = preNum.subtract(publishNum);
for (LeaseApplyDetails applyDetails : applyDetailsList) {
// 待发布数量
BigDecimal subNum = applyDetails.getPendingNum();
if (subtractNum.compareTo(subNum) <= 0) {
applyDetails.setPendingNum(subtractNum);
leaseApplyInfoMapper.updateLeaseNum(applyDetails);
break;
} else if (subtractNum.compareTo(subNum) > 0) {
subtractNum = subtractNum.subtract(subNum);
applyDetails.setPendingNum(subtractNum);
leaseApplyInfoMapper.updateLeaseNum(applyDetails);
}
}
// 差值
BigDecimal leaseSubtractNum = preNum.subtract(publishNum);
for (LeaseApplyDetails publishDetails : publishDetailsList) {
// 待发布数量
BigDecimal pendingNum = publishDetails.getPendingNum();
if (leaseSubtractNum.compareTo(pendingNum) <= 0) {
publishDetails.setPendingNum(leaseSubtractNum);
leaseApplyInfoMapper.updateLeasePublish(publishDetails);
break;
} else if (leaseSubtractNum.compareTo(pendingNum) > 0) {
leaseSubtractNum = leaseSubtractNum.subtract(pendingNum);
publishDetails.setPendingNum(leaseSubtractNum);
leaseApplyInfoMapper.updateLeasePublish(publishDetails);
}
}
} else if (preNum.compareTo(publishNum) < 0) {
// 差值
BigDecimal leaseSubtractNum = publishNum.subtract(preNum);
for (LeaseApplyDetails publishDetails : publishDetailsList) {
// 发布数量
BigDecimal num = publishDetails.getPublishNum();
if (leaseSubtractNum.compareTo(num) == 0) {
//删除该条发布数据
leaseApplyInfoMapper.deletePublish(publishDetails);
//处理lease_apply_details表数据
leaseApplyInfoMapper.updateLeaseApplyDetails(publishDetails);
break;
} else if (leaseSubtractNum.compareTo(num) > 0) {
leaseSubtractNum = leaseSubtractNum.subtract(num);
leaseApplyInfoMapper.deletePublish(publishDetails);
//处理lease_apply_details表数据
leaseApplyInfoMapper.updateLeaseApplyDetails(publishDetails);
} else if (leaseSubtractNum.compareTo(num) < 0) {
publishDetails.setPublishNum(leaseSubtractNum);
leaseApplyInfoMapper.subtractLeasePublish(publishDetails);
//处理lease_apply_details表数据
leaseApplyInfoMapper.updateLeaseApplyDetails(publishDetails);
break;
}
}
}
} else {
int res = leaseApplyInfoMapper.updateLeaseNumTwo(leaseApplyDetails);
if (res <= 0){
return AjaxResult.error("修改领料表失败");
int result = leaseApplyInfoMapper.updateLeaseNumTwo(leaseApplyDetails);
if (result <= 0) {
throw new Exception("修改领料表失败");
}
}
return AjaxResult.success("修改成功");

View File

@ -89,7 +89,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark, lad.company_id,
mt4.type_id as firstId,
su.sign_url as signUrl,
su.sign_type as signType
su.sign_type as signType,
IFNULL(lad.pre_num,0) as pendingPublishNum
from
lease_apply_details lad
left join
@ -893,4 +894,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by lpd.id
</select>
<select id="getPublishNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
parent_id as parentId,
GREATEST(SUM(IFNULL(pre_num, 0)) - SUM(IFNULL(publish_num, 0)), 0 ) AS pendingPublishNum
FROM
lease_apply_details
WHERE
parent_id = #{parentId}
AND type_id IN
<foreach item="item" collection="oldTypeIdList" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@ -279,6 +279,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete id="deletePublish">
delete from lease_publish_details where id = #{id}
</delete>
<select id="getTaskId" resultType="java.lang.String">
select task_id
from lease_apply_info
@ -840,9 +844,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateLeaseNum">
update lease_apply_details
set publish_num=#{publishNum}
where parent_id = #{parentId}
AND new_type = #{newTypeId}
set publish_num = IFNULL(publish_num, 0) + #{pendingNum}
where id = #{id}
</update>
<update id="updateLeaseNumTwo">
@ -854,10 +857,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateLeasePublish">
update lease_publish_details
set num = #{preNum}
set num = num + #{pendingNum}
where id = #{id}
</update>
<update id="subtractLeasePublish">
update lease_publish_details
set num = num - #{publishNum}
where id = #{id}
</update>
<update id="updateLeaseApplyDetails">
update lease_apply_details
set publish_num = IFNULL(publish_num, 0) - #{publishNum}
where parent_id = #{parentId}
AND new_type = #{newTypeId}
AND publish_task = #{publishTask}
and type_id = #{typeId}
</update>
<select id="getUserList" resultMap="LeaseApplyInfoResult">
@ -987,14 +1001,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getPublishNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
id AS id,
parent_id AS parentId,
type_id AS typeId,
publish_num AS publishNum
pre_num AS preNum,
publish_num AS publishNum,
pre_num - IFNULL( publish_num, 0 ) AS pendingNum
FROM
lease_apply_details
WHERE
parent_id = #{parentId}
and new_type = #{newTypeId}
AND type_id IN
<foreach item="item" collection="oldTypeIdList" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
parent_id,
type_id
</select>
<select id="getSignPublishList" resultType="com.bonus.common.biz.domain.lease.LeaseApplyInfo">
@ -1259,4 +1282,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<select id="getPublishNumTwo" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
lpd.id as id,
lpd.parent_id as parentId,
lpd.type_id as typeId,
lpd.new_type as newTypeId,
lad.pre_num - IFNULL( lad.publish_num, 0 ) as pendingNum,
lpd.num as publishNum
FROM
lease_publish_details lpd
LEFT JOIN lease_apply_details lad ON lpd.parent_id = lad.parent_id
AND lpd.type_id = lad.type_id
WHERE
lpd.new_type = #{newTypeId}
AND lpd.parent_id = #{parentId}
AND lpd.publish_task = #{publishTask}
GROUP BY
lpd.parent_id,
lpd.type_id
</select>
</mapper>