领料出库优化

This commit is contained in:
sxu 2024-11-19 10:33:56 +08:00
parent 20dc13b756
commit 949cfd2c9a
15 changed files with 151 additions and 173 deletions

View File

@ -61,4 +61,6 @@ public interface BmAgreementInfoMapper
public int deleteBmAgreementInfoByAgreementIds(Long[] agreementIds);
public int selectNumByMonth(Date nowDate);
String getProtocol(String agreementId);
}

View File

@ -74,4 +74,6 @@ public interface LeaseApplyDetailsMapper {
LeaseApplyDetails getLeaseApplyDetails(@Param("record") LeaseOutDetails record);
int updateLeaseApplyDetailsByLeaseOutRecord(@Param("record") LeaseOutDetails record);
LeaseApplyDetails getOutboundNum(LeaseOutDetails record);
}

View File

@ -57,4 +57,6 @@ public interface LeaseApplyInfoMapper {
* @return 结果
*/
int deleteLeaseApplyInfoByIds(Long[] ids);
String getTaskId(Long parentId);
}

View File

@ -46,7 +46,7 @@ public interface LeaseOutDetailsMapper {
* @param leaseOutDetails 领料出库详细
* @return 结果
*/
public int insertLeaseOutDetails(LeaseOutDetails leaseOutDetails);
// public int insertLeaseOutDetails(LeaseOutDetails leaseOutDetails);
/**
* 修改领料出库详细
@ -72,25 +72,7 @@ public interface LeaseOutDetailsMapper {
*/
public int deleteLeaseOutDetailsByIds(Long[] ids);
LeaseApplyDetails getOutboundNum(LeaseOutDetails record);
String getTaskId(Long parentId);
int updateTaskStatus(@Param("taskId") String taskId, @Param("status")int status);
/** 插入领料出库详情表 -- 根据字段选择注入 */
int insertSelective(LeaseOutDetails record);
SltAgreementInfo getSltAgreementInfo(LeaseOutDetails record);
int updSltInfo(SltAgreementInfo sltAgreementInfo);
String getAgreementId(String taskId);
String getProtocol(String agreementId);
int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId,@Param("ma") Type ma);
int insertLeaseOutDetails(LeaseOutDetails record);
}

View File

@ -3,7 +3,6 @@ package com.bonus.material.lease.service.impl;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
import com.bonus.common.biz.enums.MaMachineStatusEnum;
@ -12,13 +11,17 @@ import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
import com.bonus.material.ma.domain.Type;
import com.bonus.material.ma.mapper.MachineMapper;
import com.bonus.material.ma.mapper.TypeMapper;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -36,6 +39,9 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
@Autowired
LeaseApplyInfoMapper leaseApplyInfoMapper;
@Autowired
private LeaseOutDetailsMapper leaseOutDetailsMapper;
@ -47,6 +53,18 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
@Autowired
TypeMapper typeMapper;
@Autowired
private TmTaskMapper tmTaskMapper;
@Autowired
private SltAgreementInfoMapper sltAgreementInfoMapper;
@Autowired
BmAgreementInfoMapper bmAgreementInfoMapper;
@Autowired
TmTaskAgreementMapper tmTaskAgreementMapper;
/**
* 查询领料出库详细
*
@ -157,7 +175,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
throw new RuntimeException("出库失败,修改任务状态失败");
}
// 5插入结算记录
String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId());
String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId());
res = insSltInfo(taskId, record);
if (res == 0) {
throw new RuntimeException("出库失败,插入结算记录失败");
@ -179,7 +197,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
// 判断库存是否足够
private boolean checkStorageIsEnough(LeaseOutDetails record) {
if (record.getManageType().equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId())) {
LeaseApplyDetails details = leaseOutDetailsMapper.getOutboundNum(record);
LeaseApplyDetails details = leaseApplyDetailsMapper.getOutboundNum(record);
if (details == null) {
return false;
}
@ -204,12 +222,12 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
i++;
}
}
String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId());
String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId());
if (i == leaseApplyDetailsList.size()) {
leaseOutDetailsMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus());
tmTaskMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus());
res = 1;
} else {
leaseOutDetailsMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
tmTaskMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
res = 1;
}
return res;
@ -251,7 +269,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
}
if (res > 0) {
// 插入领料出库明细表lease_out_details
res = leaseOutDetailsMapper.insertSelective(record);
res = leaseOutDetailsMapper.insertLeaseOutDetails(record);
if (res > 0) {
// 普通机具减少 (ma_type 设备规格表)的库存数量
res = typeMapper.updateMaTypeStockNum(record);
@ -264,15 +282,15 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
public int insSltInfo(String taskId, LeaseOutDetails record) {
int res = 0;
SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record);
SltAgreementInfo sltAgreementInfo = sltAgreementInfoMapper.getSltAgreementInfo(record);
if (sltAgreementInfo != null) {
Long num = sltAgreementInfo.getNum();
Long outNum = record.getOutNum();
sltAgreementInfo.setNum(num + outNum);
res = leaseOutDetailsMapper.updSltInfo(sltAgreementInfo);
res = sltAgreementInfoMapper.updSltInfo(sltAgreementInfo);
} else {
String agreementId = leaseOutDetailsMapper.getAgreementId(taskId);
String protocol = leaseOutDetailsMapper.getProtocol(agreementId);
String agreementId = tmTaskAgreementMapper.getAgreementId(taskId);
String protocol = bmAgreementInfoMapper.getProtocol(agreementId);
Type maType = typeMapper.getMaType(record.getTypeId());
if (StringUtils.isEmpty(protocol)) {
maType.setFinalPrice(maType.getLeasePrice());
@ -285,7 +303,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
maType.setFinalPrice(maType.getLeasePrice());
}
}
res = leaseOutDetailsMapper.insSltInfo(record, agreementId, maType);
res = sltAgreementInfoMapper.insSltInfo(record, agreementId, maType);
}
return res;
}

View File

@ -1,7 +1,11 @@
package com.bonus.material.settlement.mapper;
import java.util.List;
import com.bonus.material.lease.domain.LeaseOutDetails;
import com.bonus.material.ma.domain.Type;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import org.apache.ibatis.annotations.Param;
/**
* 结算信息Mapper接口
@ -57,4 +61,10 @@ public interface SltAgreementInfoMapper {
* @return 结果
*/
public int deleteSltAgreementInfoByIds(Long[] ids);
SltAgreementInfo getSltAgreementInfo(LeaseOutDetails record);
int updSltInfo(SltAgreementInfo sltAgreementInfo);
int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId, @Param("ma") Type ma);
}

View File

@ -58,4 +58,6 @@ public interface TmTaskAgreementMapper {
* @return 结果
*/
int deleteTmTaskAgreementByTaskIds(Long[] taskIds);
String getAgreementId(String taskId);
}

View File

@ -95,11 +95,6 @@ public interface TmTaskMapper {
*/
String selectTaskNumByMonths(Date nowDate, Integer taskType);
// List<TmTaskRequestVo> getAuditListByLeaseTmTask(@Param("record") TmTaskRequestVo tmTaskRequestVo);
//
// List<TmTaskRequestVo> getAuditListByLeaseTmTaskByPeople(@Param("record") TmTaskRequestVo tmTaskRequestVo);
//
// List<LeaseApplyInfo> getAuditListByLeaseInfo(@Param("record") TmTaskRequestVo record);
//
// List<LeaseApplyDetails> getLeaseApplyDetails(@Param("record") LeaseApplyInfo record);
int updateTaskStatus(@Param("taskId") String taskId, @Param("status")int status);
}

View File

@ -125,4 +125,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectNumByMonth" resultType="java.lang.Integer">
select count(*) from bm_agreement_info where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m')
</select>
<select id="getProtocol" resultType="java.lang.String">
select protocol
from bm_agreement_info
where agreement_id = #{agreementId}
</select>
</mapper>

View File

@ -188,4 +188,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE
parent_id = #{record.parentId} and type_id = #{record.typeId}
</update>
<select id="getOutboundNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT id, parent_id as parentId, type_id as typeId, pre_num as preNum, al_num as alNum, `status`, remark
FROM lease_apply_details
WHERE id = #{id} AND (pre_num - IFNULL(al_num, 0)) > 0
</select>
</mapper>

View File

@ -191,4 +191,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="getTaskId" resultType="java.lang.String">
select task_id
from lease_apply_info
where id = #{parentId}
</select>
</mapper>

View File

@ -53,92 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
lod.parent_id = #{parentId}
</where>
</select>
<insert id="insertLeaseOutDetails" parameterType="com.bonus.material.lease.domain.LeaseOutDetails" useGeneratedKeys="true" keyProperty="id">
insert into lease_out_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="typeId != null">type_id,</if>
<if test="maId != null">ma_id,</if>
<if test="outNum != null">out_num,</if>
<if test="outType != null">out_type,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="companyId != null">company_id,</if>
<if test="carCode != null">car_code,</if>
<if test="pushNotifications != null">push_notifications,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="maId != null">#{maId},</if>
<if test="outNum != null">#{outNum},</if>
<if test="outType != null">#{outType},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="companyId != null">#{companyId},</if>
<if test="carCode != null">#{carCode},</if>
<if test="pushNotifications != null">#{pushNotifications},</if>
</trim>
</insert>
<update id="updateLeaseOutDetails" parameterType="com.bonus.material.lease.domain.LeaseOutDetails">
update lease_out_details
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="maId != null">ma_id = #{maId},</if>
<if test="outNum != null">out_num = #{outNum},</if>
<if test="outType != null">out_type = #{outType},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="carCode != null">car_code = #{carCode},</if>
<if test="pushNotifications != null">push_notifications = #{pushNotifications},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLeaseOutDetailsById" parameterType="Long">
delete from lease_out_details where id = #{id}
</delete>
<delete id="deleteLeaseOutDetailsByIds" parameterType="String">
delete from lease_out_details where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getOutboundNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT id, parent_id as parentId, type_id as typeId, pre_num as preNum, al_num as alNum, `status`, remark
FROM lease_apply_details
WHERE id = #{id} AND (pre_num - IFNULL(al_num, 0)) > 0
</select>
<select id="getTaskId" resultType="java.lang.String">
select task_id
from lease_apply_info
where id = #{parentId}
</select>
<update id="updateTaskStatus">
update tm_task
set task_status = #{status},
update_time = NOW()
where task_id = #{taskId}
</update>
<insert id="insertSelective">
insert into lease_out_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
@ -210,57 +126,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<select id="getSltAgreementInfo" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT
id,
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId,
num AS num,
start_time AS startTime,
end_time AS endTime,
status AS status,
lease_id AS leaseId,
back_id AS backId,
lease_price AS leasePrice,
buy_price AS buyPrice,
company_id AS companyId
FROM
slt_agreement_info
WHERE
lease_id = #{parentId}
AND
type_id = #{typeId}
AND
ma_id IS NULL
AND
status = '0'
AND
DATE(start_time) = CURDATE();
</select>
<update id="updSltInfo">
update slt_agreement_info
set num = #{num},
update_time = now()
<update id="updateLeaseOutDetails" parameterType="com.bonus.material.lease.domain.LeaseOutDetails">
update lease_out_details
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="maId != null">ma_id = #{maId},</if>
<if test="outNum != null">out_num = #{outNum},</if>
<if test="outType != null">out_type = #{outType},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="carCode != null">car_code = #{carCode},</if>
<if test="pushNotifications != null">push_notifications = #{pushNotifications},</if>
</trim>
where id = #{id}
</update>
<select id="getAgreementId" resultType="java.lang.String">
select agreement_id
from tm_task_agreement
where task_id = #{taskId}
</select>
<delete id="deleteLeaseOutDetailsById" parameterType="Long">
delete from lease_out_details where id = #{id}
</delete>
<select id="getProtocol" resultType="java.lang.String">
select protocol
from bm_agreement_info
where agreement_id = #{agreementId}
</select>
<insert id="insSltInfo">
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time)
values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType},now());
</insert>
<delete id="deleteLeaseOutDetailsByIds" parameterType="String">
delete from lease_out_details where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -135,4 +135,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="getSltAgreementInfo" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT
id,
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId,
num AS num,
start_time AS startTime,
end_time AS endTime,
status AS status,
lease_id AS leaseId,
back_id AS backId,
lease_price AS leasePrice,
buy_price AS buyPrice,
company_id AS companyId
FROM
slt_agreement_info
WHERE
lease_id = #{parentId}
AND
type_id = #{typeId}
AND
ma_id IS NULL
AND
status = '0'
AND
DATE(start_time) = CURDATE();
</select>
<update id="updSltInfo">
update slt_agreement_info
set num = #{num},
update_time = now()
where id = #{id}
</update>
<insert id="insSltInfo">
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time)
values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType},now());
</insert>
</mapper>

View File

@ -60,4 +60,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{taskId}
</foreach>
</delete>
<select id="getAgreementId" resultType="java.lang.String">
select agreement_id
from tm_task_agreement
where task_id = #{taskId}
</select>
</mapper>

View File

@ -132,4 +132,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY create_time DESC LIMIT 1
</select>
<update id="updateTaskStatus">
update tm_task
set task_status = #{status},
update_time = NOW()
where task_id = #{taskId}
</update>
</mapper>